Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Importing classes?
#2
Python style is generally to do all imports at the top of the file. If you do that they are accessible anywhere in the file. I only violate that in two cases: dynamic imports (where you don't know ahead of time what is going to be imported), and if __main__ blocks that need something that isn't needed when the file is imported.

You can import the functions into the file with the GUI, or you can import them both into a third file. The main problem would be if you created an cycle in your imports (foo.py imports bar, when bar.py is trying to import foo).
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Importing classes? - by frequency - Dec-30-2018, 02:21 PM
RE: Importing classes? - by ichabod801 - Dec-30-2018, 02:29 PM
RE: Importing classes? - by frequency - Dec-30-2018, 02:42 PM
RE: Importing classes? - by ichabod801 - Dec-30-2018, 03:01 PM
RE: Importing classes? - by frequency - Dec-30-2018, 03:10 PM
RE: Importing classes? - by ichabod801 - Dec-30-2018, 03:22 PM
RE: Importing classes? - by frequency - Dec-30-2018, 07:04 PM
RE: Importing classes? - by frequency - Dec-30-2018, 08:20 PM
RE: Importing classes? - by ichabod801 - Dec-30-2018, 08:27 PM
RE: Importing classes? - by frequency - Dec-31-2018, 03:34 PM
RE: Importing classes? - by frequency - Dec-31-2018, 04:48 PM
RE: Importing classes? - by ichabod801 - Dec-31-2018, 07:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pygame importing classes Padalinkiller1 2 3,836 Nov-15-2017, 02:08 PM
Last Post: Padalinkiller1
  Problems with importing classes in different folder Xeraphim 3 3,447 Nov-08-2017, 03:20 PM
Last Post: Larz60+
  Using classes? Can I just use classes to structure code? muteboy 5 5,183 Nov-01-2017, 04:20 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

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