Cleaning up after failing to contructing objects

2009-07-06 Thread brasse
Hello! I have been thinking about how write exception safe constructors in Python. By exception safe I mean a constructor that does not leak resources when an exception is raised within it. The following is an example of one possible way to do it: class Foo(object): def __init__(self, name,

Function arguments

2009-01-26 Thread brasse
Hello! Is there any way that I can get at all the arguments passed to a function as a map without using keyword arguments? def foo(a, b, c): # Can I access all the arguments in a collection somewhere? I'm mainly curious since I have stumbled on to some cases where it might have been nice to

Re: Function arguments

2009-01-26 Thread brasse
On Jan 26, 10:11 am, Chris Rebert c...@rebertia.com wrote: On Mon, Jan 26, 2009 at 1:03 AM, brasse thebra...@gmail.com wrote: Hello! Is there any way that I can get at all the arguments passed to a function as a map without using keyword arguments? def foo(a, b, c):    # Can I access

Re: Function arguments

2009-01-26 Thread brasse
On Jan 26, 10:39 am, Chris Rebert c...@rebertia.com wrote: On Mon, Jan 26, 2009 at 1:34 AM, brasse thebra...@gmail.com wrote: On Jan 26, 10:11 am, Chris Rebert c...@rebertia.com wrote: On Mon, Jan 26, 2009 at 1:03 AM, brasse thebra...@gmail.com wrote: Hello! Is there any way that I can

Re: contextlib.nested()

2008-11-07 Thread brasse
On Nov 6, 5:45 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: If you had a class that wanted to acquire some external resources that must be released at some point, how would you rewrite the code from my example? If you *can*, use a context. Use __enter__ and __exit__. Try really hard to

Re: contextlib.nested()

2008-11-07 Thread brasse
On Nov 7, 10:33 am, Peter Otten [EMAIL PROTECTED] wrote: brasse wrote: with nested(Foo('a'), Foo('b', True)) as (a, b):     print a.tag     print b.tag If been watching this thread for a while, and I think that your problems will go away if you write actual nested with-blocks: with Foo

contextlib.nested()

2008-11-06 Thread brasse
Hello! I have been running in to some problems when using contextlib.nested(). My problem arises when using code similar to this: from __future__ import with_statement from contextlib import nested class Foo(object): def __init__(self, tag, fail=False): print 'ctor', tag

Re: contextlib.nested()

2008-11-06 Thread brasse
On Nov 6, 11:43 am, Robert Lehmann [EMAIL PROTECTED] wrote: On Thu, 06 Nov 2008 01:02:34 -0800, brasse wrote: Hello! I have been running in to some problems when using contextlib.nested(). My problem arises when using code similar to this: from __future__ import with_statement from

Re: Builing Python 2.6 on AIX 5.2

2008-10-07 Thread brasse
could build Python on AIX without the multiprocessing module. Is there some way I can skip some selected modules when building Python. I tried with ./configure --without- multiprocessing, but that didn't work. :.:: mattias On Mon, Oct 6, 2008 at 4:16 AM, brasse [EMAIL PROTECTED] wrote: Hello

Re: Builing Python 2.6 on AIX 5.2

2008-10-07 Thread brasse
On Oct 6, 10:16 am, brasse [EMAIL PROTECTED] wrote: Hello! I am having some trouble building Python 2.6 on AIX. The steps I have taken are: export PATH=/usr/bin/:/usr/vacpp/bin/ ./configure --with-gcc=xlc_r --with-cxx=xlC_r --disable-ipv6 make This is the error message I'm seeing

Builing Python 2.6 on AIX 5.2

2008-10-06 Thread brasse
Hello! I am having some trouble building Python 2.6 on AIX. The steps I have taken are: export PATH=/usr/bin/:/usr/vacpp/bin/ ./configure --with-gcc=xlc_r --with-cxx=xlC_r --disable-ipv6 make This is the error message I'm seeing: ./Modules/ld_so_aix xlc_r -bI:Modules/python.exp build/