[Tutor] Possibly odd question on everything
Kirby Urner
urnerk@qwest.net
Thu, 22 Nov 2001 18:26:08 -0800
That's a good question Gregor.
Most primitives, like 'hash', live as builtin functions,
and if you ask for their types, you get something
like:
>>> type(hash)
<type 'builtin_function_or_method'>
But 'print' is special in that its appearance constitutes
an executable command -- it doesn't need (won't take)
any arguments. So
>>> type(print)
has to be regarded as bad syntax, since 'print' is an
interpretable command as is.
Python keywords may be listed using the keyword module:
>>> keyword.kwlist
['and', 'assert', 'break', 'class', 'continue', 'def', 'del',
'elif', 'else', 'except', 'exec', 'finally', 'for', 'from',
'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or',
'pass', 'print', 'raise', 'return', 'try', 'while', 'yield']
None of these have a type per se. They're part of the
syntax, but don't behave like objects. Neither do the
operators, unless imported as objects from the operator
module. E.g. you can't go type(+) or type(==).
Kirby