Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'sys': 0.05; 'versions,': 0.05; 'python': 0.09; 'currently,': 0.09; 'imported.': 0.09; 'modules.': 0.09; 'subject:Modules': 0.09; 'symlink': 0.09; 'writable': 0.09; 'cc:addr:python-list': 0.10; 'tutorials': 0.15; '.py': 0.16; 'files).': 0.16; 'pythonic': 0.16; 'reusable': 0.16; 'sys.path': 0.16; 'travis': 0.16; 'wrote:': 0.17; 'app': 0.19; 'module': 0.19; 'putting': 0.20; 'subject:) ': 0.20; 'written': 0.20; 'import': 0.21; 'assuming': 0.22; 'cc:2**0': 0.23; 'apps': 0.23; "i've": 0.23; 'seems': 0.23; 'cc:no real name:2**0': 0.24; 'command': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'creating': 0.26; 'appreciated.': 0.26; 'possibly': 0.27; 'separate': 0.27; 'module.': 0.27; 'actual': 0.28; '"the': 0.29; "i'm": 0.29; 'attach': 0.30; 'problem.': 0.32; 'could': 0.32; 'print': 0.32; 'curious': 0.33; 'another': 0.33; 'path': 0.35; 'same.': 0.35; 'pm,': 0.35; 'add': 0.36; 'tool': 0.36; 'but': 0.36; 'modules': 0.36; 'subject: (': 0.36; 'level': 0.37; 'two': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'things': 0.38; 'received:192': 0.39; 'called': 0.39; 'little': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'your': 0.60; 'high': 0.61; 'relatively': 0.62; 'different': 0.63; 'love': 0.63; 'more': 0.63; 'show': 0.63; 'making': 0.64; 'our': 0.65; 'serial': 0.66; 'family': 0.68; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'products.': 0.74; 'quickest': 0.84; 'ultimate': 0.93 Date: Fri, 07 Sep 2012 14:09:30 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Travis Griggs Subject: Re: Reusable (local) Modules References: <01D5A43C-4E12-410C-9D40-7DDFCA0867E4@gmail.com> In-Reply-To: <01D5A43C-4E12-410C-9D40-7DDFCA0867E4@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:RmmQ0hIyoQ+I7nTmYNC8HsZecpjP8fzhKZMvItCev3W pfP4LWUDY4CH1n8/+0REklU8RTkqwqt4IOh3Lkhq7y8hQh03F2 qHMJaxl1GA0g9cgsEGEVKLv6iaC6muhsODAJ/fWA7own2QPT3A tmEd5TUA4Q+qFcxrB2nZHWEM5Pf9HraVtRwbcYrj0BIGP8CALr z4IcwNQGSKse/xfyC1w0XvN/F4SQuB/wuljODjUnGrJg3yR+Fj 4iEf7dmd4aFFQJXl5xWAex3I3gUYN89TN6hdCPKB76wRrjshPZ /02LJi3TZ5DEAUOIX3REyYyil8RmEp+MuHWptbukTHi6TfAQg= = Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347041392 news.xs4all.nl 6918 [2001:888:2000:d::a6]:60088 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28700 On 09/07/2012 01:56 PM, Travis Griggs wrote: > I'm relatively new to Python (coming from strong C and Smalltalk backgrounds). I've written a couple of relatively small apps (one or two .py files). I'm using PyCharm (I love it). > > I'm curious what the pythonic approach is to creating your own reusable modules. Any tutorials or high level explanations, or detailed, much appreciated. > > For example, I have a small module called valvenumbers.py. It's a family of functions that we use to do a variety of things with the serial numbers we attach to some of our products. Now I'm making a little desktop app using wxpython, and I want to use (import) that module. Using PyCharm, I have two separate projects in sibling directories. And there's another separate command line tool that wants to do the same. Currently, I just place a symlink to the valvenumbers.py, local to the directory of these apps. This seems like "the quickest thing that could possibly work", but I'm assuming there's a more pythonic way to approach this general problem. > > TIA! > > Travis Griggs > "Simplicity is the ultimate sophistication." -- Leonardo Da Vinci > import sys print sys.path This will show you your path for imports. The actual directories change by default with different python versions, but one of them will be suitable for putting new modules to be imported. Naturally, you don't want to add to the place where the stdlib is placed, but some of those are normal writable directories. -- DaveA