Bruno Desthuilliers wrote:
Ethan Furman a écrit :
Bruno Desthuilliers wrote:
Bruno Desthuilliers a écrit :
Ethan Furman a écrit :
Bruno Desthuilliers wrote:
Duncan Booth a écrit :
(snip)
Or you could create the default as a class attribute
from the OP:
"""
I have a class (FuncDesigner o
Ethan Furman a écrit :
Bruno Desthuilliers wrote:
Bruno Desthuilliers a écrit :
Ethan Furman a écrit :
Bruno Desthuilliers wrote:
Duncan Booth a écrit :
(snip)
Or you could create the default as a class attribute
from the OP:
"""
I have a class (FuncDesigner oofun) that has no attribute
Bruno Desthuilliers wrote:
Bruno Desthuilliers a écrit :
Ethan Furman a écrit :
Bruno Desthuilliers wrote:
Duncan Booth a écrit :
(snip)
Or you could create the default as a class attribute
from the OP:
"""
I have a class (FuncDesigner oofun) that has no attribute "size", but
it is overlo
Bruno Desthuilliers a écrit :
Ethan Furman a écrit :
Bruno Desthuilliers wrote:
Duncan Booth a écrit :
(snip)
Or you could create the default as a class attribute
from the OP:
"""
I have a class (FuncDesigner oofun) that has no attribute "size", but
it is overloaded in __getattr__, so if s
Ethan Furman a écrit :
Bruno Desthuilliers wrote:
Duncan Booth a écrit :
(snip)
Or you could create the default as a class attribute
from the OP:
"""
I have a class (FuncDesigner oofun) that has no attribute "size", but
it is overloaded in __getattr__, so if someone invokes
"myObject.size",
Bruno Desthuilliers wrote:
Duncan Booth a écrit :
Bruno Desthuilliers wrote:
If you don't want to create as many Whatever instances as MyClass
instances, you can create a single Whatever instance before defining
your class:
DEFAULT_WHATEVER = Whathever()
class MyClass(object):
def __
Duncan Booth a écrit :
Bruno Desthuilliers wrote:
If you don't want to create as many Whatever instances as MyClass
instances, you can create a single Whatever instance before defining
your class:
DEFAULT_WHATEVER = Whathever()
class MyClass(object):
def __init__(self, x, y):
Bruno Desthuilliers wrote:
> If you don't want to create as many Whatever instances as MyClass
> instances, you can create a single Whatever instance before defining
> your class:
>
> DEFAULT_WHATEVER = Whathever()
>
> class MyClass(object):
> def __init__(self, x, y):
> self.x
dmitrey a écrit :
(snip)
This doesn't stack with the following issue: sometimes user can write
in code "myObject.size = (some integer value)" and then it will be
involved in future calculations as ordinary fixed value; if user
doesn't supply it, but myObject.size is involved in calculations, the
On Tue, Jul 20, 2010 at 9:39 AM, dmitrey wrote:
>>How about using a property instead of the __getattr__() hook? A property is a
>>computed attribute that (among other things) plays much nicer with hasattr.
>
> Could anyone provide an example of it to be implemented, taking into
> account that a u
On 7/20/10 11:39 AM, dmitrey wrote:
e.g. one that just looks in the object's dictionary so as to avoid returning
true for properties or other such fancy attributes.
So can anyone explain me how to look into object's dict? As I have
wrote, "something in dir(...)" requires O(numOfFields) while I
On 7/20/10 6:59 AM, dmitrey wrote:
On Jul 20, 1:37 pm, Chris Rebert wrote:
Least ugly suggestion: Just don't use hasattr(); use your `x in
dir(y)` trick instead.
something in dir() consumes O(n) operations for lookup, while hasattr
or getattr() require O(log(n)). It matters for me, because
dmitrey wrote:
>> e.g. one that just looks in the object's dictionary so as to avoid
>> returning true for properties or other such fancy attributes.
>
> So can anyone explain me how to look into object's dict? As I have
> wrote, "something in dir(...)" requires O(numOfFields) while I would
> l
dmitrey wrote:
On 20 июл, 15:00, Jean-Michel Pichavant
wrote:
dmitrey wrote:
hi all,
I have a class (FuncDesigner oofun) that has no attribute "size", but
it is overloaded in __getattr__, so if someone invokes
"myObject.size", it is generated (as another oofun) and connected to
myObjec
On 20 июл, 18:39, Neil Cerutti wrote:
> On 2010-07-20, dmitrey wrote:
>
> > This doesn't stack with the following issue: sometimes user can
> > write in code "myObject.size = (some integer value)" and then
> > it will be involved in future calculations as ordinary fixed
> > value; if user doesn't
On 2010-07-20, dmitrey wrote:
> This doesn't stack with the following issue: sometimes user can
> write in code "myObject.size = (some integer value)" and then
> it will be involved in future calculations as ordinary fixed
> value; if user doesn't supply it, but myObject.size is involved
> in calc
> e.g. one that just looks in the object's dictionary so as to avoid returning
> true for properties or other such fancy attributes.
So can anyone explain me how to look into object's dict? As I have
wrote, "something in dir(...)" requires O(numOfFields) while I would
like to use o(log(n))
>How
On 20 июл, 15:00, Jean-Michel Pichavant
wrote:
> dmitrey wrote:
> > hi all,
> > I have a class (FuncDesigner oofun) that has no attribute "size", but
> > it is overloaded in __getattr__, so if someone invokes
> > "myObject.size", it is generated (as another oofun) and connected to
> > myObject as
Am 20.07.2010 12:10, schrieb dmitrey:
> hi all,
> I have a class (FuncDesigner oofun) that has no attribute "size", but
> it is overloaded in __getattr__, so if someone invokes
> "myObject.size", it is generated (as another oofun) and connected to
> myObject as attribute.
How about using a propert
dmitrey wrote:
hi all,
I have a class (FuncDesigner oofun) that has no attribute "size", but
it is overloaded in __getattr__, so if someone invokes
"myObject.size", it is generated (as another oofun) and connected to
myObject as attribute.
So, when I invoke in other code part "hasattr(myObject,
dmitrey wrote:
> hi all,
> I have a class (FuncDesigner oofun) that has no attribute "size", but
> it is overloaded in __getattr__, so if someone invokes
> "myObject.size", it is generated (as another oofun) and connected to
> myObject as attribute.
>
> So, when I invoke in other code part "hasa
On Jul 20, 1:37 pm, Chris Rebert wrote:
> On Tue, Jul 20, 2010 at 3:10 AM, dmitrey wrote:
> > hi all,
> > I have a class (FuncDesigner oofun) that has no attribute "size", but
> > it is overloaded in __getattr__, so if someone invokes
> > "myObject.size", it is generated (as another oofun) and co
On Tue, Jul 20, 2010 at 3:10 AM, dmitrey wrote:
> hi all,
> I have a class (FuncDesigner oofun) that has no attribute "size", but
> it is overloaded in __getattr__, so if someone invokes
> "myObject.size", it is generated (as another oofun) and connected to
> myObject as attribute.
>
> So, when I
hi all,
I have a class (FuncDesigner oofun) that has no attribute "size", but
it is overloaded in __getattr__, so if someone invokes
"myObject.size", it is generated (as another oofun) and connected to
myObject as attribute.
So, when I invoke in other code part "hasattr(myObject, 'size')",
instead
24 matches
Mail list logo