Here is an idea that might help - you do have some control over
assignment to attributes of an object. If you stored your objects in
another object you could assign __name__ attributes automatically. For
example:
class Container(object):
def __setattr__(self, name, value):
if no
Kent Johnson a écrit :
[...big snip...]
> Do you know that you can probably just assign a __name__ attribute to
> the objects? Or name, or whatever you like?
>
> In [13]: class Foo(object): pass
>:
>
> In [14]: f=Foo()
>
> In [15]: f.name
> ---
On Sat, Nov 29, 2008 at 5:09 PM, spir <[EMAIL PROTECTED]> wrote:
> Kent Johnson a écrit :
>> On Fri, Nov 28, 2008 at 6:01 PM, spir <[EMAIL PROTECTED]> wrote:
>>> Kent Johnson a écrit :
>> OK, functions (and methods, which are also functions, both of which
>> are instances of some builtin type), cla
On Fri, Nov 28, 2008 at 6:01 PM, spir <[EMAIL PROTECTED]> wrote:
> Kent Johnson a écrit :
>> I'm not sure what you are trying to accomplish. Custom classes have
>> __name__ attributes; instances of built-in and custom classes don't
>> have __name__ attributes.
>
> Hem, what do you mean? Functions,
On Fri, Nov 28, 2008 at 3:55 PM, spir <[EMAIL PROTECTED]> wrote:
> I try to find a way to give a cutom type ('s instances) attributes like some
> built-in types have, for instance __name__. (For any reason, such attributes
> are not equally shared by all kinds of objects.)
> I tried to achieve that
Hello,
I try to find a way to give a cutom type ('s instances) attributes like some
built-in types have, for instance __name__. (For any reason, such attributes
are not equally shared by all kinds of objects.)
I tried to achieve that with inheritance, but I couldn't make it work with
built-in