Favorite non-python language trick?

Jeffrey Maitland jeff.maitland at gmail.com
Fri Jun 24 13:50:21 EDT 2005


1 trick I liked in C++ was for For loops.

{
for(int i = 0; i < 100; i++){
 //do stuff
}
} 

wrapping the for loop in { } makes the i a local variable and then you
can use it again in the code if not  you will get a variable already
defined error.

As a side note python already keeps it a local variable, as most of us
know, and even if it did we can redifne it if we needed with ease.

Jeff
 
On 6/24/05, D H <d at e.f> wrote:
> Roy Smith wrote:
> > Tom Anderson  <twic at urchin.earth.li> wrote:
> >
> >>The one thing i really do miss is method overloading by parameter
> >>type.  I used this all the time in java
> >
> >
> > You do things like that in type-bondage languages like Java and C++
> > because you have to.  Can you give an example of where you miss it in
> > Python?
> 
> Well it's coming to a future Python version, so apparently there are
> many who can use it:
> http://wiki.python.org/moin/Python3.0Suggestions#head-7df9d7035174644fdae024ed4a5ea0960a003ef5
> I don't know if you'll have method overloading, but there will be type
> checking.  It's not actually compile-time "static typing" though.  The
> type checking still happens at run-time similar to your isinstance
> example, making code run slightly slower than a normal python method:
> "Type checking is going to slow down your code." -GVR 2005 keynote,
> http://www.sauria.com/%7Etwl/conferences/pycon2005/20050324/The%20State%20of%20Python.html
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list