[Tutor] Why are expressions not allowed as parameters in function definition statements?
boB Stepp
robertvstepp at gmail.com
Sat Jun 18 15:04:46 EDT 2016
I have (Finally!) gotten a bit of time to look at Peter's answer to my
Model-View-Controller question from May 29th, particularly his
CircleImageView class to which he added a "#FIXME" comment. I thought
it would be helpful to abbreviate his distance function in the
interpreter while I played around with pencil and graph paper. I got:
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900
64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
py3: def d(row, col/2, radius=5):
File "<stdin>", line 1
def d(row, col/2, radius=5):
^
SyntaxError: invalid syntax
And this surprised me. It seems that only identifiers are allowed as
parameters in a function definition statement, and I cannot help but
wonder why? It seems that in most other places in Python's syntax it
will allow one to insert almost any kind of object or expression.
TIA!
--
boB
More information about the Tutor
mailing list