Apr-28-2023, 02:10 AM
(This post was last modified: Apr-28-2023, 02:45 AM by deanhystad.)
There is a problem with this:
That is what import does, your know. Yes, it pulls in modules and compiles them to byte code, but it also creates objects and assigns them to variables. import inflext loads the inflect module, but it also creates a variable named "inflext" to which it assigns a module object. In your pyfiglet example you never did "import pyfiglet". There was no variable named "pyfiglet" created and no module object created. "from pyfiglet import Figlet" creates a variable named Figlet and assigns pyfiglet.Figlet (probably a class) to the variable.
This should work.
from pyfiglet import Figlet figlet = Figlet() pyfiglet.getFonts() figlet.setFont(font=f)You did not import pyfiglet. You only imported Figlet. The "figlet = Figlet()" probably works. "pyfiglet.getFonts()" would fail and cause a crash with a NameError because you never assigned a value to a variable named "pyfiglet.
That is what import does, your know. Yes, it pulls in modules and compiles them to byte code, but it also creates objects and assigns them to variables. import inflext loads the inflect module, but it also creates a variable named "inflext" to which it assigns a module object. In your pyfiglet example you never did "import pyfiglet". There was no variable named "pyfiglet" created and no module object created. "from pyfiglet import Figlet" creates a variable named Figlet and assigns pyfiglet.Figlet (probably a class) to the variable.
This should work.
import pyfiglet from pyfiglet import Figlet figlet = Figlet() pyfiglet.getFonts() figlet.setFont(font=f)I don't know why you would have a problem with inflect. Can you post a program that uses inflect and has an error. Also post the error message and error trace.