Button titles with numbers have invalid syntax?
I was calling on a button starting with a number, and the number gets coded as red and when I run the app it says “invalid syntax” on the 8 shown below. Is there a work around for this? Thanks.
def wb8(8oz./0.237L): #^invalid syntax
@RocketBlaster05 Python variables names have to begin with alphabetic.
If you wb8 is the action of a button, use def wb8(sender):
Usually, we don't set as parameter the title of the button.
You also cannot use periods or slashes in the name of a variable/identifier.
As cvp said, identifiers must start with an alphabet character, then contain only a-z and 0-9, or underscore Also, no special characters, no reserved keywords, no operators.
I wonder if you meant to pass in a string default value or something, but that's not how button actions work.
@JonB, in these modern times we can use all unicode alphabetic characters in variables, so I could have e.g.
päiviä(days) as a variable name.
Yes, but does Pythonista support modern fashion?
@RocketBlaster05 anyway, don't use the name or title of your buttons as parameter for their action, use the standard way of naming it "sender"
in this case you can always get the button name or title via
That could seem strange for you, but assume two buttons have the same action...
Thanks for all the replies. I decided to just use sender. I didn't realise how easy it is to just write sender for the buttons lol. Thanks for the suggestions everyone!