Teaching Programming
Martin P. Hellwig
martin.hellwig at dcuktec.org
Wed May 5 18:01:08 EDT 2010
On 05/04/10 12:59, superpollo wrote:
> Martin P. Hellwig ha scritto:
<cut>
>> For the corner cases (I can think of a couple) it is good to know you
>> can use ';' most of the time.
>>
>
> most but not always as i noted (think about loops or function definition)
>
Well through in some exec magic then, for example:
for number in [1,2,3,4]:
def nprint(number):
print(number)
number += 1
nprint(number
translates to:
>>> exec('for number in [1,2,3,4]:\n\tdef
nprint(number):\n\t\tprint(number)\n\tnumber += 1\n\tnprint(number)')
2
3
4
5
But if you have an example why indentation is still a problem please
give it :-)
--
mph
More information about the Python-list
mailing list