On Aug 7, 4:06 am, Eric Snow ericsnowcurren...@gmail.com wrote:
Thought I knew how to provide a dynamic __name__ on instances of a
class. My first try was to use a non-data descriptor:
# module base.py
class _NameProxy(object):
def __init__(self, oldname):
self.oldname =
On Wed, Aug 10, 2011 at 8:48 AM, Fuzzyman fuzzy...@gmail.com wrote:
__name__ can be a descriptor, so you just need to write a descriptor
that can be fetched from classes as well as instances.
Here's an example with a property (instance only):
class Foo(object):
... @property
... def
On Aug 10, 4:25 pm, Ian Kelly ian.g.ke...@gmail.com wrote:
On Wed, Aug 10, 2011 at 8:48 AM, Fuzzyman fuzzy...@gmail.com wrote:
__name__ can be a descriptor, so you just need to write a descriptor
that can be fetched from classes as well as instances.
Here's an example with a property
On Wed, Aug 10, 2011 at 8:48 AM, Fuzzyman fuzzy...@gmail.com wrote:
On Aug 7, 4:06 am, Eric Snow ericsnowcurren...@gmail.com wrote:
Thought I knew how to provide a dynamic __name__ on instances of a
class. My first try was to use a non-data descriptor:
# module base.py
class
On Sat, Aug 6, 2011 at 10:47 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
Eric Snow wrote:
Thought I knew how to provide a dynamic __name__ on instances of a
class. My first try was to use a non-data descriptor:
Perhaps you should explain what you are trying to do. If you
Thought I knew how to provide a dynamic __name__ on instances of a
class. My first try was to use a non-data descriptor:
# module base.py
class _NameProxy(object):
def __init__(self, oldname):
self.oldname = oldname
def __get__(self, obj, cls):
if obj is None:
Eric Snow wrote:
Thought I knew how to provide a dynamic __name__ on instances of a
class. My first try was to use a non-data descriptor:
Perhaps you should explain what you are trying to do. If you want to give
instances their own name, why not just give them an instance
attribute name?