Dumb*ss newbie Q

Captain Dondo yan at NsOeSiPnAeMr.com
Tue Mar 29 07:47:45 EST 2005


On Mon, 28 Mar 2005 08:42:22 -0600, Larry Bates wrote:

> Others have answered your specific question, I thought I
> would add some suggestions (not tested):
> 
> 1) You don't need a separate set_title method.  You can
> change the title attribute at any time by just saying
> m.title="new title".  No method is required unless you
> need to do some pre/post processing.
> 
> m.title="anything you want"
> 
> 2) To get class to prepare its output, just insert a
> __str__ method like following:
> 
>     def __str__(self):
>     return '<a href="avi://%s/%s/%s"> <img src="%s>%s/tn/%s.jpg</a>' % \
>            (self.audience, self.title,
>             self.driver, self.audience,
>             self.title, self.title)
> 
> 
> Then you can eliminate the html method and thumb method and just write:
> 
> print m
> 
> 3) Add extend keyword arguments for url and audience to the __init__
> method. That way you (or other users) will know that each keyword
> means when they run in Idle or other interpreter that expands
> keyword arguments on the screen as you are typing):
> 
>     m=Movie(title="Fate_is_the_Hunter", audience="kids", \
>       driver="X=hermes.seiner.lan:xv,athena.seiner.lan:xmga," \
>              "default:x11;console=vesa")
>     print m
> 
> 
> If you plan on doing a lot of this you may want to take a look
> at the htmlgen module at:
> 
> http://starship.python.net/crew/friedrich/HTMLgen/html/main.html
> 
> (I actually stole the idea of using the the __str__ method to
> generate the output from this module).
> 
> Hope information helps.

Thanks, it does.  I am trying to write a much simplified album -
<http://marginalhacks.com/Hacks/album/> . The author has taken it in a
direction that is no longer useful to me and I am desparately incompetent
in perl....  Python and I like each other, except that I don't have much
experience writing it from scratch....

For now I am using this tutorial as a go-by:
<http://www.linuxgazette.com/issue19/python.html>, but I will check out
the link you provided.

--Yan

-- 

use munged address above to email me
SpamTrap DoMeNow at seiner.com 




More information about the Python-list mailing list