will python 3000 break my code?
Daniel Berlin
dan at cgsoftware.com
Wed Mar 1 17:11:56 EST 2000
>>>>> "FL" == Fredrik Lundh <effbot at telia.com> writes:
>> | 3. be impossible to identify by automatic tools. | Tim's excellent
>> checkappend.py can spot many | cases, but not all.
>> Actually, this isn't true (that it's impossible). If you really like,
>> i'll take a few days of my spring break and write one guaranteed to
>> catch every single case.
FL> how about this one:
| foo = list.append
| for bar in range(100):
| foo(bar, bar, bar)
__name__ of foo will be append and type(foo.__self__) will be list
I had already planned on checking this.
FL> or this one:
| class Foo:
| def __init__(self):
| self.setup()
| self.add = self.list.append
| def setup(self):
| self.list = []
| foo = Foo()
| foo.add(bar, bar, bar)
It still has the same pattern in the bytecode.
foo.add.__name__ will be append
type(foo.add.__self__) will be list.
--Dan
FL> </F>
More information about the Python-list
mailing list