This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Button titles with numbers have invalid syntax?
RocketBlaster05 last edited by RocketBlaster05
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
cvp last edited by
@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.
JonB last edited by
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.
mikael last edited by
@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.
cvp last edited by
Yes, but does Pythonista support modern fashion?
cvp last edited by cvp
@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...
RocketBlaster05 last edited by
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!