>>7
Don't listen to this man
>>8
I got the first example, until i saw what came after, and you fucking lost me... All you're doing for fvar is wrapping it in a list? why does this work?
In Python, all variables are references to objects in memory. When you do:
x = 1
x = 2
You're
not setting x to an object int(1), then modifying its content into 2. What you're really doing is creating an object int(1) somewhere and binding x to refer to this object; then creating a new object int(2) somewhere and binding x to this new object. (Objects no longer referenced by anything are automatically garbage-collected.)
When you assign (or use +=, -=, etc.) to a variable anywhere in a function, you create a new variable for this whole function; not from the point you do but for the whole function. Inner variables obscure outer variables. So when you do fvar = 1 inside a function, you're making Python create a new fvar variable, obscuring any fvar from outer scopes.
If, however, you wrap fvar into a list, you can then modify its values. When you do fvar[0] = 1, you're not rebinding fvar or creating it as a local variable, but accessing its elements and substituting the first element (which was a reference to some object) by a reference to a new object.
I want a current_room variable (just a single int) that is changeable from any number of nested functions deep, and is also readable from any number deep.
Wrap it into a list.
>>10-11
One word, trolls get old, trolling over.
>>14
Good job, though you're barely scratching Python. Keep diving into the advanced features. Perhaps you could listen to
>>12 and create a TextAdventure interpreter class; just don't get obsessed with objects and classes because they're just one more tool you use when it fits, and ignore when it doesn't.
>>22
Logo is a Lisp cousin created by master Abelson. It's not even bad. It's just that most people don't take it seriously and never learn all of it.