Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Alain Ketterlin
Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> writes: > On Mon, 19 Feb 2018 09:40:09 +0100, Alain Ketterlin wrote: > >> Tim Delaney <timothy.c.dela...@gmail.com> writes: >> >> [...] >>> As others have said, typing is about how the underlying

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Alain Ketterlin
Chris Angelico <ros...@gmail.com> writes: > On Mon, Feb 19, 2018 at 9:04 PM, Alain Ketterlin > <al...@universite-de-strasbourg.fr.invalid> wrote: >> Look at the C11 standard, section 6.3.2.3 ("Pointers"), 6.5.§6-7 >> ("effective types"

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Alain Ketterlin
Chris Angelico <ros...@gmail.com> writes: > On Mon, Feb 19, 2018 at 7:40 PM, Alain Ketterlin > <al...@universite-de-strasbourg.fr.invalid> wrote: >> No. C has much stronger rules, not on casting, but on accessing the >> pointees, which basically invalidates

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Alain Ketterlin
Tim Delaney writes: [...] > As others have said, typing is about how the underlying memory is treated. No. It is much more than that. Typing is about everything you can say about a given statement. Some type systems are focusing on type labels only (like most

Re: "None" and "pass"

2018-02-05 Thread Alain Ketterlin
r...@zedat.fu-berlin.de (Stefan Ram) writes: > A participant of my Python course asked whether one could > also use "None" instead of "pass". What do you think? > > def f(): > pass > > can also be written as > > def f(): > None > > . Is there any place where "None" could not be

Re: Doubt in line_profiler documentation

2018-01-27 Thread Alain Ketterlin
Abhiram R writes: [...] > https://github.com/rkern/line_profiler > > The definition for the time column says - > > "Time: The total amount of time spent executing the line in the timer's > units. In the header information before the tables, you will see a line > 'Timer

Re: CSV file edition

2018-01-09 Thread Alain Ketterlin
Manuel Rincon writes: [...] > Type=0 MarketTime=11:18:26.549 Price=112.8300 > Type=0 MarketTime=11:18:28.792 Price=112.8300 [...] > > I would need to filter only the numeric part of all the columns. I assume that by "numeric" you mean the value after Price=

Re: Tips or strategies to understanding how CPython works under the hood

2018-01-09 Thread Alain Ketterlin
ElChino writes: > Chris Angelico wrote: > >> CPython is a stack-based interpreter, which means it loads values onto >> an (invisible) internal stack, processes values at the top of the >> stack, and removes them when it's done. > > Is this similar to how Lua operates too? No.

Re: integer copy

2017-10-20 Thread Alain Ketterlin
"ast" writes: > "ast" a écrit dans le message de > news:59e9b419$0$3602$426a7...@news.free.fr... > > Neither works for large integers which is > even more disturbing > > a = 6555443 > b = copy.copy(a) > a is b > > True In copy.py: | [...] | def

Typo-squatting PyPi

2017-09-17 Thread Alain Ketterlin
In case you haven't heard about this: https://developers.slashdot.org/story/17/09/16/2030229/pythons-official-repository-included-10-malicious-typo-squatting-modules Here is the Slashdot summary: | The Slovak National Security Office (NBU) has identified ten malicious | Python libraries

Re: Proposed new syntax

2017-08-11 Thread Alain Ketterlin
Ian Kelly writes: > On Thu, Aug 10, 2017 at 8:28 AM, Steve D'Aprano > wrote: >> What would you expect this syntax to return? >> >> [x + 1 for x in (0, 1, 2, 999, 3, 4) while x < 5] > > I would expect the for to be an outer loop and the while

[OT] Re: how to guess the number of cluster when do not know?

2017-08-04 Thread Alain Ketterlin
Ho Yeung Lee writes: > i find kmeans has to input number of cluster [...] https://en.wikipedia.org/wiki/Determining_the_number_of_clusters_in_a_data_set Completely off-topic on this group/list, please direct your questions elsewhere. -- Alain. --

Re: Write this accumuator in a functional style

2017-07-11 Thread Alain Ketterlin
Steven D'Aprano writes: > I have a colleague who is allergic to mutating data structures. Yeah, I > know, he needs to just HTFU but I thought I'd humour him. > > Suppose I have an iterator that yields named tuples: > > Parrot(colour='blue', species='Norwegian',

Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-01 Thread Alain Ketterlin
Marko Rauhamaa writes: > It would be nice to be able to use a / in my file names. Funny enough, > I'm allowed to use a zillion unprintable characters in my file names but > no slashes allowed. > > Example: > >results-Q2/2017.json Use U+2215 (DIVISION SLASH). I have tried

Re: Who are the "spacists"?

2017-03-19 Thread Alain Ketterlin
Jon Ribbens writes: > On 2017-03-18, Grant Edwards wrote: >> On 2017-03-18, Mikhail V wrote: >>> How would one come to the idea to use spaces for indentation at all? >> >> Because tabs are a major security

Re: When will os.remove fail?

2017-03-12 Thread Alain Ketterlin
Steve D'Aprano writes: > On Linux, if I call os.remove on a file which I own but don't have write > permission on, the file is still deleted: > > > py> f = open('/tmp/no-write', 'w') > py> os.path.exists('/tmp/no-write') > True > py> os.chmod('/tmp/no-write', 0) #

Re: The hardest problem in computer science...

2017-01-06 Thread Alain Ketterlin
Steve D'Aprano writes: [...] > Fiction > ├─ Fantasy > │ ├─ Terry Pratchett > │ │ ├─ Discworld > │ │ │ ├─ Wyrd Sisters > │ │ │ └─ Carpe Jugulum > │ │ └─ Dodger > │ └─ JK Rowling [...] > what do we call the vertical and

Re: Why does this list swap fail?

2016-11-14 Thread Alain Ketterlin
38016226...@gmail.com writes: > L=[2,1] > L[0],L[L[0]-1]=L[L[0]-1],L[0] > > The L doesn't change. Can someone provide me the detail procedure of > this expression? From: https://docs.python.org/3/reference/simple_stmts.html#grammar-token-assignment_stmt | Although the definition of assignment

Re: How to pick out the same titles.

2016-10-16 Thread Alain Ketterlin
Seymore4Head writes: [...] > I have a long text file that has movie titles in it and I would like > to find dupes. > > The thing is that sometimes I have one called "The Killing Fields" and > it also could be listed as "Killing Fields" Sometimes the title will >

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread Alain Ketterlin
meInvent bbird writes: > how to refactor nested for loop into smaller for loop assume each of them > independent? > > because memory is not enough > > for ii in range(1,2000): > for jj in range(1,2000): > for kk in range(1,2000): > print run(ii,jj,kk) n = 0 while n

Re: Problem with difflib SequenceMatcher

2016-09-12 Thread Alain Ketterlin
Jay writes: > I am having an odd problem with difflib.SequenceMatcher. Sample code below: > > The strings "src" and "trg" differ only a little. How exactly? (Please be precise, it helps testing.) > The SequenceMatcher.ratio() for these strings 0.0. Many other similar >

Re: Well, I finally ran into a Python Unicode problem, sort of

2016-07-03 Thread Alain Ketterlin
John Ladasky writes: > from math import pi as π > [...] > c = 2 * π * r > Up until today, every character I've tried has been accepted by the > Python interpreter as a legitimate character for inclusion in a > variable name. Now I'm copying a formula which defines a

Re: Assignment Versus Equality

2016-06-27 Thread Alain Ketterlin
Grant Edwards writes: > On 2016-06-26, BartC wrote: > >> (Note, for those who don't know (old) Fortran, that spaces and tabs are >> not significant. So those dots are needed, otherwise "a eq b" would be >> parsed as "aeqb".) > > I've always been

Re: Detecting repeated subsequences of identical items

2016-04-21 Thread Alain Ketterlin
Steven D'Aprano writes: > I want to group repeated items in a sequence. For example, I can group > repeated sequences of a single item at a time using groupby: [...] > Now I want to group subsequences. For example, I have: > > "ABCABCABCDEABCDEFABCABCABCB" > > and I want to

Re: Serious error in int() function?

2016-04-13 Thread Alain Ketterlin
martin.spic...@gmail.com writes: > print int(float(2.8/0.1)) > > yields > > 27 > > instead of 28!! That's how floating-point arithmetic works: look at the result of 2.8/0.1 to see why int() is correct. > Is that known? Yes, it is known, and correct since you use "float". See

Re: A new module for performing tail-call elimination

2015-07-16 Thread Alain Ketterlin
Antoon Pardon antoon.par...@rece.vub.ac.be writes: On 07/13/2015 05:44 PM, Th. Baruchel wrote: Hi, after having spent much time thinking about tail-call elimination in Python (see for instance http://baruchel.github.io/blog/ ), I finally decided to write a module for that. You may find it at:

Re: Can Python function return multiple data?

2015-06-05 Thread Alain Ketterlin
Steven D'Aprano st...@pearwood.info writes: On Fri, 5 Jun 2015 04:17 am, Alain Ketterlin wrote: Steven D'Aprano st...@pearwood.info writes: [...] But you still find a few people here and there who have been exposed to Java foolishness, and will argue that Python is pass by value, where

Re: Can Python function return multiple data?

2015-06-05 Thread Alain Ketterlin
Grant Edwards invalid@invalid.invalid writes: [...] Or to be a bit obtuse: Python parameters are passed by value, but all values are references. Exactly, that's a perfect description. There's is no need for a new name. As a corollary, all names (including variables and object attributes) are

Re: Can Python function return multiple data?

2015-06-05 Thread Alain Ketterlin
Marko Rauhamaa ma...@pacujo.net writes: Alain Ketterlin al...@universite-de-strasbourg.fr.invalid: Grant Edwards invalid@invalid.invalid writes: [...] Or to be a bit obtuse: Python parameters are passed by value, but all values are references. Exactly, that's a perfect description

Re: Can Python function return multiple data?

2015-06-04 Thread Alain Ketterlin
Steven D'Aprano st...@pearwood.info writes: [...] But you still find a few people here and there who have been exposed to Java foolishness, and will argue that Python is pass by value, where the value is an implementation dependent reference to the thing that you thought was the value. I

Re: fork/exec close file descriptors

2015-06-03 Thread Alain Ketterlin
Chris Angelico ros...@gmail.com writes: On Wed, Jun 3, 2015 at 7:06 AM, Alain Ketterlin al...@universite-de-strasbourg.fr.invalid wrote: I've no idea what the OP's program was doing, so I'm not going to split hairs. I can't imagine why one would like to mass-close an arbitrary set of file

Re: fork/exec close file descriptors

2015-06-03 Thread Alain Ketterlin
Marko Rauhamaa ma...@pacujo.net writes: Alain Ketterlin al...@universite-de-strasbourg.fr.invalid: Marko Rauhamaa ma...@pacujo.net writes: First, if close() fails, what's a poor program to do? Warn the user? Not assume everything went well? It all depends on the application, and what

Re: fork/exec close file descriptors

2015-06-03 Thread Alain Ketterlin
random...@fastmail.us writes: On Wed, Jun 3, 2015, at 03:11, Alain Ketterlin wrote: Thank you, I know this. What I mean is: what are the reasons that you cannot access your file descriptors one by one? To me closing a range of descriptors has absolutely no meaning, simply because ranges have

Re: fork/exec close file descriptors

2015-06-02 Thread Alain Ketterlin
Marko Rauhamaa ma...@pacujo.net writes: Alain Ketterlin al...@universite-de-strasbourg.fr.invalid: The close(2) manpage has the following warning on my Linux system: | Not checking the return value of close() is a common but | nevertheless serious programming error. It is quite possible

Re: fork/exec close file descriptors

2015-06-02 Thread Alain Ketterlin
Skip Montanaro skip.montan...@gmail.com writes: Reviving (and concluding) a thread I started a couple weeks ago, I asked: The basic fork/exec dance is not a problem, but how do I discover all the open file descriptors in the new child process to make sure they get closed? Do I simply start

Re: Using Python instead of Bash

2015-05-31 Thread Alain Ketterlin
Cecil Westerhof ce...@decebal.nl writes: I help someone that has problems reading. For this I take photo's of text, use convert from ImageMagick to make a good contrast (original paper is grey) and use lpr to print it a little bigger. import glob import subprocess treshold =

Re: subprocess.Popen zombie

2015-05-20 Thread Alain Ketterlin
Robin Becker ro...@reportlab.com writes: As part of a long running PyQT process running as a window app in Arch linux I needed an alert sound, I decided to use the beep command and the app code then looked like pid = Popen(['/home/robin/bin/mybeep', '-r3', '-f750', '-l100', '-d75']).pid

Re: Throw the cat among the pigeons

2015-05-07 Thread Alain Ketterlin
Dave Angel da...@davea.name writes: On 05/06/2015 11:36 AM, Alain Ketterlin wrote: Yes, plus the time for memory allocation. Since the code uses r *= ..., space is reallocated when the result doesn't fit. The new size is probably proportional to the current (insufficient) size. This means

Re: Throw the cat among the pigeons

2015-05-06 Thread Alain Ketterlin
Paul Rubin no.email@nospam.invalid writes: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: Multiplying upwards seems to be more expensive than multiplying downwards... I can only guess that it has something to do with the way multiplication is implemented, or perhaps the memory

Re: Am I missing something here? ipaddress vs socket

2015-05-01 Thread Alain Ketterlin
the.lo...@gmail.com writes: Given the following code: import ipaddress import socket ip = ipaddress.ip_address(mystring) sock_family = ip. socket = socket.socket(sock_family, socket.SOCK_STREAM) Am I crazy or is this undoable? sock.AF_INET == 2 sock.AF_INET6 == 10 ip.version ==

Re: Best search algorithm to find condition within a range

2015-04-09 Thread Alain Ketterlin
Marko Rauhamaa ma...@pacujo.net writes: Dave Angel da...@davea.name: So the C standard can specify such things as undefined. The architecture still will do something specific, right or wrong, and that's what Marko's claim was about. The C compiler has separate types for unsigned and for

Re: Best search algorithm to find condition within a range

2015-04-09 Thread Alain Ketterlin
Marko Rauhamaa ma...@pacujo.net writes: Alain Ketterlin al...@dpt-info.u-strasbg.fr: No, it would not work for signed integers (i.e., with lo and hi of int64_t type), because overflow is undefined behavior for signed. All architectures I've ever had dealings with have used 2's-complement

Re: Best search algorithm to find condition within a range

2015-04-09 Thread Alain Ketterlin
Marko Rauhamaa ma...@pacujo.net writes: The basic arithmetic algorithms are independent of the base. Right. For example, here's how you can add two 128-bit integers in C using 64-bit digits: typedef struct { uint64_t lo, hi; } uint128_t; uint128_t add128(uint128_t

Re: Best search algorithm to find condition within a range

2015-04-09 Thread Alain Ketterlin
Chris Angelico ros...@gmail.com writes: On Thu, Apr 9, 2015 at 11:57 PM, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: Because, in: z = x+y; // all signed ints if ( z x ) ... either there was no overflow (and the condition is false), or there was, and the result

Re: Socket ICMP V6 error

2015-01-22 Thread Alain Ketterlin
ermanolillo ermanoli...@hotmail.com writes: HOST is send by the keyboard. It´s the IPv6 address of my interface eth0. For example, FE80::0202:B3FF:FE1E:8329. This is a link-local address, you can't use it just like that (you may have several interfaces with the same link-local addr). Use

Re: OTish: using short-term TCP connections to send to multiple slaves

2014-11-16 Thread Alain Ketterlin
jkn jkn...@nicorp.f9.co.uk writes: I have a use case of a single 'master' machine which will need to periodically 'push' data to a variety of 'slave' devices on a small local subnet, over Ethernet. We are talking perhaps a dozen devices in all with comms occurring perhaps once very few

Re: Send UDP packet to link-local IPv6 address?

2014-10-29 Thread Alain Ketterlin
Grant Edwards invalid@invalid.invalid writes: [...] With link-local addresses you also need to specify which interface to use. The normal way of doing this on Linux with command-line utilities is append %ifname to the address/hostname (e.g. ping6 ff02::1%net1). That doesn't work:

Re: (test) ? a:b

2014-10-23 Thread Alain Ketterlin
Marko Rauhamaa ma...@pacujo.net writes: BartC b...@freeuk.com: x = [f, g][cond]() It will select f or g (which should refer to functions), and call one of those depending on cond. That's not a problem. The problem is it will still evaluate both f and g, That's not really the problem.

Re: Truthiness

2014-10-23 Thread Alain Ketterlin
Simon Kennedy sffjun...@gmail.com writes: Just out of academic interest, is there somewhere in the Python docs where the following is explained? 3 == True False if 3: print(It's Twue) It's Twue i.e. in the if statement 3 is True but not in the first

Re: your mail

2014-10-18 Thread Alain Ketterlin
Terry Reedy tjre...@udel.edu writes: On 10/17/2014 6:43 AM, Cameron Simpson wrote: On 17Oct2014 11:45, Dhananjay dhananjay.c.jo...@gmail.com wrote: 2.1576318858 -1.8651195165 4.2333428278 ... (total of 200 lines) Columns 1,2,3 corresponds to x,y,z axis data points. for line in

Re: OT: This Swift thing

2014-06-07 Thread Alain Ketterlin
Sturla Molden sturla.mol...@gmail.com writes: Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: Sturla Molden sturla.mol...@gmail.com writes: Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: Many of these students suggest Python as the development language (they learned it and liked

Re: OT: This Swift thing

2014-06-07 Thread Alain Ketterlin
Mark Lawrence breamore...@yahoo.co.uk writes: On 07/06/2014 09:20, Alain Ketterlin wrote: Sturla Molden sturla.mol...@gmail.com writes: Many of these students suggest Python as the development language (they learned it and liked it), and the suggestion is (almost) always rejected, in favor

Re: OT: This Swift thing

2014-06-06 Thread Alain Ketterlin
Travis Griggs travisgri...@gmail.com writes: On Jun 5, 2014, at 1:14, 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

Re: OT: This Swift thing

2014-06-06 Thread Alain Ketterlin
Terry Reedy tjre...@udel.edu writes: On 6/5/2014 4:07 PM, Alain Ketterlin wrote: When I compile Cython modules I use LLVM on this computer. Cython is not Python, it is another language, with an incompatible syntax. Cython compiles Python with optional extensions that allow additional

Re: OT: This Swift thing

2014-06-06 Thread Alain Ketterlin
Sturla Molden sturla.mol...@gmail.com writes: Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: Many of these students suggest Python as the development language (they learned it and liked it), and the suggestion is (almost) always rejected, in favor of Java or C# or C/C

Re: OT: This Swift thing

2014-06-06 Thread Alain Ketterlin
Chris Angelico ros...@gmail.com writes: On Fri, Jun 6, 2014 at 7:23 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 05/06/2014 21:07, Alain Ketterlin wrote: Sturla Molden sturla.mol...@gmail.com writes: On 05/06/14 10:14, Alain Ketterlin wrote: Type safety. Perhaps. Python has

Re: OT: This Swift thing

2014-06-06 Thread Alain Ketterlin
Sturla Molden sturla.mol...@gmail.com writes: On 05/06/14 22:27, Alain Ketterlin wrote: I have seen dozens of projects where Python was dismissed because of the lack of static typing, and the lack of static analysis tools. [...] When is static analysis actually needed and for what purpose

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

Re: OT: This Swift thing

2014-06-05 Thread Alain Ketterlin
Sturla Molden sturla.mol...@gmail.com writes: On 05/06/14 10:14, Alain Ketterlin wrote: Type safety. Perhaps. Python has strong type safety. Come on. [...] (And with it comes better performance ---read battery life--- and better static analysis tools, etc.) Perhaps, perhaps not. My

Re: OT: This Swift thing

2014-06-05 Thread Alain Ketterlin
Chris Angelico ros...@gmail.com writes: On Thu, Jun 5, 2014 at 7:42 PM, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: 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

Re: OT: This Swift thing

2014-06-05 Thread Alain Ketterlin
Chris Angelico ros...@gmail.com writes: On Fri, Jun 6, 2014 at 6:07 AM, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: Perhaps, perhaps not. My experience is that only a small percentage of the CPU time is spent in the Python interpreter. Basically, you're saying that a major fraction

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: 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 (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 (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: 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: 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: 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: 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: 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: 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: 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: 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: 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-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-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: 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: 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: Best Scripting Language for Embedded Work?

2013-07-10 Thread Alain Ketterlin
David T. Ashley dash...@gmail.com writes: We develop embedded software for 32-bit micros using Windows as the development platform. I'll mostly ignore the Windows qualifier. If you're stuck with Windows CE or similar, then ask them what they suggest. If you're developing on Windows and deploy

Re: Apache and suexec issue that wont let me run my python script

2013-06-01 Thread Alain Ketterlin
Νικόλαος Κούρας nikos.gr...@gmail.com writes: [...] [Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] suexec failure: could not open log file Here is a link to suexec documentation (at least some version of it, this is the second link provided by google):

Re: subprocess question re waiting

2013-04-08 Thread Alain Ketterlin
loial jldunn2...@gmail.com writes: I want to call a child process to run a shell script and wait for that script to finish. Will the code below wait for the script to finish? If not then how do I make it wait? [...] process = subprocess.Popen(command,

Re: Doing both regex match and assignment within a If loop?

2013-03-29 Thread Alain Ketterlin
Victor Hooi victorh...@gmail.com writes: expression1 = re.compile(r'') expression2 = re.compile(r'') [...] Just a quick remark: regular expressions are pretty powerful at representing alternatives. You could just stick everything inside a single re, as in '...|...' Then use

Re: Monitoring updating directory for image for GUI

2013-02-07 Thread Alain Ketterlin
ciscorucin...@gmail.com writes: Basically I am creating a program that will stream musical notes into a program called Lilypond one-by-one and it will create the sheet music for that stream of music via OS command. Your understanding of Lilypond is not needed, but you need to know that for

Re: Random and fork

2013-02-06 Thread Alain Ketterlin
Julien Le Goff julien.leg...@gmail.com writes: Today I came accross a behaviour I did not expect in python (I am using 2.7). In my program, random.random() always seemed to return the same number; it turned out to be related to the fact that I was using os.fork. The random number generator

Vigil, the eternal morally vigilant programming language

2013-01-07 Thread Alain Ketterlin
I just came across Vigil, an extension to python for serious software engineers, at https://github.com/munificent/vigil and thought everybody in this group would be interested (sorry if it has been announced before). From README: | Vigil is a very safe programming language, and an entry in the

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

  1   2   3   >