Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.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.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'binary': 0.07; 'laura': 0.07; 'rename': 0.07; '"my': 0.09; 'creighton': 0.09; 'happen.': 0.09; 'cc:addr:python-list': 0.11; '>in': 0.16; 'nameerror:': 0.16; 'received:openend.se': 0.16; 'received:theraft.openend.se': 0.16; 'unexpected': 0.16; 'code.': 0.18; 'wed,': 0.18; 'feb': 0.22; 'import': 0.22; 'cc:addr:gmail.com': 0.22; 'cc:addr:python.org': 0.22; 'subject:problem': 0.24; 'fine': 0.24; 'script': 0.25; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'unix': 0.29; 'cc:2**2': 0.30; 'url:mailman': 0.30; 'that.': 0.31; '+0100,': 0.31; 'writes:': 0.31; 'file': 0.32; 'run': 0.32; 'linux': 0.33; 'url:python': 0.33; 'there,': 0.34; 'problem': 0.35; 'something': 0.35; 'test': 0.35; 'but': 0.35; 'there': 0.35; 'that!': 0.36; 'done': 0.36; 'url:listinfo': 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'system,': 0.38; 'problems': 0.38; 'expect': 0.39; 'bad': 0.39; 'system.': 0.39; 'url:mail': 0.40; 'header:Message-Id:1': 0.63; 'email addr:gmail.com': 0.63; 'name': 0.63; '>from': 0.68; "'test'": 0.84; '2015': 0.84; 'safe.': 0.84; 'received:89': 0.85; 'cc:no real name:2**2': 0.91; 'shell,': 0.91 To: Laura Creighton From: Laura Creighton Subject: Re: function inclusion problem In-Reply-To: Message from Laura Creighton of "Wed, 11 Feb 2015 01:06:00 +0100." <201502110006.t1B060VZ021974@fido.openend.se> References: <201502110006.t1B060VZ021974@fido.openend.se> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <24277.1423613791.1@fido> Content-Transfer-Encoding: quoted-printable Date: Wed, 11 Feb 2015 01:16:31 +0100 Cc: python-list@python.org, vlyamtsev@gmail.com, lac@openend.se 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1423613800 news.xs4all.nl 2857 [2001:888:2000:d::a6]:58702 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85491 In a message of Wed, 11 Feb 2015 01:06:00 +0100, Laura Creighton writes: >In a message of Tue, 10 Feb 2015 15:38:02 -0800, vlyamtsev@gmail.com writ= es: >>I defined function Fatalln in "mydef.py" and it works fine if i call it = from "mydef.py", but when i try to call it from "test.py" in the same fold= er: >>import mydef >>... >>Fatalln "my test" >>i have NameError: name 'Fatalln' is not defined >>I also tried include('mydef.py') with the same result... >>What is the right syntax? >>Thanks >>-- = >>https://mail.python.org/mailman/listinfo/python-list > >from mydef import Fatalln > Also, please be warned. If you use a unix system, or a linux system. There are lots of problems you can get into if you expect something named 'test' to run your code. Because they already have one in their shell, and that one wins, and so ... well, test.py is safe. But if you rename it as a script and call it the binary file test ... Bad and unexpected things happen. Name it 'testme' or something like that. Never have that problem again. :) Been there, done that! Laura