__str__ vs. __repr__

Fredrik Lundh fredrik at pythonware.com
Thu Nov 18 05:33:03 EST 1999


Phil Hunt <philh at vision25.demon.co.uk> wrote:
> How about:
> 
>    x = a + b + c
>    x = (a + b) + c
>    x=a+b+c
> 
> I'd guess these all produce the same bytecode.

footnote: the abc80 computer I mentioned
in my earlier post had an extra byte code
for this purpose.  users can buy that you
add spaces and reformat their code, but
they won't accept that you remove their
parentheses...

> I'd also not be surprised if you could consistently change the
> name of a local variable within a function without changing bytecodes,
> i.e. Python internally doesn't know the names of local variables.

print myfunction.func_code.co_names

</F>

<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
(news: just posted an errata for the 'first printing') -->





More information about the Python-list mailing list