Faqts : Computers : Programming : Languages : Python : Language and Syntax

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 8 people (88%) answered Yes
Recently 7 of 8 people (88%) answered Yes

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 "=".