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
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 floats etc
self.value = val
class
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 pr
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 __getattrib
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).
>
mple was not supposed to reflect how I
> effectively mean to use per-instance descriptors, it was just a kind of
> Minimal Working Code (tm). The real life code is about 500 LOC, and
> explaining the whole thing would take far too long. Also, as I said,
> this is mostly syntactic su
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
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
>>>>
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):
>>
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
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 wo
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 getattr(obj, 'bar', '
21 matches
Mail list logo