<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>kwatch</author_name>
  <author_url>https://blog.hatena.ne.jp/kwatch/</author_url>
  <blog_title>kなんとかの日記</blog_title>
  <blog_url>https://kwatch.hatenadiary.org/</blog_url>
  <categories>
    <anon>python</anon>
  </categories>
  <description>import 文を使わずに、任意の Python スクリプトをモジュールとして読み込む方法。こうすると、拡張子が「.py」じゃなくても読み込み可能。 import os file = 'foo.py' name = 'foo' module = type(os)(name) # (*1) module.__file__ = file execfile(file, module.__dict__, module.__dict__) # (*2) print module #=&gt; &lt;module 'foo' from 'foo.py'&gt;ポイントとなるのは次のところ。 (*1) 「type(os)(…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fkwatch.hatenadiary.org%2Fentry%2F20100412%2F1271021583&quot; title=&quot; import 文を使わずにモジュールを作成する - kなんとかの日記&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2010-04-12 06:33:03</published>
  <title> import 文を使わずにモジュールを作成する</title>
  <type>rich</type>
  <url>https://kwatch.hatenadiary.org/entry/20100412/1271021583</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
