Re: [pypy-dev] Access the name of variable that is being assigned

2014-07-15 Thread Bengt Richter
Hi Anatoly, Haven't done any python in a loong time now, but I lurk sometimes on the pypy list, and thought ok, I'll play with that, and see if it's nay use to you. I wrote techtonik.py (included at the end) and used it interactively to show some features, first trying to approximate the interact

Re: [pypy-dev] Access the name of variable that is being assigned

2014-07-15 Thread Yichao Yu
I guess this feature is mainly useful for debugging since it is really hard to do it consistantly in python. And IMHO, for debuging, it might be more useful to record the position (file + line num etc) where the object is created, which has less ambiguity and can probably already be done by tracing

Re: [pypy-dev] Access the name of variable that is being assigned

2014-07-15 Thread Steven D'Aprano
On Tue, Jul 15, 2014 at 5:05 PM, anatoly techtonik wrote: > Is it possible at all to define a class in Python that > can read name of variable it is assigned to on init? > > >>> MyObject = SomeClass() > >>> print(MyObject) > 'MyObject' This feature would be useful for things like namedtupl

Re: [pypy-dev] Access the name of variable that is being assigned

2014-07-15 Thread anatoly techtonik
On Tue, Jul 15, 2014 at 12:50 PM, Yichao Yu wrote: > On Tue, Jul 15, 2014 at 5:05 PM, anatoly techtonik > wrote: >> Hi, >> >> Is it possible at all to define a class in Python that >> can read name of variable it is assigned to on init? >> >> >>> MyObject = SomeClass() >> >>> print(MyObject)

Re: [pypy-dev] Access the name of variable that is being assigned

2014-07-15 Thread Yichao Yu
On Tue, Jul 15, 2014 at 5:05 PM, anatoly techtonik wrote: > Hi, > > Is it possible at all to define a class in Python that > can read name of variable it is assigned to on init? > > >>> MyObject = SomeClass() > >>> print(MyObject) > 'MyObject' I thing in general a normal object in Python do