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

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

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. -- h

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 de

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)

Re: doctest and decorators

2007-09-05 Thread Daniel Larsson
.__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?:

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 PROTECT

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): >

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

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

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 examp

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

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]> wr

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? I

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:/

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

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

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 m

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 tha

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 t

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. Her