doctest and decorators

2007-09-04 Thread Daniel Larsson
Hi,

I assume this is a FAQ, but I couldn't find much helpful information
googling. I'm having trouble with doctest skipping my functions, if I'm
using decorators (that are defined in a separate module). If I'm
understanding what is happening correctly, it's because doctest checks if
the function's func_global attribute is the same as the module's __dict__
attribute. The decorator in question returns a wrapping function, though, so
this check fails.

What are some solutions to this? I can define __test__, but it seems rather
cumbersome.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: doctest and decorators

2007-09-04 Thread Daniel Larsson
On 9/4/07, Ferenczi Viktor <[EMAIL PROTECTED]> wrote:
>
> > I assume this is a FAQ, but I couldn't find much helpful information
> > googling. I'm having trouble with doctest skipping my functions, if I'm
> > using decorators (that are defined in a separate module). If I'm
> > understanding what is happening correctly, it's because doctest checks
> if
> > the function's func_global attribute is the same as the module's
> __dict__
> > attribute. The decorator in question returns a wrapping function,
> though,
> > so this check fails.
> > What are some solutions to this? I can define __test__, but it seems
> rather
> > cumbersome.
>
> Please take a look at the documentation of the functools standard module
> in
> the Python manual, especially the wraps decorator. It could probably help.
>


Hmm, not really.

# decorator.py
import functools

def simplelog(f):
@functools.wraps
def new_f(*args, **kwds):
print "Wrapper calling func"
return f(*args, **kwds)
return new_f

# test.py
from decorator import simplelog

@simplelog
def test():
"""
>>> test()
'works!'
"""
return "works!"

if __name__ == '__main__':
import doctest
doctest.testmod()

$ python test.py -v
1 items had no tests:
__main__
0 tests in 1 items.
0 passed and 0 failed.
Test passed.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: doctest and decorators

2007-09-04 Thread Daniel Larsson
On 9/4/07, Ferenczi Viktor <[EMAIL PROTECTED]> wrote:
>
> > @functools.wraps
>
> Correctly:
>
> @functools.wraps(f)
>
> Pass the function to be wrapped by the decorator to the wraps function.


Ooops, right. That doesn't change the fact that decorated functions get
hidden from doctest though.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: doctest and decorators

2007-09-04 Thread Daniel Larsson
On 9/5/07, Ferenczi Viktor <[EMAIL PROTECTED]> wrote:
>
> > > @functools.wraps(f)
> > > Pass the function to be wrapped by the decorator to the wraps
> function.
> > Ooops, right. That doesn't change the fact that decorated functions get
> > hidden from doctest though.


I have no issue when the decorator is defined in the same module as the
decorated function, my problem is running doctests on functions using an
imported decorator. Having to implement the decorator in every source module
isn't very practical. Try splitting your module in two, as I did, and run
with -v, and you'll see the problem.

Run my test script (one file) with the -v (verbose) option. Without the -v
> option it does not show output. This fact is documented in the Python
> manual
> at the doctest module.
>
> --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
> import functools
>
> def simplelog(f):
> @functools.wraps(f)
> def new_f(*args, **kwds):
> print "Wrapper calling func"
> return f(*args, **kwds)
> return new_f
>
> @simplelog
> def test():
> """
> >>> test()
> Wrapper calling func
> 'works!'
> """
> return 'works!'
>
> def fn():
> """
> >>> fn()
> 'ok'
> """
> return 'ok'
>
> if __name__ == '__main__':
> import doctest
> doctest.testmod()
> --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
>
> Regard, Viktor
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: doctest and decorators

2007-09-04 Thread Daniel Larsson
On 9/5/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
>
> En Tue, 04 Sep 2007 19:29:11 -0300, Daniel Larsson
> <[EMAIL PROTECTED]> escribi�:
>
> > On 9/5/07, Ferenczi Viktor <[EMAIL PROTECTED]> wrote:
> >>
> >> > > @functools.wraps(f)
> >> > > Pass the function to be wrapped by the decorator to the wraps
> >> function.
> >> > Ooops, right. That doesn't change the fact that decorated functions
> >> get
> >> > hidden from doctest though.
> >
> >
> > I have no issue when the decorator is defined in the same module as the
> > decorated function, my problem is running doctests on functions using an
> > imported decorator. Having to implement the decorator in every source
> > module
> > isn't very practical. Try splitting your module in two, as I did, and
> run
> > with -v, and you'll see the problem.
>
> Looks like a bug. doctest is failing to recognize that the decorated
> function belongs to the module being tested.
>
> A simple patch: In doctest.py, method _from_module, near line 840, you
> have these lines:
>
>  elif inspect.getmodule(object) is not None:
>  return module is inspect.getmodule(object)
>
> Move them up, just before the line:
>
>  elif inspect.isfunction(object):


Yes, that was basically what I did as well. It makes much more sense to
check __module__ first (which is modifiable) rather than func_globals (which
obviously isn't).

I would have guessed the inspect.getmodule check would cover the isclass
test as well (?)

This works fine in this case, but I'm not sure whether this breaks in
> other circumstances (but I can't think of a case when using
> inspect.getmodule() would not be appropiate).
>
> PS: I can't see any tests for decorated functions (except
> @classmethod/@staticmethod) in the library test suite. I'll try to add
> some and submit a patch.
>
> --
> Gabriel Genellina
>
> --
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: doctest and decorators

2007-09-05 Thread Daniel Larsson
The __module__ attribute is set, but the problem is the test in
doctest.py(DocTestFinder._from_module)

...
elif inspect.isfunction(object):
return module.__dict__ is object.func_globals
elif inspect.isclass(object):
return module.__name__ == object.__module__
elif inspect.getmodule(object) is not None:
return module is inspect.getmodule(object)

On 9/5/07, Michele Simionato <[EMAIL PROTECTED]> wrote:
>
> > En Tue, 04 Sep 2007 19:29:11 -0300, Daniel Larsson
> > <[EMAIL PROTECTED]> escribi?:
> >
> >
> >
> > > On 9/5/07, Ferenczi Viktor <[EMAIL PROTECTED]> wrote:
> >
> > >> > > @functools.wraps(f)
> > >> > > Pass the function to be wrapped by the decorator to the wraps
> > >> function.
> > >> > Ooops, right. That doesn't change the fact that decorated functions
> > >> get
> > >> > hidden from doctest though.
> >
> > > I have no issue when the decorator is defined in the same module as
> the
> > > decorated function, my problem is running doctests on functions using
> an
> > > imported decorator. Having to implement the decorator in every source
> > > module
> > > isn't very practical.
>
> I cannot reproduce your problem. Using functools.wraps
> the __module__ attribute is set correctly and everything
> works, even for decorators defined in separated modules.
> Care to post a complete example of what you are doing?


inspect.isfunction(object) returns true, but the function's func_globals
isn't the same as the module's __dict__, since the function is actually my
decorator wrapper function.

Here's my two files again:

# decorator.py
import functools

def simplelog(f):
@functools.wraps(f)
def new_f(*args, **kwds):
print "Wrapper calling func"
return f(*args, **kwds)
return new_f

# test.py
from decorator import simplelog

@simplelog
def test():
"""
This test should fail, since the decorator prints output. Seems I don't
get called though
>>> test()
'works!'
"""
return "works!"

if __name__ == '__main__':
import doctest
doctest.testmod()



 Michele Simionato
>
> P.S. for some reason your messages are not appearing on
> Google groups, I see only the replies.
>
>
Weird... afraid I have no clue why not :)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: concise code (beginner)

2007-09-05 Thread Daniel Larsson
def process_devs(devs, fun):
for dev in devs:
try:
fun(dev)
except:
 print exception
 remove dev from devs
 return devs

process_devs(devs, lambda d: d.read1())
process_devs(devs, lambda d: d.read2())
...

On 9/5/07, bambam <[EMAIL PROTECTED]> wrote:
>
> I have about 30 pages (10 * 3 pages each) of code like this
> (following). Can anyone suggest a more compact way to
> code the exception handling? If there is an exception, I need
> to continue the loop, and continue the list.
>
> Steve.
>
> ---
> for dev in devs
> try:
> dev.read1()
> except
> print exception
> remove dev from devs
>
> for dev in devs
> try:
> dev.read2()
> except
> print exception
> remove dev from devs
>
> for dev in devs
> try:
> dev.read3()
> except
> print exception
> remove dev from devs
>
> etc.
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: decorator and signal handler

2007-09-05 Thread Daniel Larsson
On 9/5/07, stalex <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I wrote the following code since I want to try using a decorator to
> install signal handler:
>
> ## The test.py script
> #
> import os
> import time
> import signal
>
> def sigHandler(sid):
> def handler(f):
> signal.signal(sid, f)
> return f
> return handler
>
> class Test(object):
> @sigHandler(signal.SIGTERM)
> def _sigHandler(self, signalId, currentFrame):
> print "Received:", signalId
>
> if __name__ == "__main__":
> print "pid:", os.getpid()
>
> t = Test()
> time.sleep(300)
>
> # From terminal, say A
> 
> $ python test.py
> pid: 1234
>
> # From terminal, say B
> ###
> $ kill -TERM 1234
>
> After issuing the kill command from terminal B, the process of test.py
> from terminal A is terminated.
> Python print out some exception message as following:
> Traceback (most recent call last):
> File "a.py", line 22, in 
> time.sleep(300)
> TypeError: _sigHandler() takes exactly 3 arguments (2 given)
>
> At a guess, I think the decorator I defined did not pass the 'self' as
> the first argument to _sigHandler() method, did it? And I have no idea
> of how to write a correct one. Any suggestion?


You can't call an unbound method without supplying the instance explicitly.

Try decorate a global function instead, and it should work.

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

Re: Accessing Module variables from another Module

2007-09-05 Thread Daniel Larsson
On 9/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> I am new to Python (I have come from a large background of Java) and
> wondered if someone could explain to me how I can access variables
> stored in my main module to other functions within other modules
> called
> from this module


No, don't introduce circular dependencies, and make it explicit what your
functions operate on by passing things as parameters, instead of using
global references.

for example
> file: main.py
>
> from Storage import store
> from Initialise import init
> from ProcessSteps import process
>
> storeList = store()   #Creates a object to store Step objects
> init()
> process()


It is *much* more preferable to pass 'storeList' as a parameter to your
functions. Don't change things behind the scenes.

file: Initialise.py
> def init()
> ..
> storeList.addStep([a,b,c])
>
>
> file: ProcessSteps.py
> def process()
> for step in storeList.stepList:
> etc
>
> I am currently just passing the variable in as a parameter
> but I thought with Python there would be a way to gain direct access
> to
> storeList within the modules called from the top main module?


Keep it the way it is. It's wrong on too many levels to do it the other way.

Cheers
> Chris
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: python exec behaves inconsistent with respect to module imports

2007-09-05 Thread Daniel Larsson
On 9/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hello
>
> I am completely puzzled why the following exec code does not work:
>
> mycode = "import math\ndef f(y):\nprint math.floor(y)\nf(3.14)"
> def execute():
> exec mycode
> execute()
>
>
> I get the error:
>
> [EMAIL PROTECTED]:/opt/qbase# python error1.py
> Traceback (most recent call last):
>   File "error1.py", line 5, in ?
> execute()
>   File "error1.py", line 4, in execute
> exec mycode
>   File "", line 4, in ?
>   File "", line 3, in f
> NameError: global name 'math' is not defined


This is due to a namespace issue with exec, see
http://docs.python.org/ref/exec.html#l2h-569

The namespace used in an exec statement is the local scope. This scope is
different in your two cases. If you change the exec call to

def execute():
exec mycode in globals()

It will work as you expect.


Note that the following code _does_ work:
>
> mycode = "import math\ndef f(y):\nprint math.floor(y)\nf(3.14)"
> exec mycode
>
>
> I have tested this in python 2.3 and 2.4.
>
>
> Regards
> Carl
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: handling modules in packages

2007-09-05 Thread Daniel Larsson
On 9/5/07, Tommy Grav <[EMAIL PROTECTED]> wrote:
>
> >>
> > The simplest thing to do would be to have PyAstro.__init__.py
> > import all
> > the sub-modules, and define __all__ as the set of names that the
> > package
> > should inject into importing modules.
> >
> > Then you could write (for example)
> >
> > from PyAstro import numpy, constants, conversion, obsrvations
> >
> > However if you are simply worried about run-time efficiency then don't
> > be: once a module is imported further imports essentially reduce to
> > checking that the module is already present in the sys.modules
> > dict, and
> > so take almost no time at all.
>
> So am I understanding it right that a second import numpy statement
> in a different module (and thus a different namespace) just results in
> a binding to the already existing numpy "object"?


Yes, correct
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Checking if elements are empty

2007-09-05 Thread Daniel Larsson
On 9/5/07, Chris Mellon <[EMAIL PROTECTED]> wrote:
>
> On 9/5/07, Steve Holden <[EMAIL PROTECTED]> wrote:
> > Doran, Harold wrote:
>
> > >
> > > Is there a way to check if the first element of y is null?
> > >
> >
> > len(y[0]) == 0
> >
> > would be the obvious way, assuming "null" means "the null string".
> >
>
> Better spelled as
>
> if y[0]:


Even better spelled as

if not y[0]:

;-)

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

Re: Soemthing wrong w/ urllib module or something.

2007-09-05 Thread Daniel Larsson
Are you using http proxying when you browse to the server? Have you tried to
do

$ curl http://DOMAINHERE/

If that works, connecting with a plain socket should work too. Otherwise, I
believe urllib has support for a proxying server, check the docs.

On 9/5/07, Lamonte Harris <[EMAIL PROTECTED]> wrote:
>
> Anyone got an answer for this?
>
> On 9/3/07, Lamonte Harris <[EMAIL PROTECTED]> wrote:
> >
> > Yeah I can browse it like normal.  For some reason though my News System
> > that worked like a charm just stopped working also.  Is there any
> > alternatives that I could try to use to POST to a PHP script?
> >
> > On 9/3/07, Tim Golden <[EMAIL PROTECTED] > wrote:
> > >
> > > [Tim Golden]
> > > >> To do the obvious, can you open a socket connection
> > > >> to the domain you're using?
> > > >>
> > > >> 
> > > >> from socket import socket
> > > >> socket ().connect (("DOMAINHERE", 80))
> > > >>
> > > >> 
> > > >>
> > > >> or does it give you the same error?
> > >
> > > [Lamonte Harris]
> > > > Yeah I basically got the same error.
> > > >
> > > > Traceback (most recent call last):
> > > >   File "", line 1, in 
> > > >   File "", line 1, in connect
> > > > socket.error: (10053, 'Software caused connection abort')
> > >
> > > OK, then *something's* blocking access to that host (at least)
> > > on port 80. Can you browse the web normally from this machine?
> > > In particular, can you browse to that site ("DOMAINHERE")?
> > >
> > > TJG
> > >
> >
> >
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: concise code (beginner)

2007-09-05 Thread Daniel Larsson
On 9/5/07, Karthik Gurusamy <[EMAIL PROTECTED]> wrote:
>
> On Sep 5, 11:17 am, James Stroud <[EMAIL PROTECTED]> wrote:
> > bambam wrote:
> > > I have about 30 pages (10 * 3 pages each) of code like this
> > > (following). Can anyone suggest a more compact way to
> > > code the exception handling? If there is an exception, I need
> > > to continue the loop, and continue the list.
> >
> > > Steve.
> >
> > > ---
> > > for dev in devs
> > > try:
> > > dev.read1()
> > > except
> > > print exception
> > > remove dev from devs
> >
> > > for dev in devs
> > > try:
> > > dev.read2()
> >
> > [etc.]
> >
> > My keen sense of pattern recognition tells me that all of your read's
> > follow the same naming pattern--or was that just an accidental naming
> > coincidence on your part for the sake of example?
> >
> > for i in xrange(number_of_reads):
> >for dev in devs:
> >  try:
> >_reader = getattr(dev, 'read%d' % i)
> >_reader()
> >  except Exception, e:
> >print e
> >devs.remove(dev)
>
> I see in many of the solutions suggested above, the devs sequence/
> iterator is being modified while iterating. I know it is not defined
> for interation over dictionary keys. Are they defined for other
> collections like lists?
>
> Karthik


You're  right, that's a bad thing. You should collect the "bad" devs in a
separate list, and remove them outside the loop.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: library to launch program in linux

2007-09-06 Thread Daniel Larsson
On 9/6/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi there,
>
> I'm a new user. What library should I use so that I can launch program
> in linux using python? Thank you in advance.


os.system or the commands library.

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

Re: Class design (information hiding)

2007-09-07 Thread Daniel Larsson
On 9/7/07, Alexander Eisenhuth <[EMAIL PROTECTED]> wrote:
>
> Bruno Desthuilliers schrieb:
>
> > Nope. It's either 'interface' (no leading underscore),  'implementation'
> > (single leading underscore), 'implementation with some protection
> > against accidental overriding' (two leading underscores).
>
> What do you mean with 'implementation'? What does it express?


"Don't touch my _members, they're my private parts! If you do, face the
consequences!"

Again, this isn't enforced by the language (other than the slight name
mangling on __names), but a convention that python programmers should adhere
to.

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

Re: Class design (information hiding)

2007-09-07 Thread Daniel Larsson
On 9/7/07, Alexander Eisenhuth <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I'm wodering how the information hiding in python is ment. As I understand
> there
>   doesn't exist public / protected / private  mechanism, but a '_' and
> '__'
> naming convention.
>
> As I figured out there is only public and private possible as speakin in
> "C++
> manner". Are you all happy with it. What does "the zen of python" say to
> that
> design? (protected is useless?)


Strictly speaking, everything is public in python. Members prefixed with
"__" just get name mangled. But conceptually, yes, there is only public and
private members. Information hiding is based on convention, otherwise it
would be hard to write debuggers in python, which by definition wants to
break the information hiding principle. If you're not writing a debugger,
doc generator, or other type of meta level program, follow the conventions
of not peeking under the hood.

class A:
> def __init__(self):
> self.__z = 1
> self._z = 2
> self.z = 3
> def _getX(self):
> return "X"
> def __getY(self):
> return "Y"
> def doAnything(self):
> print self.__getY()
>
>
> class B(A):
> def __init__(self):
> A.__init__(self)
> print dir (self)
> >>> b = B()
> ['_A__getY', '_A__z', '__doc__', '__init__', '__module__', '_getX', '_z',
> 'doAnything', 'z']
>
> I was a bit surprised about '_A__getY' and '_A__z'.


This is so that in class B, you can also have members called __getY and __z,
and they won't interfere with class A (they'll be called _B__getY and _B__z
respectively ).

What would you say to a C++ Programmer about class interfaces in big Python
> systems? What is the idea behind the _ and __ naming.


As a rough analogy:

__name -> private
_name -> protected

Use or don't use '_'
> methods ? (As Designer of the software, as Programmer of the software)


I don't know if you're making a distinction here between "designer" and
"programmer". Are you meaning "implementer of library" and "user of
library"? As a user of a library, never ever explicitly call members
starting with an underscore.

Regards Alexander
>
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: We need PIGs :)

2007-09-16 Thread Daniel Larsson
On 9/16/07, Colin J. Williams <[EMAIL PROTECTED]> wrote:
>
> Marc 'BlackJack' Rintsch wrote:
> > On Thu, 06 Sep 2007 09:00:02 +0200, Stefan Arentz wrote:
> >
> >> What I find really frustrating in Python (combined with usually bad
> >> documentation) is that many people have different styles. The most
> >> frustratinng being getFoo() vs .foo, vs get_foo().
> >
> > `getFoo()` is discouraged by PEP 8.  You don't have the choice between
> > `.foo` and `.get_foo()` in Java because Java has no properties and
> people
> > are trained to write getters and setters for everything.  I like that
> > choice in Python because I can write shorter code that is not cluttered
> > with very simple getters and setters.
> >
> > Ciao,
> >   Marc 'BlackJack' Rintsch
> Perhaps PEP 8 needs rethinking.  I prefer getFoo().
> Similarly, I feel that the standard indent of 4 increases the
> likelihood of running off the end of a line.  An indent of 1 isn't
> quite clear visually, but 2 is.


The point with a style guide is not to cater for everyones preferences, but
to set a common compromise.

If you find yourself going off the right margin a lot, perhaps you should
consider restructuring and refactoring your application, rather than
reducing your indentation.

Colin W.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python 3K or Python 2.9?

2007-09-17 Thread Daniel Larsson
On 9/13/07, Stefan Bellon <[EMAIL PROTECTED]> wrote:
>
> On Thu, 13 Sep, TheFlyingDutchman wrote:
>
> > Bruce said that no other mainstream OO language is explicitly passing
> > the object as a parameter to class methods.
>
> Ada 95 does. And Ada 95 was the first standardized OO language.


Now that's debatable :)

"SIMULA 67 was formally standardized on the first meeting of the SIMULA
Standards Group (SSG) in February 1968."

 http://en.wikipedia.org/wiki/Simula
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Entering username & password automatically using urllib.urlopen

2007-10-14 Thread Daniel Larsson
You form the URL thus:

http://:@:/

This is defined in RFC 1738 

On 10/14/07, rodrigo <[EMAIL PROTECTED]> wrote:
>
> I am trying to retrieve a password protected page using:
>
> get = urllib.urlopen('http://password.protected.url";').read()
>
> While doing this interactively, I'm asked for  the username, then the
> password at the terminal.
> Is there any way to do this non-interactively? To hardcode the user/
> pass into the script so I can get the page automatically?
>
> (This is not a cracking attempt, I am trying to retrieve a page I have
> legitimate access to, just doing it automatically when certain
> conditions are met.)
>
> Thanks,
>
> Rodrigo
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python - why don't this script work?

2007-10-22 Thread Daniel Larsson
Try:
$ python image-harvester.py

On 10/23/07, Ohmster <[EMAIL PROTECTED]> wrote:
>
> I am trying to use this cool script that some MIT guy wrote and it just
> does not work, I get a stream of errors when I try to run it. It is
> supposed to visit a URL and snag all of the pictures on the site. Here is
> the script:
> http://web.mit.edu/pgbovine/www/image-harvester/image-harvester.py
>
> Here is my output when I try to run it on my Fedora 6 machine:
>
> [EMAIL PROTECTED] bench]$ image-harvester.py
> http://public.fotki.com/DaGennelman/
> /home/ohmster/scripts/image-harvester.py: line 59: from: command not found
> [EMAIL PROTECTED] bench]$
>
> The script is to be folowed up with another one to weed out the small
> thumbnails and banner images, here is the base URL:
> http://web.mit.edu/pgbovine/www/image-harvester/
>
> Line 59 in image-harvester.py reads as follows:
>
> 59: from sgmllib import SGMLParser
> 60: import urllib
> 70: from urlparse import urlparse, urljoin
> 71: import re
> 72: import os
>
>
> Can anyone tell me what is wrong with this script and why it will not run?
> It does not like the command "from", is there such a command in python?
> Does this mean that python has the "import" command but not the "from"
> command or do we not know this yet as it hangs right away when it hits the
> very first word of the script, "from"? Maybe this is not a Linux script or
> something? I wonder why it needs the x-server anyway, I tried running it
> from an ssh term window and it had a fit about no x-server so now I am
> doing this in a gnome term window. This looked so cool too. :(
>
> Please be patient with me, I do not know python at all, I just want for
> this script to work and if I see enough working examples of python, I may
> just take up study on it, but for right now, I do not know the language.
> Total newbie.
>
> Thanks.
>
>
> --
> ~Ohmster | ohmster /a/t/ ohmster dot com
> Put "messageforohmster" in message body
> (That is Message Body, not Subject!)
> to pass my spam filter.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list