Python Forum
Is there an error in the code?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there an error in the code?
#3
As per my knowledge, I think the request for 'n' raises a NameError. This is since n is a variable local to func and we cannot access it elsewhere. It is also true that Python only evaluates default parameter values once; every invocation shares the default value. If one invocation modifies it, that is what another gets. This means you should only ever use primitives, strings, and as default parameters, not mutable objects.
Reply


Messages In This Thread
Is there an error in the code? - by himanibansal - Dec-19-2018, 12:21 PM
RE: Is there an error in the code? - by buran - Dec-19-2018, 12:37 PM
RE: Is there an error in the code? - by dukoolsharma - Dec-20-2018, 06:15 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020