Brian Elmegaard wrote: > Can it be written in a few words, so I may understand why lists > are (and have to be) so different from "normal" variables? how about two and a half words: "they're not" ;-) confusing? let's go back to the "python objects" page. the first set of clues are hidden under "objects": "Some objects have methods that allow you to change the contents of the object." (lists belong to this category. you can use methods to modify the contents of a list). "Some objects only have methods that allow you to access the contents, not change it." ("normal variables", like integers, floats, strings, belong to this category. if you want a new integer/float/string value, you have to create a new object) the second set of clues can be found under "assignments": "Assignment modify namespaces, not objects" (when you type "s = 10", you're modifying a namespace, not whatever "s" contained before. anyone looking at the original object won't see the change -- because nothing has changed!) "Things like name.attr and name[index] are just syntactic sugar for method calls." (when you type "s[0] = 10", you ask whatever "s" points to to replace item zero with a new value. in your case, you ask the list "s" to modify it's first item. anyone else referring to the same list object will see this change) ::: now read alex' reply once or twice. then read the "python objects" page again, and make sure you understand every- thing in there. once you've done this, the standard docs may start to make a little more sense ;-) (or maybe you're more confused than ever. in that case, we do apologize for the inconvenience...) Cheers /F
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4