r/learnpython • • Feb 20 '21

What are you having difficulty learning or are currently struggling to learn?

I'm curious what the community here has difficulty with when it comes to learning Python. Partly because I want to see if the more experienced community here (or myself) can help point you into the right direction. . . but also because I'm trying to come up with video tutorial ideas for future content and would love to hear from Python learners what would be most useful to dedicate our time on.

I'm looking forward to hearing what you guys have to say!

417 Upvotes

324 comments sorted by

View all comments

Show parent comments

3

u/unphamiliarterritory Feb 20 '21

What is the "-> None" stuff, I haven't seen that syntax before?

2

u/MaraudingAvenger Feb 20 '21

it's the python version of typing -- in the line

def show_blop(thing: Bloop) -> None:

thing: Bloop means the function takes a thing of type Bloop. the -> None before the end colon means the function doesn't return anything (None). It's a slightly more explicit way of programming. If you're interested, check out the typing library. It's got lots of example code.

2

u/unphamiliarterritory Feb 20 '21

When you say "of type Bloop" you mean an object Bloop previously defined with the class keyword, right?

Thanks for the info on the typing library!

1

u/MaraudingAvenger Feb 20 '21

Yep! when you make a class, you're defining a new type of thing, like a string or an int -- and every one of the Bloops I create has a type of Bloop (or really, it'll be a __main__.Bloop, but that could be splitting hairs).

2

u/AchillesDev Feb 20 '21

To be more precise, the 'python version of typing' is better (and officially) called type hinting. It's there for people reading the code, but isn't enforced by the runtime.

2

u/Raknarg Feb 21 '21

*and static analyzers like mypy or Pycharm's built in version, which one should always be using with python