Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-05 Thread Terry Reedy
Marco Bizzarri wrote: I understand that Python is a balance between different forces (like any software object around the world) and I'm simply asking some pointers to the discussion leading to this balance. The original decisions by Guido were nearly 20 years ago and other discussions are

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-05 Thread Marco Bizzarri
On Thu, Sep 4, 2008 at 7:15 PM, Timothy Grant [EMAIL PROTECTED] wrote: I think the most obvious solution to the problem is effective unit tests. If you type a.y =1 and have a test that asserts a.x == 1 then you would quite quickly discover that you made a typo. -- Stand Fast, tjg.

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-05 Thread Diez B. Roggisch
Ivan Illarionov schrieb: On 4 сент, 21:49, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Ivan Illarionov a écrit : On 4 сент, 22:59, Carl Banks [EMAIL PROTECTED] wrote: You can write code to guard against this if you want: class A: legal = set([x]) def __setattr__(self,attr,val):

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-05 Thread Ivan Illarionov
On 5 сент, 19:23, Diez B. Roggisch [EMAIL PROTECTED] wrote: Ivan Illarionov schrieb: On 4 сент, 21:49, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Ivan Illarionov a écrit : On 4 сент, 22:59, Carl Banks [EMAIL PROTECTED] wrote: You can write code to guard against this if you want:

Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Marco Bizzarri
Let's say I've a class a, where I can write: -- Marco Bizzarri http://notenotturne.blogspot.com/ http://iliveinpisa.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Diez B. Roggisch
Marco Bizzarri wrote: Let's say I've a class a, where I can write: Anticipating this obviously premature posting: http://dirtsimple.org/2004/12/python-is-not-java.html Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Marco Bizzarri
On Thu, Sep 4, 2008 at 1:00 PM, Diez B. Roggisch [EMAIL PROTECTED] wrote: Marco Bizzarri wrote: Let's say I've a class a, where I can write: Anticipating this obviously premature posting: http://dirtsimple.org/2004/12/python-is-not-java.html Diez --

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Marco Bizzarri
Sorry... pressed enter but really didn't want to. As I said, let's say I have a class class A: def __init__(self): self.x = None Python makes the decision to allow the developers to directly access the attribute x, so that they can directly write: a.x = 1, or whatever; this has

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Diez B. Roggisch
Of course, I know that while I'm fresh, I've a good knowledge of the code, and anything else, I will be able to avoid such stupid errors; however, I'm afraid of the times when I'm tired, when I have to put my hands on the code of someone else, and so on. Please, understand that I'm not

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Bruno Desthuilliers
Marco Bizzarri a écrit : Sorry... pressed enter but really didn't want to. As I said, let's say I have a class class A: def __init__(self): self.x = None Python makes the decision to allow the developers to directly access the attribute x, So do Java, if you make your

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Marco Bizzarri
On Thu, Sep 4, 2008 at 1:19 PM, Diez B. Roggisch [EMAIL PROTECTED] wrote: What you are essentially asking is: why is python dynamic instead of static? Most probably you're right. Maybe I will make a trip back to my university books and take a look at them again :-) Thanks Marco -- Marco

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Marco Bizzarri
On Thu, Sep 4, 2008 at 4:39 PM, Marco Bizzarri [EMAIL PROTECTED] wrote: Most probably you're right. Maybe I will make a trip back to my university books and take a look at them again :-) Meant: you *are* right. Sorry. Saluti Marco -- Marco Bizzarri http://notenotturne.blogspot.com/

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread George Sakkis
On Sep 4, 7:09 am, Marco Bizzarri [EMAIL PROTECTED] wrote: Sorry... pressed enter but really didn't want to. As I said, let's say I have a class class A:     def __init__(self):          self.x = None Python makes the decision to allow the developers to directly access the attribute x,  

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Timothy Grant
On Thu, Sep 4, 2008 at 4:09 AM, Marco Bizzarri [EMAIL PROTECTED] wrote: Sorry... pressed enter but really didn't want to. As I said, let's say I have a class class A: def __init__(self): self.x = None Python makes the decision to allow the developers to directly access the

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Carl Banks
On Sep 4, 7:09 am, Marco Bizzarri [EMAIL PROTECTED] wrote: Sorry... pressed enter but really didn't want to. As I said, let's say I have a class class A: def __init__(self): self.x = None Python makes the decision to allow the developers to directly access the attribute x,

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Ivan Illarionov
On 4 сент, 22:59, Carl Banks [EMAIL PROTECTED] wrote: You can write code to guard against this if you want: class A:     legal = set([x])     def __setattr__(self,attr,val):         if attr not in self.legal:             raise AttributeError(A object has no attribute '%s' % attr)        

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Bruno Desthuilliers
Ivan Illarionov a écrit : On 4 сент, 22:59, Carl Banks [EMAIL PROTECTED] wrote: You can write code to guard against this if you want: class A: legal = set([x]) def __setattr__(self,attr,val): if attr not in self.legal: raise AttributeError(A object has no attribute

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Ivan Illarionov
On 4 сент, 21:49, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Ivan Illarionov a écrit : On 4 сент, 22:59, Carl Banks [EMAIL PROTECTED] wrote: You can write code to guard against this if you want: class A: legal = set([x]) def __setattr__(self,attr,val): if attr

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Bruno Desthuilliers
Ivan Illarionov a écrit : On 4 сент, 21:49, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Ivan Illarionov a écrit : On 4 сент, 22:59, Carl Banks [EMAIL PROTECTED] wrote: You can write code to guard against this if you want: class A: legal = set([x]) def __setattr__(self,attr,val):

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Carl Banks
On Sep 4, 3:15 pm, Ivan Illarionov [EMAIL PROTECTED] wrote: On 4 ÓÅÎÔ, 22:59, Carl Banks [EMAIL PROTECTED] wrote: You can write code to guard against this if you want: class A: legal = set([x]) def __setattr__(self,attr,val): if attr not in self.legal: raise

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Marco Bizzarri
On Thu, Sep 4, 2008 at 8:59 PM, Carl Banks [EMAIL PROTECTED] wrote: You can write code to guard against this if you want: class A: legal = set([x]) def __setattr__(self,attr,val): if attr not in self.legal: raise AttributeError(A object has no attribute '%s' %