Newbie look at Python and OO

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu May 10 19:58:46 EDT 2007


En Thu, 10 May 2007 18:21:42 -0300, <half.italian at gmail.com> escribió:

> These conversations are funny to me.  I use Python every day and I
> have never actually thought about the implications of binding objects
> to names, or two names pointing to the same object.  Problems of this
> sort just never come up in actual programming for me.  It just works.
>
> Python was my virgin language, so maybe that just makes it natural to
> me, but it seems like people coming from other languages get hung up
> on testing out the differences and theories rather than just
> programming in it.  Alas, maybe I have yet to get deep enough to run
> into these kinds of problems.

Certainly, learning Python as a first language has some advantages. But I  
think you'd feel a bit shocked if you had to program in C++ someday; these  
rather innocent lines might not do what you think:

a = 0;
b = a;

 From a C++ point of view, it would be natural that:
- a is not 0, and it might not even be a number.
- (a==0) may be false, and (b==0) too.
- b is not the same thing as a, may be a totally different type, and if it  
were something like Python's "mutable containers", mutating b would have  
no effect on a.

Simple things have so complex and ugly rules that... ugh, enough for now.  
But people coming from other languages/backgrounds may think Python syntax  
a bit strange at first - just for a while, but if they can pass the "Gimme  
my curly braces back!" stage, most end loving Python.

-- 
Gabriel Genellina




More information about the Python-list mailing list