I'm creating a module that I'll import in a main script. In the module, called "colors", there's a function: "info()".
colors-module:
def info(function=None):
print("\ncolors\n Info\n")
The problem I have, is that I may also create a function called "info()", in the main script. This won't be a problem, as long as I import the colors-module as:
import colors
If so, I would call the function in the module by writing:
colors.info()
If I instead import the module as:
from colors import *
I have two functions called the exact same.
Main script:
from colors import *
def info(): # A
print("Main script's function")
info() # A
colors.info() # Am I able to force use of the module name before calling the
# function, if I import the module as in this script? Can this
# be done from the module, and not from the main script? As said,
# force use of module name, as "colors.info()", shall only apply
# when the module is being imported with "from colors import *".
EDIT 1
The reason why I want to import the module this way, is because of global variables in it:
bwc0 = (0, 0, 0)
bwc1 = (1, 1, 1)
bwc2 = (2, 2, 2)
# All the way to 255
After a few answers, I'll try adding these to a class, and import that class as *, if possible. I also have a few functions in it, that I want imported as *, too. I'm not exactly sure how to import them, yet. It's probably easy, I suppose.
def redc(value):
return value, 0, 0
def greenc(value):
return 0, value, value
Thanks for all help