Re: Flattening lists

2009-02-05 Thread jason-sage
mk wrote: Hello everybody, Any better solution than this? def flatten(x): res = [] for el in x: if isinstance(el,list): res.extend(flatten(el)) else: res.append(el) return res a = [1, 2, 3, [4, 5, 6], [[7, 8], [9, 10]]] print flatten(a) It

Re: Mathematica 7 compares to other languages

2008-12-04 Thread jason-sage
Xah Lee wrote: alright, here's my improved code, pasted near the bottom. let me say a few things about Jon's code. If we rate that piece of mathematica code on the level of: Beginner Mathematica programer, Intermediate, Advanced, where Beginner is someone who just learned tried to program

Re: Mathematica 7 compares to other languages

2008-12-03 Thread jason-sage
[EMAIL PROTECTED] wrote: So when you need an algorithm, you can often find it already inside, for example in the large Combinatorics package. So it has WAY more batteries included, compared to Python. I'd like to see something as complete as that Combinatorics package in Python. Sage

clearing all warning module caches in a session

2008-07-26 Thread jason-sage
Hi all, I just started using the warnings module in Python 2.5.2. When I trigger a warning using the default warning options, an entry is created in a module-level cache so that the warning is ignored in the future. However, I don't see an easy way to clear or invalidate these module-level