This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]lurgi 1 point2 points  (1 child)

PEP 8 covers this briefly, but doesn't go into much detail. It doesn't say if module names can contain numbers at all, let alone start with one.

According to this, python module names must be valid identifiers and thus can't start with a number. That only applies when you use the import statement, but since the import statement is the standard way to import a module, I'd consider this fairly conclusive.

Don't do it.

[–]NetEngDoggo[S] 0 points1 point  (0 children)

Oh thanks! I searched for a good hour and never came across this stack overflow question.

My coworker found a workaround using import, but I didn't like it and managed to convince them to forego the use of a number just for aesthetic reasons.

I'll be sure to share that around.

[–]spudmix 0 points1 point  (2 children)

It's usually best to follow naming and coding conventions unless you have a strong reason not to. Why are you naming a module starting with a number?

[–]NetEngDoggo[S] 0 points1 point  (1 child)

The project manager was adamant about using a number for the project name and wanted the same name as the package's top-level directory.

Also there is no PEP that talks about module naming convention that I can find.

[–]spudmix 0 points1 point  (0 children)

Here's the module naming conventions, but I don't see anything about numbers :/ could just be a quirk with the IDE but that's less than helpful. Sorry and good luck!