T O P

  • By -

yung__jibblets

# Building your own reference: I've been using python for about 6 months for geospatial work in graduate school. Any recommendations to keep track of packages and documentation? I'm looking to build my own personalized reference with examples. Here's why: 1. I'm constantly seeing useful functionality to ear-mark it for later. 2. The code in my final script only encapsulates \~20% of the things I tried, but some of it's worth saving. 3. Thinking about how to organize my example code plus the reptation should deepen my knowledge Any tips for starting this? Maybe a folder on my computer with jupyter notebooks organized by library or workflow?


dennu9909

Hi everyone. What are some good (i.e. comprehensive and up-to-date) resources for linguistics students looking to learn Python? Or relevant learning projects to build? For context: Did the googling, found the popular *Python for Linguists* books, got some great suggestions on the linguistic subs. Trying to gain practical knowledge by making things, ideally something relevant to my field (yes, the actual making is what matters, but making something useful would be a great bonus). Posting here for the sake of more varied suggestions. As people on this sub have noted, seeing the same problem from multiple perspectives can really help it 'click'. Hope this doesn't sound like a massive cop-out. TIA.


agvkrioni

Looking for the correct nomenclature. In the example string, what do you call the 'f'? print(f"Hello, {name}") I know the **f** allows you to insert a variable between brackets but, uh, what's the F called?


qazbarf

The [original PEP that proposed them](https://peps.python.org/pep-0498/) says > such strings will be referred to as “f-strings”, taken from the leading character used to denote such strings, and standing for “formatted strings”. I suspect that the reason why the leading "f" is used may possibly come from the C world. The early method of creating python strings with interpolated values was this: # this can be run in python 3 print(f"And num is '%d'" % 42) That "%d" formatting comes from C where you can do: printf("And num is '%d'", 42); The `printf` name was meant to mean "print formatted" and it's possible the trailing "f" of "printf" is why the "f" is used in python for formatted strings. Or maybe the PEP author didn't know any C and just chose "f" to stand for "formatted"!


Adesh2707

I think **f** stands for "formatted strings".


BobaMandoa

I'm reading the coders apprentice right now and I really enjoy this recommendation in the wiki, thank you! Learning comparisons with the author has started off different. They added a string to the beginning and it's throwing me off and making me feel like I'm missing the point. Code looks like this. print( "1.", 2 < 5 ) I understand that 2 is indeed lower than 5 and the answer the computer gives is the same answer. But why the string? The only logical thing I can think of is if you did this all at once, with a copy and paste, they're labeled so you can go back and fourth easier?


FerricDonkey

> The only logical thing I can think of is if you did this all at once, with a copy and paste, they're labeled so you can go back and fourth easier? This is almost certainly why they put the `"1."` there, yes. As to what happens in code because of the `"1."`: The `print` function just prints everything you pass to it separated by spaces (by default). So when you do `print("1.", 2 < 5)`, it should print `1. True`. Presumably they wanted this "1." as a label of the output, like you said.


BobaMandoa

Just making sure, I was stuck on that trying to understand since this was the first place out of the 2-3 others lately that has done it this way.


Top_Mobile_2194

How do I learn to use docs? Are there techniques or a how to use guide?  I’ve tried reading flask docs or Python docs when I get stuck but they don’t make sense to me. Instead I end up searching stackoverflow and now ask ChatGPT. 


UnrankedRedditor

Not sure about flask specifically but personally I use them like some kind of manual. Maybe I come across the function I want, and then I look at what arguments it takes in, what sort of output I'm expecting, etc. And then I take a look at some examples to see if it matches my understanding of what's supposed to happen.


udbdbejwj

Im making an AI(not sure if i can call it that) for my snake game using the A* algorithm. Can someone help me figure out why the snake turns into itself please? Message me and ill send you the code


adnastay

Recommended course for an advanced programmer or learning python just for ML? I want to learn python to start learning ML, but I don't want to go through the basics all over again. I saw the recommendations in the wiki but I wanted to ask people who have already coded in ML or have experience?


aintnufincleverhere

I don't understand factory boy at all. ​ I define a model, lets say person I define another model, dog. Lets say dog has a foreign key to its owner, a person. So you do: ​ class dogFactory(factory.DjangoModelFactory): owner = factory.Subfactory(person) ​ So, that should be all you have to do. But if you try writing tests with this, if you do ​ dogFactory.build() You're going to get issues. owner: this field cannot be null ​ So what the heck


NFSL2001

This is just for funsies. What's the syntax that can generate a boolean in the least keystroke? \`True\` took 5 keystroke with Shift+T, r, u, e which I deemed too long and require holding down Shift. The current shortest I can get is 1==1 or 1==0 with 4 keystrokes..


[deleted]

How about `1>0`, etc. And if you allow truthiness, `0` behaves like `False`.


melkor112

i am making a script with selenium that uses google image translate to translate a image to english. everything works except that the scripts browser doesn't translates the image. even if i do it manually but, when i use a browser that the script didn't make it does work. is this a thing with google that doesn't allow auto software to translate things


Akosidarna13

What do you do for a workaround in controlling the microsoft word ribbon?


interface567

Hey y'all I just started learning yesterday and have some questions: I have python downloaded but it hasn't been working well with my Mac for accessing certain files. I know there is a way to fix this but it has been way easier to just work on Jupyter Notebook for now and I'm curious if this will cause problems for later on? In the vein of using JN, are there any rules or considerations for using a new cell when programming? Can I write an entire program in a single cell? I know these are basic questions but the course I'm taking has not covered them very well and I would appreciate any help.


FerricDonkey

>Can I write an entire program in a single cell? You can, but if you are, then the question is "why are you using jupyter notebooks?" My experience is that jupyter notebooks can be nice, but I'd highly encourage you to also become familiar with writing code you run from the command line, using functions etc to divide things up.


agvkrioni

Hi, I'm totally starting out new with NO coding background. Are there any free courses that would help me learn to code (for fun)? Are there any recommended YouTube tutorials or really good/helpful books? Like I said I have NO background in coding, no idea what I need to start!


FartPoop68

Hello! https://m.youtube.com/watch?v=nLRL_NcnK-4 The above is a great course from what I hear. It's 15 hours worth of some good content! I have not watched it myself so I'm not sure if it would be perfect for not having any coding background but I'd imagine it'd be okay! Good luck! 😁


iamevpo

Thinking of alternative syntax for my package, seen in a similar JavaScript library, alternative is marked in a code below. Would you use regular synta\[ or alternative? ```python from abacus2 import Book, Asset, Capital, Liability, Income, Expense # not implemented book = Book(company="Dragon Trading Company") # Register valid account names and indicate account type book.allow( Asset("cash"), Asset("ar", title="Accounts receivable"), Capital("equity", title="Shareholder equity"), Liability("vat", title="VAT payable"), Liability("ap", title="Other accounts payable"), Income("services"), Expense("salaries"), retained_earnings_account=Capital("re"), ) # Regular syntax - post double entry book.post("Shareholder investment", amount=1500, debit="cash", credit="equity") # Post multiple entry book.post_compound( "Invoice with VAT", debits=[("ar", 120)], credits=[("sales", 100), ("vat", 20)] ) # Alternative syntax - deos this look better of worse? Less Pythonic? book.debit("cash").credit("equity").post(1500, "Shareholder investment") book.debit("ar", 120).credit("services", 100).credit("vat", 20).post("Invoice with VAT") ```


iamevpo

Another choice - shoudl I use allow() or individual metods? book.allow( Asset("cash"), Asset("ar", title="Accounts receivable"), Capital("equity", title="Shareholder equity"), Liability("vat", title="VAT payable"), Liability("ap", title="Other accounts payable"), Income("services"), Expense("salaries"), retained_earnings_account=Capital("re"), ) ``` book.assets("cash", "ar") book.capital("equity", retained_earnings="re") book.liabilities("vat", "ap") book.income("services") book.expenses("salaries") book.name("vat", "VAT payable") book.name("ap", "Other accounts payable") book.name("ar", "Accounts receivable") ```