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 wrote: > On Thu, 05 Aug 2010 17:07:53 +0100, wheres pythonmonks > wrote: > You're not testing for equivalence there, you're testing for identity.  "is" > and "is not" test whether the two objects concerned are (or are not) the > same object.  Two object

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 informat

Re: subprocess escaping POpen?!

2010-08-06 Thread Lawrence D'Oliveiro
In message , 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 yes, but what if you actually want

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-

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 dict

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 wrote: On Thu, 05 Aug 2010 17:07:53 +0100, wheres pythonmonks wrote: You're not testing for equivalence there, you're testing for identity. "is" and "is not" test whether the two objects concerned are (or are not) the s

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 , 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 wrote: > Richard D. Moores a écrit : >> >> On Thu, Aug 5, 2010 at 16:15, Rhodri James >> wrote: >>> >>> On Thu, 05 Aug 2010 17:07:53 +0100, wheres pythonmonks >>> wrote: >> >>> You're not testing for equivalence there, you're testing for identity

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 b

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 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 offsets. Input: This is

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 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 following code. It s

Re: Byte Offsets of Tokens, Ngrams and Sentences?

2010-08-06 Thread Muhammad Adeel
On Aug 6, 10:49 am, "Gabriel Genellina" wrote: > En Fri, 06 Aug 2010 06:07:32 -0300, Muhammad Adeel   > 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 offset

Re: abstract metaclass

2010-08-06 Thread Gabriel Genellina
En Thu, 05 Aug 2010 10:46:29 -0300, Roald de Vries 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): ... /opt/local/Library/Frameworks/Pyt

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 r

Re: Unicode error

2010-08-06 Thread kj
In Nobody 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 >exceptions could be raised. In practice, that isn't possible, a

Re: Python Portability--Not very portable?

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

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

2010-08-06 Thread Roy Smith
In article , David Cournapeau 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 only true if you limit yourself to C89 (as python seems to >

Re: easy question on parsing python: "is not None"

2010-08-06 Thread DG
On Aug 6, 2:32 am, Bruno Desthuilliers wrote: > Richard D. Moores a écrit : > > > > > On Thu, Aug 5, 2010 at 16:15, Rhodri James > > wrote: > >> On Thu, 05 Aug 2010 17:07:53 +0100, wheres pythonmonks > >> wrote: > > >> You're not testing for equivalence there, you're testing for identity.   > >

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, y

Re: pylint scores

2010-08-06 Thread Matteo Landi
On Sun, Aug 1, 2010 at 12:27 PM, News123 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 'x' or

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/listinf

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 Py

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 wrote: > In article , >  David Cournapeau 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 only

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,

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 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 script should re

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 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__, but I've also seen

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 = u"proba test ¾æèð¹" > draw.text((20,8), text ,font=arial, fill="red") Nope i gives: SyntaxError: (u

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

2010-08-06 Thread nn
On Aug 5, 2:01 pm, Daniel Urban 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 last line of cod

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 = u"proba test �" >> draw.text((20,8), text ,font=arial, fill="red") > >

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 u

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 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

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 tel

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

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.

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.

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

2010-08-06 Thread Aahz
In article , rlevesque 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 assistance you need. Generally speaking, the community philosophy is "pay forward" -- help

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 -- http://mail.python.

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 = u"proba test ¾æèð¹" >> draw.text((20,8), text ,fo

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 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 c

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 software

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 IDL

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. 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

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 cachin

Re: Python Portability--Not very portable?

2010-08-06 Thread CM
On Aug 5, 9:50 pm, "W. eWatson" 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 numpy > than I use.

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 > an

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 -- http://mail.python.org/mailman/listinfo/pyth

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" -- http://mail.python.org/mailman/

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(d

Re: python interview quuestions

2010-08-06 Thread James Mills
On Sat, Aug 7, 2010 at 4:32 AM, Tim Chase 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 some py3l questions > to

Re: Python Portability--Not very portable?

2010-08-06 Thread geremy condra
On Fri, Aug 6, 2010 at 10:58 AM, 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. http://tinyurl.com/3yhwjfj Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list

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 Chase 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 thr

Re: python interview quuestions

2010-08-06 Thread James Mills
On Sat, Aug 7, 2010 at 5:11 AM, Tim Chase 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 a very good point! Someon

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 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: >        __impo

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 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 >>> serious. However, I've

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: >__import_

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 func(d

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 o

Re: ctypes: pointer to method

2010-08-06 Thread Martin Landa
Hi, On Aug 5, 9:32 pm, Nobody 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, POINTER(c_char), PO

Re: ctypes: pointer to method

2010-08-06 Thread Martin Landa
Hi, On Aug 6, 10:10 pm, Martin Landa 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 your program when a ca

Re: python interview quuestions

2010-08-06 Thread geremy condra
On Fri, Aug 6, 2010 at 11:45 AM, James Mills wrote: > On Sat, Aug 7, 2010 at 4:32 AM, Tim Chase > 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 th

Re: python interview quuestions

2010-08-06 Thread James Mills
On Sat, Aug 7, 2010 at 6:28 AM, geremy condra 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 over, it can be done

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

2010-08-06 Thread Jon Clements
On 5 Aug, 16:15, Brandon McCombs wrote: > Jon Clements wrote: > > On 5 Aug, 08:25, Brandon McCombs 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 checkQueue functio

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 specific

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 wrote: > Jon Clements wrote: >> >> On 5 Aug, 08:25, Brandon McCombs 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

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

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

Re: default behavior

2010-08-06 Thread Wolfram Hinderer
On 6 Aug., 22:07, John Posner 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 bogus.

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 > cod

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

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 progra

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, sure

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 s

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 pipil

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')2

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 > 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 se

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 -- http://mai

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 m

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 per

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

2010-08-06 Thread dmtr
> > Well...  63 bytes per item for very short unicode strings... Is there > > any way to do better than that? Perhaps some compact unicode objects? > > There is a certain price you pay for having full-feature Python objects. Are there any *compact* Python objects? Optimized for compactness? > Wha

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

2010-08-06 Thread Chris Rebert
On Fri, Aug 6, 2010 at 6:39 PM, dmtr wrote: >> > Well...  63 bytes per item for very short unicode strings... Is there >> > any way to do better than that? Perhaps some compact unicode objects? >> >> If you think that unicode objects are going to be *smaller* than byte >> strings, I think you're

Re: python interview quuestions

2010-08-06 Thread Roy Smith
Steven D'Aprano wrote: > Personally, I'd rather see how a potential hire *tests* his code than how > he writes it. Writing code is easy. Testing code is harder. Testing it > properly is harder still -- it's amazing how many people forget that it's > not just necessary to test the function on d

  1   2   >