Steven D'Aprano a écrit :
(snip)
But it's quite rare to see double-underscore "really private" attributes
in Python code. It is considered to go against the spirit of the language.
Not necessarily "against the spirit" - it's mostly than __name_mangling
is only really useful when you want to pr
On Aug 25, 4:31 am, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Sun, 24 Aug 2008 23:56:27 -0700, Hussein B wrote:
> > On Aug 24, 7:12 pm, Steven D'Aprano <[EMAIL PROTECTED]
> > cybersource.com.au> wrote:
> >> >> I noted that Python encourage the usage of: -- obj.prop = data
> >> >> x = obj.prop
This is probably what you want:
http://www.python.org/download/releases/2.2/descrintro/#property
Available in Python 2.2 or later.
Enjoy,
Ken Seehart
Hussein B wrote:
Hey,
I noted that Python encourage the usage of:
--
obj.prop = data
x = obj.prop
--
to set/get an object's property value.
Wha
On Sun, 24 Aug 2008 23:56:27 -0700, Hussein B wrote:
> On Aug 24, 7:12 pm, Steven D'Aprano <[EMAIL PROTECTED]
> cybersource.com.au> wrote:
>> >> I noted that Python encourage the usage of: -- obj.prop = data
>> >> x = obj.prop
>> >> --
>> >> to set/get an object's property value. What if I want t
On Aug 25, 4:56 pm, Hussein B <[EMAIL PROTECTED]> wrote:
> AFAIUY (understand you), what it is called a property in Java, it is
> called an attribute in Python?
> Why Python encourages direct access to object's attributes?
The simplest answer is "Because Python is not Java" :)
Speaking of which,
On Aug 24, 7:12 pm, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> On Sun, 24 Aug 2008 12:28:53 +0200, Peter Otten wrote:
> > Hussein B wrote:
>
> >> I noted that Python encourage the usage of: --
> >> obj.prop = data
> >> x = obj.prop
> >> --
> >> to set/get an object's property v
On Sun, 24 Aug 2008 12:28:53 +0200, Peter Otten wrote:
> Hussein B wrote:
>
>> I noted that Python encourage the usage of: --
>> obj.prop = data
>> x = obj.prop
>> --
>> to set/get an object's property value. What if I want to run some logic
>> upon setting/getting a property? What is Python pref
On Aug 24, 5:07 am, Hussein B <[EMAIL PROTECTED]> wrote:
> Hey,
> I noted that Python encourage the usage of:
> --
> obj.prop = data
> x = obj.prop
> --
> to set/get an object's property value.
> What if I want to run some logic upon setting/getting a property?
> What is Python preferred method to
On Aug 24, 5:28 am, Peter Otten <[EMAIL PROTECTED]> wrote:
> Hussein B wrote:
> > I noted that Python encourage the usage of:
> > --
> > obj.prop = data
> > x = obj.prop
> > --
> > to set/get an object's property value.
> > What if I want to run some logic upon setting/getting a property?
> > What
Hussein B wrote:
> I noted that Python encourage the usage of:
> --
> obj.prop = data
> x = obj.prop
> --
> to set/get an object's property value.
> What if I want to run some logic upon setting/getting a property?
> What is Python preferred method to do so (using the new feature
> 'property')?
>
Hey,
I noted that Python encourage the usage of:
--
obj.prop = data
x = obj.prop
--
to set/get an object's property value.
What if I want to run some logic upon setting/getting a property?
What is Python preferred method to do so (using the new feature
'property')?
I don't think __getattr__ and __s
11 matches
Mail list logo