{"id":1453,"date":"2020-06-17T00:00:00","date_gmt":"2020-06-16T15:00:00","guid":{"rendered":"https:\/\/www.ishikawasekkei.com\/?p=1453"},"modified":"2020-06-17T07:03:26","modified_gmt":"2020-06-16T22:03:26","slug":"python-programing-name","status":"publish","type":"post","link":"https:\/\/www.ishikawasekkei.com\/index.php\/2020\/06\/17\/python-programing-name\/","title":{"rendered":"Python \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 __name__\u3063\u3066\u306a\u306b\uff1f"},"content":{"rendered":"\n<p>\u3000\u4eca\u65e5\u3082\u898b\u306b\u6765\u3066\u304f\u3060\u3055\u3063\u3066\u3001\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\u3002\u77f3\u5ddd\u3055\u3093\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3000\u304a\u53cb\u3060\u3061\u304b\u3089\u3001__name__\u306e\u3053\u3068\u304c\u3088\u304f\u5206\u304b\u3089\u306a\u3044\u3001\u3068\u3001\u8cea\u554f\u3092\u3044\u305f\u3060\u3044\u305f\u306e\u3067\u3001\u5b9f\u969b\u306b\u3069\u3046\u306a\u3063\u3066\u3044\u308b\u306e\u304b\u3001\u5b9f\u884c\u7d50\u679c\u3092\u78ba\u8a8d\u3057\u3064\u3064\u3001\u8aac\u660e\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u306f\u3058\u3081\u306b<\/h2>\n\n\n\n<p>\u3000\u307e\u305a\u521d\u3081\u306b\u3001dir()\u3068\u3044\u3046\u7d44\u307f\u8fbc\u307f\u95a2\u6570\u304c\u3042\u308a\u307e\u3057\u3066\u3001\u30b3\u30de\u30f3\u30c9\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u30fc\u3067\u5b9f\u884c\u3059\u308b\u3068\u3001\u73fe\u5728\u306e\u30ed\u30fc\u30ab\u30eb\u30b9\u30b3\u30fc\u30d7\u306b\u3042\u308b\u540d\u524d\u306e\u30ea\u30b9\u30c8\u3092\u8fd4\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">In [1]: print(dir())\n['In', 'Out', '_', '__', '___', '__builtin__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '_dh', '_i', '_i1', '_ih', '_ii', '_iii', '_oh', 'exit', 'get_ipython', 'quit']\n<\/pre>\n\n\n\n<p>\u3000\u51fa\u529b\u7d50\u679c\u306e1\u884c\u76ee\u306e\u53f3\u7aef\u306b\u3042\u308a\u307e\u3059\u306d\u3002\u3053\u3093\u306a\u611f\u3058\u3067\u3001\u300c__name__\u300d\u3068\u3044\u3046\u540d\u524d\u304cPython\u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u306e\u4e2d\u306b\u4e8b\u524d\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3055\u3066\u3001\u3053\u3061\u3089\u304c\u306a\u306b\u304b\u3001\u3061\u3087\u3063\u3068\u8abf\u3079\u3066\u307f\u307e\u3059\u3002\u7d44\u307f\u8fbc\u307f\u95a2\u6570\u306etype()\u3092\u4f7f\u3046\u3068\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u578b\u3092\u8fd4\u3057\u3066\u304f\u308c\u307e\u3059\u3002\u307e\u305a\u306ftype()\u3067\u578b\u3092\u8abf\u3079\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">In [2]: type(__name__)\nOut[2]: str<\/pre>\n\n\n\n<p>\u3000\u306a\u308b\u307b\u3069\u3001\u3053\u3053\u3067\u3001\u300c__name__\u300d\u304c\u6587\u5b57\u5217\u306e\u5909\u6570\u3067\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3057\u305f\u3002\u4e2d\u8eab\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">In [3]: print(__name__)\n__main__<\/pre>\n\n\n\n<p>\u3000\u5909\u6570\u300c__name__\u300d\u306e\u4e2d\u8eab\u306f\u300c&#8221;__main__&#8221;\u300d\u3068\u3044\u3046\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30d5\u30a1\u30a4\u30eb\u3092\u3064\u304f\u3063\u3066\u78ba\u8a8d\u3057\u307e\u3059<\/h2>\n\n\n\n<p>\u3000\u30b3\u30de\u30f3\u30c9\u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u3067\u78ba\u8a8d\u3057\u3066\u307f\u308b\u3068\u3001\u30bb\u30c3\u30c8\u3055\u308c\u305f\u5024\u306f\u300c__main__\u300d\u3067\u3057\u305f\u3002\u3053\u306e\u5024\u306f\u3001\u300c__main__\u300d\u4ee5\u5916\u306b\u8a2d\u5b9a\u3055\u308c\u308b\u3053\u3068\u306f\u3042\u308b\u306e\u3067\u3057\u3087\u3046\u304b\uff1f\u5229\u7528\u3055\u308c\u3066\u3044\u308b\u7b87\u6240\u3067\u77e5\u3063\u3066\u3044\u308b\u306e\u306f\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u3067\u3057\u305f\u3002\u3068\u3001\u3044\u3046\u3053\u3068\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u300cmynameis.py\u300d\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\"\"\"\" __name__ \u306b\u3069\u3093\u306a\u5024\u304c\u30bb\u30c3\u30c8\u3055\u308c\u3066\u3044\u308b\u304b\u3001\u78ba\u8a8d\u3057\u307e\u3059\u3002 \"\"\"\n\nprint(\"My name is \" + __name__)<\/pre>\n\n\n\n<p>\u3000\u5358\u7d14\u306b\u3001\u5024\u3092print()\u3059\u308b\u3060\u3051\u306e\u8a18\u8ff0\u3092\u542b\u3080\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002<br>\u3055\u3066\u3001\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">In [4]: %run mynameis.py\nMy name is __main__<\/pre>\n\n\n\n<p>\u3000\u30d5\u30c4\u30fc\u306b\u5b9f\u884c\u3059\u308b\u3068\u3001\u3084\u306f\u308a\u300c__main__\u300d\u304c\u30bb\u30c3\u30c8\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3061\u306a\u307f\u306b%run\u306fIPython\u306e\u30de\u30b8\u30c3\u30af\u30b3\u30de\u30f3\u30c9\u3067\u3001\u6307\u5b9a\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u76f4\u63a5\u5b9f\u884c\u3057\u307e\u3059\u3002\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u3060\u3068\u3001\u300cpython mynameis.py\u300d\u3068\u5b9f\u884c\u3059\u308b\u306e\u3068\u540c\u3058\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002<br>\u3055\u3066\u3001\u6b21\u306b\u3053\u306e\u300cmnameis.py\u300d\u30d5\u30a1\u30a4\u30eb\u304c\u30e2\u30b8\u30e5\u30fc\u30eb\u3060\u3068\u3044\u3046\u3053\u3068\u306b\u3057\u3066\u3001import\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">In [5]: import mynameis\nMy name is mynameis<\/pre>\n\n\n\n<p>\u3000import\u3059\u308b\u3068\u3001mynameis.py\u306e\u5185\u5bb9\u304c\u8aad\u307f\u8fbc\u307e\u308c\u3001\u3059\u3079\u3066\u4e0a\u304b\u3089\u9806\u756a\u306b\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u300c__name__\u300d\u306b\u306f\u3001\u3053\u306e\u3088\u3046\u306b\u30e2\u30b8\u30e5\u30fc\u30eb\u540d\u304c\u30bb\u30c3\u30c8\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u3064\u304f\u308b\u3068\u304d\u306f\u3001\u3053\u306e\u9055\u3044\u3092\u5229\u7528\u3057\u3066\u3001<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">if __name__ == \"__main__\":<\/pre>\n\n\n\n<p>\u3068\u3044\u3046\u3075\u3046\u306b\u30e2\u30b8\u30e5\u30fc\u30eb\u5185\u306bif\u6587\u3092\u8a18\u8f09\u3059\u308b\u3053\u3068\u3067\u3001import\u304b\u3089\u5b9f\u884c\u3055\u308c\u305f\u3068\u304d\u3068\u3001%run\u306a\u3069\u3067\u76f4\u63a5\u5b9f\u884c\u3055\u308c\u305f\u3068\u304d\u306e\u3075\u308b\u307e\u3044\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u3000\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f5c\u308b\u3068\u304d\u3001import\u3067\u547c\u3073\u51fa\u3057\u3066\u5229\u7528\u3059\u308b\u3060\u3051\u3067\u306a\u304f\u3001\u76f4\u63a5\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306b\u3001\u300c__name__\u300d\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u4eca\u65e5\u3082\u898b\u306b\u6765\u3066\u304f\u3060\u3055\u3063\u3066\u3001\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\u3002\u77f3\u5ddd\u3055\u3093\u3067\u3059\u3002 \u3000\u304a\u53cb\u3060\u3061\u304b\u3089\u3001__name__\u306e\u3053\u3068\u304c\u3088\u304f\u5206\u304b\u3089\u306a\u3044\u3001\u3068\u3001\u8cea\u554f\u3092\u3044\u305f\u3060\u3044\u305f\u306e\u3067\u3001\u5b9f\u969b\u306b\u3069\u3046\u306a\u3063\u3066\u3044\u308b\u306e\u304b\u3001\u5b9f\u884c\u7d50\u679c\u3092\u78ba\u8a8d\u3057\u3064\u3064\u3001\u8aac\u660e\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002  &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.ishikawasekkei.com\/index.php\/2020\/06\/17\/python-programing-name\/\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Python \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 __name__\u3063\u3066\u306a\u306b\uff1f&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,2],"tags":[],"class_list":["post-1453","post","type-post","status-publish","format-standard","hentry","category-program","category-blog"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts\/1453","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/comments?post=1453"}],"version-history":[{"count":4,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts\/1453\/revisions"}],"predecessor-version":[{"id":1457,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/posts\/1453\/revisions\/1457"}],"wp:attachment":[{"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/media?parent=1453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/categories?post=1453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ishikawasekkei.com\/index.php\/wp-json\/wp\/v2\/tags?post=1453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}