[ANN] Leipzig Python User Group - Meeting, August 10, 2010, 08:00pm

2010-08-06 Thread Stefan Schwarzer
=== Leipzig Python User Group === We will meet on Tuesday, August, 10th, 8:00 pm at the training center of Python Academy in Leipzig, Germany ( http://www.python-academy.com/center/find.html ). Markus Zapke-Gründemann will be talking about pip, distribute and virtualenv. Mike Müller will tell us

Announcing: python-ghostscript 0.1

2010-08-06 Thread Hartmut Goebel
Announcing: python-ghostscript 0.1 A Python-Interface to the Ghostscript library using ctypes :Version: Version 0.1 :Copyright: GNU Public License v3 (GPLv3) :Author:Hartmut Goebel h.goe...@crazy-compiler.com :Homepage:

Re: Why is python not written in C++ ?

2010-08-06 Thread David Cournapeau
On Fri, Aug 6, 2010 at 8:45 AM, Roy Smith r...@panix.com wrote: In article i3e43n$v7...@lust.ihug.co.nz,  Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote: In message roy-6bcfa7.22564104082...@news.panix.com, Roy Smith wrote: C++, for all its flaws, had one powerful feature which

Re: easy question on parsing python: is not None

2010-08-06 Thread Richard D. Moores
On Thu, Aug 5, 2010 at 16:15, Rhodri James rho...@wildebst.demon.co.uk wrote: On Thu, 05 Aug 2010 17:07:53 +0100, wheres pythonmonks wherespythonmo...@gmail.com wrote: You're not testing for equivalence there, you're testing for identity.  is and is not test whether the two objects concerned

Re: easy question on parsing python: is not None

2010-08-06 Thread Bruno Desthuilliers
Roald de Vries a écrit : 'not None' first casts None to a bool, and then applies 'not', so 'x is not None' means 'x is True'. Obviously plain wrong : Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type help, copyright, credits or license for more information.

Re: subprocess escaping POpen?!

2010-08-06 Thread Lawrence D'Oliveiro
In message mailman.1621.1281012420.1673.python-l...@python.org, Chris Withers wrote: Wolfgang Rohdewald wrote: On Donnerstag 05 August 2010, Chris Withers wrote: But why only the request for auth credentials? for security reasons I suppose - make sure a human enters the password Well

Re: Import python modules from sub-directories

2010-08-06 Thread 夏震
Hi guys, I am new to python and would like to import certain classes in sub-directories of the working directory. I was wondering how will I be able to achieve this? Regards, Nav -- http://mail.python.org/mailman/listinfo/python-list Please try touch __init__.py in sub-directories.

Re: assigning variables from list data

2010-08-06 Thread Bruno Desthuilliers
Chris Hare a écrit : I have a database query result (see code below). In PHP, I would have said list(var1,var2,var) = $result Other already answered on the Python equivalent. But there's an IMHO better way, which is to use (if the DB-API connector provides it) a DictCursor, that yields

Re: easy question on parsing python: is not None

2010-08-06 Thread Bruno Desthuilliers
Richard D. Moores a écrit : On Thu, Aug 5, 2010 at 16:15, Rhodri James rho...@wildebst.demon.co.uk wrote: On Thu, 05 Aug 2010 17:07:53 +0100, wheres pythonmonks wherespythonmo...@gmail.com wrote: You're not testing for equivalence there, you're testing for identity. is and is not test

How to read large amounts of output via popen

2010-08-06 Thread loial
I need to read a large amount of data that is being returned in standard output by a shell script I am calling. (I think the script should really be writing to a file but I have no control over that) Currently I have the following code. It seeems to work, however I suspect this may not work with

Byte Offsets of Tokens, Ngrams and Sentences?

2010-08-06 Thread Muhammad Adeel
Hi, Does any one know how to tokenize a string in python that returns the byte offsets and tokens? Moreover, the sentence splitter that returns the sentences and byte offsets? Finally n-grams returned with byte offsets. Input: This is a string. Output: This 0 is 5 a 8 string. 10

Re: Python Portability

2010-08-06 Thread Lawrence D'Oliveiro
In message i3fpos$p7...@news.eternal-september.org, W. eWatson wrote: I made a one character change to it and sent him the new py file. He can't execute it. What exactly was the problem? -- http://mail.python.org/mailman/listinfo/python-list

Re: easy question on parsing python: is not None

2010-08-06 Thread Richard D. Moores
On Fri, Aug 6, 2010 at 01:32, Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid wrote: Richard D. Moores a écrit : On Thu, Aug 5, 2010 at 16:15, Rhodri James rho...@wildebst.demon.co.uk wrote: On Thu, 05 Aug 2010 17:07:53 +0100, wheres pythonmonks wherespythonmo...@gmail.com

Re: Python Script Cannot Write to Directory

2010-08-06 Thread Lawrence D'Oliveiro
In message 4c5a6d00$0$29614$426a3...@news.free.fr, News123 wrote: The original question lacks necessary information That seems to be very common in this newsgroup. -- http://mail.python.org/mailman/listinfo/python-list

Re: easy question on parsing python: is not None

2010-08-06 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Thu, 05 Aug 2010 12:07:53 -0400, wheres pythonmonks wrote: P.S. Sorry for the top-post -- is there a way to not do top posts from gmail? I haven't used usenet since tin. Er, surely you can just move the cursor before you start typing??? CTRL+END will

Re: Byte Offsets of Tokens, Ngrams and Sentences?

2010-08-06 Thread Gabriel Genellina
En Fri, 06 Aug 2010 06:07:32 -0300, Muhammad Adeel nawabad...@gmail.com escribió: Does any one know how to tokenize a string in python that returns the byte offsets and tokens? Moreover, the sentence splitter that returns the sentences and byte offsets? Finally n-grams returned with byte

Re: Python Script Cannot Write to Directory

2010-08-06 Thread Jean-Michel Pichavant
Lawrence D'Oliveiro wrote: In message 4c5a6d00$0$29614$426a3...@news.free.fr, News123 wrote: The original question lacks necessary information That seems to be very common in this newsgroup. ... JM -- http://mail.python.org/mailman/listinfo/python-list

Re: easy question on parsing python: is not None

2010-08-06 Thread Roald de Vries
On Aug 6, 2010, at 9:25 AM, Bruno Desthuilliers wrote: Roald de Vries a écrit : 'not None' first casts None to a bool, and then applies 'not', so 'x is not None' means 'x is True'. Obviously plain wrong : Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type help,

Re: How to read large amounts of output via popen

2010-08-06 Thread Gabriel Genellina
En Fri, 06 Aug 2010 06:06:29 -0300, loial jldunn2...@gmail.com escribió: I need to read a large amount of data that is being returned in standard output by a shell script I am calling. (I think the script should really be writing to a file but I have no control over that) Currently I have the

Re: Byte Offsets of Tokens, Ngrams and Sentences?

2010-08-06 Thread Muhammad Adeel
On Aug 6, 10:49 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Fri, 06 Aug 2010 06:07:32 -0300, Muhammad Adeel nawabad...@gmail.com   escribió: Does any one know how to tokenize a string in python that returns the byte offsets and tokens? Moreover, the sentence splitter that returns

Re: abstract metaclass

2010-08-06 Thread Gabriel Genellina
En Thu, 05 Aug 2010 10:46:29 -0300, Roald de Vries downa...@gmail.com escribió: I'm trying to create a metaclass that keeps track of its objects, and implement this as a collections.MutableMapping. That is, something like this: class type2(type, MutableMapping): ...

Re: easy question on parsing python: is not None

2010-08-06 Thread Vito 'ZeD' De Tullio
Richard D. Moores wrote: So there would be a different implementation for each operating system? One for Windows, one for linux? Or one for Vista and one for XP? I'm just trying to clarify what is meant by implementation. there are dozillions of implementation of python: one for each release

Re: Unicode error

2010-08-06 Thread kj
In pan.2010.07.23.21.46.03.547...@nowhere.com Nobody nob...@nowhere.com writes: On Fri, 23 Jul 2010 10:42:26 +, Steven D'Aprano wrote: Don't write bare excepts, always catch the error you want and nothing else. That advice would make more sense if it was possible to know which

Re: Python Portability--Not very portable?

2010-08-06 Thread Tiago Katcipis
On Fri, Aug 6, 2010 at 12:28 AM, W. eWatson wolftra...@invalid.com wrote: On 8/5/2010 7:45 PM, geremy condra wrote: On Thu, Aug 5, 2010 at 6:50 PM, W. eWatsonwolftra...@invalid.com wrote: In my on-again-off-again experience with Python for 18 months, portability seems an issue. As an

Re: Why is python not written in C++ ?

2010-08-06 Thread Roy Smith
In article mailman.1666.1281075732.1673.python-l...@python.org, David Cournapeau courn...@gmail.com wrote: Yes, there are a few corner cases where valid C syntax has different semantics in C and C++.  But, they are very few.  Calling C++ a superset of C is essentially correct. This is

Re: easy question on parsing python: is not None

2010-08-06 Thread DG
On Aug 6, 2:32 am, Bruno Desthuilliers bruno. 42.desthuilli...@websiteburo.invalid wrote: Richard D. Moores a écrit : On Thu, Aug 5, 2010 at 16:15, Rhodri James rho...@wildebst.demon.co.uk wrote: On Thu, 05 Aug 2010 17:07:53 +0100, wheres pythonmonks wherespythonmo...@gmail.com wrote:

Re: How to read large amounts of output via popen

2010-08-06 Thread Nobody
On Fri, 06 Aug 2010 02:06:29 -0700, loial wrote: I need to read a large amount of data that is being returned in standard output by a shell script I am calling. (I think the script should really be writing to a file but I have no control over that) If the script is writing to stdout, you

Re: pylint scores

2010-08-06 Thread Matteo Landi
On Sun, Aug 1, 2010 at 12:27 PM, News123 news1...@free.fr wrote: Hi, On 07/31/2010 11:04 AM, Matteo Landi wrote: What are the messages one should really care about while evaluating its code using pylint? It's easy to get 5 scored with a lot of public methods or bad named variables such as

Re: Import python modules from sub-directories

2010-08-06 Thread Navkirat Singh
On 06-Aug-2010, at 1:13 PM, 夏震 wrote: Hi guys, I am new to python and would like to import certain classes in sub-directories of the working directory. I was wondering how will I be able to achieve this? Regards, Nav -- http://mail.python.org/mailman/listinfo/python-list

Re: easy question on parsing python: is not None

2010-08-06 Thread Stefan Schwarzer
Hi DG, On 2010-08-06 14:28, DG wrote: I've always thought of it as you don't compare strings with is, you *should* use == The reasoning is that you don't know if that string instance is the only one in memory. I've heard as an implementation detail, since strings are immutable, that Python

Re: Why is python not written in C++ ?

2010-08-06 Thread David Cournapeau
On Fri, Aug 6, 2010 at 8:39 PM, Roy Smith r...@panix.com wrote: In article mailman.1666.1281075732.1673.python-l...@python.org,  David Cournapeau courn...@gmail.com wrote: Yes, there are a few corner cases where valid C syntax has different semantics in C and C++.  But, they are very few.  

Need help from someone that have PIL installed

2010-08-06 Thread alejandro
Can please someone run this little script that should output characters like ¾æè¹ð in an image. If it does it correctly can you tell me what OS, python version PIL version you have? Or better if someone can tell me why this is not working properly on my PC? (Win XP, PIL 1.1.6., Python 2.6...)

Re: Need help from someone that have PIL installed

2010-08-06 Thread Peter Otten
alejandro wrote: Can please someone run this little script that should output characters like � in an image. If it does it correctly can you tell me what OS, python version PIL version you have? Or better if someone can tell me why this is not working properly on my PC? (Win XP, PIL

Re: How to read large amounts of output via popen

2010-08-06 Thread loial
Ok, thats great. Thanks for the very elegant solution(s) On 6 Aug, 13:44, Nobody nob...@nowhere.com wrote: On Fri, 06 Aug 2010 02:06:29 -0700, loial wrote: I need to read a large amount of data that is being returned in standard output by a shell script I am calling. (I think the

Re: [Tutor] Finding the version # of a module, and py module problem

2010-08-06 Thread Richard D. Moores
On Thu, Aug 5, 2010 at 18:47, Philip Semanchuk phi...@semanchuk.com wrote: it's just a question of whether or not the module in question exposes any kind of a version attribute. There's no standard, unfortunately. The most popular convention seems to be via an attribute called __version__,

Re: Need help from someone that have PIL installed

2010-08-06 Thread alejandro
# the last tuple is the background color img = Image.new(RGBA,(300, 50), (0, 0, 0, 0)) Thank you for this # I think that the PIL can cope with unicode, so add a u-prefix here: text = uproba test ¾æèð¹ draw.text((20,8), text ,font=arial, fill=red) Nope i gives: SyntaxError: (unicode

Re: new to python - trouble calling a function from another function

2010-08-06 Thread nn
On Aug 5, 2:01 pm, Daniel Urban urban.d...@gmail.com wrote: I'm building an elevator simulator for a class assignment. I recently ran into a roadblock and don't know how to fix it. For some reason, in my checkQueue function below, the call to self.goUp() is never executed. It is on the

Re: Need help from someone that have PIL installed

2010-08-06 Thread Peter Otten
alejandro wrote: # the last tuple is the background color img = Image.new(RGBA,(300, 50), (0, 0, 0, 0)) Thank you for this # I think that the PIL can cope with unicode, so add a u-prefix here: text = uproba test � draw.text((20,8), text ,font=arial, fill=red) Nope i gives:

Re: Python Portability--Not very portable?

2010-08-06 Thread W. eWatson
I would think there are some small time and big time Python players who sell executable versions of their programs for profit? Yes. What's your point? That someone must know how to distribute them without having the source code ripped off. disutils. Sounds familiar. I'm pretty sure I was

Re: [Tutor] Finding the version # of a module, and py module problem

2010-08-06 Thread Philip Semanchuk
On Aug 6, 2010, at 10:20 AM, Richard D. Moores wrote: On Thu, Aug 5, 2010 at 18:47, Philip Semanchuk phi...@semanchuk.com wrote: it's just a question of whether or not the module in question exposes any kind of a version attribute. There's no standard, unfortunately. The most popular

Re: Python Portability--Not very portable?

2010-08-06 Thread Peter Otten
W. eWatson wrote: I would think there are some small time and big time Python players who sell executable versions of their programs for profit? Yes. What's your point? That someone must know how to distribute them without having the source code ripped off. Yes, but he won't tell for fear

Re: Need help from someone that have PIL installed

2010-08-06 Thread alejandro
Make sure that # encoding:utf-8 is the first line of your script, details and fineprint here: http://www.python.org/dev/peps/pep-0263/ Peter Tryed that... What was the output of my script on your computer? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Portability--Not very portable?

2010-08-06 Thread W. eWatson
I can't respond to otten directly, since he uses gmane. Here's my response. W. eWatson wrote: I would think there are some small time and big time Python players who sell executable versions of their programs for profit? Yes. What's your point? That someone must know how to

Re: Need help from someone that have PIL installed

2010-08-06 Thread Peter Otten
alejandro wrote: Make sure that # encoding:utf-8 is the first line of your script, details and fineprint here: http://www.python.org/dev/peps/pep-0263/ Peter Tryed that... What happened? What was the output of my script on your computer? $ python -V Python 2.6.4 $ python -c import

Re: Python Portability--Not very portable?

2010-08-06 Thread Peter Otten
W. eWatson wrote: I can't respond to otten directly, since he uses gmane. Here's my response. W. eWatson wrote: I would think there are some small time and big time Python players who sell executable versions of their programs for profit? Yes. What's your point? That

Re: Checking that 2 pdf are identical (md5 a solution?)

2010-08-06 Thread Aahz
In article f496a1ac-c5b9-471c-877e-ad5334ada...@q12g2000yqj.googlegroups.com, rlevesque raynald.leves...@gmail.com wrote: Given your expertise I will not be able to 'repay' you by helping on Python problems but if you ever need help with SPSS related problems I will be pleased to provide the

Smith-Waterman Algorithm in Python

2010-08-06 Thread Muhammad Adeel
Hi, Does any one about any implementation of classical Smith Waterman local alignment algorithm and it's variants for aligning natural language text? thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Smith-Waterman Algorithm in Python

2010-08-06 Thread Daniel Fetchinson
Does any one about any implementation of classical Smith Waterman local alignment algorithm and it's variants for aligning natural language text? Please see http://tinyurl.com/2wy43fh Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown --

Re: Need help from someone that have PIL installed

2010-08-06 Thread Thomas Jollans
On 08/06/2010 04:37 PM, alejandro wrote: # the last tuple is the background color img = Image.new(RGBA,(300, 50), (0, 0, 0, 0)) Thank you for this # I think that the PIL can cope with unicode, so add a u-prefix here: text = uproba test ¾æèð¹ draw.text((20,8), text ,font=arial,

Re: easy question on parsing python: is not None

2010-08-06 Thread Peter Pearson
On Fri, 06 Aug 2010 15:37:04 +0200, Stefan Schwarzer wrote: [snip] I can imagine a case where you might want to compare a string with `is`: FORWARD = forward BACKWARD = backward ... def func(direction=FORWARD): if direction is FORWARD: ...

Re: Python Portability--Not very portable?

2010-08-06 Thread geremy condra
On Fri, Aug 6, 2010 at 8:00 AM, W. eWatson wolftra...@invalid.com wrote: I would think there are some small time and big time Python players who sell executable versions of their programs for profit? Yes. What's your point? That someone must know how to distribute them without having the

Re: Python Portability--Not very portable?

2010-08-06 Thread W. eWatson
On 8/6/2010 9:03 AM, Peter Otten wrote: ... Seriously, I try to make a joke once in a while, usually with devastating results. The idea you were meant to take away was that once you start thinking about a protection scheme there is always a next step until you reach the point where your

python interview quuestions

2010-08-06 Thread prakash jp
Hi all, I would like to aquint myself with Python Interview questions . I am a Python Scripter, so if u could orient the pointers in the same direction it would be very handy Regards -- http://mail.python.org/mailman/listinfo/python-list

Re: python interview quuestions

2010-08-06 Thread Gary Herron
On 08/06/2010 10:44 AM, prakash jp wrote: Hi all, I would like to aquint myself with Python Interview questions . I am a Python Scripter, so if u could orient the pointers in the same direction it would be very handy Regards Huh??? -- http://mail.python.org/mailman/listinfo/python-list

Re: [Tutor] Finding the version # of a module, and py module problem

2010-08-06 Thread W. eWatson
On 8/5/2010 6:47 PM, Philip Semanchuk wrote: On Aug 5, 2010, at 8:55 PM, W. eWatson wrote: It's been awhile since I've used python, and I recall there is a way to find the version number from the IDLE command line prompt. dir, help, __version.__? Hi Wayne, FYI it's got nothing to do with

Re: Python Portability--Not very portable?

2010-08-06 Thread W. eWatson
On 8/6/2010 10:31 AM, geremy condra wrote: On Fri, Aug 6, 2010 at 8:00 AM, W. eWatsonwolftra...@invalid.com wrote: I would think there are some small time and big time Python players who sell executable versions of their programs for profit? Yes. What's your point? That someone must know

Re: Python Portability--Not very portable?

2010-08-06 Thread Peter Otten
W. eWatson wrote: So you think Python is part of open software in terms of distributing a product? So I should stick to C, where one can distribute programs w/o revealing code details, and having a customer compile the code? It's No, I'm trying to make you reconsider what you're going to

Re: easy question on parsing python: is not None

2010-08-06 Thread Terry Reedy
On 8/6/2010 5:27 AM, Richard D. Moores wrote: So there would be a different implementation for each operating system? One for Windows, one for linux? Or one for Vista and one for XP? I'm just trying to clarify what is meant by implementation. Different version of CPython (that string caching

Re: Python Portability--Not very portable?

2010-08-06 Thread CM
On Aug 5, 9:50 pm, W. eWatson wolftra...@invalid.com wrote: In my on-again-off-again experience with Python for 18 months, portability seems an issue. As an example, my inexperienced Python partner 30 miles away has gotten out of step somehow. I think by installing a different version of

Re: Python Portability--Not very portable?

2010-08-06 Thread CM
As an example, my inexperienced Python partner 30 miles away has gotten out of step somehow. I think by installing a different version of numpy than I use. I gave him a program we both use months ago, and he had no trouble. (We both use IDLE on 2.5). I made a one character change to it and

Re: python interview quuestions

2010-08-06 Thread Tim Chase
I would like to aquint myself with Python Interview questions This came up a while ago: http://www.mail-archive.com/python-list@python.org/msg168961.html Most of that thread is still relevant (perhaps throw in some py3l questions too) -tkc --

Perl - Python unpack

2010-08-06 Thread James Mills
Hey all, Quick question for you Python enthusiasts that also happen to know Perl quite well... What does a* or A* translate to in Python when unpacking binary data with struct.unpack(...) ? cheers James -- -- James Mills -- -- Problems are solved by method --

Re: easy question on parsing python: is not None

2010-08-06 Thread Stefan Schwarzer
Hello Peter, On 2010-08-06 19:20, Peter Pearson wrote: On Fri, 06 Aug 2010 15:37:04 +0200, Stefan Schwarzer wrote: [snip] I can imagine a case where you might want to compare a string with `is`: FORWARD = forward BACKWARD = backward ... def func(direction=FORWARD):

Re: python interview quuestions

2010-08-06 Thread James Mills
On Sat, Aug 7, 2010 at 4:32 AM, Tim Chase python.l...@tim.thechases.com wrote: I would like to aquint myself with Python Interview questions This came up a while ago: http://www.mail-archive.com/python-list@python.org/msg168961.html Most of that thread is still relevant (perhaps throw in

Re: Python Portability--Not very portable?

2010-08-06 Thread geremy condra
On Fri, Aug 6, 2010 at 10:58 AM, W. eWatson wolftra...@invalid.com wrote: Is there a complete illustration of using disutils? Our only dependencies are on Python Org material. We use no commercial or licensed code. http://tinyurl.com/3yhwjfj Geremy Condra --

Re: python interview quuestions

2010-08-06 Thread Tim Chase
On 08/06/10 13:45, James Mills wrote: On Sat, Aug 7, 2010 at 4:32 AM, Tim Chasepython.l...@tim.thechases.com wrote: I would like to aquint myself with Python Interview questions This came up a while ago: http://www.mail-archive.com/python-list@python.org/msg168961.html Most of that thread

Re: python interview quuestions

2010-08-06 Thread James Mills
On Sat, Aug 7, 2010 at 5:11 AM, Tim Chase python.l...@tim.thechases.com wrote: Another common thing you can do on a newsgroup is mention the FizzBuzz problem.  Any good competent newsgroup will produce a multitude of proposed solutions, the majority of which will be wrong. ;-) That's actually

Re: [Tutor] Finding the version # of a module, and py module problem

2010-08-06 Thread W. eWatson
I must be missing something. I tried this. (Windows, IDLE, Python 2.5) # Try each module import sys import numpy import scipy import string dependencies = numyp, scipy for dependency in dependencies: try: __import__(dependency.name) except ImportError: # Uh oh!

Re: [Tutor] Finding the version # of a module, and py module problem

2010-08-06 Thread Benjamin Kaplan
On Fri, Aug 6, 2010 at 12:14 PM, W. eWatson wolftra...@invalid.com wrote: I must be missing something. I tried this. (Windows, IDLE, Python 2.5) # Try each module import sys import numpy import scipy import string dependencies = numyp, scipy for dependency in dependencies:    try:      

Re: Easy questions from a python beginner

2010-08-06 Thread Albert van der Horst
In article 4c495b50$0$28634$c3e8...@news.astraweb.com, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Thu, 22 Jul 2010 21:23:05 -0700, Stephen Hansen wrote: On 7/22/10 7:47 PM, wheres pythonmonks wrote: [...] The truth is that I don't intend to use these approaches in anything

Re: [Tutor] Finding the version # of a module, and py module problem

2010-08-06 Thread Tommy Grav
On Aug 6, 2010, at 3:14 PM, W. eWatson wrote: I must be missing something. I tried this. (Windows, IDLE, Python 2.5) # Try each module import sys import numpy import scipy import string dependencies = numyp, scipy for dependency in dependencies: try:

Re: easy question on parsing python: is not None

2010-08-06 Thread Ethan Furman
Stefan Schwarzer wrote: Hello Peter, On 2010-08-06 19:20, Peter Pearson wrote: On Fri, 06 Aug 2010 15:37:04 +0200, Stefan Schwarzer wrote: [snip] I can imagine a case where you might want to compare a string with `is`: FORWARD = forward BACKWARD = backward ... def

Re: default behavior

2010-08-06 Thread John Posner
On 8/2/2010 11:00 PM, John Posner wrote: On 7/31/2010 1:31 PM, John Posner wrote: Caveat -- there's another description of defaultdict here: http://docs.python.org/library/collections.html#collections.defaultdict ... and it's bogus. This other description claims that __missing__ is a method

Re: ctypes: pointer to method

2010-08-06 Thread Martin Landa
Hi, On Aug 5, 9:32 pm, Nobody nob...@nowhere.com wrote: I don't know about methods, but it works for functions. Sample code:     ...     G_set_error_routine(byref(self._print_error)) This won't work; you have to be more explicit, e.g.:         errtype = CFUNCTYPE(c_int,

Re: ctypes: pointer to method

2010-08-06 Thread Martin Landa
Hi, On Aug 6, 10:10 pm, Martin Landa landa.mar...@gmail.com wrote: Any idea how to solve it. Thanks, Martin I overlooked note Make sure you keep references to CFUNCTYPE objects as long as they are used from C code. ctypes doesn’t, and if you don’t, they may be garbage collected, crashing

Re: python interview quuestions

2010-08-06 Thread geremy condra
On Fri, Aug 6, 2010 at 11:45 AM, James Mills prolo...@shortcircuit.net.au wrote: On Sat, Aug 7, 2010 at 4:32 AM, Tim Chase python.l...@tim.thechases.com wrote: I would like to aquint myself with Python Interview questions This came up a while ago:

Re: python interview quuestions

2010-08-06 Thread James Mills
On Sat, Aug 7, 2010 at 6:28 AM, geremy condra debat...@gmail.com wrote: If I had to wait 5 minutes while a candidate tried to solve this problem I would not hire them. Yes you do raise a valid point. It should really only take you a mere few seconds or so to write a solution to this. More

Re: new to python - trouble calling a function from another function

2010-08-06 Thread Jon Clements
On 5 Aug, 16:15, Brandon McCombs n...@none.com wrote: Jon Clements wrote: On 5 Aug, 08:25, Brandon McCombs n...@none.com wrote: Hello, I'm building an elevator simulator for a class assignment. I recently ran into a roadblock and don't know how to fix it. For some reason, in my

HL7 v3 (XML) importer

2010-08-06 Thread Luke Kenneth Casson Leighton
an HL7 v2 importer was written by john paulett, and it has been enhanced to support some of the HL7 v3 standard, which is XML-based. no dependencies are required: xml.sax is used so as to reduce the dependencies to purely python. additionally, as HL7 has versions/revisions, published data

Re: new to python - trouble calling a function from another function

2010-08-06 Thread geremy condra
On Thu, Aug 5, 2010 at 8:15 AM, Brandon McCombs n...@none.com wrote: Jon Clements wrote: On 5 Aug, 08:25, Brandon McCombs n...@none.com wrote: Hello, I'm building an elevator simulator for a class assignment. I recently ran into a roadblock and don't know how to fix it. For some reason, in

Re: easy question on parsing python: is not None

2010-08-06 Thread Steven D'Aprano
On Fri, 06 Aug 2010 17:20:30 +, Peter Pearson wrote: On Fri, 06 Aug 2010 15:37:04 +0200, Stefan Schwarzer wrote: [snip] I can imagine a case where you might want to compare a string with `is`: FORWARD = forward BACKWARD = backward [...] Actually, I've never seen such a use, as

Re: easy question on parsing python: is not None

2010-08-06 Thread Steven D'Aprano
On Fri, 06 Aug 2010 05:28:40 -0700, DG wrote: I've always thought of it as you don't compare strings with is, you *should* use == The reasoning is that you don't know if that string instance is the only one in memory. This is excellent advice. I won't say that there is never a use-case for

Re: default behavior

2010-08-06 Thread Wolfram Hinderer
On 6 Aug., 22:07, John Posner jjpos...@optimum.net wrote: On 8/2/2010 11:00 PM, John Posner wrote: On 7/31/2010 1:31 PM, John Posner wrote: Caveat -- there's another description of defaultdict here: http://docs.python.org/library/collections.html#collections.defaultdict ... and it's

Re: Python Portability--Not very portable?

2010-08-06 Thread Steven D'Aprano
On Fri, 06 Aug 2010 08:00:55 -0700, W. eWatson wrote: I would think there are some small time and big time Python players who sell executable versions of their programs for profit? Yes. What's your point? That someone must know how to distribute them without having the source code ripped

Re: easy question on parsing python: is not None

2010-08-06 Thread Steven D'Aprano
On Fri, 06 Aug 2010 15:37:04 +0200, Stefan Schwarzer wrote: Plus, I believe the == operator will check if the variables point to the same object. No, that's what `is` is for. Actually, yes, equality is implemented with a short-cut that checks for identity first. That makes something like:

Re: Unicode error

2010-08-06 Thread Steven D'Aprano
On Fri, 06 Aug 2010 11:23:50 +, kj wrote: I don't get your point. Even when I *know* that a certain exception may happen, I don't necessarily catch it. I catch only those exceptions for which I can think of a suitable response that is *different* from just letting the program fail.

Re: Python Portability--Not very portable?

2010-08-06 Thread Steven D'Aprano
On Fri, 06 Aug 2010 10:35:38 -0700, W. eWatson wrote: So you think Python is part of open software in terms of distributing a product? Python itself *is* open source software. It doesn't *require* you to write open source software. So I should stick to C, where one can distribute programs

Re: easy question on parsing python: is not None

2010-08-06 Thread Steven D'Aprano
On Fri, 06 Aug 2010 11:42:39 +0200, Jean-Michel Pichavant wrote: Steven D'Aprano wrote: On Thu, 05 Aug 2010 12:07:53 -0400, wheres pythonmonks wrote: P.S. Sorry for the top-post -- is there a way to not do top posts from gmail? I haven't used usenet since tin. Er, surely you can just

Re: Python Portability--Not very portable?

2010-08-06 Thread Steven D'Aprano
On Thu, 05 Aug 2010 18:50:14 -0700, W. eWatson wrote: As an example, my inexperienced Python partner 30 miles away has gotten out of step somehow. I think by installing a different version of numpy than I use. I gave him a program we both use months ago, and he had no trouble. (We both use

Re: Python Portability--Not very portable?

2010-08-06 Thread Steven D'Aprano
On Fri, 06 Aug 2010 10:58:24 -0700, W. eWatson wrote: Is there a complete illustration of using disutils? Our only dependencies are on Python Org material. We use no commercial or licensed code. Oh my, the sheer ignorance that sentence reveals. Python and the standard library *is* licensed.

Re: default behavior

2010-08-06 Thread John Posner
On 8/6/2010 6:24 PM, Wolfram Hinderer wrote: This is probably nitpicking, but the patch calls __missing__ a special method. However, unlike special methods, it is not invoked by special syntax but by the dict's __getitem__ method. (len() invokes __len__ on any object - you can't do something

How to implement a pipeline...??? Please help

2010-08-06 Thread Ritchy lelis
Hi guys In the development of my ADC project i have a new new challenge. First i need to implement a 10 Bit pipelineADC that will be the basis to later implement any kind of pipeline arquitecture (i mean, with 10 Bit, 16 Bit or any other configuration i want) i wish to... What's a 10 Bit

Microsoft lessening commitment to IronPython and IronRuby

2010-08-06 Thread Neil Hodgson
There is a blog post from Jimmy Schementi who previously worked at Microsoft on IronRuby about the state of dynamic language work there. http://blog.jimmy.schementi.com/2010/08/start-spreading-news-future-of-jimmy.html Neil -- http://mail.python.org/mailman/listinfo/python-list

Is there any way to minimize str()/unicode() objects memory usage [Python 2.6.4] ?

2010-08-06 Thread dmtr
I'm running into some performance / memory bottlenecks on large lists. Is there any easy way to minimize/optimize memory usage? Simple str() and unicode objects() [Python 2.6.4/Linux/x86]: sys.getsizeof('') 24 bytes sys.getsizeof('0')25 bytes sys.getsizeof(u'')28 bytes

Re: Is there any way to minimize str()/unicode() objects memory usage [Python 2.6.4] ?

2010-08-06 Thread Steven D'Aprano
On Fri, 06 Aug 2010 17:45:31 -0700, dmtr wrote: I'm running into some performance / memory bottlenecks on large lists. Is there any easy way to minimize/optimize memory usage? Yes, lots of ways. For example, do you *need* large lists? Often a better design is to use generators and iterators

Re: Is there any way to minimize str()/unicode() objects memory usage [Python 2.6.4] ?

2010-08-06 Thread Thomas Jollans
On 08/07/2010 02:45 AM, dmtr wrote: I'm running into some performance / memory bottlenecks on large lists. Is there any easy way to minimize/optimize memory usage? Simple str() and unicode objects() [Python 2.6.4/Linux/x86]: sys.getsizeof('') 24 bytes sys.getsizeof('0')25 bytes

Re: python interview quuestions

2010-08-06 Thread Steven D'Aprano
On Sat, 07 Aug 2010 06:37:05 +1000, James Mills wrote: On Sat, Aug 7, 2010 at 6:28 AM, geremy condra debat...@gmail.com wrote: If I had to wait 5 minutes while a candidate tried to solve this problem I would not hire them. Yes you do raise a valid point. It should really only take you a

Re: easy question on parsing python: is not None

2010-08-06 Thread Gregory Ewing
Ethan Furman wrote: Instead of using 'is' use '=='. Maybe not as cute, but definitely more robust! It's also just as efficient if you use strings that resemble identifiers, because they will be interned, so the comparison will end up just doing an indentity test anyway. -- Greg --

Re: easy question on parsing python: is not None

2010-08-06 Thread Gregory Ewing
Steven D'Aprano wrote: Generally, when testing for None, you actually want None and not some look-alike that merely tests equal to None. That's true, although I can't think of a use case for an object that compares equal to None but isn't -- except for obfuscated code competition entries and

Re: Is there any way to minimize str()/unicode() objects memory usage [Python 2.6.4] ?

2010-08-06 Thread dmtr
Steven, thank you for answering. See my comments inline. Perhaps I should have formulated my question a bit differently: Are there any *compact* high performance containers for unicode()/str() objects in Python? By *compact* I don't mean compression. Just optimized for memory usage, rather than

  1   2   3   >