Re: Printable string for 'self'

2006-03-17 Thread Michael Tobis
> What were you planning to do with this object exactly that didn't involve > binding it to any other names during its lifetime? Nothing so silly as that. The idea is not to prevent other references from binding to the object, but to allow the object to ensure that a certain symbol always points

Re: Printable string for 'self'

2006-03-16 Thread Duncan Booth
Michael Tobis wrote: > I got in some trouble in these parts a few months back for advocating > some sort of immutable reference, like > > fred -> C("fred") > > where any reassignment of the refernce during the lifetime of the > referent would raise an exception. This seems to be seen as wronghea

Re: Printable string for 'self'

2006-03-15 Thread Michael Tobis
This behavior seems to be commonly wanted by people discovering Python, and it is the rare case of something one can imagine that is really a stretch to achieve in Python. Because more or less than one name may refer to an object, in general an object can't know its name. You can get part of the w

Re: Printable string for 'self'

2006-03-15 Thread Bruno Desthuilliers
Don Taylor a écrit : (snip) > My overall intent is to try to build something that can record > interactions against an object so that they can be replayed later for > testing and debugging. I had in mind to generate the recording as a > sequence of Python statements. You may want to have a l

Re: Printable string for 'self'

2006-03-15 Thread Don Taylor
Fredrik Lundh wrote: > Q. How can my code discover the name of an object? > > A. The same way as you get the name of that cat you found on your > porch: the cat itself cannot tell you its name, and it doesn't really > care -- so the only way to find out what it's called is to ask

Re: Printable string for 'self'

2006-03-15 Thread Steve Holden
Don Taylor wrote: > Fredrik Lundh wrote: > >>objects don't have names in Python, and the source is not part of >>the running program. >> >>have you read this ? >> >>http://effbot.org/zone/python-objects.htm > > > I have now. Thank you very much. > > "objects don't have names in Python": It

Re: Printable string for 'self'

2006-03-15 Thread Fredrik Lundh
Don Taylor wrote: > Fredrik Lundh wrote: > > objects don't have names in Python, and the source is not part of > > the running program. > > > > have you read this ? > > > > http://effbot.org/zone/python-objects.htm > > I have now. Thank you very much. > > "objects don't have names in Python":

Re: Printable string for 'self'

2006-03-15 Thread Don Taylor
Fredrik Lundh wrote: > objects don't have names in Python, and the source is not part of > the running program. > > have you read this ? > > http://effbot.org/zone/python-objects.htm I have now. Thank you very much. "objects don't have names in Python": It appears from the code that Micha

Re: Printable string for 'self'

2006-03-14 Thread Fredrik Lundh
Don Taylor wrote: > And if I call my method: A().qualify global_names_bound_to_me() then I > get an empty list back. > > Is what I want to do not possible without referring back to the source? objects don't have names in Python, and the source is not part of the running program. have you read th

Re: Printable string for 'self'

2006-03-14 Thread Ben Cartwright
Don Taylor wrote: > Is there a way to discover the original string form of the instance that > is represented by self in a method? > > For example, if I have: > > fred = C() > fred.meth(27) > > then I would like meth to be able to print something like: > > about to call meth(fred,

Re: Printable string for 'self'

2006-03-14 Thread Terry Reedy
"Don Taylor" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is there a way to discover the original string form of the instance that > is represented by self in a method? > For example, if I have: > fred = C() > fred.meth(27) > then I would like meth to be able to print something l

Re: Printable string for 'self'

2006-03-14 Thread Don Taylor
Michael Spencer wrote: > > > In general, this requires exhaustive search of name bindings e.g.,: > > >>> def get_names_of(obj, ns): > ... return [name for name, value in ns.iteritems() if value is obj] > ... > >>> class A(object): > ... def global_names_bound_to_me(self): > ...

Re: Printable string for 'self'

2006-03-14 Thread Michael Spencer
Don Taylor wrote: > Is there a way to discover the original string form of the instance that > is represented by self in a method? > > For example, if I have: > > fred = C() > fred.meth(27) > > then I would like meth to be able to print something like: > > about to call meth(