Re: etree/lxml/XSLT and dynamic stylesheet variables

2012-01-20 Thread Stefan Behnel
Adam Tauno Williams, 20.01.2012 21:38: > I'm using etree to perform XSLT transforms, such as - > > from lxml import etree > source = etree.parse(self.rfile) > xslt = etree.fromstring(self._xslt) > transform = etree.XSLT(xslt) > result = transform(source) > > according to the docs at >

Re: can some one help me with my code. thanks

2012-01-20 Thread Chris Angelico
On Sat, Jan 21, 2012 at 1:23 PM, Steven D'Aprano wrote: > On Fri, 20 Jan 2012 16:21:30 -0800, Rick Johnson wrote: >> Your variable names need a bit more thought >> >>> def average(bin): >> >> What is a "bin"? Maybe you shoulc have called this a "lst" eh? > > "Bin" is a standard English world. You

Masking a dist package with a copy in my own package

2012-01-20 Thread Sam Simmons
Hey all, I'm using twisted in a project and have run into a class that's in version 11.1 but not 8.2 in OSX. I was thinking to get it working for mac users I could just extract the 11.1 twisted package and through it under my package. e.g. project/ __init__.py twisted/ __init__.py ...

Re: LibreOffice with Python

2012-01-20 Thread Adam Tauno Williams
On Tue, 2012-01-10 at 19:04 -0500, Terry Reedy wrote: > On 1/10/2012 5:29 PM, Ben Finney wrote: > > LibreOffice supports scripting with several languages, including Python > > http://help.libreoffice.org/Common/Scripting> > So that page says. But it only tells how to attach a Python script once >

Re: can some one help me with my code. thanks

2012-01-20 Thread Steven D'Aprano
On Fri, 20 Jan 2012 16:21:30 -0800, Rick Johnson wrote: > On Jan 20, 12:49 pm, Tamanna Sultana wrote: >> > If you can give me some lead to fix the code I wrote below that will >> > be great: > > Your variable names need a bit more thought > >> def average(bin): > > What is a "bin"? Maybe you s

Re: can some one help me with my code. thanks

2012-01-20 Thread Jon Clements
On Jan 20, 9:26 pm, Terry Reedy wrote: > On 1/20/2012 2:46 PM, Terry Reedy wrote: > > > > > > > > > > > On 1/20/2012 1:49 PM, Tamanna Sultana wrote: > > >> can some one help me?? > >>> I would like to create a function that, given a bin, which is a list > >>> (example below), generates averages fo

Re: Please don't use "setuptools", the "rotten .egg" install system.

2012-01-20 Thread Raffaele Ricciardi
In order to build and run Mercurial on Linux, I needed Python with docutils. I've just installed Python from source and later setuptools. As a non-Pythonista, my impression has been that the procedure of installing setuptools and then using them is quite straightforward, but it's not advertis

Re: Is a with on open always necessary?

2012-01-20 Thread Steven D'Aprano
On Fri, 20 Jan 2012 15:44:17 +, Andrea Crotti wrote: > I normally didn't bother too much when reading from files, and for > example I always did a > > content = open(filename).readlines() > > But now I have the doubt that it's not a good idea, does the file > handler stays open until the int

Re: subprocess module and long-lived subprocesses

2012-01-20 Thread Nobody
On Fri, 20 Jan 2012 08:42:16 -0600, skip wrote: > The library documentation doesn't talk a lot about long-lived subprocesses > other than the possibility of deadlock when using Popen.wait(). Ideally, I > would write to the subprocess's stdin, check for output on stdout and > stderr, then lather,

Re: can some one help me with my code. thanks

2012-01-20 Thread Rick Johnson
On Jan 20, 12:49 pm, Tamanna Sultana wrote: > > If you can give me some lead to fix the code I wrote below that will be > > great: Your variable names need a bit more thought > def average(bin): What is a "bin"? Maybe you shoulc have called this a "lst" eh? >     num=[] Why would you call a l

Re: Is a with on open always necessary?

2012-01-20 Thread Roy Smith
In article , Arnaud Delobelle wrote: > > So maybe doing a > > > > with open(filename) as f: > >     contents = f.readlines() > > That's what I do, unless I'm in an interactive session. >From the resource management point of view, there's no doubt that's the right thing to be doing. That be

Re: Weird Loop Behaviour

2012-01-20 Thread Arnaud Delobelle
On 20 January 2012 20:47, Yigit Turgut wrote: > Hi, > > In the following code, I am trying to run "black" screen for 3 seconds > and respectively 2 seconds "white" screen. Black routine takes 3 > seconds and white 2 seconds, 2 x black + white = 8 seconds which > should be the expected value but wh

Re: Extending PyGTK widgets with Glade

2012-01-20 Thread Adam Tauno Williams
Quoting Richard Carlson : I'm working on a program using PyGTK and Glade. I create a glade XML file using Glade Designer and then load widgets like this: class MyDialog: def __init__(self): self.dialog = gtk.glade.XML(self.GLADEFILE).get_widget ("dialog.xml") I think it would be bett

Re: can some one help me with my code. thanks

2012-01-20 Thread Terry Reedy
On 1/20/2012 2:46 PM, Terry Reedy wrote: On 1/20/2012 1:49 PM, Tamanna Sultana wrote: can some one help me?? I would like to create a function that, given a bin, which is a list (example below), generates averages for the numbers separated by a string 'end'. I am expecting to have 4 averages f

Re: Weird Loop Behaviour

2012-01-20 Thread Emile van Sebille
On 1/20/2012 12:47 PM Yigit Turgut said... Hi, In the following code, I am trying to run "black" screen for 3 seconds and respectively 2 seconds "white" screen. Black routine takes 3 seconds and white 2 seconds, 2 x black + white = 8 seconds which should be the expected value but when I run it I

Re: can some one help me with my code. thanks

2012-01-20 Thread Tim Chase
On 01/20/12 13:46, Terry Reedy wrote: def average(bin): num=[] total = 0.0 count=0 for number in bin: if number!='end': total += float(number) count+=1 else: num.append(total/count) total = 0.0

etree/lxml/XSLT and dynamic stylesheet variables

2012-01-20 Thread Adam Tauno Williams
I'm using etree to perform XSLT transforms, such as - from lxml import etree source = etree.parse(self.rfile) xslt = etree.fromstring(self._xslt) transform = etree.XSLT(xslt) result = transform(source) according to the docs at I can pass a dic

Re: Weird Loop Behaviour

2012-01-20 Thread MRAB
On 20/01/2012 20:47, Yigit Turgut wrote: Hi, In the following code, I am trying to run "black" screen for 3 seconds and respectively 2 seconds "white" screen. Black routine takes 3 seconds and white 2 seconds, 2 x black + white = 8 seconds which should be the expected value but when I run it I g

Weird Loop Behaviour

2012-01-20 Thread Yigit Turgut
Hi, In the following code, I am trying to run "black" screen for 3 seconds and respectively 2 seconds "white" screen. Black routine takes 3 seconds and white 2 seconds, 2 x black + white = 8 seconds which should be the expected value but when I run it I get black-white-black- white instead of bl

Re: verify the return value of a function

2012-01-20 Thread Terry Reedy
On 1/20/2012 10:07 AM, Steven D'Aprano wrote: What should be avoided, when possible, is over-reliance on isinstance checks instead of protocol or interface checks. For example, don't check for a list if your function doesn't *need* a list but would be happy with a tuple or some other sequence.

Re: python logging filter limitation, looks intentional?

2012-01-20 Thread Terry Reedy
On 1/20/2012 2:17 PM, Vinay Sajip wrote: On Jan 19, 12:50 am, Terry Reedy wrote: I don't want people to have to code differently for Python 3.3 and for older versions. This is not a general policy, else we would never add new features ;-) Do you plan to keep logging feature-frozen forever,

Re: can some one help me with my code. thanks

2012-01-20 Thread Terry Reedy
On 1/20/2012 1:49 PM, Tamanna Sultana wrote: can some one help me?? I would like to create a function that, given a bin, which is a list (example below), generates averages for the numbers separated by a string 'end'. I am expecting to have 4 averages from the above bin, since there are 4 sets

Re: can some one help me with my code. thanks

2012-01-20 Thread Vincent Vande Vyvre
Le 20/01/12 19:49, Tamanna Sultana a écrit : can some one help me?? I would like to create a function that, given a bin, which is a list (example below), generates averages for the numbers separated by a string 'end'. I am expecting to have 4 averages from th

Re: python logging filter limitation, looks intentional?

2012-01-20 Thread Vinay Sajip
On Jan 19, 12:50 am, Terry Reedy wrote: > > >> I don't want people to have to code differently for Python 3.3 and for > >> older versions. > > This is not a general policy, else we would never add new features ;-) > Do you plan to keep logging feature-frozen forever, or just for another > release?

Re: First python project : Tuner

2012-01-20 Thread Anssi Saari
Jérôme writes: > - I tried to clarify the dependencies of my program by adding > "PyGObject (python-gi)." > I believe PyGObject is the name, but python-gi being the name of the debian > package (and possibly other distros' package, I didn't check), I assumed it > would be more helpful.

Re: Installing Python on CentOS 6 - a big pain

2012-01-20 Thread Anssi Saari
Benedict Verheyen writes: > If i need to install a new version of Python, as I happen to have done today, > I only need to do step 4. Which is maybe 5 minutes of work. I don't really understand why you compile these common libraries (zlib, ncurses, readline) yourself instead of using the relevan

can some one help me with my code. thanks

2012-01-20 Thread Tamanna Sultana
can some one help me?? > I would like to create a function that, given a bin, which is a list > (example below), generates averages for the numbers separated by a > string 'end'. I am expecting to have 4 averages from the above bin, > since there are 4 sets of numbers separated by 4 'end' strings

Re: subprocess module and long-lived subprocesses

2012-01-20 Thread skip
(Apologies for the non-threaded reply. My subscription to the list is currently set to no-mail and I can't get to gmane.org, so have no clean way to reply...) Mike Fletcher wrote: > Definitely *will* block, you have to explicitly set them non-blocking to > have non-blocking behaviour: ... >

Re: Installing Python on CentOS 6 - a big pain

2012-01-20 Thread rusi
On Jan 20, 2:39 pm, Benedict Verheyen wrote: > On 19/01/2012 5:36, Steven D'Aprano wrote: > > > > > > > > > On Wed, 18 Jan 2012 19:10:43 -0800, alex23 wrote: > > > > > download the tar ball > > extract the contents of the file > > cd into the source directory > > run ./configure > > run make > >

Re: C++ and Embedded Python

2012-01-20 Thread Stefan Behnel
jasonked...@hotmail.com, 20.01.2012 14:52: > Is there a method to allow a pointer to an object in local memory to > be shared with embedded Python within a C++ executable? > > The reason I require this is I have a C++ instance of a class that has > data memers that are themeselves pointers to othe

ANN: python-ldap 2.4.7

2012-01-20 Thread Michael Ströder
Find a new release of python-ldap: http://pypi.python.org/pypi/python-ldap/2.4.4 python-ldap provides an object-oriented API to access LDAP directory servers from Python programs. It mainly wraps the OpenLDAP 2.x libs for that purpose. Additionally it contains modules for other LDAP-related st

Extending PyGTK widgets with Glade

2012-01-20 Thread Richard Carlson
I'm working on a program using PyGTK and Glade. I create a glade XML file using Glade Designer and then load widgets like this: class MyDialog: def __init__(self): self.dialog = gtk.glade.XML(self.GLADEFILE).get_widget ("dialog.xml") I think it would be better if I extended the Dialo

Re: Please don't use "setuptools", the "rotten .egg" install system.

2012-01-20 Thread Michael Torrie
On 01/19/2012 10:05 AM, John Nagle wrote: > I can do it, I just have better things to do than system > administration. The fact that Python doesn't "just work" is > part of why it's losing market share. Yes you keep saying that. Of course you are complaining on the wrong list. You should b

Re: Changing interpolation

2012-01-20 Thread Chris Rebert
On Fri, Jan 20, 2012 at 7:35 AM, Hugo Léveillé wrote: > Another quick question this morning > > Does anyone have the syntax to change keyframe interpolation of a curve > ? > > For exemple, I am trying to change the curve of the translate of a > camera using this and it does not do much > > nuke.se

Re: Is a with on open always necessary?

2012-01-20 Thread Arnaud Delobelle
On 20 January 2012 15:44, Andrea Crotti wrote: > I normally didn't bother too much when reading from files, and for example > I always did a > > content = open(filename).readlines() > > But now I have the doubt that it's not a good idea, does the file handler > stays > open until the interpreter q

Re: Is a with on open always necessary?

2012-01-20 Thread Justin Simms
As I understand it, with gives you a cleaner way of doing the following steps: 1) pre processing 2) actual work 3) post processing, where the __enter__ and __exit__ methods are used to take care of 1 and 3. So with is not always necessary, but it is the preferred was to do things like file proces

Is a with on open always necessary?

2012-01-20 Thread Andrea Crotti
I normally didn't bother too much when reading from files, and for example I always did a content = open(filename).readlines() But now I have the doubt that it's not a good idea, does the file handler stays open until the interpreter quits? So maybe doing a with open(filename) as f: con

Changing interpolation

2012-01-20 Thread Hugo Léveillé
Another quick question this morning Does anyone have the syntax to change keyframe interpolation of a curve ? For exemple, I am trying to change the curve of the translate of a camera using this and it does not do much nuke.selectedNode().knobs()['translate'].animations()[0].changeInterpolation(

Re: subprocess module and long-lived subprocesses

2012-01-20 Thread Mike C. Fletcher
On 12-01-20 09:42 AM, s...@pobox.com wrote: > I'm converting some os.popen calls to use subprocess.Popen. I had > previously been ignoring stdout and stderr when using os.popen. The primary > motivation to switch to subprocess.Popen now is that I now want to check > stderr, so would have to make

Re: verify the return value of a function

2012-01-20 Thread Ian Kelly
On Fri, Jan 20, 2012 at 2:15 AM, Ulrich Eckhardt < ulrich.eckha...@dominolaser.com> wrote: > Am 19.01.2012 21:45, schrieb Jabba Laci: > > In a unit test, I want to verify that a function returns a >> cookielib.LWPCookieJar object. What is the correct way of doing that? >> >> 1) First I tried to f

Re: verify the return value of a function

2012-01-20 Thread Steven D'Aprano
On Fri, 20 Jan 2012 08:53:13 -0500, Mel Wilson wrote: > Jean-Michel Pichavant wrote: > >> isinstance is fine, if you could find the source where it is >> discouraged... Could be a consequence of some specific context. >> However, checking types in OOP is in general a failure. Unitary tests >> are

subprocess module and long-lived subprocesses

2012-01-20 Thread Skip Montanaro
I'm converting some os.popen calls to use subprocess.Popen. I had previously been ignoring stdout and stderr when using os.popen. The primary motivation to switch to subprocess.Popen now is that I now want to check stderr, so would have to make code changes to use os.popen[34] anyway. Might as w

Re: verify the return value of a function

2012-01-20 Thread Roy Smith
In article , Jabba Laci wrote: > Hi, > > In a unit test, I want to verify that a function returns a > cookielib.LWPCookieJar object. What is the correct way of doing that? jar = my_function_being_tested() self.assertIsInstance(jar, cookielib.LWPCookieJar) That works in 2.7. If you're using s

Re: verify the return value of a function

2012-01-20 Thread Mel Wilson
Jean-Michel Pichavant wrote: > isinstance is fine, if you could find the source where it is > discouraged... Could be a consequence of some specific context. > However, checking types in OOP is in general a failure. Unitary tests > are possibly an exception. I think it's discouraged when people t

C++ and Embedded Python

2012-01-20 Thread jasonkeddie
Is there a method to allow a pointer to an object in local memory to be shared with embedded Python within a C++ executable? The reason I require this is I have a C++ instance of a class that has data memers that are themeselves pointers to other object types. It is a fairly complicated object. In

Re: verify the return value of a function

2012-01-20 Thread Ulrich Eckhardt
Am 19.01.2012 21:45, schrieb Jabba Laci: In a unit test, I want to verify that a function returns a cookielib.LWPCookieJar object. What is the correct way of doing that? 1) First I tried to figure out its type with type(return_value) but it is I'm not sure where the problem here is and where e

Re: verify the return value of a function

2012-01-20 Thread Jean-Michel Pichavant
Jabba Laci wrote: Hi, In a unit test, I want to verify that a function returns a cookielib.LWPCookieJar object. What is the correct way of doing that? 1) First I tried to figure out its type with type(return_value) but it is 2) return_value.__class__ .__name__ gives 'LWPCookieJar', which is b

Re: Installing Python on CentOS 6 - a big pain

2012-01-20 Thread Benedict Verheyen
On 19/01/2012 5:36, Steven D'Aprano wrote: > On Wed, 18 Jan 2012 19:10:43 -0800, alex23 wrote: > > > download the tar ball > extract the contents of the file > cd into the source directory > run ./configure > run make > optionally run make test > run sudo make altinstall > > As a total n00b who

Wrong directory encoding when building a windows setup from Linux

2012-01-20 Thread Benedict Verheyen
Hi, I have a suite of scripts that I develop on Debian Linux, python version 2.7.1 but the resulting server where the scripts are deployed to is Windows based. I struggled making my setup.py file include data I need for my testing suite, but in the end i succeeded by making a MANIFEST.in file c