what's the general way of separating classes?

Ben Cartwright bencvt at gmail.com
Tue Mar 21 01:52:31 CET 2006

John Salerno wrote:
> bruno at modulix wrote:
> >> It seems like this can
> >> get out of hand, since modules are separate from one another and not
> >> compiled together. You'd end up with a lot of import statements.
> >
> > Sorry, but I don't see the correlation between compilation and import
> > here ?
> I meant that in a language like C#, which compiles all the separate
> files into one program, it is not necessary to have the equivalent of an
> import/include type of statement.

Er?  Surely you've used C#'s "using" statement?  Apples and oranges,

C#'s "using Foo.Bar;" is roughly analogous to Python's
"from foo.bar import *".

C#'s "int x = Foo.Bar.f();" is roughly analogous to Python's
"import foo.bar; x = foo.bar.f()".

> You can just refer to the classes from
> any other file.

Iff they're in the same namespace.  You can have multiple namespaces in
the same .NET assembly, you know.

> But in Python, without this behavior, you must
> explicitly import any external files.

That's true.  Each Python file is essentially its own namespace.  And
when, say, __init__.py does a "from submodule import *" it essentially
merges submodule's namespace into its own.


More information about the Python-list mailing list