[TriZPUG] jump start needed

Philip Semanchuk philip at semanchuk.com
Sat Dec 6 23:11:18 CET 2008


On Dec 5, 2008, at 8:34 PM, Scott Hicks wrote:

> Hi,
>
> I wanted to send out a message to see if anyone in Trizpug would be  
> gracious
> enough to answer a few questions and/or provide a little help to get  
> me
> started with Python.  I recently took the plunge and bought a new  
> MacBook
> Pro.  So, I am also learning the Mac OSx environment.  Here's is  
> what I am
> interested in:
>
> * Getting a python development environment setup correctly on the  
> Mac.  I
> would like to start with 3.0 since I am new, but do not yet see a  
> Mac image
> available yet on Python.org

Hi Scott,
Congrats on your new purchase. I really like my Macbook Pro as a user  
tool (email, surfing the Web, etc.) and as a development tool (Python,  
gcc, SSH, Unix-y goodness, etc.)

You already have a Python development on your Mac, v2.5 if I'm not  
mistaken. You can have multiple versions installed. In fact, I have  
two versions of 2.5 installed right now on my machine. I use my Mac as  
a standard Unix environment with /usr/local/src holding packages that  
I've downloaded and compiled. I downloaded the source for Python 2.5.1  
to /usr/local/src/Python-2.5.1 and ran the standard unix build steps  
of configure and make.

I think Python will find and make use of readline libs if it finds  
them already installed. This is what allows you to do command history  
& editing in the Python interpreter. You might want to download,  
compile & install that before compiling & installing Python.

The README that comes with Python 2.x has some specifics related to OS  
X. You probably want to pass the --enable-framework option to  
configure. (I'm assuming Py3k has similar options to Py2.x). AFAIK  
there's no penalty to doing so, and it will give you more flexibility  
later.

I don't remember whether or not this will create links in /usr/local/ 
bin, but if it doesn't, you probably want to do that. On my system, / 
usr/local/bin/python is a symlink to this:
/Library/Frameworks/Python.framework/Versions/2.5/bin/python

Note that OS X expects /usr/bin/python to point to the system Python,  
so you probably want to leave that symlink alone.

Then in ~/.profile I added this:
export PATH=/usr/local/bin:$PATH

So in Terminal when I type "Python" it finds "my" Python in /usr/local/ 
bin first. You could of course create symlinks called python25 and  
python3 or some such if you want to be able to invoke both interpreters.

I've never used Idle or any of the other apps that come along with  
Python.


> * I have purchased TextMate and would like to learn tips and tricks  
> of that
> editor

It's a nice editor. Let me know if you find a code completer that  
works. I've always been disappointed. I did a fair amount of coding in  
VB in the 90s and the excellent code completion was a nice aid.


> * I have a particular project in mind.  Pretty simple html parsing /
> processing and reading and writing to an sqlite database (database is
> complete).  I have looked at and played around with HTMLParser,  
> urllib, and
> other libraries such as twill.  They all seem to do the same job and  
> I am
> not sure which one would best suit my needs.  Eventually, I want to  
> get into
> driving Selenium Grid with Python.

Dunno about twill but HTMLParser and urllib are entirely different  
tools. Urllib is a semi-low level library for fetching things from the  
Net. HTMLParser parses HTML. They're complementary -- you could use  
urllib to fetch files and HTMLParser to parse them.

That said, HTMLParser is notoriously fussy, or that's my understanding  
of it. It is based on SGMLParser which complains if the SGML is  
malformed, and most Web pages are. [1] The canonical recommendation is  
to use a package called BeautifulSoup to parse messy Web HTML. I had  
used a library called htmldata that I liked and found a bit simpler  
than BeautifulSoup, but it's a little neglected at this point, I think:
http://www.connellybarnes.com/code/htmldata/


Hope that helps. I think the Mac is a fine development environment for  
Python. I hope you do too.


bye
P

PS - Thanks for putting in a good word about me to Santa; I'll need it.


[1] - Of the pages submitted to my validator Nikita the Spider, just  
38% were error free:
http://NikitaTheSpider.com/articles/ByTheNumbers/fall2008.html#basics


>
>
> I realize it is the holiday season and I do not want to get started  
> until
> January.  Hopefully, Python 3 will be available for the Mac by then.
>
> If anyone is willing to help me out, it would be much appreciated.   
> I will
> make sure Santa is extra nice to you.....
>
> Thanks,
>
> Scott Hicks
> _______________________________________________
> TriZPUG mailing list
> TriZPUG at python.org
> http://mail.python.org/mailman/listinfo/trizpug
> http://trizpug.org is the Triangle Zope and Python Users Group



More information about the TriZPUG mailing list