> >Michael Prager wrote: > >> To expand on that, be aware that Python has a rather fanciful > >> use of the assignment operator for "mutable" objects > > > >there is no assignment operator. (it's a statement) > > > >and it doesn't care whether the object is mutable or not. > > To the naive user, the EFFECT is different. If the object is > immutable, the statement appears to act just like it does in > many other languages. (It may not really act that way, but the > difference is hidden.) > > If the object is mutable, the difference is quite important, in > that modifying later what's pointed to by name "b" can also > modify what's pointed to by name "a". > > That behavior is not in agreement with the "mental model" used > by many other languages, so I would think it a major pitfall for > beginners -- at least, it was for this beginner. It's either How is this different from the behaviour of a C pointer (at a conceptual level)? char a[10] = "Hello, world!\0"; char *b = a; /* b refers to same memory space as a */ a[1] = '?'; /* a & b now refer to the same string "H?llo, world!" */ /* Note: it's been a while since I've done any C, but I think this is all right ... */ Tim Delaney Avaya Australia +61 2 9352 9079 All recipient(s) of this email have permission to forward or reply to this email, quoting this email in full or in part.
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