Python is wierd!

Rainer Deyke root at rainerdeyke.com
Tue Jul 25 12:38:33 EDT 2000


"Jonathan" <theebh at yahoo.com> wrote in message
news:8lj7kr$ttc$1 at nnrp1.deja.com...
> Hi, just finished going through the 'Learning Python' book, and the
> feeling that i get is that Python is really wierd(compared to other
> conventional languages like C++, Java, etc). For e.g.(correct me if i'm
> wrong)
>
> 1. There are no keywords to declare static or instance variables; it
> all depends where they are placed(whether it's right after the <class>
> statement, or inside a <def>). Isn't it harder for other programmers to
> know at one glance what type of attributes the class define?
>
> 2. No *formal* declaration of static class methods, e.g. no 'static'
> keyword (though i'm not sure how useful static methods are in OOP
> design). I read somewhere in this newsgroup that the workaround way is
> to define the method outside of the class - doesn't it break
> the 'encapsulation' a class suppose to have?

Static variables and methods are a mess anyway.  In Python, there is no need
for them - just place the variables and functions outside the class.  In
Java, they are a (poor) substitite for placing things outside the class.  In
C++, static class members are sometimes useful for access control and
templates, both of which have no place in Python.

> 3. No keywords to differentiate between passing arguments by reference
> or value! An integer is passed by value(reference to a new copy), while
> a mutable object is by reference. To pass a list by 'value', i know you
> just need to insert one more line(list = [:]), but it seems
> so 'inconsistent' compared to Java or even PHP.

In Python, all arguments, including integers, are passed by reference.
Always.


--
Rainer Deyke (root at rainerdeyke.com)
Shareware action/role-playing games      -      http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list