<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>pandazx</author_name>
  <author_url>https://blog.hatena.ne.jp/pandazx/</author_url>
  <blog_title>pandazx's blog</blog_title>
  <blog_url>https://pandazx.hatenablog.com/</blog_url>
  <categories>
    <anon>python</anon>
  </categories>
  <description>以下のようにしておけば、sample.py が他のスクリプトから呼ばれた時に main()を実行することを避けられる。 # sample.py import sys def calc(val): x = val + 1 def main(): calc(1) if sys.argsv[0] == __file__: main() これにより、前に作ったスクリプトのメソッドを流用したい時に、簡単にimportできるようになる。</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fpandazx.hatenablog.com%2Fentry%2F2017%2F10%2F26%2F103835&quot; title=&quot;python2で実行スクリプト名の判定 - pandazx&amp;#39;s blog&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>2017-10-26 10:38:35</published>
  <title>python2で実行スクリプト名の判定</title>
  <type>rich</type>
  <url>https://pandazx.hatenablog.com/entry/2017/10/26/103835</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
