In article <[EMAIL PROTECTED]>, Jarek Zgoda <[EMAIL PROTECTED]> wrote: 

> Gekitsuu napisal(a):
> 
> > use strict;
> > use WWW::Mechanize;
> > use CGI;
> > 
> > This seems to be the de facto standard in the Perl community but in
> > python it seems most of the code I look at has import statements
> > everywhere in the code. Is there a sound reason for putting the imports
> > there are are developers just loading modules in as they need them. I
> > own Damian Conway's book of Perl Best Practices and it seems from a
> > maintainability standpoint  that having all the modules declared at the
> > beginning would make it easier for someone coming behind you to see
> > what other modules they need to use yours. Being new I didn't know if
> > there was a performance reason for doing this or it is simply a common
> > habit of developers.
> 
> Sometimes putting import statements at the beginning is not feasible
> (i.e. only when some condition has been met), as importing has some
> impact on program execution (importing executes code in imported
> module). This does not resemble Java imports (I don't know Perl).
> 
> -- 
Wow ?!   I've only started looking at python but that sounds like very
dangerous programming !  Can you give an example.

BTW this topic relates to a recent point raised by the C man's
[I think Richie, dated ca. 1973] crit of Pascal. He said that
Pascal's restriction of not being able to declare globals, near
where they were needed, was bad.  And I thought so too, before I
considered that the programmer must KNOW that they are global.
Ie. the ability to declare them at a 'nice' place is just syntactic
sugar, hiding the reality the globals are bad, and have to be avoided
and respected.

== Chris Glur.



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to