[issue15836] unittest assertRaises should verify excClass is actually a BaseException class

2012-09-17 Thread Daniel Wagner-Hall
Daniel Wagner-Hall added the comment: Is anything blocking this patch's submission? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15836

[issue15864] Package cache doesn't cache packages with overlapping sys.path entries

2012-09-04 Thread Daniel Wagner-Hall
New submission from Daniel Wagner-Hall: Importing the same module twice should only execute its code once, and should only lead to one copy of the classes defined in the module's file. If a subdirectory of $PWD is on $PYTHONPATH, and a package is imported both relative to $PWD and relative

[issue15864] Package cache doesn't cache packages with overlapping sys.path entries

2012-09-04 Thread Daniel Wagner-Hall
Daniel Wagner-Hall added the comment: That is indeed the behaviour I'm talking about. In particular I came across this where two libraries imported an exception type using different sys.path traversals, which both led to the same file, and a try-catch didn't catch the exception because it had

[issue15836] unittest assertRaises should verify excClass is actually a BaseException class

2012-09-03 Thread Daniel Wagner-Hall
Daniel Wagner-Hall added the comment: Cool, my contributor agreement has been received, please merge if happy! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15836

[issue15836] unittest assertRaises should verify excClass is actually a BaseException class

2012-08-31 Thread Daniel Wagner-Hall
New submission from Daniel Wagner-Hall: The following code in a unittest test is a no-op: self.assertRaises(lambda: 1) I would expect this to fail the test, because I naively assumed omitting the exception class would act as: self.assertRaises(BaseException, lambda: 1) verifying that *any

[issue15836] unittest assertRaises should verify excClass is actually a BaseException class

2012-08-31 Thread Daniel Wagner-Hall
Daniel Wagner-Hall added the comment: I seem to be getting exceptions why trying to upload a new patch to rietveld, either by the web interface (in several browsers), or by upload.py - attaching new patchset here Also, if I wanted to backport to 2.7 including an isinstance(e, types.ClassType

[issue15836] unittest assertRaises should verify excClass is actually a BaseException class

2012-08-31 Thread Daniel Wagner-Hall
Daniel Wagner-Hall added the comment: Added patch for 2.7. I'll sign the contributor form just as soon as I can get to a printer. Thanks for taking me through my first contribution. -- versions: +Python 2.7 Added file: http://bugs.python.org/file27081/issue15836-2.7.patch

[issue13139] multiprocessing.map skips finally blocks

2011-10-09 Thread Daniel Wagner-Hall
Daniel Wagner-Hall dawag...@gmail.com added the comment: Explanation of behaviour at http://stackoverflow.com/questions/7700929/python-multiprocessing-map-if-one-thread-raises-an-exception-why-arent-other tl;dr SIGTERM kills subprocesses and finally blocks aren't called. I still consider

[issue13139] multiprocessing.map skips finally blocks

2011-10-08 Thread Daniel Wagner-Hall
New submission from Daniel Wagner-Hall dawag...@gmail.com: import random from multiprocessing import Pool from time import sleep def Process(x): try: print x sleep(random.random()) raise Exception('Exception: ' + x) finally: print 'Finally: ' + x Pool(3).map(Process, ['1

Re: merge list of tuples with list

2010-10-20 Thread Daniel Wagner
Many thanks for all these suggestions! here is a short proof that you guys are absolutely right and my solution is pretty inefficient. One of your ways: $ python /[long_path]/timeit.py 'a=[(1,2,3),(4,5,6)];b=(7,8);[x+(y,) for x,y in zip(a,b)]' 100 loops, best of 3: 1.44 usec per loop And my

Re: merge list of tuples with list

2010-10-20 Thread Daniel Wagner
[b.pop(0)] This has to lookup the global b, resize it, create a new list, concatenate it with the list x (which creates a new list, not an in-place concatenation) and return that. The amount of work is non-trivial, and I don't think that 3us is unreasonable. I forgot to take account

merge list of tuples with list

2010-10-19 Thread Daniel Wagner
: a = [(1,2,3,7), (4,5,6)] It was possible for me to create this output using a for i in a technique but I think this isn't a very nice way and there should exist a solution using the map(), zip()-functions I appreciate any hints how to solve this problem efficiently. Greetings, Daniel Wagner

Re: merge list of tuples with list

2010-10-19 Thread Daniel Wagner
On Oct 19, 8:35 pm, James Mills prolo...@shortcircuit.net.au wrote: On Wed, Oct 20, 2010 at 10:16 AM, Daniel Wagner brocki2...@googlemail.com wrote: My short question: I'm searching for a nice way to merge a list of tuples with another tuple or list. Short example: a = [(1,2,3), (4,5,6

Re: merge list of tuples with list

2010-10-19 Thread Daniel Wagner
I used the following code to add a single fixed value to both tuples. But this is still not what I want... a = [(1,2,3), (4,5,6)] b = 1 a = map(tuple, map(lambda x: x + [1], map(list, a))) a [(1, 2, 3, 1), (4, 5, 6, 1)] What I need is: a = [(1,2,3), (4,5,6)] b = (7,8) a = CODE a [(1,2,3,7),

Re: merge list of tuples with list

2010-10-19 Thread Daniel Wagner
SOLVED! I just found it out I'm searching for a nice way to merge a list of tuples with another tuple or list. Short example: a = [(1,2,3), (4,5,6)] b = (7,8) After the merging I would like to have an output like: a = [(1,2,3,7), (4,5,6)] The following code solves the problem: a =