a simple def how-to

Stefan Behnel stefan_ml at behnel.de
Sun Mar 7 18:17:01 CET 2010


vsoler, 07.03.2010 16:05:
> Hello,
>
> My script starts like this:
>
> book=readFromExcelRange('book')
> house=readFromExcelRange('house')
> table=readFromExcelRange('table')
> read=readFromExcelRange('read')
> ...
>
> But I would like to have something equivalent, like...
>
> ranges=['book','house','table','read']
> for i in ranges:
>      var[i]=readFromExcelRange(i)

Note that the name "i" is rather badly chosen as it generally implies a 
totally different thing (integer) than what you use it for (names of ranges).

"ranges" seems to fall into the same bucket, but I guess that's just 
because I can't extract the meaning from your code snippet (which is not a 
good sign).

Try to use expressive names in your code, so that people who look at it for 
the first time get an idea about what it does with what kind of data.

Stefan




More information about the Python-list mailing list