Re: python simply not scaleable enough for google?

2009-11-11 Thread Alain Ketterlin
Terry Reedy tjre...@udel.edu writes: I can imagine a day when code compiled from Python is routinely time-competitive with hand-written C. Have a look at http://code.google.com/p/unladen-swallow/downloads/detail?name=Unladen_Swallow_PyCon.pdfcan=2q= Slide 6 is impressive. The bottom of

Re: Repost: Read a running process output

2010-02-05 Thread Alain Ketterlin
Ashok Prabhu ashokprab...@gmail.com writes: from subprocess import * p1=Popen('/usr/sunvts/bin/64/vtsk -d',stdout=PIPE,shell=True) Use Popen(['/usr/...','-d'],stdout=PIPE), i.e., no shell. -- Alain. -- http://mail.python.org/mailman/listinfo/python-list

Re: Repost: Read a running process output

2010-02-05 Thread Alain Ketterlin
Ashok Prabhu ashokprab...@gmail.com writes: p1=Popen('/usr/sunvts/bin/64/vtsk -d',stdout=PIPE,shell=True) Use Popen(['/usr/...','-d'],stdout=PIPE), i.e., no shell. -- Alain. Thanks for the response. However it throws an error. Please find below. from subprocess import *

Re: a +b ?

2010-06-11 Thread Alain Ketterlin
yanhua gasf...@163.com writes: it's a simple question: input two integers A and B in a line,output A+B? this is my program: s = input() input() is probably not what you think it is. Check raw_input instead. t = s.split() a = int(t[0]) b = int(t[1]) print(a+b) but i think it's too

Re: pythonize this!

2010-06-15 Thread Alain Ketterlin
superpollo ute...@esempio.net writes: goal (from e.c.m.): evaluate 1^2+2^2+3^2-4^2-5^2+6^2+7^2+8^2-9^2-10^2+...-2010^2, where each three consecutive + must be followed by two - (^ meaning ** in this context) my solution: s = 0 for i in range(1, 2011): ... s += i**2 ... if not

Re: Normalizing A Vector

2010-07-30 Thread Alain Ketterlin
Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes: Say a vector V is a tuple of 3 numbers, not all zero. You want to normalize it (scale all components by the same factor) so its magnitude is 1. The usual way is something like this: L = math.sqrt(V[0] * V[0] + V[1] * V[1] +

Re: Normalizing A Vector

2010-07-31 Thread Alain Ketterlin
Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes: What I don’t like is having that intermediate variable L leftover after the computation. Well, it also guarantees that the square root is computed once. OK, this version should solve that problem, without requiring any new

Re: Normalizing A Vector

2010-08-01 Thread Alain Ketterlin
Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes: V = tuple \ ( x / l for x in V for l in (math.sqrt(reduce(lambda a, b : a + b, (y * y for y in V), 0)),) ) You got the order wrong (it has

Re: Normalizing A Vector

2010-08-02 Thread Alain Ketterlin
Bartc ba...@freeuk.com writes: def norm(V): L = math.sqrt( sum( [x**2 for x in V] ) ) return [ x/L for x in V ] There's a cost involved in using those fancy constructions. Sure. The above has three loops that take some time. I found the following to be about twice as fast, when

Re: path to data files

2010-08-19 Thread Alain Ketterlin
Daniel Fetchinson fetchin...@googlemail.com writes: If a python module requires a data file to run how would I reference this data file in the source in a way that does not depend on whether the module is installed system-wide, installed in $HOME/.local or is just placed in a directory from

Re: Large regular expressions

2010-03-15 Thread Alain Ketterlin
Nathan Harmston iwanttobeabad...@googlemail.com writes: [...] Could anyone suggest other methods of these kind of string matching in Python? I m trying to see if my swigged alphabet trie is faster than whats possible in Python! Since you mention using a trie, I guess it's just a big

Re: GIF89A and PIL

2010-03-27 Thread Alain Ketterlin
Stephen Hansen apt.shan...@gmail.invalid writes: Is it possible to get PIL to save GIF's in GIF89A format, instead of GIF87A? GIF89 was patented. I guess that is why it isn't used by PIL. (The patent has expired now, IIRC.) Anyway, PNG was supposed to replace GIF. If not, are there any

Incorrect scope of list comprehension variables

2010-04-03 Thread Alain Ketterlin
Hi all, I've just spent a few hours debugging code similar to this: d = dict() for r in [1,2,3]: d[r] = [r for r in [4,5,6]] print d THe problem is that the r in d[r] somehow captures the value of the r in the list comprehension, and somehow kills the loop interator. The (unexpected)

Re: Incorrect scope of list comprehension variables

2010-04-06 Thread Alain Ketterlin
Alain Ketterlin al...@dpt-info.u-strasbg.fr writes: d = dict() for r in [1,2,3]: d[r] = [r for r in [4,5,6]] print d Thanks to Chris and Paul for the details (the list comp. r actually leaks). I should have found this by myself. My background is more on functional programming languages

Re: Incorrect scope of list comprehension variables

2010-04-06 Thread Alain Ketterlin
Steven D'Aprano st...@remove-this-cybersource.com.au writes: d = dict() for r in [1,2,3]: d[r] = [r for r in [4,5,6]] print d This isn't directly relevant to your problem, but why use a list comprehension in the first place? [r for r in [4,5,6]] is just [4,5,6], only slower. Sure.

Re: Incorrect scope of list comprehension variables

2010-04-17 Thread Alain Ketterlin
Steven D'Aprano st...@remove-this-cybersource.com.au writes: On Fri, 16 Apr 2010 08:48:03 -0700, Aahz wrote: Nevertheless, it is a common intuition that the list comp variable should *not* be exposed outside of the list comp, and that the for-loop variable should. Perhaps it makes no sense, but

Re: Incorrect scope of list comprehension variables

2010-04-17 Thread Alain Ketterlin
Steven D'Aprano st...@remove-this-cybersource.com.au writes: On Sat, 17 Apr 2010 12:05:03 +0200, Alain Ketterlin wrote: I don't know of any language that creates a new scope for loop variables, but perhaps that's just my ignorance... I think Pascal and Modula-2 do this, Fortran does

Re: Kindly show me a better way to do it

2010-05-08 Thread Alain Ketterlin
Oltmans rolf.oltm...@gmail.com writes: a = [ [1,2,3,4], [5,6,7,8] ] Currently, I'm iterating through it like for i in [k for k in a]: for a in i: print a I would prefer: for i in a: for v in i: print v i.e., not messing with a and avoiding an additional

Re: solve a newspaper quiz

2010-05-09 Thread Alain Ketterlin
superpollo ute...@esempio.net writes: if a b c are digits, solve ab:c=a*c+b solved in one minute with no thought: Obviously. for a in range(10): for b in range(10): for c in range(10): try: if (10.*a+b)/c==a*c+b: print

Re: if, continuation and indentation

2010-05-27 Thread Alain Ketterlin
HH henri...@gmail.com writes: if (width == 0 and height == 0 and color == 'red' and emphasis == 'strong' or highlight 100): raise ValueError(sorry, you lose) I prefer to see the and at the beginning of continuation lines, and usually group

Re: map is useless!

2010-06-06 Thread Alain Ketterlin
rantingrick rantingr...@gmail.com writes: Python map is just completely useless. [...] import time def test1(): l = range(1) t1 = time.time() map(lambda x:x+1, l) t2= time.time() print t2-t1 def test2(): l = range(1) t1 = time.time()

Re: SQLite3 and lastrowid

2010-11-19 Thread Alain Ketterlin
Alexander Gattin xr...@yandex.ru writes: The proper way to get the number of rows is to use the COUNT aggregate function, e.g., SELECT COUNT(*) FROM TABLE1, which will return a single row with a single column containing the number of rows in table1. It's better to select count(1) instead

Re: SQLite3 and lastrowid

2010-11-19 Thread Alain Ketterlin
Alexander Gattin xr...@umc.com.ua writes: On Fri, Nov 19, 2010 at 12:32:19PM +0100, Alain Ketterlin wrote: Alexander Gattin xr...@yandex.ru writes: It's better to select count(1) instead of count(*). The latter may skip rows consisting entirely of NULLs IIRC. Wrong: count(anyname

Re: PIL how to enlarge image

2010-12-04 Thread Alain Ketterlin
robos85 prog...@gmail.com writes: Hi, I try to enlarge original image. I have image in size: 100x100 and I want to make it 120x120. But resize() doesn't make it bigger. Is there any method for that? You have to use i.transform() -- Alain. --

Re: simple threading.Thread and Semaphores hang

2010-12-06 Thread Alain Ketterlin
lnenov lne...@mm-sol.com writes: My application hangs on exit. I have isoleted this piece of code that reproduces the error: (the time module is extra and not needed to reproduce) import threading import time def func(): b = threading.Semaphore(value=0) b.acquire() This waits

Re: Newbie needs regex help

2010-12-06 Thread Alain Ketterlin
Dan M d...@catfolks.net writes: I took at look at http://docs.python.org/howto/regex.html, especially the section titled The Backslash Plague. I started out trying : import re r = re.compile('x([0-9a-fA-F]{2})') a = This \xef file \xef has \x20 a bunch \xa0 of \xb0 crap \xc0 The

Re: How to populate all possible hierarchical clusterings from a set of elements?

2011-01-13 Thread Alain Ketterlin
justin justpar...@gmail.com writes: Suppose I have [1,2,3,4,5], then there are many ways of making clustering. Among them, I want to pair up terminals until there is only one left at the end. Are you trying ascending hierarchical clustering by any chance? In that case you're supposed to use

Re: How to populate all possible hierarchical clusterings from a set of elements?

2011-01-13 Thread Alain Ketterlin
DevPlayer devpla...@gmail.com writes: def maketup(lst): if len(lst) == 1: return lst[0] elif len(lst) == 2: return (lst[0],lst[1]) elif len(lst) 2: return ( (maketup(lst[:-2]), lst[-2]), lst[-1]) The OP wants all binary trees over the elements, not

Re: How to populate all possible hierarchical clusterings from a set of elements?

2011-01-13 Thread Alain Ketterlin
Richard Thomas chards...@gmail.com writes: On Jan 13, 10:02 am, Alain Ketterlin al...@dpt-info.u-strasbg.fr def clusterings(l):     if len(l) == 1:         print repr(l)     else:         n = len(l)         for i in xrange(n):             for j in xrange(i+1,n

Re: Perl Hacker, Python Initiate

2011-02-02 Thread Alain Ketterlin
Gary Chambers gwch...@gwcmail.com writes: Given the following Perl script: [41 lines of Perl removed] Sorry, I'm lucky enough to be able to completely ignore Perl. Will someone please provide some insight on how to accomplish that task in Python? From what I understood in the comments of

Re: Parsing numeric ranges

2011-02-25 Thread Alain Ketterlin
Seldon sel...@katamail.it writes: I have to convert integer ranges expressed in a popular compact notation (e.g. 2, 5-7, 20-22, 41) to a the actual set of numbers (i.e. 2,5,7,20,21,22,41). What form does the input have? Are they strings, or some other representation? Is there any library

Re: Get Path of current Script

2011-03-14 Thread Alain Ketterlin
Alexander Schatten asch...@gmail.com writes: could someone help me with a small problem? I wrote a Python script that does some RegEx... transformations. Now, this script loads some configuration data from a file located in the same directory: sys.path[0] is the path to the directory

Re: Critic my module

2013-07-25 Thread Alain Ketterlin
Devyn Collier Johnson devyncjohn...@gmail.com writes: I made a Python3 module that allows users to use certain Linux shell commands from Python3 more easily than using os.system(), subprocess.Popen(), or subprocess.getoutput(). This module (once placed with the other modules) can be used

Re: outputting time in microseconds or milliseconds

2013-08-04 Thread Alain Ketterlin
matt.doolittl...@gmail.com writes: self.logfile.write('%s\t'%(str(time( [...] 2013-08-0323:59:341375588774.89 [...] Why is it only giving me the centisecond precision? the docs say i should get microsecond precision with the code i put together. Because of str()'s default

Re: Tail recursion to while iteration in 2 easy steps

2013-10-02 Thread Alain Ketterlin
Terry Reedy tjre...@udel.edu writes: Part of the reason that Python does not do tail call optimization is that turning tail recursion into while iteration is almost trivial, once you know the secret of the two easy steps. Here it is. Assume that you have already done the work of turning a

Re: Tail recursion to while iteration in 2 easy steps

2013-10-02 Thread Alain Ketterlin
rusi rustompm...@gmail.com writes: On Wednesday, October 2, 2013 3:00:41 AM UTC+5:30, Terry Reedy wrote: Part of the reason that Python does not do tail call optimization is that turning tail recursion into while iteration is almost trivial, once you know the secret of the two easy steps.

Re: Tail recursion to while iteration in 2 easy steps

2013-10-04 Thread Alain Ketterlin
Mark Janssen dreamingforw...@gmail.com writes: def fact(n): return 1 if n = 1 else n * fact(n-1) class Strange: ... def __le__(dummy): global fact fact = someotherfun # this is binding return false You cannot prevent this in python. No, but you can't prevent a lot of

Re: Tail recursion to while iteration in 2 easy steps

2013-10-07 Thread Alain Ketterlin
Terry Reedy tjre...@udel.edu writes: On 10/4/2013 5:49 AM, Alain Ketterlin wrote: I think allowing rebinding of function names is extremely strange, Steven already countered the 'is extremely strange' part by showing that such rebinding is common, generally useful, and only occasionally

Re: Tail recursion to while iteration in 2 easy steps

2013-10-08 Thread Alain Ketterlin
random...@fastmail.us writes: On Mon, Oct 7, 2013, at 13:15, Alain Ketterlin wrote: That's fine. My point was: you can't at the same time have full dynamicity *and* procedural optimizations (like tail call opt). Everybody should be clear about the trade-off. Let's be clear about what

Re: Tail recursion to while iteration in 2 easy steps

2013-10-08 Thread Alain Ketterlin
Antoon Pardon antoon.par...@rece.vub.ac.be writes: Op 07-10-13 19:15, Alain Ketterlin schreef: [...] That's fine. My point was: you can't at the same time have full dynamicity *and* procedural optimizations (like tail call opt). Everybody should be clear about the trade-off. Your wrong

Re: Basic Python Questions - Oct. 31, 2013

2013-10-31 Thread Alain Ketterlin
E.D.G. edgrs...@ix.netcom.com writes: The calculation speed question just involves relatively simple math such as multiplications and divisions and trig calculations such as sin and tan etc. These are not simple computations. Any compiled language (Fortran, C, C++, typically) will

Re: Basic Python Questions - Oct. 31, 2013

2013-10-31 Thread Alain Ketterlin
Chris Angelico ros...@gmail.com writes: On Fri, Nov 1, 2013 at 12:17 AM, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: E.D.G. edgrs...@ix.netcom.com writes: The calculation speed question just involves relatively simple math such as multiplications and divisions and trig

Re: Basic Python Questions - Oct. 31, 2013

2013-10-31 Thread Alain Ketterlin
Mark Lawrence breamore...@yahoo.co.uk writes: On 31/10/2013 13:17, Alain Ketterlin wrote: E.D.G. edgrs...@ix.netcom.com writes: The calculation speed question just involves relatively simple math such as multiplications and divisions and trig calculations such as sin and tan etc

Re: Comparing strings from the back?

2012-09-04 Thread Alain Ketterlin
Roy Smith r...@panix.com writes: There's been a bunch of threads lately about string implementations, and that got me thinking (which is often a dangerous thing). Let's assume you're testing two strings for equality. You've already done the obvious quick tests (i.e they're the same

Re: which a is used?

2012-09-25 Thread Alain Ketterlin
Jayden jayden.s...@gmail.com writes: # Begin a = 1 def f(): print a def g(): a = 20 f() g() #End I think the results should be 20, but it is 1. Would you please tell me why? When python looks at g(), it sees that a variable a is assigned to, and decides it is a local

Re: parse an environment file

2012-10-01 Thread Alain Ketterlin
Jason Friedman ja...@powerpull.net writes: [...] I want my python 3.2.2 script, called via cron, to know what those additional variables are. How? This is not a python question. Have a look at the crontab(5) man page, it's all explained there. -- Alain. --

Re: Combinations of lists

2012-10-03 Thread Alain Ketterlin
Steen Lysgaard boxeakast...@gmail.com writes: I am looking for a clever way to compute all combinations of two lists. Look at this example: h = ['A','A','B','B'] m = ['a','b'] the resulting combinations should be of the same length as h and each element in m can be used twice. The sought

Re: pyw program not displaying unicode characters properly

2012-10-14 Thread Alain Ketterlin
jjmeric jjme...@free.fr writes: Our language lab at INALCO is using a nice language parsing and analysis program written in Python. As you well know a lot of languages use characters that can only be handled by unicode. Here is an example of the problem we have on some Windows computers.

Re: pyw program not displaying unicode characters properly

2012-10-14 Thread Alain Ketterlin
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: On Sun, 14 Oct 2012 19:19:33 +0200, Alain Ketterlin wrote: Usenet has no attachments. *snarfle* You almost owed me a new monitor. I nearly sprayed my breakfast all over it. [...] I owe you nothing, and you can do whatever you

Re: ElementTree Issue - Search and remove elements

2012-10-17 Thread Alain Ketterlin
Tharanga Abeyseela tharanga.abeyse...@gmail.com writes: I need to remove the parent node, if a particular match found. It looks like you can't get the parent of an Element with elementtree (I would love to be proven wrong on this). The solution is to find all nodes that have a Rating (grand-)

Re: Python does not take up available physical memory

2012-10-19 Thread Alain Ketterlin
Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de writes: Am 19.10.2012 21:03 schrieb Pradipto Banerjee: [...] Still got MemoryError, but at least this time python tried to use the physical memory. What I noticed is that before it gave me the error it used up

Re: Split single file into multiple files based on patterns

2012-10-23 Thread Alain Ketterlin
satyam dirac@gmail.com writes: I have a text file like this A1980JE3937 2732 4195 12.527000 A1980JE3937 3465 9720 22.00 A1980JE3937 2732 9720 18.00 A1980KK18700010 130 303 4.985000 A1980KK18700010 7 4915 0.435000 [...] I want to split the file and get multiple

Re: How to pass class instance to a method?

2012-11-26 Thread Alain Ketterlin
ALeX inSide alex.b.ins...@gmail.com writes: How to statically type an instance of class that I pass to a method of other instance? Python does not do static typing. I suppose there shall be some kind of method decorator to treat an argument as an instance of class? Decorators are an

Re: using ffmpeg command line with python's subprocess module

2013-12-03 Thread Alain Ketterlin
Ben Finney ben+pyt...@benfinney.id.au writes: Chris Angelico ros...@gmail.com writes: On Mon, Dec 2, 2013 at 10:34 PM, iMath redstone-c...@163.com wrote: ffmpeg -f concat -i (for f in ./*.wav; do echo file '$f'; done) -c copy output.wav ffmpeg -f concat -i (printf file '%s'\n ./*.wav)

Re: How to write this as a list comprehension?

2014-01-18 Thread Alain Ketterlin
Piet van Oostrum p...@vanoostrum.org writes: [...] I could define a auxiliary function like: def auxfunc(then, name): _, mn, dy, _, _, _, wd, _, _ = localtime(then) return somefunc(mn, day, wd, name) and then use [auxfunc(then, name) for then, name in mylist] [...] labels =

Re: Flag control variable

2014-02-12 Thread Alain Ketterlin
luke.gee...@gmail.com writes: Can I make it that if C = int(sys.argv[3]) But when I only enter 2 argumentvariable it sets c automaticly to 0 or 1 C = int(sys.argv[3]) if len(sys.argv) 3 else 0 is one possibility. -- Alain. -- https://mail.python.org/mailman/listinfo/python-list

Re: A curious bit of code...

2014-02-13 Thread Alain Ketterlin
forman.si...@gmail.com writes: I ran across this and I thought there must be a better way of doing it, but then after further consideration I wasn't so sure. if key[:1] + key[-1:] == '': ... Some possibilities that occurred to me: if key.startswith('') and key.endswith(''): ... and:

Re: Is there a better way to do this snippet?

2012-04-03 Thread Alain Ketterlin
python w.g.sned...@gmail.com writes: tag23gr is a list of lists each with two items. g23tag is an empty dictionary when I run the for loop below. When is is complete each key is a graphic name who's values are a list of tags. for item in tag23gr: ... value, key = tuple(item) ...

Re: Is there a better way to do this snippet?

2012-04-03 Thread Alain Ketterlin
nn prueba...@latinmail.com writes: for item in tag23gr: ...        value, key = tuple(item) ...        if(g23tag.get(key)): ...                g23tag[key].append(value) ...        else: ...                g23tag[key] = [value] for item in tag23gr:    

Re: No os.copy()? Why not?

2012-04-04 Thread Alain Ketterlin
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: On Tue, 03 Apr 2012 15:46:31 -0400, D'Arcy Cain wrote: On 03/28/12 16:12, John Ladasky wrote: I'm looking for a Python (2.7) equivalent to the Unix cp command. open(outfile, w).write(open(infile).read()) Because your cp

Re: Python Gotcha's?

2012-04-05 Thread Alain Ketterlin
Miki Tebeka miki.teb...@gmail.com writes: [...] (Note that I want over http://wiki.python.org/moin/PythonWarts already). The local variable and scoping is, imho, something to be really careful about. Here is an example: class A(object): def __init__(self): self.x = 0 def

Re: Python randomly exits with Linux OS error -9 or -15

2012-04-09 Thread Alain Ketterlin
Janis janis.vik...@gmail.com writes: I have this problem with my script exiting randomly with Linux OS status code -9 (most often) or -15 (also sometimes, but much more rarely). As far as I understand -9 corresponds to Bad file descriptor and -15 Block device required. How do you get -9 and

Re: system call that is killed after n seconds if not finished

2012-04-16 Thread Alain Ketterlin
Jaroslav Dobrek jaroslav.dob...@gmail.com writes: I would like to execute shell commands, but only if their execution time is not longer than n seconds. Like so: monitor(os.system(do_something), 5) I.e. the command do_somthing should be executed by the operating system. If the call has not

Re: why () is () and [] is [] work in other way?

2012-04-20 Thread Alain Ketterlin
dmitrey dmitre...@gmail.com writes: I have spent some time searching for a bug in my code, it was due to different work of is with () and []: () is () True [] is [] False (Python 2.7.2+ (default, Oct 4 2011, 20:03:08) [GCC 4.6.1] ) Is this what it should be or maybe yielding unified

Re: tiny script has memory leak

2012-05-17 Thread Alain Ketterlin
gry georgeryo...@gmail.com writes: sys.version -- '2.6 (r26:66714, Feb 21 2009, 02:16:04) \n[GCC 4.3.2 [gcc-4_3-branch revision 141291]] I thought this script would be very lean and fast, but with a large value for n (like 15), it uses 26G of virtural memory, and things start to

Re: Dynamic comparison operators

2012-05-24 Thread Alain Ketterlin
mlangenho...@gmail.com writes: I would like to pass something like this into a function test(val1,val2,'=') and it should come back with True or False. def test(x,y,c): return c(x,y) Call with: test(v1,v2, lambda x,y:x=y ). A bit noisy imho. If you have a finite number of comparison

Re: ./configure

2012-06-03 Thread Alain Ketterlin
Janet Heath janetcatherine.he...@gmail.com writes: [...] configure:3161: checking machine type as reported by uname -m configure:3164: result: x86_64 configure:3177: checking for --without-gcc configure:3221: result: no configure:3282: checking for gcc configure:3312: result: no

Re: Help needed with nested parsing of file into objects

2012-06-04 Thread Alain Ketterlin
richard pullenjenn...@gmail.com writes: Hi guys i am having a bit of dificulty finding the best approach / solution to parsing a file into a list of objects / nested objects any help would be greatly appreciated. #file format to parse .txt [code] An instance of TestArray a=a b=b c=c

Re: Help needed with nested parsing of file into objects

2012-06-05 Thread Alain Ketterlin
richard pullenjenn...@gmail.com writes: [I'm leaving the data in the message in case anybody has troubles going up-thread.] Hi guys still struggling to get the code that was posted to me on this forum to work in my favour and get the output in the format shown above. This is what I have so

Re: Help needed with nested parsing of file into objects

2012-06-05 Thread Alain Ketterlin
richard pullenjenn...@gmail.com writes: An instance of TestArray  a=a  b=b  c=c  List of 2 A elements:   Instance of A element    a=1    b=2    c=3   Instance of A element    d=1    e=2    f=3  List of 1 B elements   Instance of B element    a=1    b=2    c=3

Re: Compare 2 times

2012-06-06 Thread Alain Ketterlin
Alain Ketterlin al...@dpt-info.u-strasbg.fr writes: loial jldunn2...@gmail.com writes: I have a requirement to test the creation time of a file with the current time and raise a message if the file is more than 15 minutes old. Platform is Unix. I have looked at using os.path.getctime

Re: [newbie] Equivalent to PHP?

2012-06-12 Thread Alain Ketterlin
Gilles nos...@nospam.com writes: I notice that Python-based solutions are usually built as long-running processes with their own web server (or can run in the back with eg. Nginx and be reached through eg. FastCGI/WSGI ) while PHP is simply a language to write scripts and requires a web

Re: code review

2012-06-30 Thread Alain Ketterlin
Thomas Jollans t...@jollybox.de writes: def is_valid_password(password): return mud.minpass = len(password) = mud.maxpass Which of the two comparisons is done first anyway? In the face of ambiguity, refuse the temptation to guess. There is no ambiguity. See the language reference:

Re: code review

2012-06-30 Thread Alain Ketterlin
Thomas Jollans t...@jollybox.de writes: On 06/30/2012 11:47 PM, Terry Reedy wrote: def is_valid_password(password): return mud.minpass = len(password) = mud.maxpass Which of the two comparisons is done first anyway? In the face of ambiguity, refuse the temptation to guess. There is

Re: the meaning of rユ.......ï¾

2012-07-23 Thread Alain Ketterlin
Henrik Faber hfa...@invalid.net writes: On 23.07.2012 15:55, Henrik Faber wrote: Dear Lord. Python 3.2 (r32:88445, Dec 8 2011, 15:26:58) [GCC 4.5.2] on linux2 Type help, copyright, credits or license for more information. fööbär = 3 fööbär 3 I didn't know this. How awful.

Re: print(....,file=sys.stderr) buffered?

2012-08-14 Thread Alain Ketterlin
Helmut Jarausch jarau...@skynet.be writes: On Mon, 13 Aug 2012 15:43:31 +, Grant Edwards wrote: On 2012-08-13, Helmut Jarausch jarau...@skynet.be wrote: Hi, for tracing purposes I have added some print outs like print('+++ before calling foo',file=sys.stderr) x=foo(..) print('---

Re: Strange behavior

2012-08-14 Thread Alain Ketterlin
light1qu...@gmail.com writes: However if you run the code you will notice only one of the strings beginning with 'x' is removed from the startingList. def testFunc(startingList): xOnlyList = []; for str in startingList: if (str[0] == 'x'):

Re: Strange behavior

2012-08-15 Thread Alain Ketterlin
Chris Angelico ros...@gmail.com writes: Other people have explained the problem with your code. I'll take this example as a way of introducing you to one of Python's handy features - it's an idea borrowed from functional languages, and is extremely handy. It's called the list comprehension,

Re: Strange behavior

2012-08-15 Thread Alain Ketterlin
light1qu...@gmail.com writes: I got my answer by reading your posts and referring to: http://docs.python.org/reference/compound_stmts.html#the-for-statement (particularly the shaded grey box) Not that the problem is not specific to python (if you erase the current element when traversing a

Re: _mysql_exceptions.OperationalError: (2005, Unknown MySQL server host

2012-08-15 Thread Alain Ketterlin
Hans Mulder han...@xs4all.nl writes: On 15/08/12 15:30:26, nepaul wrote: The code: import MySQLDB strCmd = user = 'root', passwd = '123456', db = 'test', host = 'localhost' _mysql_exceptions.OperationalError: (2005, Unknown MySQL server host 'user = 'root', passwd = '123456', db =

Re: sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]'f2f68'

2012-08-17 Thread Alain Ketterlin
nepaul xs.nep...@gmail.com writes: ===case1==: import sqlalchemy test1 = 631f2f68-8731-4561-889b-88ab1ae7c95a cmdTest1 = select * from analyseresult where uid = + test1 engine =

Re: DOCTYPE + SAX

2011-04-09 Thread Alain Ketterlin
jdownie jdow...@gmail.com writes: I'm trying to get xml.sax to interpret a file that begins with… !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http:// www.w3.org/TR/html4/loose.dtd After a while I get... http://www.w3.org/TR/html4/loose.dtd:31:2: error in processing

Re: 3.1.4 release candidate 1

2011-05-30 Thread Alain Ketterlin
Raymond Hettinger pyt...@rcn.com writes: On May 29, 3:44 pm, Benjamin Peterson benja...@python.org wrote: On behalf of the Python development team, I'm happy as a swallow to announce a release candidate for the fourth bugfix release for the Python 3.1 series, Python 3.1.4. The Pi release

Re: Something is rotten in Denmark...

2011-06-02 Thread Alain Ketterlin
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: The part that I don't see much about in the docs (some books, that is) is that the lambda lookups occur late (the lambda is evaluated at the time it is called). The Python docs on-line *do say* this (I found too late) but its one

Re: Something is rotten in Denmark...

2011-06-03 Thread Alain Ketterlin
Gregory Ewing greg.ew...@canterbury.ac.nz writes: Alain Ketterlin wrote: But going against generally accepted semantics should at least be clearly indicated. Lambda is one of the oldest computing abstraction, and they are at the core of any functional programming language. Yes, and Python's

Re: Standard Deviation One-liner

2011-06-03 Thread Alain Ketterlin
Billy Mays no...@nohow.com writes: I'm trying to shorten a one-liner I have for calculating the standard deviation of a list of numbers. I have something so far, but I was wondering if it could be made any shorter (without imports). a=lambda d:(sum((x-1.*sum(d)/len(d))**2 for x in

Re: Standard Deviation One-liner

2011-06-03 Thread Alain Ketterlin
Alain Ketterlin al...@dpt-info.u-strasbg.fr writes: aux = lambda s1,s2,n: (s2 - s1*s1/n)/(n-1) sv = lambda d: aux(sum(d),sum(x*x for x in d),len(d)) Err, sorry, the final square root is missing. -- Alain. -- http://mail.python.org/mailman/listinfo/python-list

Re: Lambda question

2011-06-05 Thread Alain Ketterlin
jyoun...@kc.rr.com writes: f = lambda x, n, acc=[]: f(x[n:], n, acc+[(x[:n])]) if x else acc f(Hallo Welt, 3) ['Hal', 'lo ', 'Wel', 't'] http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-s ized-chunks-in-python/312644 It doesn't work with a huge list,

Re: International translation of docs - is it a scam?

2011-06-07 Thread Alain Ketterlin
Chris Gonnerman ch...@gonnerman.org writes: On the 30th of May, I received an email from a man (I'll leave out his name, but it was properly male) offering to translate the docs for the gdmodule (which I maintain) into Belorussian. [...] The same has happened on the gcc list, where it has

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Percy Tambunan percy.tambu...@gmail.com writes: Hai, I would like to parse this multiple root element XML object class=EnumDnSched [...] /object object class=EnumDnSched [...] /object Technically speaking, this is not a well-formed XML document (it is a well-formed external general parsed

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Marko Rauhamaa ma...@pacujo.net writes: Alain Ketterlin al...@dpt-info.u-strasbg.fr: Technically speaking, this is not a well-formed XML document (it is a well-formed external general parsed entity, though). If you have other XML processors in your workflow, they will/should reject

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Marko Rauhamaa ma...@pacujo.net writes: Alain Ketterlin al...@dpt-info.u-strasbg.fr: Marko Rauhamaa ma...@pacujo.net writes: Sometimes the XML elements come through a pipe as an endless sequence. You can still use the wrapping technique and a SAX parser. However, the other option

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Marko Rauhamaa ma...@pacujo.net writes: Alain Ketterlin al...@dpt-info.u-strasbg.fr: which does an exact traversal of potential the DOM tree... (assuming a DOM is even defined on a non well-formed XML document). Anyway, my point was only to warn the OP that he is not doing XML. I consider

Re: How can this assert() ever trigger?

2014-05-10 Thread Alain Ketterlin
alb...@spenarnc.xs4all.nl (Albert van der Horst) writes: [...] Now on some matrices the assert triggers, meaning that nom is zero. How can that ever happen? mon start out as 1. and gets multiplied [several times] with a number that is asserted to be not zero. Finite precision. Try:

Re: Fortran (Was: The does Python have variables? debate)

2014-05-11 Thread Alain Ketterlin
Mark H Harris harrismh...@gmail.com writes: On 5/10/14 8:42 AM, Roy Smith wrote: http://tinyurl.com/mr54p96 'Julia' is going to give everyone a not so small run for competition; justifiably so, not just against FORTRAN. Julia is Matlab and R, Python, Lisp, Scheme; all rolled together on

Re: Fortran (Was: The does Python have variables? debate)

2014-05-12 Thread Alain Ketterlin
Mark H Harris harrismh...@gmail.com writes: On 5/11/14 12:05 PM, Alain Ketterlin wrote: Julia is Matlab and R, Python, Lisp, Scheme; all rolled together on steroids. Its amazing as a dynamic language, and its fast, like lightning fast as well as multiprocessing (parallel processing) at its

Re: Fortran

2014-05-13 Thread Alain Ketterlin
Mark H Harris harrismh...@gmail.com writes: On 5/12/14 3:44 AM, Alain Ketterlin wrote: When you are doing scientific computation, this overhead is unacceptable, because you'll have zillions of computations to perform. I'm still trying to sort that out. I have not tested this yet

Re: Fortran

2014-05-14 Thread Alain Ketterlin
Marko Rauhamaa ma...@pacujo.net writes: Alain Ketterlin al...@dpt-info.u-strasbg.fr: The real nice thing that makes Julia a different language is the optional static typing, which the JIT can use to produce efficient code. It's the only meaningful difference with the current state of python

Re: OT: This Swift thing

2014-06-05 Thread Alain Ketterlin
Sturla Molden sturla.mol...@gmail.com writes: Dear Apple, Why should I be exited about an illegitmate child of Python, Go and JavaScript? [...] Type safety. (And with it comes better performance ---read battery life--- and better static analysis tools, etc.) LLVM (an Apple-managed project)

Re: OT: This Swift thing

2014-06-05 Thread Alain Ketterlin
Chris Angelico ros...@gmail.com writes: On Thu, Jun 5, 2014 at 6:14 PM, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: Swift's memory management is similar to python's (ref. counting). Which makes me think that a subset of python with the same type safety would be an instant success

  1   2   3   >