Guido van Rossum wrote:
> On 9/28/05, Jim Fulton <[EMAIL PROTECTED]> wrote:
>
...
> I think we need to be real careful with chosing a name -- in Jim's
> example, *anyone* could assign to Spam().eggs to override the value.
> The name "readproperty" is too close to "readonlyproperty",
In fact, prop
On Wed, 2005-09-28 at 19:14, Phillip J. Eby wrote:
> Because it only works in classic classes due to a bug in descriptor handling:
Blah. ;)
-Barry
signature.asc
Description: This is a digitally signed message part
___
Python-Dev mailing list
Python-D
At 01:34 PM 9/29/2005 +1200, Greg Ewing wrote:
>Guido van Rossum wrote:
> > I think we need to be real careful with chosing a name
>
>In Eiffel, the keyword "once" is used for something
>analogous -- a method that is called once the first
>time it's referenced, and the return value cached.
>
>So pe
Guido van Rossum wrote:
> I think we need to be real careful with chosing a name
In Eiffel, the keyword "once" is used for something
analogous -- a method that is called once the first
time it's referenced, and the return value cached.
So perhaps this could be called a "once_property".
--
Greg
At 06:23 PM 9/28/2005 -0400, Barry Warsaw wrote:
>I /must/ be missing something. Why not just use property as a
>decorator?
>
>class C:
> @property
> def eggs(self):
> print 'in eggs'
> self.eggs = 7
> return self.eggs
>
> >>> c = C()
> >>> c.eggs
>in eggs
>7
> >>>
It doesn't work that way for new-style classes.
On 9/28/05, Barry Warsaw <[EMAIL PROTECTED]> wrote:
> On Wed, 2005-09-28 at 10:16, Jim Fulton wrote:
>
> > When we ask for the eggs attribute the first time, we call the
> > descriptor, which calls the eggs function. The function sets the eggs
> > a
On Wed, 2005-09-28 at 10:16, Jim Fulton wrote:
> When we ask for the eggs attribute the first time, we call the
> descriptor, which calls the eggs function. The function sets the eggs
> attribute, overriding the descriptor. The next time the eggs attribute
> is accessed, the saved value will be u
Oleg Broytmann wrote:
>It seems many people reinvent this particular wheel. Which is
> understandable.
>
>propertytools.py, anyone?
"import magic" ;)
Cheers,
Nick.
P.S. Such a module may actually be a good idea, if it reduces the variation in
metaclass and descriptor hacks across some
At 05:28 PM 9/28/2005 +, iga Seilnacht wrote:
>You can use something like this to find a descriptor's name:
>
The given code fails if the same property appears under more than one name
or is used in more than one class. It also requires the property object to
be mutable, and is subject
On Wed, Sep 28, 2005 at 10:16:12AM -0400, Jim Fulton wrote:
>class readproperty(object):
[skip]
> I do this often enough
I use it since about 2000 often enough under the name CachedAttribute:
http://cvs.sourceforge.net/viewcvs.py/ppa/qps/qUtils.py
(The current maintainer of the code is
Michael Hudson python.net> writes:
>
> "Phillip J. Eby" telecommunity.com> writes:
>
> > Unfortunately, finding out a descriptor's name is non-trivial; it'd be nice
> > if there were a descriptor hook __bind__(cls,name) that was called by
> > classes during cls.__new__ or assignment to a cla
Jim Fulton wrote:
> A common use of read descriptors is for lazily computed data:
>
>class readproperty(object):
>"Create a read descriptor from a function"
>
>def __init__(self, func):
>self.func = func
>
>def __get__(self, inst, class_):
>if ins
"Phillip J. Eby" <[EMAIL PROTECTED]> writes:
> Unfortunately, finding out a descriptor's name is non-trivial; it'd be nice
> if there were a descriptor hook __bind__(cls,name) that was called by
> classes during cls.__new__ or assignment to a class attribute, and which
> you could define to ret
At 10:16 AM 9/28/2005 -0400, Jim Fulton wrote:
>I do this often enough that I think it would be useful to include it
>in python, either as a builtin (like property) or in the library. (Or
>possibly by adding an option to property to generate a read
>descriptor.) I'd be happy to add this for 2.5.
>
On 9/28/05, Jim Fulton <[EMAIL PROTECTED]> wrote:
> Read descriptors (defining only __get__) and data descripttors have
> (defining __get__ and __set__) different semantics. In particular,
> read descriptors are overridden by instance data, while data
> descriptors are not. A common use of read de
Read descriptors (defining only __get__) and data descripttors have
(defining __get__ and __set__) different semantics. In particular,
read descriptors are overridden by instance data, while data
descriptors are not. A common use of read descriptors is for lazily
computed data:
class readprope
16 matches
Mail list logo