Objects in Python

Ian Kelly ian.g.kelly at gmail.com
Thu Aug 23 14:17:37 EDT 2012


On Thu, Aug 23, 2012 at 12:02 PM, Jan Kuiken <jan.kuiken at quicknet.nl> wrote:
> On 8/23/12 06:11 , Steven D'Aprano wrote:
>
>>> 2) Related to the above, you can infinitely nest scopes. There's nothing
>>> wrong with having six variables called 'q'; you always use the innermost
>>> one. Yes, this can hurt readability
>>
>>
>> Well, there you go. There *is* something wrong with having six variables
>> called 'q'.
>
>
> Sometimes you don't want only six variables called 'q' but a hundred
> of them :-)
>
>   def fac(q):
>       if q < 1 :
>           return 1
>       else:
>           return q * fac(q-1)
>
>   print(fac(100))

That's only one variable called 'q', instantiated 100 times simultaneously.



More information about the Python-list mailing list