On Mon, Apr 6, 2015 at 11:20 AM, Joel Goldstick <[email protected]> wrote: > On Mon, Apr 6, 2015 at 10:54 AM, boB Stepp <[email protected]> wrote: >> Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit >> (Intel)] on win32 >> Type "copyright", "credits" or "license()" for more information. >>>>> d = {'n': 'Print me!'} >>>>> d >> {'n': 'Print me!'} >>>>> d['n'] >> 'Print me!' >>>>> def func(d['n']): >> SyntaxError: invalid syntax >>>>> def func(d): >> print d['n'] >> >>>>> func(d) >> Print me! >> >> The plain text does not show it, but in the invalid syntax the "[" is >> highlighted red. >> >> Why is it invalid syntax to pass a particular dictionary value in a >> function? Or does it require a different form to do so? >> > > Here is another example: > >>>> def f(6): > File "<stdin>", line 1 > def f(6): > ^ > SyntaxError: invalid syntax >>>> > > You can't pass a value as a parameter to a function definition. You > need to provide a name. The actual value is supplied when you call > the function
The python.org site has this: https://docs.python.org/2/reference/compound_stmts.html#function-definitions > >> Thanks! >> >> -- >> boB >> _______________________________________________ >> Tutor maillist - [email protected] >> To unsubscribe or change subscription options: >> https://mail.python.org/mailman/listinfo/tutor > > > > -- > Joel Goldstick > http://joelgoldstick.com -- Joel Goldstick http://joelgoldstick.com _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
