[Tutor] Doubt
Steven D'Aprano
steve at pearwood.info
Mon Jan 7 19:26:29 EST 2019
On Mon, Jan 07, 2019 at 09:59:31PM +0530, Amit Yadav wrote:
> How can simply typing
>
> print "hello world"
>
> work?
> Like without including any header file or import statements how can it work.
Why shouldn't it work? Python is not C and doesn't use header files.
In Python, the interpreter knows the meaning of print, just as it knows
the meaning of strings ("abc") and ints (123) and floats (4.56).
Some operations (keywords, operators like + - * etc, a handful of
special constants like None) are known to the interpreter. Other
functions (len, chr, ord, min, max etc) are in the "builtins" module,
which doesn't need to be imported because it is always available. And
some functions are in additional modules which need to be imported.
--
Steve
More information about the Tutor
mailing list