filbert icon indicating copy to clipboard operation
filbert copied to clipboard

Creating functions with optional parameters

Open nemoyatpeace opened this issue 11 years ago • 2 comments

I seem to get an error if I try to create a function with a default value assigned to a parameter:

class A:
   def __init__(self):
        self.b = 'hi'

   def main(self):
       def r(a,b=7):
           return a*7
       self.r = r

a=A()
a.main()
print(a.r)
print(a.r(8))

This code run just fine (in the filbert tester) until I added the parameter b=7.

nemoyatpeace avatar Jul 14 '14 17:07 nemoyatpeace

#8 is a catchall for advanced function arguments. We can use this issue to track default arguments.

differentmatt avatar Jul 14 '14 17:07 differentmatt

OK, so now I should actually read the issues that are already listed before I post my next one...

nemoyatpeace avatar Jul 14 '14 17:07 nemoyatpeace