Python is wierd!

Martijn Faassen m.faassen at vet.uu.nl
Thu Jul 27 08:25:59 EDT 2000


Jonathan <theebh at yahoo.com> wrote:
[snip]
> IT's just that i never expected its OOP
> constructs can be so 'loose', for e.g. you can even declare a instance
> variable out of the <class> scope(am i right?),

You mean like this?

a = 1
print a

The advantage of being able to do that is that it's a Python program.
Also, please note that functions and classes are 'first class' in 
Python; in effect this creates a module-global variable called 'foo':

def foo():
    pass

and this too:

class foo:
    pass

> or you put static methods OUTSIDE of the class.

They're not static methods. They're called 'functions'; you know,
procedures; venerable very useful construct in programming. :)

> From the postings so far, i began to
> understand the reasons for them; but the nagging feeling is that ppl
> may just 'mix' them too much and create unreadable codes.

Programming in Python, just like any other language, takes self
discipline. If people don't have enough self discipline to avoid global
variables (when the program is significant), then they won't have enough
self-discipline to write any readable code at all. So that's not problem;
those of us who do know how to write readable code won't be corrupted
by such simple freedoms, and those who are have a lot to learn anyway.

[some suggestions about languages]
> Err...i don't think i have the time now:) In fact, i'm trying to learn
> python and Zope at the same time (as fast as possible), as I have an
> upcoming web development project, where i need to assess the
> feasibility of using Zope as a development tool.

I would advise you not to learn Python within the context of the Zope
framework. Try a Python program in isolation (you can always connect
it up to Zope later). Zope, while very powerful, is a complex framework
which will severely muddle up the clarity that is Python. Just look
at the average DTML expression; those are Python expressions, but
Zope's quoting rules and namespace stack and acquisition make them
hellishly complicated to understand.

Regards,

Martijn
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?



More information about the Python-list mailing list