En Wed, 02 Jan 2008 01:11:12 -0300, <[EMAIL PROTECTED]> escribió:
> I am trying to experiment a little bit with new-style class and I am
> confused why following example always returns 0 (zero). I was
> expecting will return values from 0 to 9 and finaly
> an Exception.
>
> class GenExample(objec
Steven,
thanks for a nice explanation.
I am trying to experiment a little bit with new-style class and I am
confused why following example always returns 0 (zero). I was
expecting will return values from 0 to 9 and finaly
an Exception.
class GenExample(object):
def getInfo(self):
fo
On Tue, 01 Jan 2008 13:01:24 -0800, petr.jakes.tpc wrote:
>> > My question is: is it possible to set the "property" for any
>> > attribute when I do not know what will be the name of the attribute
>> > in the future?
>>
>> Uhm... I don't understand the question. Perhaps if you think of a
>> concre
> > My question is: is it possible to set the "property" for any attribute
> > when I do not know what will be the name of the attribute in the
> > future?
>
> Uhm... I don't understand the question. Perhaps if you think of a concrete
> case...?
Thanks for reply,
few minutes after i posted my que
En Tue, 01 Jan 2008 16:57:41 -0200, <[EMAIL PROTECTED]> escribi�:
> Gabriel, if I understand it properly, it is necessary to define get/
> set/del/doc methods for each attribute for which I want to set the
> "property" data descriptor (which triggers get/set/del/doc function
> calls upon access to
Hi all,
I am trying to understand new-style classes in Python and I have found
your postings here.
Gabriel, if I understand it properly, it is necessary to define get/
set/del/doc methods for each attribute for which I want to set the
"property" data descriptor (which triggers get/set/del/doc fun
En Mon, 31 Dec 2007 16:01:38 -0200, <[EMAIL PROTECTED]> escribi�:
> Thanks you Gabriel and Timm for your thoughtful responses. I am very
> appreciative.
>
> I had heard about the properties function, but wanted to understand
> the old syntax first before I tried that. Thanks to your responses, I
I didn't actually answer your question, my apologies!
The reason you're failing is due to your use of the __setattr__ call.
Remember, when you override __setattr__, you need to handle *all* of the
logic behind setting object attributes. You're only attempting to do so
when handling the 'name' pro
Thanks you Gabriel and Timm for your thoughtful responses. I am very
appreciative.
I had heard about the properties function, but wanted to understand
the old syntax first before I tried that. Thanks to your responses, I
was able to see what the problem was.
Here is a solution I came up with:
A couple items of note:
> class Person:
This should be "class Person(object)" to take advantage of some
of the features that new-style classes offer...particularly in
this case.
> def __init__(self, fName="", lName=""):
> self.__fName = fName
> self.__lName = lName
>
> d
En Mon, 31 Dec 2007 14:56:02 -0200, <[EMAIL PROTECTED]> escribi�:
> Hi Python Community:
>
> Despite my new-ness to Python I have alreadhy been able to do some (I
> think) amazing things. It is a truly elegant and smart language.
>
> Yet, I can not seem to get a handle on something simple.
>
> I
Perhaps you'd be better off using a standard property? Within your Person
class, you can define a property 'name' to handle what you're trying to do:
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "copyright", "credits" or "license()" for
Hi Python Community:
Despite my new-ness to Python I have alreadhy been able to do some (I
think) amazing things. It is a truly elegant and smart language.
Yet, I can not seem to get a handle on something simple.
I would like to make a class which has private varaiables fName and
lName. It sh
13 matches
Mail list logo