Re: len() should always return something

2009-07-24 Thread Andre Engels
On Sat, Jul 25, 2009 at 4:50 AM, Dr. Phillip M. Feldman wrote: > > Here's a simple-minded example: > > def dumbfunc(xs): >   for x in xs: >      print x > > This function works fine if xs is a list of floats, but not if it is single > float.  It can be made to work as follows: > > def dumbfunc(xs):

Re: trouble with minidom

2009-07-24 Thread Gabriel Genellina
En Fri, 24 Jul 2009 14:56:29 -0300, Ronn Ross escribió: On Tue, Jul 21, 2009 at 7:32 PM, Gabriel Genellina wrote: En Tue, 21 Jul 2009 21:08:57 -0300, Ronn Ross escribió: Hello I'm trying to read an xml file using minidome. The xml looks like: myProj /here/ I have used

Re: time in milliseconds by calling time.time()

2009-07-24 Thread Steven D'Aprano
On Sat, 25 Jul 2009 07:47:14 +0200, Andre Engels wrote: > On Sat, Jul 25, 2009 at 3:27 AM, Roy Smith wrote: > >> Keep in mind that while a float may have a large apparent precision, >> there's no promise that the actual value returned by the OS has that >> much precision.  You should be fine if a

Re: time in milliseconds by calling time.time()

2009-07-24 Thread Andre Engels
On Sat, Jul 25, 2009 at 3:27 AM, Roy Smith wrote: > Keep in mind that while a float may have a large apparent precision, > there's no promise that the actual value returned by the OS has that much > precision.  You should be fine if all you're looking for is ms, but I > wouldn't count on much more

Re: len() should always return something

2009-07-24 Thread Carl Banks
On Jul 24, 6:57 am, Grant Edwards wrote: > On 2009-07-24, Dr. Phillip M. Feldman wrote: > > > > > Some aspects of the Python design are remarkably clever, while > > others leave me perplexed. Here's an example of the latter: > > Why does len() give an error when applied to an int or float? > > le

Re: If Scheme is so good why MIT drops it?

2009-07-24 Thread Carl Banks
On Jul 24, 11:06 am, Raffael Cavallaro wrote: > On 2009-07-23 23:51:02 -0400, Carl Banks said: > > > On Jul 23, 5:52 pm, Rui Maciel wrote: > >> fft1976 wrote: > >>> How do you explain that something as inferior as Python beat Lisp in > >>> the market place despite starting 40 years later. > > >>

Re: len() should always return something

2009-07-24 Thread Chris Rebert
On Fri, Jul 24, 2009 at 7:50 PM, Dr. Phillip M. Feldman wrote: > > Here's a simple-minded example: > > def dumbfunc(xs): >   for x in xs: >      print x > > This function works fine if xs is a list of floats, but not if it is single > float.  It can be made to work as follows: > > def dumbfunc(xs):

Re: len() should always return something

2009-07-24 Thread Dr. Phillip M. Feldman
Here's a simple-minded example: def dumbfunc(xs): for x in xs: print x This function works fine if xs is a list of floats, but not if it is single float. It can be made to work as follows: def dumbfunc(xs): if isinstance(xs,(int,float,complex)): xs= [xs] for x in xs: print

Re: regex: multiple matching for one string

2009-07-24 Thread rurpy
Scott David Daniels wrote: > ru...@yahoo.com wrote: >> Nick Dumas wrote: >>> On 7/23/2009 9:23 AM, Mark Lawrence wrote: scriptlear...@gmail.com wrote: > For example, I have a string "#a=valuea;b=valueb;c=valuec;", and I > will like to take out the values (valuea, valueb, and valuec).

Re: len() should always return something

2009-07-24 Thread Dr. Phillip M. Feldman
"As far as I know, there is no programming language which treats scalars like ints as if they were vectors of length 1" Actually, Matlab does: >> length(5) ans = 1 >> -- View this message in context: http://www.nabble.com/len%28%29-should-always-return-something-tp24639361p24654358.html

Re: list vs. tuple [Re: len() should always return something]

2009-07-24 Thread Dr. Phillip M. Feldman
isinstance(x, (int, float, complex)) is certainly very compact, and does what I want. Thanks! -- View this message in context: http://www.nabble.com/len%28%29-should-always-return-something-tp24639361p24654347.html Sent from the Python - python-list mailing list archive at Nabble.com. -- htt

Re: pack an integer into a string

2009-07-24 Thread Paul Rubin
superpollo writes: > >>> number = 252509952 > >>> hex(number) > '0xf0cff00' > >>> > > so i would like a string like '\xf0\xcf\xf0\x00' def encode(number): h = '%x' % number if len(h) % 2 == 1: h = '0' + h return h.decode('hex') -- http://mail.python.org/mailman/listinfo/p

Re: time in milliseconds by calling time.time()

2009-07-24 Thread Roy Smith
In article <9c600f0c-f4a0-4e8c-bbb9-27f128aec...@m7g2000prd.googlegroups.com>, "scriptlear...@gmail.com" wrote: > I am trying to measure some system response time by using the time.time > () or time.clock() in my script. However, the numbers I get are in > 10s of milliseconds. > [...] > The tr

Why doesn't `from pkg import mod' work after `del pkg.mod'?

2009-07-24 Thread ryles
According to http://www.python.org/doc/essays/packages.html: "The import statement first tests whether the item is defined in the package; if not, it assumes it is a module and attempts to load it." However, I've noticed that once a module is imported using the `from pkg import mod' syntax, if it

Re: Python ctypes on win64

2009-07-24 Thread Aahz
In article , ulf wrote: > >Does anybody know if python includes a win64 version of ctypes? > >According to the documentation it should be included - at least >there's no special remarks for win64, and I haven't found any recent >notes saying that it shouldn't work on win64. Yet it looks like both

time in milliseconds by calling time.time()

2009-07-24 Thread scriptlear...@gmail.com
I am trying to measure some system response time by using the time.time () or time.clock() in my script. However, the numbers I get are in 10s of milliseconds. For example, 1248481670.34 #from time.time() 0.08 #from time.clock() That won't work for me, since the response time

Re: pack an integer into a string

2009-07-24 Thread casevh
On Jul 24, 3:28 pm, superpollo wrote: > is there a pythonic and synthetic way (maybe some standard module) to > "pack" an integer (maybe a *VERY* big one) into a string? like this: > >   >>> number = 252509952 >   >>> hex(number) >   '0xf0cff00' >   >>> > > so i would like a string like '\xf0\xcf\

Re: cgi.fieldstorage()

2009-07-24 Thread Diez B. Roggisch
gert schrieb: On Jul 24, 7:32 pm, "Diez B. Roggisch" wrote: gert schrieb: this is a non standard way to store multi part post data on disk def application(environ, response): with open('/usr/httpd/var/wsgiTemp','w') as f: while True: chunk = environ['wsgi.input'].read(

Re: pack an integer into a string

2009-07-24 Thread John Yeung
On Jul 24, 7:16 pm, superpollo wrote: > thanks a lot, but [struct] does not work for large integers: Since the struct module is designed specifically for C-style structs, it's definitely not going to handle arbitrary-length integers on its own. You could chop up your Python (long) integer into C

Freetype2 in PIL

2009-07-24 Thread moerchendiser2k3
Hi, I have a problem with Freetype2 in the Python Image Library. I compiled it as 64bit and I got a file named freetype239.lib. So I added this file to a folder called lib. I added the parent folder of the lib folder to the setup.py settings (like all the others: libjpeg, zlib). LIbjpeg and Zlib w

Freetype2 in PIL

2009-07-24 Thread moerchendiser2k3
Hi, I have a problem with Freetype2 in the Python Image Library. I compiled it as 64bit and I got a file named freetype239.lib. So I added this file to a folder called lib. I added the parent folder of the lib folder to the setup.py settings (like all the others: libjpeg, zlib). LIbjpeg and Zlib w

Re: how can a child thread notify a parent thread its status?

2009-07-24 Thread MRAB
Christian Heimes wrote: scriptlear...@gmail.com wrote: My parent thread keeps a counter for the number of free child workers (say 100) and initializes some child threads and call child.start(). Once the number of free child workers reach 0, the parent thread will wait until some at least one chi

Re: how can a child thread notify a parent thread its status?

2009-07-24 Thread Christian Heimes
scriptlear...@gmail.com wrote: > My parent thread keeps a counter for the number of free child workers > (say 100) and initializes some child threads and call child.start(). > Once the number of free child workers reach 0, the parent thread will > wait until some at least one child thread finishes

Re: how can a child thread notify a parent thread its status?

2009-07-24 Thread MRAB
scriptlear...@gmail.com wrote: My parent thread keeps a counter for the number of free child workers (say 100) and initializes some child threads and call child.start(). Once the number of free child workers reach 0, the parent thread will wait until some at least one child thread finishes and th

Re: clean way prepend an element to a numpy array

2009-07-24 Thread Robert Kern
On 2009-07-24 18:26, greg wrote: Robert Kern wrote: a[:0] = array('i', [0]) Not when 'a' is a numpy array rather than an array.array. That's true, but I got the impression that the OP was talking about array.array, not numpy.array. Did you read the Subject: line? :-) -- Robert Kern "I h

Re: clean way prepend an element to a numpy array

2009-07-24 Thread greg
Robert Kern wrote: a[:0] = array('i', [0]) Not when 'a' is a numpy array rather than an array.array. That's true, but I got the impression that the OP was talking about array.array, not numpy.array. It's very confusing having two widely-used types both called 'array'. :-( -- Greg -- http:/

how can a child thread notify a parent thread its status?

2009-07-24 Thread scriptlear...@gmail.com
My parent thread keeps a counter for the number of free child workers (say 100) and initializes some child threads and call child.start(). Once the number of free child workers reach 0, the parent thread will wait until some at least one child thread finishes and then it will initialize another chi

Re: pack an integer into a string

2009-07-24 Thread superpollo
Piet van Oostrum wrote: ... You have the string wrong. oops yea. But the correct one you get with: In [67]: import struct In [68]: number = 252509952 In [69]: struct.pack('>I', number) Out[69]: '\x0f\x0c\xff\x00' (Please note that this is big endian) thanks a lot, but it does not work f

Re: len() should always return something

2009-07-24 Thread bartc
"Dr. Phillip M. Feldman" wrote in message news:mailman.3644.1248417347.8015.python-l...@python.org... Some aspects of the Python design are remarkably clever, while others leave me perplexed. Here's an example of the latter: Why does len() give an error when applied to an int or float? len()

Re: pack an integer into a string

2009-07-24 Thread superpollo
superpollo wrote: Sebastian Bassi wrote: On Fri, Jul 24, 2009 at 7:28 PM, superpollo wrote: is there a pythonic and synthetic way (maybe some standard module) to "pack" an integer (maybe a *VERY* big one) into a string? like this: What do you mean to pack? Maybe Pickle is what you want.

Re: pack an integer into a string

2009-07-24 Thread Piet van Oostrum
> superpollo (s) wrote: >s> is there a pythonic and synthetic way (maybe some standard module) to >s> "pack" an integer (maybe a *VERY* big one) into a string? like this: > number = 252509952 > hex(number) >s> '0xf0cff00' > >s> so i would like a string like '\xf0\xcf\xf0\x00'

Re: pack an integer into a string

2009-07-24 Thread superpollo
Sebastian Bassi wrote: On Fri, Jul 24, 2009 at 7:28 PM, superpollo wrote: is there a pythonic and synthetic way (maybe some standard module) to "pack" an integer (maybe a *VERY* big one) into a string? like this: What do you mean to pack? Maybe Pickle is what you want. import cPickle variab

Re: Script runs manually, but cron fails

2009-07-24 Thread Emile van Sebille
On 7/24/2009 2:11 PM Bryan said... The script runs fine in my bash shell, what could cron be doing to interfere? It's likely environmental -- make sure you're starting with the same path, etc. Sometimes I'll create a sell script by env'ing to a bash script file and append the actual command

Re: pack an integer into a string

2009-07-24 Thread Sebastian Bassi
On Fri, Jul 24, 2009 at 7:28 PM, superpollo wrote: > is there a pythonic and synthetic way (maybe some standard module) to "pack" > an integer (maybe a *VERY* big one) into a string? like this: What do you mean to pack? Maybe Pickle is what you want. import cPickle variable = 124348654333577698 c

Re: installing 2.6 on vista64

2009-07-24 Thread Martin v. Löwis
> I just downloaded and attempted to install python 2.6.2. The > installer proceeds to do its work then dies, leaving an entry in the > eventlog: > > Windows Installer installed the product. Product Name: Python 2.6.2. > Product Version: 2.6.2150. Product Language: 1033. Installation > success or

pack an integer into a string

2009-07-24 Thread superpollo
is there a pythonic and synthetic way (maybe some standard module) to "pack" an integer (maybe a *VERY* big one) into a string? like this: >>> number = 252509952 >>> hex(number) '0xf0cff00' >>> so i would like a string like '\xf0\xcf\xf0\x00' i wrote some code to do it, so ugly i am ashame

Re: If Scheme is so good why MIT drops it?

2009-07-24 Thread ACL
On Jul 24, 2:06 pm, Raffael Cavallaro wrote: > On 2009-07-23 23:51:02 -0400, Carl Banks said: > > > On Jul 23, 5:52 pm, Rui Maciel wrote: > >> fft1976 wrote: > >>> How do you explain that something as inferior as Python beat Lisp in > >>> the market place despite starting 40 years later. > > >>

Re: list vs. tuple [Re: len() should always return something]

2009-07-24 Thread Duncan Booth
Roy Smith wrote: > In article , > Terry Reedy wrote: > >> Better:if isinstance(x, (int, float, complex)): > > I never noticed this before, but it seems odd that the second argument > to isinstance() should be a tuple. Using the normal arguments made > about tuples vs. lists, it seems lik

Script runs manually, but cron fails

2009-07-24 Thread Bryan
I have a backup script that runs fine when I run it manually from the command line. When I run it with cron, the script stops running at random points in the source code. The script calls rsync with the subprocess module, which in turn uses ssh to backup files from a box on my lan. It also uses

Re: non-owning references?

2009-07-24 Thread Terry Reedy
Steven D'Aprano wrote: On Fri, 24 Jul 2009 15:55:45 +0200, Hrvoje Niksic wrote: The term "variable" is used in the Python language reference and elsewhere, and is quite compatible with how other popular languages (Java, PHP, Lisp, ...) use it. Please stop complaining about valid terminology; i

How do I generate dia diagrams from python source code?

2009-07-24 Thread Qauzzix
Greetings. Since I have been using dia to make my UML diagrams. I also found an util named dia2code that generates python code from dia diagram. Now that I have that option I really want to find a way to generate dia diagram from existing code and/or maintain my diagrams. I have been googling li

Re: len() should always return something

2009-07-24 Thread Terry Reedy
Chris Rebert wrote: I think the point made by Grant Edwards is instructive. len(x) = 1 typically implies list(x)[0] and similar should be valid. At least, one should be able to iterate with x and get len(x) items. See below. And there's nothing ambiguous about len(42). Really? What is its

Re: list vs. tuple [Re: len() should always return something]

2009-07-24 Thread Terry Reedy
Steven D'Aprano wrote: On Fri, 24 Jul 2009 15:03:29 -0400, Roy Smith wrote: In article , Terry Reedy wrote: Better:if isinstance(x, (int, float, complex)): I never noticed this before, but it seems odd that the second argument to isinstance() should be a tuple. Using the normal argume

Re: ANN: psyco V2

2009-07-24 Thread Christian Tismer
On 7/24/09 1:04 AM, William Dode wrote: On 23-07-2009, Christian Tismer wrote: ... Wasn't the project plan saying the opposite, borrowing some ideas from psyco? :-) http://code.google.com/p/unladen-swallow/wiki/ProjectPlan How do you see the future of psyco when unladen-swallow will grab the

Re: len() should always return something

2009-07-24 Thread Chris Rebert
On Fri, Jul 24, 2009 at 1:30 PM, Tim Chase wrote: > Marcus Wanner wrote: >> >> First one to correctly decompress the value 0 into an ASCII >> character wins the title of the world's most capable hacker :p > > Bah...uncompressing the value 0 into *an* ASCII character is easy. >  Uncompressing it int

Re: len() should always return something

2009-07-24 Thread Tim Chase
Marcus Wanner wrote: First one to correctly decompress the value 0 into an ASCII character wins the title of the world's most capable hacker :p Bah...uncompressing the value 0 into *an* ASCII character is easy. Uncompressing it into the *original* ASCII character from which it was compressed

Re: len() should always return something

2009-07-24 Thread Marcus Wanner
On 7/24/2009 4:18 PM, Mark Lawrence wrote: Marcus Wanner wrote: On 7/24/2009 3:04 PM, Roy Smith wrote: In article <0279f596$0$5185$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: On Fri, 24 Jul 2009 16:50:03 +0200, superpollo wrote: Nah. 7 contains three bits, so len(7) should *clearl

Re: len() should always return something

2009-07-24 Thread Mark Lawrence
Marcus Wanner wrote: On 7/24/2009 3:04 PM, Roy Smith wrote: In article <0279f596$0$5185$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: On Fri, 24 Jul 2009 16:50:03 +0200, superpollo wrote: Nah. 7 contains three bits, so len(7) should *clearly* return 3. and len("7") must return 8, by

Re: len() should always return something

2009-07-24 Thread Marcus Wanner
On 7/24/2009 3:04 PM, Roy Smith wrote: In article <0279f596$0$5185$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: On Fri, 24 Jul 2009 16:50:03 +0200, superpollo wrote: Nah. 7 contains three bits, so len(7) should *clearly* return 3. and len("7") must return 8, by the same token... but

Re: len() should always return something

2009-07-24 Thread Chris Rebert
On Fri, Jul 24, 2009 at 12:05 PM, Steven D'Aprano wrote: > On Fri, 24 Jul 2009 00:02:28 -0700, Chris Rebert wrote: > >> On Thu, Jul 23, 2009 at 11:35 PM, Dr. Phillip M. >> Feldman wrote: >>> >>> Some aspects of the Python design are remarkably clever, while others >>> leave me perplexed. Here's an

Re: Eclipse Pydev update error ?

2009-07-24 Thread Linuxguy123
On Fri, 2009-07-24 at 16:43 -0300, Fabio Zadrozny wrote: > On Fri, Jul 24, 2009 at 4:17 PM, Linuxguy123 wrote: > > Does anyone know why this error is occurring in my Eclipse Pydev > > update ? > > > > An error occurred while collecting items to be installed > > No repository found containing: > >

Re: exceptions.TypeError an integer is required

2009-07-24 Thread Terry Reedy
jakecjacobson wrote: I am trying to do a post to a REST API over HTTPS and requires the script to pass a cert to the server. I am getting "exceptions.TypeError an integer is required" error and can't find the reason. I commenting out the lines of code, it is happening on the connection.request(

Re: ElementTree's Element substitution in Python 3

2009-07-24 Thread André
On Jul 24, 4:17 pm, Piet van Oostrum wrote: > > André (A) a écrit: > >A> I have a function to replace the content of an ElementTree Element by > >A> that of another one which works using Python 2 but not with Python 3. > >A> I get an assertion error. [SNIP] > >A> Traceback (most recent call

Re: ElementTree's Element substitution in Python 3

2009-07-24 Thread Terry Reedy
André wrote: I have a function to replace the content of an ElementTree Element by that of another one which works using Python 2 but not with Python 3. I get an assertion error. The function is as follows: def replace_element(elem, replacement): '''replace the content of an ElementTree Ele

Re: Eclipse Pydev update error ?

2009-07-24 Thread Fabio Zadrozny
On Fri, Jul 24, 2009 at 4:17 PM, Linuxguy123 wrote: > Does anyone know why this error is occurring in my Eclipse Pydev > update ? > > An error occurred while collecting items to be installed >  No repository found containing: > org.python.pydev/osgi.bundle/1.4.7.2843 >  No repository found containi

Re: ElementTree's Element substitution in Python 3

2009-07-24 Thread Piet van Oostrum
> André (A) a écrit: >A> I have a function to replace the content of an ElementTree Element by >A> that of another one which works using Python 2 but not with Python 3. >A> I get an assertion error. The function is as follows: >A> def replace_element(elem, replacement): >A> '''replace t

Re: list vs. tuple [Re: len() should always return something]

2009-07-24 Thread Steven D'Aprano
On Fri, 24 Jul 2009 15:03:29 -0400, Roy Smith wrote: > In article , > Terry Reedy wrote: > >> Better:if isinstance(x, (int, float, complex)): > > I never noticed this before, but it seems odd that the second argument > to isinstance() should be a tuple. Using the normal arguments made > a

Re: Adding method from one class to another class or to instance of another class

2009-07-24 Thread Terry Reedy
marekw2143 wrote: Hi, I have one class (A) that has defined method createVars. I would like to add that method to class B The code looks like this: class A(object): def createVars(self): self.v1 = 1 self.v2 = 3 pass class B(object): pass I don't want to use inheritan

Eclipse Pydev update error ?

2009-07-24 Thread Linuxguy123
Does anyone know why this error is occurring in my Eclipse Pydev update ? An error occurred while collecting items to be installed No repository found containing: org.python.pydev/osgi.bundle/1.4.7.2843 No repository found containing: org.python.pydev.ast/osgi.bundle/1.4.7.2843 No repository

Re: exceptions.TypeError an integer is required

2009-07-24 Thread Steven D'Aprano
On Fri, 24 Jul 2009 11:24:58 -0700, jakecjacobson wrote: > I am trying to do a post to a REST API over HTTPS and requires the > script to pass a cert to the server. I am getting "exceptions.TypeError > an integer is required" error and can't find the reason. I commenting > out the lines of code,

Re: ElementTree's Element substitution in Python 3

2009-07-24 Thread André
Sorry for replying to myself ... the following seems to be a working solution to my original problem. On Jul 24, 2:54 pm, André wrote: > I have a function to replace the content of an ElementTree Element by > that of another one which works using Python 2 but not with Python 3. > I get an asserti

Re: len() should always return something

2009-07-24 Thread Steven D'Aprano
On Fri, 24 Jul 2009 00:02:28 -0700, Chris Rebert wrote: > On Thu, Jul 23, 2009 at 11:35 PM, Dr. Phillip M. > Feldman wrote: >> >> Some aspects of the Python design are remarkably clever, while others >> leave me perplexed. Here's an example of the latter: Why does len() >> give an error when appli

Re: len() should always return something

2009-07-24 Thread Roy Smith
In article <0279f596$0$5185$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: > On Fri, 24 Jul 2009 16:50:03 +0200, superpollo wrote: > > >> Nah. 7 contains three bits, so len(7) should *clearly* return 3. > > > > and len("7") must return 8, by the same token... but wait! > > > > >>> len("

list vs. tuple [Re: len() should always return something]

2009-07-24 Thread Roy Smith
In article , Terry Reedy wrote: > Better:if isinstance(x, (int, float, complex)): I never noticed this before, but it seems odd that the second argument to isinstance() should be a tuple. Using the normal arguments made about tuples vs. lists, it seems like a list would be the right data

Re: non-owning references?

2009-07-24 Thread Steven D'Aprano
On Fri, 24 Jul 2009 15:55:45 +0200, Hrvoje Niksic wrote: > The term "variable" is used in the Python > language reference and elsewhere, and is quite compatible with how other > popular languages (Java, PHP, Lisp, ...) use it. Please stop > complaining about valid terminology; it is not helpful.

Re: Convert points to polygon shapefile

2009-07-24 Thread Robert Kern
On 2009-07-24 05:21, Luis Pedro Almeida wrote: Dear all, I would like to know how to convert a list of points into a polygon shapefile (esri). shapelib has Python bindings. http://shapelib.maptools.org/ -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless e

Re: len() should always return something

2009-07-24 Thread Steven D'Aprano
On Fri, 24 Jul 2009 16:50:03 +0200, superpollo wrote: >> Nah. 7 contains three bits, so len(7) should *clearly* return 3. > > and len("7") must return 8, by the same token... but wait! > > >>> len("7") > 1 > >>> > >>> > my python installation must me outdated ;-) No no no, you're obviously

Re: How can I get the line number ?

2009-07-24 Thread Maxim Khitrov
On Fri, Jul 24, 2009 at 2:51 PM, kk wrote: > Hello > > I am writing some Python code that runs in another application(has > wrapper functions). Due to lack of debugging I am printing out alot of > outputs and manual messages. I want to be able to create a function > that would let me print the curr

How can I get the line number ?

2009-07-24 Thread kk
Hello I am writing some Python code that runs in another application(has wrapper functions). Due to lack of debugging I am printing out alot of outputs and manual messages. I want to be able to create a function that would let me print the current line number that is called from. This is not for d

Re: len() should always return something

2009-07-24 Thread Terry Reedy
Phillip M. Feldman wrote: I've been converting Matlab codes to Python. In Matlab, a scalar is just a one-by-one matrix and has a length of 1. This convention seems no less arbitrary to me than Python's convention that the concept of length is not applicable to ints and floats. Multiplicati

Re: Predefined Variables

2009-07-24 Thread Piet van Oostrum
> Scott David Daniels (SDD) wrote: >SDD> Stephen Cuppett (should have written in this order): >>> "Fred Atkinson" wrote ... Is there a pre-defined variable that returns the GET line (http://www.php.net/index.php?everythingafterthequestionmark) as a single variable (rathe

exceptions.TypeError an integer is required

2009-07-24 Thread jakecjacobson
I am trying to do a post to a REST API over HTTPS and requires the script to pass a cert to the server. I am getting "exceptions.TypeError an integer is required" error and can't find the reason. I commenting out the lines of code, it is happening on the connection.request() line. Here is the pr

Re: cgi.fieldstorage()

2009-07-24 Thread gert
On Jul 24, 7:32 pm, "Diez B. Roggisch" wrote: > gert schrieb: > > > this is a non standard way to store multi part post data on disk > > > def application(environ, response): > >     with open('/usr/httpd/var/wsgiTemp','w') as f: > >         while True: > >             chunk = environ['wsgi.input'

Re: If Scheme is so good why MIT drops it?

2009-07-24 Thread Raffael Cavallaro
On 2009-07-23 23:51:02 -0400, Carl Banks said: On Jul 23, 5:52 pm, Rui Maciel wrote: fft1976 wrote: How do you explain that something as inferior as Python beat Lisp in the market place despite starting 40 years later. Probably due to similar reasons that lead php to become remotely releva

Re: non-owning references?

2009-07-24 Thread Rhodri James
On Fri, 24 Jul 2009 16:03:58 +0100, Piet van Oostrum wrote: "Rhodri James" (RJ) wrote: RJ> On Fri, 24 Jul 2009 14:55:45 +0100, Hrvoje Niksic wrote: Ben Finney writes: Utpal Sarkar writes: Is there a way I can tell a variable that the object it is pointing too is not owned by it, i

Re: Re: len() should always return something

2009-07-24 Thread Chris Rebert
> Jul 24, 2009 07:02:29 AM, c...@rebertia.com wrote: > > On Thu, Jul 23, 2009 at 11:35 PM, Dr. Phillip M. > Feldman wrote: >> >> Some aspects of the Python design are remarkably clever, while others >> leave >> me perplexed. Here's an example of the latter: Why does len() give an >> error >> when a

ElementTree's Element substitution in Python 3

2009-07-24 Thread André
I have a function to replace the content of an ElementTree Element by that of another one which works using Python 2 but not with Python 3. I get an assertion error. The function is as follows: def replace_element(elem, replacement): '''replace the content of an ElementTree Element by that of

Re: trouble with minidom

2009-07-24 Thread Ronn Ross
On Tue, Jul 21, 2009 at 7:32 PM, Gabriel Genellina wrote: > En Tue, 21 Jul 2009 21:08:57 -0300, Ronn Ross > escribió: > > > Hello I'm trying to read an xml file using minidome. The xml looks like: >> >> >> myProj >> /here/ >> >> >> >> My code looks like so: >> from xml.dom.mini

Re: len() should always return something

2009-07-24 Thread Rhodri James
On Fri, 24 Jul 2009 16:10:07 +0100, Piet van Oostrum wrote: "Rhodri James" (RJ) wrote: RJ> On Fri, 24 Jul 2009 14:57:02 +0100, Grant Edwards wrote: On 2009-07-24, Dr. Phillip M. Feldman wrote: Some aspects of the Python design are remarkably clever, while others leave me perplexed. He

Re: trouble with wrapping a c program

2009-07-24 Thread Chris Rebert
On Fri, Jul 24, 2009 at 5:34 AM, Sanne Korzec wrote: > Hi Mailing, > > I am using a c program, which first initializes for some seconds and then > waits for user input (keyboard) to type something. When enter is pressed the > c program continues. > Using the keyboard and then enter in the c progra

Re: cgi.fieldstorage()

2009-07-24 Thread Diez B. Roggisch
gert schrieb: this is a non standard way to store multi part post data on disk def application(environ, response): with open('/usr/httpd/var/wsgiTemp','w') as f: while True: chunk = environ['wsgi.input'].read(8192).decode('latin1') if not chunk: break

Re: SONAME for python modules is bad? (aka multiple module version)

2009-07-24 Thread Diez B. Roggisch
mathieu schrieb: As far as I know there has not been any consensus on how to install multiple version of a same module in python ? What are the recommended mechanism ? I use virtualenvs for everything. Especially on unixish OSes this usually works without problems. On windows, things are a bi

Re: Popen

2009-07-24 Thread Chris Rebert
> --- On Fri, 7/24/09, Diez B. Roggisch wrote: > >> From: Diez B. Roggisch >> Subject: Re: Popen >> To: python-list@python.org >> Date: Friday, July 24, 2009, 12:35 PM >> Tim schrieb: >> > Thanks! Yes I mean subprocess.Popen. >> > >> > I was wondering the meaning of "asynchronously" >> > Here is

cgi.fieldstorage()

2009-07-24 Thread gert
this is a non standard way to store multi part post data on disk def application(environ, response): with open('/usr/httpd/var/wsgiTemp','w') as f: while True: chunk = environ['wsgi.input'].read(8192).decode('latin1') if not chunk: break f.write(chun

Re: Help understanding the decisions *behind* python?

2009-07-24 Thread Uncle Roastie
On Jul 20, 12:27 pm, Phillip B Oldham wrote: > My colleagues and I have been working with python for around 6 months > now, and while we love a lot of what python has done for us and what > it enables us to do some of the decisions behind such certain > data-types and their related methods baffle

Re: effbot.org broken (WAS: Problems in commands.getoutput(cmd) with sox)

2009-07-24 Thread Chris Rebert
On Fri, Jul 24, 2009 at 2:38 AM, Piet van Oostrum wrote: >> Chris Rebert (CR) wrote: > >>CR> On Thu, Jul 23, 2009 at 12:42 PM, Chris Rebert wrote: You can use tabnanny to help diagnose the problem: http://74.125.155.132/search?q=cache:QtxvZm3QDLsJ:effbot.org/librarybook/tabnanny.htm+

Re: any suggestions to synchronize typed text and speech ?

2009-07-24 Thread Marcus Wanner
On 7/21/2009 12:13 PM, Stef Mientki wrote: hi Marcus, That sounds like a very specialized type of thing, Well from an application point of view, with the current netbooks, this looks like a perfect tool for any conversation or meeting. which only the few people with experience with wxPython, Py

Re: Re: len() should always return something

2009-07-24 Thread Phillip M. Feldman
I've read the "Zen of Python", but most of these aphorisms are vague and could be understood differently by different readers.  In particular, I don't understand the statement that "explicit is better than implicit".  Some examples of this would be helpful.I've been converting Matlab codes to Pyth

Re: Popen

2009-07-24 Thread Tim
Thanks! If that is the case, i.e. the parent doesn't wait, is the code in my last post wrong? "result" could be nothing. --- On Fri, 7/24/09, Diez B. Roggisch wrote: > From: Diez B. Roggisch > Subject: Re: Popen > To: python-list@python.org > Date: Friday, July 24, 2009, 12:35 PM > Tim schrie

SONAME for python modules is bad? (aka multiple module version)

2009-07-24 Thread mathieu
As far as I know there has not been any consensus on how to install multiple version of a same module in python ? What are the recommended mechanism ? I could not find any documentation on the subject. Does anyone sees any issue with using standard SONAME mechanism when installing a python module

Re: Popen

2009-07-24 Thread Francesco Bochicchio
On Jul 24, 6:24 pm, Tim wrote: > Thanks! > Yes I mean subprocess.Popen. > > I was wondering the meaning of "asynchronously" > Here is some code I am reading recently: > " > result = Popen(cmdline,shell=True,stdout=PIPE).stdout > for line in result.readlines(): >     if find(line,"Cross") != -1: >

Re: Popen

2009-07-24 Thread Diez B. Roggisch
Tim schrieb: Thanks! Yes I mean subprocess.Popen. I was wondering the meaning of "asynchronously" Here is some code I am reading recently: " result = Popen(cmdline,shell=True,stdout=PIPE).stdout for line in result.readlines(): if find(line,"Cross") != -1: return float(split(line)[

Re: Popen

2009-07-24 Thread Tim
Thanks! Yes I mean subprocess.Popen. I was wondering the meaning of "asynchronously" Here is some code I am reading recently: " result = Popen(cmdline,shell=True,stdout=PIPE).stdout for line in result.readlines(): if find(line,"Cross") != -1: return float(split(line)[-1][0:-1]) " T

Re: Predefined Variables

2009-07-24 Thread Scott David Daniels
Stephen Cuppett (should have written in this order): "Fred Atkinson" wrote ... Is there a pre-defined variable that returns the GET line (http://www.php.net/index.php?everythingafterthequestionmark) as a single variable (rather than individual variables)? > os.environment('QUERY_STRING') Ma

Re: regex: multiple matching for one string

2009-07-24 Thread Scott David Daniels
ru...@yahoo.com wrote: Nick Dumas wrote: On 7/23/2009 9:23 AM, Mark Lawrence wrote: scriptlear...@gmail.com wrote: For example, I have a string "#a=valuea;b=valueb;c=valuec;", and I will like to take out the values (valuea, valueb, and valuec). How do I do that in Python? The group method wi

Re: difference in printing to screen Mac / Windows

2009-07-24 Thread ryles
On Jul 18, 7:03 am, Tim Chase wrote: > Lastly, you can force all standard-output in your program to be > unbuffered without the "-u" parameter: And if you're using -u a lot, the PYTHONUNBUFFERED environment variable can also be set (but not empty), so that python adds the option automatically. --

Re: how to get no value

2009-07-24 Thread Piet van Oostrum
Well actually your subject is `how to get no value'. Your code does that perfectly. :=) -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: import vs imp and friends.

2009-07-24 Thread Emanuele D'Arrigo
Christian, Robert, thank you both for the replies, much appreciated. Manu -- http://mail.python.org/mailman/listinfo/python-list

Re: Popen

2009-07-24 Thread Piet van Oostrum
> Tim (T) wrote: >T> Hi, >T> I wonder if I use Popen, the parent process will wait for the child process >to finish or continue without waiting? >T> Thanks and regards! Only if you use Popen.wait(), Popen.communicate() or something similar like os.waitpid(), subprocess.call() -- P

Re: non-owning references?

2009-07-24 Thread Ben Finney
Hrvoje Niksic writes: > The term "variable" is used in the Python language reference and > elsewhere Yes. It should also be abundantly clear from the constant stream of confused newbies on this point that its usage of that term is different to what many expect from usage elsewhere. > and is qui

  1   2   >