-1

Given the function header:

myfunction(from): #some code 

I get a syntax error. Is this because "from" is a keyword in Python? If so are all keywords barred from being used as variable names?

1
  • 2
    Also see here and here. Try to make a greater effort at research before posting questions. Commented Dec 27, 2015 at 12:53

1 Answer 1

2

It's a keyword so you can't use it as a name, try:

def my_function(from_): # some code 
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the confirmation. Is this a common convention in Python to use "keyword_" if you desire to use a keyword as a variable?
Since _from convention is used for private names, I use from_, or e.g. from_email to avoid the keyword conflict
See here for info about a trailing underscore.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.