CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Fri, 18 Jul 2025 20:16:29 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20071208095754
location: https://web.archive.org/web/20071208095754/https://wiki.python.org/moin/LoadingModulesDynamically
server-timing: captures_list;dur=0.640547, exclusion.robots;dur=0.022830, exclusion.robots.policy;dur=0.010064, esindex;dur=0.012005, cdx.remote;dur=19.416526, LoadShardBlock;dur=350.571625, PetaboxLoader3.datanode;dur=69.594618, PetaboxLoader3.resolve;dur=252.583507
x-app-server: wwwb-app215
x-ts: 302
x-tr: 400
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app215; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Fri, 18 Jul 2025 20:16:29 GMT
content-type: text/html;charset=utf-8
x-archive-orig-date: Sat, 08 Dec 2007 09:57:53 GMT
x-archive-orig-server: Apache/2.0.54 (Debian GNU/Linux) mod_fastcgi/2.4.2
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Sat, 08 Dec 2007 09:57:54 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Tue, 10 Oct 2006 07:57:40 GMT", ; rel="prev memento"; datetime="Tue, 10 Oct 2006 07:57:40 GMT", ; rel="memento"; datetime="Sat, 08 Dec 2007 09:57:54 GMT", ; rel="next memento"; datetime="Thu, 11 Aug 2011 04:04:46 GMT", ; rel="last memento"; datetime="Sun, 21 Jul 2024 03:54:19 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_1_20071208084132_crawl105-c/52_1_20071208095245_crawl107.arc.gz
server-timing: captures_list;dur=0.505513, exclusion.robots;dur=0.020180, exclusion.robots.policy;dur=0.009913, esindex;dur=0.010632, cdx.remote;dur=14.153138, LoadShardBlock;dur=233.997736, PetaboxLoader3.resolve;dur=179.694111, PetaboxLoader3.datanode;dur=125.546439, load_resource;dur=114.277657
x-app-server: wwwb-app215
x-ts: 200
x-tr: 429
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
LoadingModulesDynamically - PythonInfo Wiki
LoadingModulesDynamically
You can load a module dynamically like so:
1 __import__("os")
If you do that, though, "os" isn't bound to anything.
1 >>> __import__("os")
2 <module 'os' from '/usr/lib/python2.3/os.pyc'>
3 >>> os
4 Traceback (most recent call last):
5 File "<stdin>", line 1, in ?
6 NameError: name 'os' is not defined
7 >>>
Once you have the module, you probably want to find classes and functions and data inside of it.
Use getattr:
1 >>> m=__import__("mine")
2 >>> m
3 <module 'mine' from 'mine.pyc'>
4 >>> getattr(m, "eggs")
5 4654
6 >>> getattr(m, "ham")
7 'Monty Python'
EditText (last edited 2005-02-21 05:44:20 by LionKimbro)
DeleteCache (cached 2007-11-21 18:09:35)- Login
- Navigation
- Actions
- Your recent pages