Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28701

Re: Reusable (local) Modules

Path csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
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; 'path,': 0.09; 'specific.': 0.09; 'subject:Modules': 0.09; 'symlink': 0.09; 'writable': 0.09; 'cc:addr:python-list': 0.10; 'yet.': 0.13; '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; 'maybe': 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; 'there': 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; 'sure': 0.38; 'several': 0.39; '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; 'complexity': 0.84; 'quickest': 0.84; 'ultimate': 0.93
Date Fri, 07 Sep 2012 14:11:00 -0400
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0
MIME-Version 1.0
To Travis Griggs <travisgriggs@gmail.com>
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:f5RWgRO9EEPcm6n3RUFejX07Rrz8YNG8Z4ADIWlKhKq ipmotdNyZD/gTZI1rjSmjJryDbyv7MTPhxNRVPWIe6z+nyA9T+ fat+Cp7pzv68tZ4YKSNdkzFGU1PJA1QjaAcqsJ9ikkR92xzMXe Wq4WqrHvy0dEvDu+Gc17tk7ScO3fYafHi3pe69ckjccjKI+aqw FZK/f+52eVFOhQFtd5zStw4EEVsEdlp6xonS1n4k/bR5SWrneQ m0Z6tcKdqVKkhyQrwqxcBn2f8BT6aAu621xIvEJdTcIJuu/8kK aL9tclT/PkqOnXLzTicMDNLzZKZhxNXwhOYjyk74F9rtGzyKg= =
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.364.1347041483.27098.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1347041483 news.xs4all.nl 6889 [2001:888:2000:d::a6]:32983
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28701

Show key headers only | View raw


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. There are also several ways to add your
own directories to that path, but maybe you don't need that complexity yet.

I'm sure others will be able to be more specific.

-- 

DaveA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Reusable (local) Modules Dave Angel <d@davea.name> - 2012-09-07 14:11 -0400

csiph-web