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

15

u/Username_RANDINT def get_random_int(): return "RANDINT" # TODO Feb 20 '21

Here's a quick demonstration:

>>> class Foo:
...   def __init__(self):
...     print(self)
... 
>>> f = Foo()
<__main__.Foo object at 0x7fdf79221710>
>>> f
<__main__.Foo object at 0x7fdf79221710>

I think this often overlooked when trying to explain it.

5

u/forkheadbox Feb 20 '21

the first <__main...> is from the print statement right?

6

u/Username_RANDINT def get_random_int(): return "RANDINT" # TODO Feb 20 '21

Yes, __init__() is called when you initialise the class.

1

u/RaidZ3ro Feb 21 '21

No, it's because Foo is created in the 'main' script(file/module), so when the object is represented it's parent is "main".

2

u/solitarium Feb 20 '21

0.0 Ohhhhhhhhhhh!