[Tutor] Is input a Python function or command?
Alan G
alan.gauld at freenet.co.uk
Mon Aug 1 08:55:02 CEST 2005
> Is input a Python function or command?
Its a function. You can tell because you need to use parens.
print, by contrast, is a command and doesn't need parens...
> I need to know because I'm planning to use it as
> a variable, and don't want to get an error.
Even if you don't want to use input() in your code masking
it with a variable name is still a bad idea. Why? Because
anyone else reading your code who sees 'input' will
automatically tend to assume the builtin name not your
variable. Its much better to use safe variable names.
A Thesaurus can help here, for example the online one at:
http://thesaurus.reference.com
Which suggests these as alternatives to input:
abstracts, brass tacks, circumstances, compilations, conclusions,
details, documents, dope, dossier, evidence, experiments,
facts, figures, goods, info, input, knowledge, materials,
measurements, memorandums, notes, picture, poop, poop sheet,
proof, reports, results, scoop, score, statistics, testimony,
whole story
Also some abbreviation skills can be used, for example:
iput, ipt, in.
Finally augmenting the name with some context information will help,
such as file_input, numeric_input, menu_input etc...
Personally I prefer the first and last techniques, abbreviations
can become obscure very quickly.
HTH,
Alan G.
More information about the Tutor
mailing list