Home Messages Index
[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index

Re: [News] Canonical Launches New Software Called 'Bazaar'

Verily I say unto thee, that Linonut spake thusly:

> It used to bug me that it was written in Python, but having studied
> Python lately, I think the language is quite up to this task (if you're
> asking me, which if I know what you think and I think I do, you're not,
> but I don't care <grin>).

I've been working with Python quite a bit recently (out of necessity),
and I am extremely impressed. It's the most flexible language I've used
so far, in more ways than one, and not that overwhelming to learn either.

Here's a snippet of a basic RSS reader I wrote:

for lastdate,thisfeed  in zip(dates, feeds):

   print thisfeed

   # fetch and parse the actual feed

   # feed may be empty
   if len(feedcontent.entries) > 0:

      # fetch the date
      if feedcontent.entries[position].has_key('published'):
      elif feedcontent.entries[position].has_key('updated'):
      elif feedcontent.has_key('modified'):

      # check for update
      entryupdstr=str(entryupd[index]) + "\n"
      # print entryupdstr
      # print lastdatestr
      if entryupdstr != lastdatestr:

         # fetch title, url and body
         if feedcontent.entries[position].has_key('content'):
         elif feedcontent.entries[position].has_key('summary'):
         elif feedcontent.entries[position].has_key('description'):
            body=" "

This could use some better error checking, and there's a snipped section
where I fall back to os functions for text formatting (I haven't quite
mastered that one yet), but I'm pleasantly surprised how easy this was,

The zip "for" loop is a nice touch; being able to loop through multiple
arrays concurrently.

In fact the hardest part of this little project is consolidating my
limited Python skills with the fact that so many syndicate feeds out
there are badly off-spec and broken, which is something I was not really
prepared for. Oh well.


.                                                     .
. "Remember, if Christmas isn't found in your heart,  .
.  you won't find it under a tree." ~ C. Carpenter    .
.                                                     .
.         Merry Christmas & A Happy New Year          .
.                                                     .

Fedora release 8 (Werewolf) on sky, running kernel
 00:32:41 up 2 days, 23:44,  4 users,  load average: 0.00, 0.01, 0.11

[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index