Am 25.09.2012 00:37 schrieb Ian Kelly:
On Mon, Sep 24, 2012 at 4:14 PM, Chris Angelico<ros...@gmail.com> wrote:
file.pos = 42 # Okay, you're at position 42
file.pos -= 10 # That should put you at position 32
foo = file.pos # Presumably foo is the integer 32
file.pos -= 100 # What should this do?
Since ints are immutable, the language specifies that it should be the
equivalent of "file.pos = file.pos - 100", so it should set the file
pointer to 68 bytes before EOF.
But this is not a "real int", it has a special use. So I don't think it
is absolutely required to behave like an int.
This reminds me of some special purpose registers in embedded
programming, where bits can only be set by hardware and are cleared by
the application by writing 1 to them.
Or some bit setting registers, like on ATxmega: OUT = 0x10 sets bit 7
and clears all others, OUTSET = 0x10 only sets bit 7, OUTTGL = 0x10
toggles it and OUTCLR = 0x10 clears it.
If this behaviour is documented properly enough, it is quite OK, IMHO.
Thomas
--
http://mail.python.org/mailman/listinfo/python-list