Can I import from a directory that starts with a dot (.) ?

Ben Finney ben+python at benfinney.id.au
Mon Apr 13 22:14:15 EDT 2009


Matthew Wilson <matt at tplus1.com> writes:

> I want to have .foo directory that contains some python code. I can't
> figure out how to import code from that .foo directory. Is this even
> possible?

Packages and modules need to have names that are valid Python
identifiers. That precludes the ‘.’ character (among many others).

You could delve into the import mechanism for ways to get a valid-named
module imported from a file with a different name; but surely it would
be simpler to have valid names on the filesystem in the first place.

-- 
 \       “The surest way to corrupt a youth is to instruct him to hold |
  `\       in higher esteem those who think alike than those who think |
_o__)                               differently.” —Friedrich Nietzsche |
Ben Finney



More information about the Python-list mailing list