Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'scripts': 0.03; 'subject:file': 0.07; '__name__': 0.09; 'executed': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:script': 0.09; 'garg': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.18; 'import': 0.22; 'header:User-Agent:1': 0.23; 'module,': 0.24; 'script.': 0.24; 'mon,': 0.24; 'script': 0.25; 'gets': 0.27; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'run': 0.32; 'running': 0.33; 'call.': 0.33; 'subject:from': 0.34; 'usual': 0.35; 'should': 0.36; 'nov': 0.38; 'somebody': 0.38; 'to:addr:python-list': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'course': 0.61; 'protect': 0.79; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: Excute script only from another file Date: Mon, 25 Nov 2013 07:16:46 -0500 References: <989ee1b9-141a-4cb3-a9a2-f1527c0d0db3@googlegroups.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 174.32.174.29 In-Reply-To: User-Agent: Groundhog Newsreader for Android X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1385381781 news.xs4all.nl 15880 [2001:888:2000:d::a6]:55436 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60410 On Mon, 25 Nov 2013 02:52:46 -0800 (PST), Himanshu Garg wrote: > My motive is "I will give scripts to somebody else and he should not run the script directly without running the parent script". Perhaps it should be a module, not a script. Have it protect itself with the usual if __name__ == "__main__" And of course it gets executed by an import and a call. -- DaveA