Re: [Tutor] attribute of built-in type

2008-12-01 Thread Kent Johnson
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

Re: [Tutor] attribute of built-in type

2008-12-01 Thread spir
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 > ---

Re: [Tutor] attribute of built-in type

2008-11-30 Thread Kent Johnson
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

Re: [Tutor] attribute of built-in type

2008-11-29 Thread Kent Johnson
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,

Re: [Tutor] attribute of built-in type

2008-11-28 Thread Kent Johnson
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

[Tutor] attribute of built-in type

2008-11-28 Thread spir
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