warnings filters for varying message

2013-06-28 Thread John Reid
Looking at the docs for warnings.simplefilter (http://docs.python.org/2/library/warnings.html) I think the following script should only produce one warning at each line as any message is matched by the simple filter import warnings warnings.simplefilter('default') for i in xrange(2):

Re: Differences creating tuples and collections.namedtuples

2013-02-19 Thread John Reid
On 19/02/13 00:18, Steven D'Aprano wrote: Terry Reedy wrote: On 2/18/2013 6:47 AM, John Reid wrote: I was hoping namedtuples could be used as replacements for tuples in all instances. This is a mistake in the following two senses. First, tuple is a class with instances while

Re: Differences creating tuples and collections.namedtuples

2013-02-19 Thread John Reid
On 19/02/13 01:47, alex23 wrote: On Feb 18, 9:47 pm, John Reid johnbaronr...@gmail.com wrote: See http://article.gmane.org/gmane.comp.python.ipython.user/10270 for more info. One quick workaround would be to use a tuple where required and then coerce it back to Result when needed

Differences creating tuples and collections.namedtuples

2013-02-18 Thread John Reid
Hi, I was hoping namedtuples could be used as replacements for tuples in all instances. There seem to be some differences between how tuples and namedtuples are created. For example with a tuple I can do: a=tuple([1,2,3]) with namedtuples I get a TypeError: from collections import namedtuple

Re: Differences creating tuples and collections.namedtuples

2013-02-18 Thread John Reid
On 18/02/13 12:05, Oscar Benjamin wrote: On 18 February 2013 12:03, Oscar Benjamin oscar.j.benja...@gmail.com wrote: On 18 February 2013 11:47, John Reid johnbaronr...@gmail.com wrote: I'm seeing this problem because of the following code in IPython: def canSequence(obj): if isinstance

Re: Differences creating tuples and collections.namedtuples

2013-02-18 Thread John Reid
On 18/02/13 12:03, Oscar Benjamin wrote: On 18 February 2013 11:47, John Reid johnbaronr...@gmail.com wrote: Hi, I was hoping namedtuples could be used as replacements for tuples in all instances. namedtuples are not really intended to serves as tuples anywhere. They are intended

Re: Differences creating tuples and collections.namedtuples

2013-02-18 Thread John Reid
On 18/02/13 12:11, Dave Angel wrote: On 02/18/2013 06:47 AM, John Reid wrote: Hi, I was hoping namedtuples could be used as replacements for tuples in all instances. There seem to be some differences between how tuples and namedtuples are created. For example with a tuple I can do: a=tuple

Re: Differences creating tuples and collections.namedtuples

2013-02-18 Thread John Reid
On 18/02/13 14:12, Oscar Benjamin wrote: On 18 February 2013 13:51, John Reid johnbaronr...@gmail.com wrote: On 18/02/13 12:03, Oscar Benjamin wrote: On 18 February 2013 11:47, John Reid johnbaronr...@gmail.com wrote: Hi, I was hoping namedtuples could be used as replacements for tuples

Re: Differences creating tuples and collections.namedtuples

2013-02-18 Thread John Reid
On 18/02/13 14:15, Oscar Benjamin wrote: On 18 February 2013 14:09, John Reid j.r...@mail.cryst.bbk.ac.uk wrote: On 18/02/13 12:11, Dave Angel wrote: On 02/18/2013 06:47 AM, John Reid wrote: Hi, I was hoping namedtuples could be used as replacements for tuples in all instances. There seem

Re: Differences creating tuples and collections.namedtuples

2013-02-18 Thread John Reid
On 18/02/13 14:53, Oscar Benjamin wrote: On 18 February 2013 14:23, John Reid j.r...@mail.cryst.bbk.ac.uk wrote: [snip] That said it would be nice to know the rationale for namedtuple.__new__ to have a different signature to tuple.__new__. I'm guessing namedtuple._make has a similar interface

ANN: pyicl, a python interval container package based on boost.icl

2012-05-21 Thread John Reid
pyicl is a python package that exposes the functionality of boost.icl to python using boost.python. Documentation: http://packages.python.org/PyICL/ PyPi page: http://pypi.python.org/pypi/PyICL/ boost.icl is a general purpose interval container library written in C++. Its author, Joachim

Re: Easiest framework to develop simple interactive web site in python?

2011-09-13 Thread John Reid
On 12/09/11 19:37, Stefaan Himpe wrote: The simplest one to learn is web2py http://www.web2py.com No configuration needed, just unpack and get started. It also has very good documentation and tons of little examples to get things done. The other options you mentioned are good too :) OK I've

Easiest framework to develop simple interactive web site in python?

2011-09-12 Thread John Reid
Hi, I need to write a web interface for some computational biology software I've written: http://sysbio.mrc-bsu.cam.ac.uk/johns/STEME/rst/_build/html/index.html I don't have much experience writing web sites or applications. Can anyone recommend a python framework that will allow me to

*** glibc detected *** gdb: malloc(): smallbin double linked list

2010-11-05 Thread John Reid
Hi, I've compiled Python 2.7 (r27:82500, Nov 2 2010, 09:00:37) [GCC 4.4.3] on linux2 with the following configure options ./configure --prefix=/home/john/local/python-dbg --with-pydebug I've installed numpy and some other packages but when I try to run my extension code under gdb I get the

Check in interpreter if running a debug version of python

2010-07-27 Thread John Reid
Can I check in the interpreter if I am running a debug version of python? I don't mean if __debug__ is set, I want to know if python was compiled in debug mode. Thanks, John. -- http://mail.python.org/mailman/listinfo/python-list

Instance method decorator garbage collection problem

2010-06-23 Thread John Reid
Hi, I've written a decorator that prints exceptions and I'm having some trouble with garbage collection. My decorator is: import sys def print_exception_decorator(fn): def decorator(self, *args, **kwds): try: return fn(*args, **kwds) except: print

Re: Instance method decorator garbage collection problem

2010-06-23 Thread John Reid
Thomas Jollans wrote: The InstanceCounted.count is 1 at the end. If I omit the call to self.method = print_exception_decorator(self.method) then the instance count goes down to 0 as desired. I thought that the decorator might be holding a reference to the instance through the bound method, so

Re: The rap against while True: loops

2009-10-13 Thread John Reid
Mensanator wrote: Nothing wrong with a having a break IMHO. My opinion is that there is everything wrong with having a break. I don't think I have ever used one, I write code that doesn't depend on that crutch. I guess its crutch-iness is in the eye of the beholder. You seem to have a

Re: The rap against while True: loops

2009-10-13 Thread John Reid
Mensanator wrote: No, it's just that the OP was asking whether avoiding while True is considered Best Practice. How can you answer such a question without sounding dogmatic? I was just pointing out your style of programming seems inflexible. Just another line that has to be interpreted

Re: The rap against while True: loops

2009-10-12 Thread John Reid
Mensanator wrote: On Oct 12, 3:36�am, greg g...@cosc.canterbury.ac.nz wrote: Mensanator wrote: while not done: � � ... � � if n==1: done = True � � ... Seems to me that 'while not done:' is no better than 'while True:', because in both cases you have to look inside the loop to find out what

Re: LaTeXing python programs

2009-05-21 Thread John Reid
Edward Grefenstette wrote: I'm trying to figure out how to use pygments. Are there any good usage examples out there? The documentation worked for me: http://pygments.org/docs/cmdline/ There is also a LaTeX package to call pygments at latex compilation time I forget what that is called

Re: LaTeXing python programs

2009-05-20 Thread John Reid
Edward Grefenstette wrote: I'm typing up my master's thesis and will be including some of the code used for my project in an appendix. The question is thus: is there a LaTeX package out there that works well for presenting python code? verbatim is a bit ugly and doesn't wrap code, and while

Re: LaTeXing python programs

2009-05-20 Thread John Reid
Alan G Isaac wrote: The listings package is great and highly configurable. Note that you can also input entire files of Python code or pieces of them based on markers. Really quite great. I tried listings. I believe pygments makes better formatted output (at least out of the box). --

Re: Presentation software for Python code

2009-04-28 Thread John Reid
Neal Becker wrote: IPython offers something similar for giving demos. I've found that very useful in the past. Really? Any pointers? http://ipython.scipy.org/doc/manual/html/api/generated/IPython.demo.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Presentation software for Python code

2009-04-23 Thread John Reid
Michael Hoffman wrote: Does anyone here have software they would suggest for making a presentation that includes Python code? Other than that it would probably be mainly bullet points. I'm willing to consider TeX- and HTML-based approaches. I like pygments for formatting python code. It can

Re: Presentation software for Python code

2009-04-23 Thread John Reid
Scott David Daniels wrote: Michael Hoffman wrote: You might take a look at Crunchy, and just do up your talk there. Crunchy is a Python program that combines an otherwise static html document with an interactive Python session within a browser http://code.google.com/p/crunchy/ IPython

python crash

2009-04-10 Thread John Reid
Python crashes in glibc with the following stack trace. I'm using an interface to R (rpy2), ipython, matplotlib, numpy, and scipy with a wx backend. I'm not sure if the stack trace shows which is the culprit. I've probably misconfigured one of their installs but knowing which one to recompile