[EMAIL PROTECTED] wrote: > Hi all, > In Python, some functions can be assigned to variables like this: > length=len > Why is it that print cannot be assigned to a variable like this? (A > syntax error is declared.) > > Thanks, > > Vaibhav >
print can't be assigned to variables since it's not a funcion, it's part of the syntax of the language, like `for', `while', etc. and it can't be assigned to variables, just as those can't be assigned. If you need a function that prints stuff, consider these two examples: [snip] PrintFunc = lambda x: print x [snip] Or, a somewhat better solution: [snip] import sys PrintFunc = sys.write [snip] -- http://mail.python.org/mailman/listinfo/python-list