Entry
How can you create a function that works like print, not requiring parenthesis around its arguments?
Mar 26th, 2002 21:29
Michael Chermside, dave meltzer,
Short answer: You can't.
This is a question which is likely to come from someone with a
background in Perl, because there you can (and often do) create such
functions. But in Python ALL functions require parentheses (or the apply
function) to be evaluated.
The question actually contains a misaprehension -- even print does not
violate this rule. The trick is that print is NOT a function. It
sometimes looks like one, but print is a STATEMENT -- one of the
fundamentals built into the interpreter like "if", "for", or "=".