newbie Q: sequence membership

MonkeeSage MonkeeSage at gmail.com
Mon Nov 19 08:34:40 CET 2007


On Nov 19, 12:32 am, saccade <tri... at gmail.com> wrote:

> I am not a programmer so I feel odd commenting about language design
> decisions. When my Prof. introduced python the first question that
> popped into mind was that since "x=9; y=9; print x is y and x == y"
> prints "True" is there a way to change the value of 9? He said that
> was silly but after class showed me that statements "True = []" work
> but suggested it was harmless and not quite a bug.
>
> So if I am permitted to think of integers as immutable objects with
> predefined labels (i.e. the integers used in the text of the program
> code) that cannot de or re referenced then what a similar treatment of
> characters will look like seams to be an arbitary (a design) decition.
>
> In this vein it seams reasonable to expect 'a'[0] and 'ba'[1] to refer
> to the same object. If one follows the convention used with integers
> (9 and 9 refer to the same object) then 'ab' and 'ab' would be the
> same. An equally reasonable assumption would be that 'ab' and 'ab' are
> two different sequences and so not equal (I do not see the problem
> here).

The problem is with side-effets. With "pure" code, your reasoning
would be sound; but given that side-effects may alter the execution
path, ab[@T1] and ab[@T2] may _not_ refer to the same object. This
observation, is, of course, highly superfluous. ;)

Regards,
Jordan



More information about the Python-list mailing list