Python import charpy

410 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
410
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Python import charpy

  1. 1. import * from ... http://www.flickr.com/photos/burnblue/ Jeff Gayle, Horizon Investments, LLC
  2. 2. >>>import json >>>print json.dumps(""foobar") ""foobar" >>>from json import dumps >>>print dumps(""foobar") ""foobar" >>>from json import * >>>from django.core import auth review http://effbot.org/zone/import-confusion.htm
  3. 3. dynamic loading
  4. 4. >>>my_mod=‘mymodule’ >>>import my_mod Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named my_mod no sweat!
  5. 5. >>>my_mod=‘mymodule’ >>>mm = __import__(my_mod) >>>mm.run_cmd() >>>import mymodule >>> >>>mm = __import__(my_mod, globals(), locals(),[run_cmd], -1) >>>mm.run_cmd() __import__
  6. 6. example
  7. 7. residue http://docs.python.org/library/imp.html http://docs.python.org/library/abc.html http://docs.python.org/library/functions.html#__import__ http://docs.python.org/library/functions.html reload function

×