I seem to be having a problem importing functions from a file whenever I use the wildcard "*".

from text import *

Raises this error:

NameError: global name '_Star' is not defined

However, if I ask it to import the Function names' manually like so:

from text import _Star, _Zero, _One

The program works perfectly, does anyone know why this is so? I have around 60 individual functions in the text.py file and I don't want to make my code semi-messy by writing out the individual functions out in the import.

Recommended Answers

Names starting with single underscore are for modules internal use and should not be imported. You are also talking about functions, but names starting with capital letter should belong to class, not function, by PEP8 style guide.

Jump to Post

All 2 Replies

Names starting with single underscore are for modules internal use and should not be imported. You are also talking about functions, but names starting with capital letter should belong to class, not function, by PEP8 style guide.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.