Python questions from C/Perl/Java programmer

Moshe Zadka moshez at math.huji.ac.il
Mon Jul 24 14:44:38 EDT 2000


On Mon, 24 Jul 2000, ye, wei wrote:

> 1. Why not use {}?!
> def f:
>     ...
> why not use {} like this:
> def f {
>     ...
> }

Please try to research a bit on Deja. There is a thread about this every
other week. Hint: most people don't write 100-lines long if statements.

> 2. Why variable doesn't have to be declared before use?

Because it takes up script lines and coding time. If you want to catch
bugs in your code, write unit tests. For unit test support, you can try
Steven's PyUnit http://pyunit.sourceforge.net

> I like variable need to be declared before use, alos perfer the declare
> with type, e.g.
> int i;
> object x;
> def f ( object x, int i):

But this *hurts* f's functionality. What if there is an object with the
same interface as int and you want to pass it as a second argument?

--
Moshe Zadka <moshez at math.huji.ac.il>
There is no IGLU cabal.
http://advogato.org/person/moshez





More information about the Python-list mailing list