web crawling.

2006-01-18 Thread S Borg

 Hello,

 I have been writing very simple Python programs that parse HTML and
such, mainly just to get
a better feel for the language. Here is my question: If I parsed an
HTML page into all of the image
files listed on that page, how could I request all of those images and
download them into some specified folder? I am sure this is quite easy,
but I am stuck.

 Thank you very much.
  Burgeoning Pythonista

-- 
http://mail.python.org/mailman/listinfo/python-list


Python Class use

2006-02-07 Thread S Borg

 Hello,

 I am running Python on Mac OS X. The interpreter has been great for
learning the basics, but I would now like to be able to reuse code.
How do I write reusable code? I have done it "The Java way": write
the class, and save it to my home directory, then call it from the
interpreter, here is an example.

my saved file##
class MyClass:
  def f(self):
  return 'calling f from MyClass'

###interpreter#
>>> x = MyClass()
>>> (unhelpful error mesages)

I hope I have clearly explained my problem. Because I
don't know the solution top this, I have to rewrite my methods
in the interpreter every single time I need to change something, and
I am quite certain that that is not the best way to do it.

Thank you very much.

S

-- 
http://mail.python.org/mailman/listinfo/python-list


line wrapping problem

2006-02-09 Thread S Borg
Hello,

 I am parsing text from one document to another. I have a scheme
similar to:

 for x in myfoobar:
   print >> mytextfile, "%s" % mydictionary[x],   #all on same line
 print >> mytextfile, '\n'  #new line


I am getting line breaks before my explicit line break. Am I
unwittingly copying '\n' characters from the original file?
How should I fix this(What is the 'Pythonic' solution)?

thanks,
-S

-- 
http://mail.python.org/mailman/listinfo/python-list


absolute removal of '\n' and the like

2006-02-10 Thread S Borg

Hello,

 If I have a string, what is the strongest way to assure the
removal of any line break characters?

Line break characters must always be the last character in a line, so
would
this:str = linestring[:-1]

 work?

This is my first real 'learning python' project, and I don't want to
get in the habit
of doing things the 'Java way'. Your comments and suggestions are very
much
appreciated.

thanks,

S

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: absolute removal of '\n' and the like

2006-02-10 Thread S Borg


Russ,

 Thanks a ton for ending a 3 day headache.

S

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: absolute removal of '\n' and the like

2006-02-10 Thread S Borg
Steven,

 Thank you very much for your insights. They are quite helpful.

S

-- 
http://mail.python.org/mailman/listinfo/python-list