[Pythonmac-SIG] warning: newbie ahead
Henning Hraban Ramm
hraban at fiee.net
Sun Sep 16 00:12:54 CEST 2007
Am 2007-09-15 um 21:35 schrieb Paul Archibald:
> I am a (Mac) C++/Java programmer looking to expand myself into
> Python. I have been working through some tutorials, which has made me
> want more, but I am having trouble understanding how to organize and
> manage the project files that I write or otherwise obtain.
>
> What I am looking for is how to manage my PDE (Python Development
> Environment) and project file so that I can write real programs,
> saving, loading and executing, importing modules and calling
> functions from various modules that I have written or otherwise
> obtained. I have grabbed some code from various places on the web,
> but I don't know where to put the files so that I an use them, except
> for opening them in the editor and executing them, which is nice but
> does not let me build real programs.
>
> So, if you are building a program, where do you keep your sourcecode
> for that progam, and how does Python know how to find it, and how do
> you "link" modules together to make bigger programs?
>
> There is a little info on configuration in the Mac Modules tutorial,
> but it I still have some problems with .py scripts that seem to
> execute okay but from which I cannot import any methods.
>
> I am using IDLE w/Python 2.5, which does not have the "set scripts
> folder" command like MacPython 2.4.
As a Java guy you're surely comfortable with Eclipse, and PyDev for
Eclipse makes a good Python IDE.
A pure Python IDE would be SPE (see http://pythonide.blogspot.com/).
Please dump IDLE.
A Python projects demans no special folder structure, but if you plan
to deploy your projects to anyone/where else, I'd propose that you
only keep a small loader script in your main folder and everything
else in subfolders - that looks cleanest and runs fastest, because
the called script is never precompiled (the other files become .pyc
or .pyo) and thus loads slowest.
Of course you can simply import classes and functions from any Python
file in the same folder.
A Python "package" is just a folder with an __init__.py and as much
class/module files as you like.
While the folder is on your Python path, you can just import it like
"import mystuff" or "from mystuff import myclass, myotherclass".
If you need the same classes for several projects, you could install
your libs in site-packages (e.g. /Library/Frameworks/Python.framework/
Versions/Current/lib/python2.5/site-packages).
I guess you know the official tutorial?
http://docs.python.org/tut/tut.html
Greetlings from Lake Constance!
Hraban
---
http://www.fiee.net
https://www.cacert.org (I'm an assurer)
More information about the Pythonmac-SIG
mailing list