4) The typical knee-jerk reaction to this 'oddity' is "what a pain, how stupid" etc, but I'm sure there is a good explanation. Can someone explain why python acts this way? faster processing? preserve memory? etc?

This comes down (largely) to a philosophical choice.  Does
the language work with things that are platonic mathematical
entities, or does it work with things that have a concrete
physical existence?

Consider this:

>>> k = Printer('csx2500')
>>> print k.sheets_left()
200
>>> m = k
>>> m.print_document(file="/tmp/my.pdf")
>>> print m.sheets_left()
190

So what should k.print_sheets() show?

There are many things in computers that work like this:  hard drives,
file systems, data bases, chunks of memory, printers, the screen, mice,
keyboards, and user interfaces.  Attaching a mouse to another name
doesn't create a new mouse.  Assigning a file to a different variable
shouldn't create a new file.

There are languages that work like you expect.  They're called pure
functional languages.  They have their adherents, but they're known
to have problems with certain things like, well, input and output.  (On
the other hand they do multiple threads of execution very well.)

What it comes down to is this:  does you program work with an idealized
universe, or does it work with the messy innards of a computer?

-jeff

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to