Re: attaching names to subexpressions

2012-10-27 Thread Chris Angelico
On Sun, Oct 28, 2012 at 4:57 PM, Devin Jeanpierre wrote: > What if he wants to avoid both downsides A and B? What solution does > he use then? He switches to a language whose BDFL is not Steven D'Aprano. :) No offense meant Steven... ChrisA -- http://mail.python.org/mailman/listinfo/python-lis

Re: problems with xml parsing (python 3.3)

2012-10-27 Thread MRAB
On 2012-10-28 02:27, janni...@gmail.com wrote: Hello all, I am new to Python and have a problem with the behaviour of the xml parser. Assume we have this xml document: Title of the first book. Title of the second book. If I no

Re: problems with xml parsing (python 3.3)

2012-10-27 Thread jannidis
To my understanding the empty element is a child of entry as is the text node. Is there anything I am doing wrong here? Any help is appreciated, Fotis -- http://mail.python.org/mailman/listinfo/python-list

problems with xml parsing (python 3.3)

2012-10-27 Thread jannidis
Hello all, I am new to Python and have a problem with the behaviour of the xml parser. Assume we have this xml document: Title of the first book. Title of the second book. If I now check for the text of all 'entry' nodes, the tex

Re: ctypes free memory which is allocated in C DLL

2012-10-27 Thread zlchen . ken
On Sunday, October 28, 2012 6:26:28 AM UTC+8, Nobody wrote: > On Sat, 27 Oct 2012 07:42:01 -0700, zlchen.ken wrote: > > > > > I have a DLL which written in C language, one of the function is to > > > allocate a structure, fill the members and then return the pointer of > > > the structure. >

Re: attaching names to subexpressions

2012-10-27 Thread rusi
On Oct 28, 5:49 am, Steven D'Aprano wrote: > It's sure as hell more beautiful and readable than assignment as an > expression. > > If we are going to judge code on the ability of people to take a quick > glance and immediately understand it, then pretty much nothing but > trivial one-liners will

Re: SSH Connection with Python

2012-10-27 Thread Cameron Simpson
On 27Oct2012 14:18, Gelonida N wrote: | On 10/27/2012 02:21 AM, Roy Smith wrote: | > In article , | > Gelonida N wrote: | > | >> Another problem is, that paramiko depends on pycrypto 2.1+ | >> which doesn't exist as binary release for python 2.7 | > | > I'm running paramiko-1.7.6 with python 2.

Re: ctypes free memory which is allocated in C DLL

2012-10-27 Thread Nobody
On Sat, 27 Oct 2012 07:42:01 -0700, zlchen.ken wrote: > I have a DLL which written in C language, one of the function is to > allocate a structure, fill the members and then return the pointer of > the structure. > > After Python called this function, and done with the returned structure, > I wo

Re: Shipping python modules - best practices?

2012-10-27 Thread Demian Brecht
I should also mention that these are just my personal best practices that I've put together during my time working with/on OS projects. You'll almost never find two projects with identical packaging, so really at the end of the day, it's totally up to you and your particular project requirements

Re: Shipping python modules - best practices?

2012-10-27 Thread Demian Brecht
1) IMHO, these should be two distinct steps. You will definitely want to run unit tests without sdist and likewise, I'm sure you'll want to sdist without unit tests. Personally, if I wanted to combine the two, I'd create tasks in a makefile and just run something along the lines of: make unit sd

Re: Error compiling python3.2.3: architecture of input file is incompatible

2012-10-27 Thread Hans Mulder
On 27/10/12 16:11:48, Tobias Marquardt wrote: > Hello, > > I am trying to compile Python 3.2.3. > On my 64 bit Ubuntu machine I have no problems but using Ubuntu 32 but I > get the following error: > > /usr/bin/ld: i386:x86-64 architecture of input file > `Parser/tokenizer_pgen.o' is incompatible

Re: ctypes free memory which is allocated in C DLL

2012-10-27 Thread Chris Angelico
On Sun, Oct 28, 2012 at 2:40 AM, Ken Chen wrote: > Yes, I agree writing a corresponding API to free the memory is the best > practice and best bet. > Sometimes, the third party API may not provide that. Then that's a majorly dangerous third party API. The only time it's safe to provide a half-on

Re: while expression feature proposal

2012-10-27 Thread Tim Chase
On 10/26/12 19:18, Steven D'Aprano wrote: > def iterate_until_none_or_false(func, *args, **kwargs): > while True: > x = func(*args, **kwargs) > # Halt if x is None or False, but not other falsey values. > if x is None or x is False: > return > yield x

Re: a.index(float('nan')) fails

2012-10-27 Thread Mark Adam
On Thu, Oct 25, 2012 at 9:04 PM, Terry Reedy wrote: > On 10/25/2012 9:46 PM, mambokn...@gmail.com wrote: > > a = [float('nan'), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > a >> >> [nan, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > > a.index(float('nan')) >> >> Traceback (most recent call last):

Re: a.index(float('nan')) fails

2012-10-27 Thread Nobody
On Sat, 27 Oct 2012 08:56:16 +0200, Thomas Rachel wrote: > Am 27.10.2012 06:48 schrieb Dennis Lee Bieber: > >> I don't know about the more modern calculators, but at least up >> through my HP-41CX, HP calculators didn't do (binary) "floating >> point"... They did a form of BCD with a fixed n

Re: a.index(float('nan')) fails

2012-10-27 Thread Nobody
On Thu, 25 Oct 2012 22:04:52 -0400, Terry Reedy wrote: > Containment of nan in collection is tested by is, not ==. AFAICT, it isn't specific to NaN. The test used by .index() and "in" appears to be equivalent to: def equal(a, b): return a is b or a == b IOW, it always checks

Re: ctypes free memory which is allocated in C DLL

2012-10-27 Thread Ken Chen
On Saturday, October 27, 2012 10:56:54 PM UTC+8, Chris Angelico wrote: > On Sun, Oct 28, 2012 at 1:42 AM, wrote: > > > Hi Guys, > > > > > > I have a DLL which written in C language, one of the function is to > > allocate a structure, fill the members and then return the pointer of the > > st

Re: ctypes free memory which is allocated in C DLL

2012-10-27 Thread Chris Angelico
On Sun, Oct 28, 2012 at 1:42 AM, wrote: > Hi Guys, > > I have a DLL which written in C language, one of the function is to allocate > a structure, fill the members and then return the pointer of the structure. > > After Python called this function, and done with the returned structure, I > woul

ctypes free memory which is allocated in C DLL

2012-10-27 Thread zlchen . ken
Hi Guys, I have a DLL which written in C language, one of the function is to allocate a structure, fill the members and then return the pointer of the structure. After Python called this function, and done with the returned structure, I would like to free the returned structure. How can I achie

Error compiling python3.2.3: architecture of input file is incompatible

2012-10-27 Thread Tobias Marquardt
Hello, I am trying to compile Python 3.2.3. On my 64 bit Ubuntu machine I have no problems but using Ubuntu 32 but I get the following error: /usr/bin/ld: i386:x86-64 architecture of input file `Parser/tokenizer_pgen.o' is incompatible with i386 output /usr/bin/ld: i386:x86-64 architecture of

Re: How to correctly pass “pointer-to-pointer” into DLL via ctypes?

2012-10-27 Thread zlchen . ken
On Thursday, November 18, 2010 8:03:57 PM UTC+8, Grigory Petrov wrote: > Hello. > > I have a DLL that allocates memory and returns it. Function in DLL is like > this: > > void Foo( unsigned char** ppMem, int* pSize ) > { >   * pSize = 4; >   * ppMem = malloc( * pSize ); >   for( int i = 0; i < *

Re: Sphinx / sys.path

2012-10-27 Thread mining . facts
So now it works, but taking my project get some trouble. I use in MyData my ConfigParser Class for configuration issues. The project.ini file is in /project and has some entries. [Logging] my_data:MyData.py#/tmp/MyData.log#logging.WARN I guess Sphinx has trouble to load the ini-file!? Thanks

Shipping python modules - best practices?

2012-10-27 Thread rambius
Hello, I developed some moderate-sized python scripts that I would like to distribute as python modules. I have never shipped modules before and I read http://docs.python.org/distutils/index.html. I was able to generate a source distribution, but I still have some questions. 1) My module conta

Re:

2012-10-27 Thread Chris Angelico
On Sun, Oct 28, 2012 at 12:13 AM, Shaojun Li wrote: > nothing Step aside, 'import this', we've found the true Zen of Python! ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: attaching names to subexpressions

2012-10-27 Thread Gelonida N
On 10/27/2012 04:42 AM, Steve Howell wrote: > I have been reading the thread "while expression feature proposal," > and one of the interesting outcomes of the thread is the idea that > Python could allow you to attach names to subexpressions, much like C > allows. In C you can say something like

Re: SSH Connection with Python

2012-10-27 Thread Gelonida N
On 10/27/2012 02:21 AM, Roy Smith wrote: In article , Gelonida N wrote: Another problem is, that paramiko depends on pycrypto 2.1+ which doesn't exist as binary release for python 2.7 I'm running paramiko-1.7.6 with python 2.7.3 on my Ubunto Precise box. I'm reasonably sure all I did was "

Re: Sphinx / sys.path

2012-10-27 Thread mining . facts
Got it spelling error! -- http://mail.python.org/mailman/listinfo/python-list

Re: Sphinx / sys.path

2012-10-27 Thread Dave Angel
On 10/27/2012 06:18 AM, mining.fa...@googlemail.com wrote: > Hi, > > I figure out how it works with sphinx documentation. But I'm stucked > in the sys.path issue? > > sys.path.insert(0, '/home/chris/projekte/dev/testmodule') > > /home/chris/projekte/dev/testmodule/doc/source/code.rst:4: WARNING:

Sphinx / sys.path

2012-10-27 Thread mining . facts
Hi, I figure out how it works with sphinx documentation. But I'm stucked in the sys.path issue? sys.path.insert(0, '/home/chris/projekte/dev/testmodule') /home/chris/projekte/dev/testmodule/doc/source/code.rst:4: WARNING: autodoc can't import/find module 'myproject', it reported error: "No mo

Re: better way for ' '.join(args) + '\n'?

2012-10-27 Thread Thomas Rachel
Am 26.10.2012 09:49 schrieb Ulrich Eckhardt: Hi! General advise when assembling strings is to not concatenate them repeatedly but instead use string's join() function, because it avoids repeated reallocations and is at least as expressive as any alternative. What I have now is a case where I'm

Re: a.index(float('nan')) fails

2012-10-27 Thread Thomas Rachel
Am 27.10.2012 06:48 schrieb Dennis Lee Bieber: I don't know about the more modern calculators, but at least up through my HP-41CX, HP calculators didn't do (binary) "floating point"... They did a form of BCD with a fixed number of significant /decimal/ digits Then, what about sqrt(x)**