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


Groups > comp.lang.python > #75216

Prob. Code Downloaded for Programming the Semantic Web (python code)

Newsgroups comp.lang.python
Date 2014-07-25 17:06 -0700
Message-ID <8e593a0d-cf61-4b1a-8273-8309496e3696@googlegroups.com> (permalink)
Subject Prob. Code Downloaded for Programming the Semantic Web (python code)
From Bruce Whealton <futurewavewebdevelopment@gmail.com>

Show all headers | View raw


Hello all,
       I downloaded some code accompanying the book "Programming the Semantic Web."  This question is not Semantic Web related and I doubt that one needs to know anything about the Semantic Web to help  me with this.  It's the first code sample in the book, I'm embarrassed to say.  I have the code shared here (just one file, not the majority of the book or anything): http://pastebin.com/e870vjYK

OK, Eclipse with PyDev doesn't like this first line, with the function:
def add(self, (sub, pred, obj)):

It complains about the parentheses just before sub.  Simply removing them just moves me down to another error.  I did try using python 3.x (3.4 to be specific), which meant changing print statements to function calls.  Of course, that didn't fix the errors I was mentioning.  The text uses python 2.7.x.  

There are other places where I thought that there were too many parentheses and I tried removing one set of them.  For example this snippet here:

    def remove(self, (sub, pred, obj)):
        """
        Remove a triple pattern from the graph.
        """
        triples = list(self.triples((sub, pred, obj)))

Are the two sets parentheses needed after self.triples?  That syntax is confusing to me.  It seems that it should be
triples = list(self.triples(sub, pred, obj))

The full listing is here: http://pastebin.com/e870vjYK

I agree with the authors that python is a fun and easy language to use, thus it is strange that I am getting stuck here.

Thanks,
Bruce    

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


Thread

Prob. Code Downloaded for Programming the Semantic Web (python code) Bruce Whealton <futurewavewebdevelopment@gmail.com> - 2014-07-25 17:06 -0700
  Re: Prob. Code Downloaded for Programming the Semantic Web (python code) Skip Montanaro <skip@pobox.com> - 2014-07-25 19:21 -0500
  Re: Prob. Code Downloaded for Programming the Semantic Web (python code) Dan Stromberg <drsalists@gmail.com> - 2014-07-25 17:52 -0700
  Re: Prob. Code Downloaded for Programming the Semantic Web (python code) Ian Kelly <ian.g.kelly@gmail.com> - 2014-07-25 19:39 -0600
  Re: Prob. Code Downloaded for Programming the Semantic Web (python code) Steven D'Aprano <steve+gmane@pearwood.info> - 2014-07-26 11:28 +1000
    Re: Prob. Code Downloaded for Programming the Semantic Web (python code) Bruce Whealton <futurewavewebdevelopment@gmail.com> - 2014-07-28 03:39 -0700
      Re: Prob. Code Downloaded for Programming the Semantic Web (python code) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-07-28 15:28 +0000
        Re: Prob. Code Downloaded for Programming the Semantic Web (python code) Bruce Whealton <futurewavewebdevelopment@gmail.com> - 2014-07-28 17:57 -0700
  Re: Prob. Code Downloaded for Programming the Semantic Web (python code) Chris Angelico <rosuav@gmail.com> - 2014-07-26 13:25 +1000
    Re: Prob. Code Downloaded for Programming the Semantic Web (python code) Bruce Whealton <futurewavewebdevelopment@gmail.com> - 2014-07-28 04:07 -0700
  Re: Prob. Code Downloaded for Programming the Semantic Web (python code) Terry Reedy <tjreedy@udel.edu> - 2014-07-26 03:05 -0400

csiph-web