Movatterモバイル変換


[0]ホーム

URL:


how to avoid importing the same module more than once?

Brian QuinlanBrianQ at ActiveState.com
Mon Apr 9 18:20:42 EDT 2001


Multiplying importing modules in Python is reasonably inexpensive. If Pythonsees that the module has already been imported (by looking in sys.modules),it does nothing.-----Original Message-----From:python-list-admin at python.org[mailto:python-list-admin at python.org]On Behalf Of Graham GuttocksSent: Monday, April 09, 2001 3:08 PMTo:python-list at python.orgSubject: how to avoid importing the same module more than once?Greetings,When breaking up a large program into several different modules, I'mwondering if there is any way to avoid importing the same global modulesmore than once, as I'm sure this is degrading performance.For example, if I have a program which uses the "os" built-in moduleand imports two custom modules which also use "os", then I end uprunning "import os" three times!Regards,Graham_____________________________________________________________________________http://movies.yahoo.com.au - Yahoo! Movies- Now showing: Dude Where's My Car, The Wedding Planner, Traffic..--http://mail.python.org/mailman/listinfo/python-list


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp