Re: Twisted and txJSON-RPC

2011-03-21 Thread Floris Bruynooghe
On Sunday, April 11, 2010 5:04:49 PM UTC+1, writeson wrote: > I get an error message: error: docs/PRELUDE.txt: No such file or > directory The setup.py code is trying to be too clever and the released package is missing files it requires. The easiest way to fix it is to simply get the latests c

Condition.wait(timeout) oddities

2011-05-23 Thread Floris Bruynooghe
Hi all I'm a little confused about the corner cases of Condition.wait() with a timeout parameter in the threading module. When looking at the code the first thing that I don't quite get is that the timeout should never work as far as I understand it. .wait() always needs to return while holdi

Re: Condition.wait(timeout) oddities

2011-05-23 Thread Floris Bruynooghe
On Monday, 23 May 2011 17:32:19 UTC, Chris Torek wrote: > In article > <94d1d127-b423-4bd4...@glegroupsg2000goo.googlegroups.com> > Floris Bruynooghe wrote: > >I'm a little confused about the corner cases of Condition.wait() with a > >timeout parameter in t

native hotshot stats module

2005-07-20 Thread Floris Bruynooghe
As part of my Google Summer of Code project I have developed a hstats module. It reads a file with profile data saved by hotshot and displays statistics of it after sorting it. The current interface is very basic in the philosophy of You Arent Gonna Need It[1]. So my question here is: please tes

Re: Need some IPC pointers

2011-12-06 Thread Floris Bruynooghe
I'm surprised no one has mentioned zeromq as transport yet. It provides scaling from in proc (between threads) to inter-process and remote machines in a fairly transparent way. It's obviously not the python stdlib and as any system there are downsides too. Regards, Floris -- http://mail.pyth

Module level descriptors or properties

2007-08-21 Thread Floris Bruynooghe
Hi When in a new-style class you can easily transform attributes into descriptors using the property() builtin. However there seems to be no way to achieve something similar on the module level, i.e. if there's a "version" attribute on the module, the only way to change that to some computation l

Re: python in academics?

2007-10-31 Thread Floris Bruynooghe
On Oct 30, 3:39 am, sandipm <[EMAIL PROTECTED]> wrote: > seeing posts from students on group. I am curious to know, Do they > teach python in academic courses in universities? In Southampton Uni (UK) they do teach (some) Python to Engineering undergrads (aero, mech, ship, maybe more) thanks to one

Creating the windows MSI of python

2007-11-28 Thread Floris Bruynooghe
Hello I've managed to build python2.4 and python2.5 in windows with MSVC++ 7.1 fine following the instructions in the PCbuild directory. However now I am wondering how to create the MSI from this[1], but can't find any instructions. All I'm looking for is the equivalent of "make install" (or "ma

Re: Creating the windows MSI of python

2007-11-28 Thread Floris Bruynooghe
On Nov 28, 5:26 pm, Christian Heimes <[EMAIL PROTECTED]> wrote: > Floris Bruynooghe wrote: > > It would be great if someone knows how Python builds it's MSI. > > The Tools/ directory contains a script in Tools/msi/msi.py. Martin von > Löwis is using the script to gene

MSI read support in msilib?

2008-01-16 Thread Floris Bruynooghe
Hi The introduction from the msilib documentation in python 2.5 claims it supports reading an msi. However on the Record class there is only a GetFieldCount() method and some Set*() methods. I was expecting to see GetString() and GetInteger() methods to be able to read the values. Maybe I'm mis

Re: MSI read support in msilib?

2008-01-17 Thread Floris Bruynooghe
On Jan 16, 7:03 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > The introduction from the msilib documentation in python 2.5 claims it > > supports reading an msi. However on the Record class there is only a > > GetFieldCount() method and some Set*() methods. I was expecting to > > see GetSt

Re: Altering imported modules

2008-03-04 Thread Floris Bruynooghe
On Mar 1, 11:56 pm, Tro <[EMAIL PROTECTED]> wrote: > I'd like to know if it's possible to make tlslite load *my* asyncore module > without changing any of the tlslite code. the pkgutil module might be helpful, not sure though as I've never used it myself. http://blog.doughellmann.com/2008/02/pymo

Re: How to send a var to stdin of an external software

2008-03-14 Thread Floris Bruynooghe
On Mar 14, 11:37 am, Benjamin Watine <[EMAIL PROTECTED]> wrote: > Bryan Olson a écrit : > > > I wrote: > >> [...] Pipe loops are tricky business. > > >> Popular solutions are to make either the input or output stream > >> a disk file, or to create another thread (or process) to be an > >> active re

Overriding base class methods in the C API

2009-01-18 Thread Floris Bruynooghe
Hello I've been trying to figure out how to override methods of a class in the C API. For Python code you can just redefine the method in your subclass, but setting tp_methods on the type object does not seem to have any influcence. Anyone know of a trick I am missing? Cheers Floris -- http://m

Re: x64 speed

2009-02-04 Thread Floris Bruynooghe
On Feb 4, 10:14 am, Robin Becker wrote: > > [rpt...@localhost tests]$ time python25 runAll.py > > . > > . > > > -- > > Ran 193 tests in 27.841s >

Re: memory recycling/garbage collecting problem

2009-02-17 Thread Floris Bruynooghe
On Feb 17, 5:31 am, Chris Rebert wrote: > My understanding is that for efficiency purposes Python hangs on to > the extra memory even after the object has been GC-ed and doesn't give > it back to the OS right away. Even if Python would free() the space no more used by it's own memory allocator (P

Re: Pythonic way to determine if a string is a number

2009-02-17 Thread Floris Bruynooghe
On Feb 16, 12:05 am, Mel wrote: > Christian Heimes wrote: > > Roy Smith wrote: > >> They make sense when you need to recover from any error that may occur, > >> possibly as the last resort after catching and dealing with more specific > >> exceptions. In an unattended embedded system (think Mars R

Re: Pythonic way to determine if a string is a number

2009-02-17 Thread Floris Bruynooghe
On Feb 16, 7:09 am, Python Nutter wrote: > silly me, forgot to mention > > build a set from digits + '.' and use that for testing. `.' is locale dependent. Some locales might use `,' instead and maybe there's even more out there that I don't know of. So developing this yourself from scratch see

C API and memory allocation

2008-12-17 Thread Floris Bruynooghe
Hi I'm slightly confused about some memory allocations in the C API. Take the first example in the documentation: static PyObject * spam_system(PyObject *self, PyObject *args) { const char *command; int sts; if (!PyArg_ParseTuple(args, "s", &command)) return NULL; sts = s

Re: C API and memory allocation

2008-12-17 Thread Floris Bruynooghe
Hello again On Dec 17, 11:06 pm, Floris Bruynooghe wrote: > So I'm assuming PyArg_ParseTuple() > must allocate new memory for the returned string.  However there is > nothing in the API that provides for freeing that allocated memory > again. I've dug a little deeper in

Re: C API and memory allocation

2008-12-18 Thread Floris Bruynooghe
On Dec 18, 6:43 am, Stefan Behnel wrote: > Floris Bruynooghe wrote: > > I'm slightly confused about some memory allocations in the C API. > > If you want to reduce the number of things you have to get your head > around, learn Cython instead of the raw C-API. It's basi

Using exceptions in defined in an extension module inside another extension module

2008-12-24 Thread Floris Bruynooghe
Hello If I have an extension module and want to use an exception I can do by declaring the exception as "extern PyObject *PyExc_FooError" in the object files if I then link those together inside a module where the module has them declared the same (but no extern) and then initialises them in the P

Re: Using exceptions in defined in an extension module inside another extension module

2008-12-24 Thread Floris Bruynooghe
Christian Heimes wrote: > Floris Bruynooghe schrieb: > > What I can't work out however is how to then be able to raise this > > exception in another extension module. Just defining it as "extern" > > doesn't work, even if I make sure the first mod

Re: C Module question

2008-11-10 Thread Floris Bruynooghe
Hi On Nov 10, 11:11 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > 1. How can I pass a file-like object into the C part? The PyArg_* > functions can convert objects to all sort of types, but not FILE*. Parse it as a generic PyObject object (format string of "O" in PyArg_*), check the type a

Re: C Module question

2008-11-10 Thread Floris Bruynooghe
On Nov 10, 1:18 pm, Floris Bruynooghe <[EMAIL PROTECTED]> wrote: > On Nov 10, 11:11 am, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > 1. How can I pass a file-like object into the C part? The PyArg_* > > functions can convert objects to all sort

Re: Logging thread with Queue and multiple threads to log messages

2008-11-10 Thread Floris Bruynooghe
Hi On Nov 9, 8:28 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I am trying to put up a queue (through a logging thread) so that all > worker threads can ask it to log messages. There is no need to do anything like this, the logging module is thread safe and you can happily just create log

Re: distutils compiler flags for extension modules

2009-03-20 Thread Floris Bruynooghe
On Mar 20, 9:48 am, Christian Meesters wrote: > as I got no answers with the previous question (subject: disabling > compiler flags in distutils), I thought I should ask the question in a > different way: Is there an option to set the compiler flags for a C/C++ > extension in distutils? There is t

Re: PEP 3143: Standard daemon process library (was: Writing a well-behaved daemon)

2009-03-20 Thread Floris Bruynooghe
On Mar 20, 9:58 am, Ben Finney wrote: > Ben Finney writes: > > Writing a Python program to become a Unix daemon is relatively > > well-documented: there's a recipe for detaching the process and > > running in its own process group. However, there's much more to a > > Unix daemon than simply detac

Re: PEP 3143: Standard daemon process library

2009-03-24 Thread Floris Bruynooghe
On Mar 21, 11:06 pm, Ben Finney wrote: > Floris Bruynooghe writes: > > Had a quick look at the PEP and it looks very nice IMHO. > > Thank you. I hope you can try the implementation and report feedback > on that too. > > > One of the things that might be

Re: Python C API String Memory Consumption

2009-04-07 Thread Floris Bruynooghe
On Apr 7, 2:10 pm, John Machin wrote: > On Apr 7, 9:19 pm, MRAB wrote: > > > > > k3xji wrote: > > > Interestaing I changed malloc()/free() usage with PyMem_xx APIs and > > > the problem resolved. However, I really cannot understand why the > > > first version does not work. Here is the latest cod

Re: Running commands on cisco routers using python

2008-05-20 Thread Floris Bruynooghe
On May 19, 4:18 pm, SPJ <[EMAIL PROTECTED]> wrote: > Is it possible to run specific commands on cisco router using Python? > I have to run command "show access-list" on few hundred cisco routers > and get the dump into a file. Please let me know if it is feasible and > the best way to achieve this.

Context manager for files vs garbage collection

2008-06-16 Thread Floris Bruynooghe
Hi I was wondering when it was worthwil to use context managers for file. Consider this example: def foo(): t = False for line in file('/tmp/foo'): if line.startswith('bar'): t = True break return t What would the benefit of using a context manager be

lxml validation and xpath id function

2008-06-30 Thread Floris Bruynooghe
Hi I'm trying to use the .xpath('id("foo")') function on an lxml tree but can't get it to work. Given the following XML: And it's XMLSchema: http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified"> Or in more readable,

Re: Module clarification

2008-07-28 Thread Floris Bruynooghe
On Jul 28, 9:54 am, Hussein B <[EMAIL PROTECTED]> wrote: > Hi. > I'm a Java guy and I'm playing around Python these days... > In Java, we organize our classes into packages and then jarring the > packages into JAR files. > What are modules in Python? An importable or runable (i.e. script) collecti

Ignoring windows registry PythonPath subkeys

2008-04-04 Thread Floris Bruynooghe
Hi We basically want the same as the OP in [1], i.e. when python starts up we don't want to load *any* sys.path entries from the registry, including subkeys of the PythonPath key. The result of that thread seems to be to edit PC/getpathp.c[2] and recompile. This isn't that much of a problem sinc

Re: Any fancy grep utility replacements out there?

2008-04-04 Thread Floris Bruynooghe
On Mar 19, 2:44 am, Peter Wang <[EMAIL PROTECTED]> wrote: > On Mar 18, 5:16 pm, Robert Kern <[EMAIL PROTECTED]> wrote: > > > > > [EMAIL PROTECTED] wrote: > > > So I need to recursively grep a bunch of gzipped files. This can't be > > > easily done with grep, rgrep or zgrep. (I'm sure given the r

@x.setter property implementation

2008-04-06 Thread Floris Bruynooghe
Hello I found out about the new methods on properties, .setter() and .deleter(), in python 2.6. Obviously that's a very tempting syntax and I don't want to wait for 2.6... It would seem this can be implemented entirely in python code, and I have seen hints in this directrion. So before I go and

Re: @x.setter property implementation

2008-04-07 Thread Floris Bruynooghe
On Apr 6, 6:41 pm, "Daniel Fetchinson" <[EMAIL PROTECTED]> wrote: > > I found out about the new methods on properties, .setter() > > and .deleter(), in python 2.6. Obviously that's a very tempting > > syntax and I don't want to wait for 2.6... > > > It would seem this can be implemented entirely i

Re: @x.setter property implementation

2008-04-10 Thread Floris Bruynooghe
On Apr 7, 2:19 pm, "Andrii V. Mishkovskyi" <[EMAIL PROTECTED]> wrote: > 2008/4/7, Floris Bruynooghe <[EMAIL PROTECTED]>: > > > > > Have been grepping all over the place and failed to find it. I found > > the test module for them, but that doesn'

Re: @x.setter property implementation

2008-04-11 Thread Floris Bruynooghe
On Apr 11, 10:16 am, Floris Bruynooghe <[EMAIL PROTECTED]> wrote: > On Apr 10, 5:09 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > > > > > On Apr 10, 3:37 pm, Floris Bruynooghe <[EMAIL PROTECTED]> > > wrote: > > > > On Apr 7, 2:19

Re: @x.setter property implementation

2008-04-11 Thread Floris Bruynooghe
On Apr 10, 5:09 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On Apr 10, 3:37 pm, Floris Bruynooghe <[EMAIL PROTECTED]> > wrote: > > > > > On Apr 7, 2:19 pm, "Andrii V. Mishkovskyi" <[EMAIL PROTECTED]> wrote: > > > > 2008/4/7

Re: @x.setter property implementation

2008-04-11 Thread Floris Bruynooghe
Oh, that was a good hint! See inline On Apr 11, 12:02 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On Apr 11, 11:19 am, Floris Bruynooghe <[EMAIL PROTECTED]> > wrote: > [...] > > > > Unfortunatly both this one and the one I posted before work when I try >

Re: How to kill Python interpreter from the command line?

2008-05-09 Thread Floris Bruynooghe
On May 9, 11:19 am, [EMAIL PROTECTED] wrote: > Thanks for the replies. > > On May 8, 5:50 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > > > Ctrl+C often works with Python, but as with any language, it's possible > > to write a program which will not respond to it.  You can use Ctrl+\ > > ins

Re: Bored.

2009-12-01 Thread Floris Bruynooghe
On Nov 30, 11:52 pm, Stef Mientki wrote: > Well I thought that after 2 years you would know every detail of a > language ;-) Ouch, I must be especially stupid then! ;-) Floris -- http://mail.python.org/mailman/listinfo/python-list

Re: Install script under a different name

2009-12-05 Thread Floris Bruynooghe
On Dec 5, 1:52 am, Lie Ryan wrote: > on linux/unix, you need to add the proper #! line to the top of any > executable scripts and of course set the executable bit permission > (chmod +x scriptname). In linux/unix there is no need to have the .py > extension for a file to be recognized as python sc

Re: question about subprocess and shells

2009-12-05 Thread Floris Bruynooghe
On Dec 4, 9:38 pm, Ross Boylan wrote: > If one uses subprocess.Popen(args, ..., shell=True, ...) > > When args finishes execution, does the shell terminate?  Either way > seems problematic. Essentially this is executing "/bin/sh args" so if you're unsure as to the behaviour just try it on your co

Ad hoc lists vs ad hoc tuples

2010-01-27 Thread Floris Bruynooghe
One thing I ofter wonder is which is better when you just need a throwaway sequence: a list or a tuple? E.g.: if foo in ['some', 'random', 'strings']: ... if [bool1, bool2, boo3].count(True) != 1: ... (The last one only works with tuples since python 2.6) Is a list or tuple better or mor

Re: Ad hoc lists vs ad hoc tuples

2010-01-27 Thread Floris Bruynooghe
On Jan 27, 10:15 pm, Terry Reedy wrote: > On 1/27/2010 12:32 PM, Antoine Pitrou wrote: > > > Le Wed, 27 Jan 2010 02:20:53 -0800, Floris Bruynooghe a écrit : > > >> Is a list or tuple better or more efficient in these situations? > > > Tuples are faster to al

Re: how to create a pip package

2009-11-10 Thread Floris Bruynooghe
On Nov 10, 2:30 pm, Phlip wrote: > On Nov 10, 1:54 am, Wolodja Wentland > wrote: > > >http://docs.python.org/library/distutils.html#module-distutils > >http://packages.python.org/distribute/ > > ktx... now some utterly retarded questions to prevent false starts. > > the distutils page starts with

Re: Queue peek?

2010-03-03 Thread Floris Bruynooghe
On Mar 2, 6:18 pm, Raymond Hettinger wrote: > On Mar 2, 8:29 am, Veloz wrote: > > > Hi all > > I'm looking for a queue that I can use with multiprocessing, which has > > a peek method. > > > I've seen some discussion about queue.peek but don't see anything in > > the docs about it. > > > Does pyt

Re: converting a timezone-less datetime to seconds since the epoch

2010-04-07 Thread Floris Bruynooghe
On Apr 7, 9:57 am, Chris Withers wrote: > Chris Rebert wrote: > > To convert from struct_time in ***UTC*** > > to seconds since the epoch > > use calendar.timegm() > > ...and really, wtf is timegm doing in calendar rather than in time? ;-) You're not alone in finding this strange: http://bugs.pyt

Re: How to read source code of python?

2010-06-10 Thread Floris Bruynooghe
On Jun 10, 8:55 am, Thomas Jollans wrote: > On 06/10/2010 07:25 AM, Qijing Li wrote: > > > Thanks for your reply. > > I'm trying to understand python language deeply and  use it efficiently. > > For example: How the operator "in" works on list? the running time is > > be O(n)?  if my list is sorte

Re: multi-thread python interpreaters and c++ program

2009-06-10 Thread Floris Bruynooghe
On Jun 9, 6:50 am, "myopc" wrote: >   I am ruuning a c++ program (boost python) , which create many python > interpreaters and each run a python script with use multi-thread > (threading). > when the c++ main program exit, I want to shut down python interpreaters, > but it crashed. Your threads a

Re: Where does setuptools live?

2009-07-04 Thread Floris Bruynooghe
On Jul 4, 4:50 pm, David Wilson wrote: > I'm trying to create a patch for a diabolical issue I keep running > into, but I can't seem to find the setuptools repository. Is it this > one? > >    http://svn.python.org/view/sandbox/trunk/setuptools/ It is, see http://mail.python.org/pipermail/distuti

Re: Best Way to Handle All Exceptions

2009-07-13 Thread Floris Bruynooghe
On Jul 13, 2:26 pm, seldan24 wrote: > The first example: > > from ftplib import FTP > try: >     ftp = FTP(ftp_host) >     ftp.login(ftp_user, ftp_pass) > except Exception, err: >     print err *If* you really do want to catch *all* exceptions (as mentioned already it is usually better to catch s