{"author_name":"kwatch","blog_title":"k\u306a\u3093\u3068\u304b\u306e\u65e5\u8a18","blog_url":"https://kwatch.hatenadiary.org/","provider_url":"https://hatena.blog","type":"rich","categories":["python"],"version":"1.0","provider_name":"Hatena Blog","published":"2010-04-12 06:33:03","url":"https://kwatch.hatenadiary.org/entry/20100412/1271021583","author_url":"https://blog.hatena.ne.jp/kwatch/","title":" import \u6587\u3092\u4f7f\u308f\u305a\u306b\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f5c\u6210\u3059\u308b","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fkwatch.hatenadiary.org%2Fentry%2F20100412%2F1271021583\" title=\" import \u6587\u3092\u4f7f\u308f\u305a\u306b\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f5c\u6210\u3059\u308b - k\u306a\u3093\u3068\u304b\u306e\u65e5\u8a18\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","description":"import \u6587\u3092\u4f7f\u308f\u305a\u306b\u3001\u4efb\u610f\u306e Python \u30b9\u30af\u30ea\u30d7\u30c8\u3092\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u3057\u3066\u8aad\u307f\u8fbc\u3080\u65b9\u6cd5\u3002\u3053\u3046\u3059\u308b\u3068\u3001\u62e1\u5f35\u5b50\u304c\u300c.py\u300d\u3058\u3083\u306a\u304f\u3066\u3082\u8aad\u307f\u8fbc\u307f\u53ef\u80fd\u3002 import os file = 'foo.py' name = 'foo' module = type(os)(name) # (*1) module.__file__ = file execfile(file, module.__dict__, module.__dict__) # (*2) print module #=> <module 'foo' from 'foo.py'>\u30dd\u30a4\u30f3\u30c8\u3068\u306a\u308b\u306e\u306f\u6b21\u306e\u3068\u3053\u308d\u3002 (*1) \u300ctype(os)(\u2026","image_url":null,"height":"190","width":"100%"}