Carl Banks wrote:
> Simon Bunker wrote:
>
>>Hi I have code similar to this:
>>
>>class Input(object):
>>
>> def __init__(self, val):
>> self.value = val
>>
>> def __get__(self, obj, objtype):
>> return self.value
>>
>> def __set__(self, obj, val):
>> # do some c
George Sakkis wrote:
> [EMAIL PROTECTED] wrote:
>
>
>>George Sakkis wrote:
>>
>>>Simon Bunker wrote:
>>>
>>>
Hi I have code similar to this:
class Input(object):
def __init__(self, val):
self.value = val
def __get__(self, obj, objtype):
[EMAIL PROTECTED] wrote:
> George Sakkis wrote:
> > Simon Bunker wrote:
> >
> > > Hi I have code similar to this:
> > >
> > > class Input(object):
> > >
> > > def __init__(self, val):
> > > self.value = val
> > >
> > > def __get__(self, obj, objtype):
> > > return self.
George Sakkis wrote:
> Simon Bunker wrote:
>
> > Hi I have code similar to this:
> >
> > class Input(object):
> >
> > def __init__(self, val):
> > self.value = val
> >
> > def __get__(self, obj, objtype):
> > return self.value
> >
> > def __set__(self, obj, val):
>
Simon Bunker wrote:
> Hi I have code similar to this:
>
> class Input(object):
>
> def __init__(self, val):
> self.value = val
>
> def __get__(self, obj, objtype):
> return self.value
>
> def __set__(self, obj, val):
> # do some checking... only accept flo
At Thursday 7/12/2006 01:58, George Sakkis wrote:
Simon Bunker wrote:
> Basically I want to have the Input class as a gateway that does lots of
> checking when the attibute is assigned or read.
>
> I have had a look at __getattribute__(), but this gets very ugly as I
> have to check if the attr
Simon Bunker wrote:
> Hi I have code similar to this:
>
> class Input(object):
>
> def __init__(self, val):
> self.value = val
>
> def __get__(self, obj, objtype):
> return self.value
>
> def __set__(self, obj, val):
> # do some checking... only accept flo
Steven Bethard wrote:
(snip code)
>
> But that looks pretty nasty to me.
> It sounds like your architecture
> could use some redesigning
Done - in much more sane way. Got rid of some more boilerplate and of
the whole problem of per-instance descriptors BTW !-)
I should probably sleep more
bruno at modulix wrote:
> Using a class as a
> decorator, I have of course only one instance of it per function - and
> for some attributes, I need an instance per function call.
Per function call? And you want the attributes on the function, not the
result of calling the function? If so, that
Steven Bethard wrote:
(some smart questions)
Steven , I owe you a *big* thank.
I knew they must have been something wrong, but couldn't point what. Now
I see, and it's of course totally obvious. Using a class as a
decorator, I have of course only one instance of it per function - and
for some at
bruno at modulix wrote:
> Steven Bethard wrote:
>> Could you explain again why you don't want baaz to be a class-level
>> attribute?
>
> Because the class is a decorator for many controller functions, and each
> controller function will need it's own set of descriptors, so I don't
> want to mess w
Steven Bethard wrote:
> bruno at modulix wrote:
>
>> Hi
>>
>> I'm currently playing with some (possibly weird...) code, and I'd have a
>> use for per-instance descriptors,
(snip)
>>
>> class MyClass2(MyClass1):
>> def __getattribute__(self, key):
>> v = MyClass1.__getattribute__(self
Michael Spencer wrote:
> Bruno Desthuilliers wrote:
>
(snip)
>
>> BTW, there may be other use case for per-instance descriptors...
>
>
> Agreed. Per-instance descriptors could be interesting (that's why the
> subject line caught my attention).
> But your solution involves a custom __getattrib
Bruno Desthuilliers wrote:
> Michael Spencer a écrit :
>> I may be missing the subtlety of what you're up to, but why is
>> overriding __getattribute__ more desirable than simply defining the
>> descriptor in a subclass?
>
> The code snippet I gave as an example was not supposed to reflect how
bruno at modulix wrote:
> Hi
>
> I'm currently playing with some (possibly weird...) code, and I'd have a
> use for per-instance descriptors, ie (dummy code):
>
> class DummyDescriptor(object):
> def __get__(self, obj, objtype=None):
> if obj is None:
> return self
> return getatt
Michael Spencer a écrit :
> bruno at modulix wrote:
>
>> Ziga Seilnacht wrote:
>>
>>> bruno at modulix wrote:
>>>
Hi
I'm currently playing with some (possibly weird...) code, and I'd
have a
use for per-instance descriptors, ie (dummy code):
>>>
>>>
>>>
>>>
Now the q
bruno at modulix wrote:
> Ziga Seilnacht wrote:
>> bruno at modulix wrote:
>>
>>> Hi
>>>
>>> I'm currently playing with some (possibly weird...) code, and I'd have a
>>> use for per-instance descriptors, ie (dummy code):
>>
>>
>>
>>> Now the question: is there any obvious (or non-obvious) drawback
Ziga Seilnacht wrote:
> bruno at modulix wrote:
>
>>Hi
>>
>>I'm currently playing with some (possibly weird...) code, and I'd have a
>>use for per-instance descriptors, ie (dummy code):
>
>
>
>
>>Now the question: is there any obvious (or non-obvious) drawback with
>>this approach ?
>
>
> St
bruno at modulix wrote:
> Hi
>
> I'm currently playing with some (possibly weird...) code, and I'd have a
> use for per-instance descriptors, ie (dummy code):
> Now the question: is there any obvious (or non-obvious) drawback with
> this approach ?
Staticmethods won't work anymore:
>>> class
19 matches
Mail list logo