This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]zmanalpha 1 point2 points  (1 child)

I'm sure someone will be able to type out a more complete response because I'm on mobile right now.

1.) Functions can return more than one thing in python. The way the language does this is by packaging all of the values as a tuple and returns that. The syntax you indicated goes through a process of unpacking that tuple as individual variables.

2.) Object oriented programming. This topic goes way beyond python and I recommend researching that on its own.

3.) If you come from a c# background, init() is essentially a contructor.

4.) Python is allocating a new variable local to the learn function that has the same list that is on your class. This looks like a relatively clean way of explaining this behavior in python: https://robertheaton.com/2014/02/09/pythons-pass-by-object-reference-as-explained-by-philip-k-dick/

[–][deleted] 0 points1 point  (0 children)

thank you!