Newbie help - Programming the Semantic Web with Python

Bruce Whealton bruce at whealton.info
Sat Jul 9 21:32:00 EDT 2011


Hello,
            So, I got this book on Programming the Semantic Web about the same time I started learning Python.  The code seems to be developed for python 2.7 and not 3, I believe.  The code is here:
http://semprog.com/content/the-book/
I tried to run simpletriple.py from inside eclipse with PYDEV.  The first thing it has a problem with is this line:
    def add(self, (sub, pred, obj)):
I think the problem is with the parentheses before the sub.  I removed those and that seemed to fix that error or make it go away.  I don’t remember how I figured that out,   It should be on the Errata page for sure.  
Then it has a problem with this line:
    print list(g.triples((None, None, None)))
If I was using python 3, it would require () around the thing that is going to be printed, right?  Maybe python 2.7 doesn’t like this line for the same reason.  

The book suggests that from IDLE, I can just use 
>>>from simplegraph import SimpleGraph
That means it is going to look for a file named simplegraph.py
but where will it be looking?  I guess I would have to have it in the same folder as the python interpreter or one of the PATH directories, right?
Thanks,
Bruce

++++++++++++++++++++++++++++++++++++++++++++++++++

Bruce Whealton, Owner Future Wave Designs

FOAF: http://whealton.info/BruceWhealtonJr/foaf.rdf

Vcard: http://whealton.info/BruceWhealtonJr/brucewhealtonvcard.html

Web Design and Development http://FutureWaveDesigns.com

http://futurewavedesigns.com/wordpress/

Web Technology wiki: http://futurewavedesigns.com/w/

++++++++++++++++++++++++++++++++++++++++++++++++++

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110709/5c304d87/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wlEmoticon-smile[1].png
Type: image/png
Size: 1041 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20110709/5c304d87/attachment.png>


More information about the Python-list mailing list