[Tutor] Fwd: question 1

Danny Yoo dyoo at hashcollision.org
Mon Sep 22 00:30:00 CEST 2014


Forwarding Clayton's original request to tutor:


---------- Forwarded message ----------
From: Clayton Kirkwood <crk at godblessthe.us>
Date: Sun, Sep 21, 2014 at 2:42 PM
Subject: RE: [Tutor] question 1
To: Danny Yoo <dyoo at hashcollision.org>


> Secondarily, why can you import a module without it importing all of
> its daughters?

The act of importing a module is "recursive": if you import a module,
and that module itself has import statements, then Python will do the
import of the child modules too.  And so forth.
> And why do you have to use a ‘for in to import submodule’, why not
> ’import module.sub’?

If I'm not mistaken, you _can_ do this.  Can you point us to a source
where it says you can't?

(There are particular style guidelines from certain organizations that
prohibit this kind of import, but that prohibition is by convention.
That is, it's not because the language disallows it, but because it
doesn't fit with the house coding style.)


[Clayton Kirkwood]
>From the interpreter:

import io
import io.FileIO
Traceback (most recent call last):
  File "<string>", line 1, in <fragment>
builtins.ImportError: No module named 'io.FileIO'; 'io' is not a package
from io import FileIO
:end



> Lastly, in some tutorials and else-sourced docs certain lines have a
> ‘;’ at the end. This seems to be most often with ‘opens’ and ‘fopen’ kind of calls.

Huh.  Can you point to a reference?  Note that third-party
documentation (and official documentation!) might be buggy or weird.
:P  If you can point us to an example, maybe one of us can investigate
what's going on there.
[Clayton Kirkwood]


Example from ' http://www.tutorialspoint.com/python/python_files_io.htm'

#!/usr/bin/python

str = raw_input("Enter your input: ");
print "Received input is : ", str


More information about the Tutor mailing list