Learn Python Easy Way

Thursday, February 18, 2016

using import in class

class C:
    os = __import__('sys')
    def f(self):
        print self.os.platform

c = C()
c.f()


Link:
http://stackoverflow.com/questions/6861487/importing-modules-inside-python-class

Posted by Gopal Singh at 1:07 PM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blog Archive

  • ►  2017 (13)
    • ►  September (4)
    • ►  August (6)
    • ►  July (3)
  • ▼  2016 (62)
    • ►  August (1)
    • ►  June (8)
    • ►  May (11)
    • ►  April (18)
    • ►  March (17)
    • ▼  February (5)
      • gtk webkit create window
      • python logging on both file and console
      • sorting algorithms
      • using import in class
      • file read in one line
    • ►  January (2)
  • ►  2015 (77)
    • ►  December (8)
    • ►  November (19)
    • ►  October (28)
    • ►  September (2)
    • ►  August (17)
    • ►  July (3)
  • ►  2013 (1)
    • ►  October (1)
Simple theme. Powered by Blogger.