Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
module run on import?
#1
I have this game I am working on. I am trying to use a config.py file for global variables like this.
from os import system

clear_screen = system("cls")
quit_game = exit(0)
output:
Output:
PS C:\Users\mcmxl>
I have also tried this. and get an attribute error.
from os import system

if __name__ == "__main__":
    clear_screen = system("cls")
    quit_game = exit(0)
Error:
Guess a letter. Traceback (most recent call last): File "c:/Users/mcmxl/mystuff/hangman/hangman.py", line 46, in main guess_letter = input("Guess a letter. ") KeyboardInterrupt During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:/Users/mcmxl/mystuff/hangman/hangman.py", line 112, in <module> main() File "c:/Users/mcmxl/mystuff/hangman/hangman.py", line 49, in main config.clear_screen AttributeError: module 'config' has no attribute 'clear_screen'
I don't know what else to do.
Reply


Messages In This Thread
module run on import? - by mcmxl22 - Mar-02-2020, 09:05 AM
RE: module run on import? - by Gribouillis - Mar-02-2020, 12:26 PM
RE: module run on import? - by buran - Mar-02-2020, 12:35 PM
RE: module run on import? - by mcmxl22 - Mar-02-2020, 04:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  is import cointegration_analysis a recognized module mitcht33 1 440 Nov-06-2023, 09:29 PM
Last Post: deanhystad
  problem in import module from other folder akbarza 5 1,446 Sep-01-2023, 07:48 AM
Last Post: Gribouillis
  can not import anaconda pandas module. PySpark pandas module is imported!! aupres 0 727 Aug-06-2023, 01:09 AM
Last Post: aupres
  import module error tantony 5 3,468 Dec-15-2022, 01:55 PM
Last Post: Lauraburmrs
  Import a module one step back of the path prathampatel9 1 1,084 Sep-21-2022, 01:34 PM
Last Post: snippsat
  Import a module for use in type hint? Milosz 0 1,495 Nov-08-2021, 06:49 PM
Last Post: Milosz
  Can't install nor import delorean module Tek 3 2,825 Oct-27-2021, 03:32 AM
Last Post: Tek
  import module with syntax error Skaperen 7 5,331 Jun-22-2021, 10:38 AM
Last Post: Skaperen
  'urllib3' Module not found when import 'requests' spanz 5 10,320 Jan-06-2021, 05:57 PM
Last Post: snippsat
  Problem with Flask Bcrypt import module marcello86 2 5,758 Aug-31-2020, 08:10 PM
Last Post: marcello86

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020