On Fri, Dec 16, 2011 at 2:32 AM, Peter Otten <__pete...@web.de> wrote:
> Ulrich wrote:
>
>> if I replace it to
>> def attributelist(self):
>> # find all attributes to the class that are of type numpy
>> arrays:
>> return [attr for attr in dir(self) if
>> isinstance(getattr(self, a
Am 16.12.2011 09:52 schrieb Ulrich:
Could anyone please explain me why this does not work / how to get b
into .__dict__ / hint me to an explanation?
b is not a data element of the particular instance, but it lives in the
class. It is, roughly spoken, a "kind of method", just to be used
witho
Ulrich wrote:
> if I replace it to
> def attributelist(self):
> # find all attributes to the class that are of type numpy
> arrays:
> return [attr for attr in dir(self) if
> isinstance(getattr(self, attr), numpy.ndarray)]
>
> it crashes going into some kind of endless loop.
>
>
On Dec 16, 10:11 am, Ulrich wrote:
> On Dec 16, 10:03 am, Steven D'Aprano
>
>
>
>
>
>
>
>
> +comp.lang.pyt...@pearwood.info> wrote:
> > On Fri, 16 Dec 2011 00:52:11 -0800, Ulrich wrote:
> > > Good morning,
>
> > > I wonder if someone could please help me out with the @property function
> > > as i
On Dec 16, 10:03 am, Steven D'Aprano wrote:
> On Fri, 16 Dec 2011 00:52:11 -0800, Ulrich wrote:
> > Good morning,
>
> > I wonder if someone could please help me out with the @property function
> > as illustrated in the following example.
>
> > class te():
> > def __init__(self):
> > se
On Fri, 16 Dec 2011 00:52:11 -0800, Ulrich wrote:
> Good morning,
>
> I wonder if someone could please help me out with the @property function
> as illustrated in the following example.
>
> class te():
> def __init__(self):
> self.a = 23
> @property
> def b(self):
> r
On Feb 26, 9:56 am, Christian Heimes wrote:
> Dan Barbus schrieb:
>
> > Hi,
>
> > I have a problem with setting a property to a class instance, in
> > python 2.5.1. The property is defined through get and set methods, but
> > when I set it, the setter doesn't get called. Instead, I believe the
> >
Dan Barbus schrieb:
> Hi,
>
> I have a problem with setting a property to a class instance, in
> python 2.5.1. The property is defined through get and set methods, but
> when I set it, the setter doesn't get called. Instead, I believe the
> property in the instance gets replaced with a new object
"manstey" <[EMAIL PROTECTED]> writes:
> Is is possible to have two classes, ClassA and ClassB, and
> setattr(ClassA, 'xx',ClassB), AND to then have ClassA.xx store an
> integer value as well, which is not part of ClassB?
You seem somewhat confused over classes and instances. There's little
need t
manstey wrote:
> Hi,
>
> Is is possible to have two classes, ClassA and ClassB, and
> setattr(ClassA, 'xx',ClassB), AND to then have ClassA.xx store an
> integer value as well, which is not part of ClassB?
>
> e.g. If ClassB has two properties, name and address:
>
> ClassA.xx=10
> ClassA.xx.nam
>On 3 Dec 2006 21:24:03 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> In the following code, I could not find out why the set and get methods
> are not called once I set the property.
>
>
> >>> class Test:
> ... def __init__(self):
> ... self._color = 12
> ... def _setcolor(
On Thu, 06 Oct 2005 16:09:22 +0200, Laszlo Zsolt Nagy <[EMAIL PROTECTED]> wrote:
>Peter Otten wrote:
>
>>Laszlo Zsolt Nagy wrote:
>>
>>
>>
>>>I was trying for a while, but I could not implement a 'classproperty'
>>>function. Is it possible at all?
>>>
>>>
>>
>>You could define a "normal" pro
On Thu, 06 Oct 2005 11:05:10 +0200, Laszlo Zsolt Nagy <[EMAIL PROTECTED]> wrote:
>Hughes, Chad O wrote:
>
>> Is there any way to create a class method? I can create a class
>> variable like this:
>>
>Hmm, seeing this post, I have decided to implement a 'classproperty'
>descriptor.
>But I could
Laszlo Zsolt Nagy wrote:
> class A(object):
>cnt = 0
>a_cnt = 0
>def __init__(self):
>A.cnt += 1
>if self.__class__ is A:
>A.a_cnt += 1
> class B(A):
>pass
> print A.cnt,A.a_cnt # 0,0
> b = B()
> print A.cnt,A.a_cnt # 1,0
> a = A()
> print A.c
Peter Otten wrote:
>Laszlo Zsolt Nagy wrote:
>
>
>
>>I was trying for a while, but I could not implement a 'classproperty'
>>function. Is it possible at all?
>>
>>
>
>You could define a "normal" property in the metaclass:
>
>
The only way I could do this is:
class MyXMetaClass(type):
Laszlo Zsolt Nagy wrote:
> I was trying for a while, but I could not implement a 'classproperty'
> function. Is it possible at all?
You could define a "normal" property in the metaclass:
> class A:
... class __metaclass__(type):
... @property
... def clsprp(cls):
16 matches
Mail list logo