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

2018-02-19 Thread Alain Ketterlin
Steven D'Aprano writes: > On Mon, 19 Feb 2018 09:40:09 +0100, Alain Ketterlin wrote: > >> Tim Delaney writes: >> >> [...] >>> As others have said, typing is about how the underlying memory is >>> treated. >> >> No. It is much more t

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

2018-02-19 Thread Alain Ketterlin
Chris Angelico writes: > On Mon, Feb 19, 2018 at 9:04 PM, Alain Ketterlin > wrote: >> Look at the C11 standard, section 6.3.2.3 ("Pointers"), 6.5.§6-7 >> ("effective types"), and 6.5.3.2 ("Address and indirection operators"). >> It i

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

2018-02-19 Thread Alain Ketterlin
Chris Angelico writes: > On Mon, Feb 19, 2018 at 7:40 PM, Alain Ketterlin > wrote: >> No. C has much stronger rules, not on casting, but on accessing the >> pointees, which basically invalidates your argument. Refer to the C >> standard for details. > > Really

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 statically typed programming languag

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 use

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 unit:' giving the conversio

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= line.split()[2].split('=')[1] lin

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. Lua uses a register

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 _copy_immutable(x): | return x | for t in (t

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 uploade

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 to be an > inner, so this would loop infinitely. +1.

[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. -- https://mail.python.org/mailman/listinfo/pytho

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', status='tired and shagged out') >

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 this once. "Next ti

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 vulnerability and should be outlawed >> in all source code. > > You forgot to mention tha

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) # Forbid ALL access. > py> os.rem

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 horizontal line elements? Box-draw

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 i

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 > have the date a year off. > > Wh

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

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 > strings are working fine

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 gradient. The > nabla symbol

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 baffled by that. > Were there other languages th

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 group it into repeatin

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 http://floating-poi

Re: A new module for performing tail-call elimination

2015-07-16 Thread Alain Ketterlin
Antoon Pardon 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: >> >> https://githu

Re: Can Python function return multiple data?

2015-06-05 Thread Alain Ketterlin
Marko Rauhamaa writes: > Alain Ketterlin : > >> Grant Edwards writes: >> >> [...] >>> Or to be a bit obtuse: Python parameters are passed by value, but all >>> values are references. >> >> Exactly, that's a perfect description. Ther

Re: Can Python function return multiple data?

2015-06-05 Thread Alain Ketterlin
Grant Edwards 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 references. -- Alain

Re: Can Python function return multiple data?

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

Re: Can Python function return multiple data?

2015-06-04 Thread Alain Ketterlin
Steven D'Aprano 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 find this clear a

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 me

Re: fork/exec & close file descriptors

2015-06-03 Thread Alain Ketterlin
Marko Rauhamaa writes: > Alain Ketterlin : > >> Marko Rauhamaa 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 the file descripto

Re: fork/exec & close file descriptors

2015-06-03 Thread Alain Ketterlin
Chris Angelico writes: > On Wed, Jun 3, 2015 at 7:06 AM, Alain Ketterlin > 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 desc

Re: fork/exec & close file descriptors

2015-06-02 Thread Alain Ketterlin
Marko Rauhamaa writes: > Alain Ketterlin : > >> 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 that >> | err

Re: fork/exec & close file descriptors

2015-06-02 Thread Alain Ketterlin
Skip Montanaro 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 at fd 3 and call o

Re: Using Python instead of Bash

2015-05-31 Thread Alain Ketterlin
Cecil Westerhof 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 = 66 > co

Re: subprocess.Popen zombie

2015-05-20 Thread Alain Ketterlin
Robin Becker 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 > > the mybeep scri

Re: Throw the cat among the pigeons

2015-05-07 Thread Alain Ketterlin
Dave Angel 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 (in

Re: Throw the cat among the pigeons

2015-05-06 Thread Alain Ketterlin
Paul Rubin writes: > Steven D'Aprano 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 management >> involved, or something. Who the hell kno

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

Re: Best search algorithm to find condition within a range

2015-04-09 Thread Alain Ketterlin
Chris Angelico writes: > On Thu, Apr 9, 2015 at 11:57 PM, Alain Ketterlin > wrote: >> Because, in: >> >> z = x+y; // all signed ints >> if ( z < x ) >> ... >> >> either there was no overflow (and the condition is false), or

Re: Best search algorithm to find condition within a range

2015-04-09 Thread Alain Ketterlin
Marko Rauhamaa writes: > Dave Angel : > >> 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 signed, while the underlyi

Re: Best search algorithm to find condition within a range

2015-04-09 Thread Alain Ketterlin
Marko Rauhamaa writes: > Alain Ketterlin : > >> 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 &g

Re: Best search algorithm to find condition within a range

2015-04-09 Thread Alain Ketterlin
Marko Rauhamaa 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 x, uint12

Re: Socket ICMP V6 error

2015-01-22 Thread Alain Ketterlin
ermanolillo 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 getaddrinfo on "FE80...%et

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

2014-11-16 Thread Alain Ketterlin
jkn 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 seconds, to much less

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

2014-10-29 Thread Alain Ketterlin
Grant Edwards 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 % to the address/hostname (e.g. ping6 ff02::1%net1). > > That doesn't work: > > s.sendto(data, ("ff02::1%net1",p

Re: Truthiness

2014-10-23 Thread Alain Ketterlin
Simon Kennedy 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 https://docs.python.or

Re: (test) ? a:b

2014-10-23 Thread Alain Ketterlin
Marko Rauhamaa writes: > "BartC" : >>> 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. The problem is in

Re: your mail

2014-10-18 Thread Alain Ketterlin
Terry Reedy writes: > On 10/17/2014 6:43 AM, Cameron Simpson wrote: >> On 17Oct2014 11:45, Dhananjay 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 open('flooding-psiphi.dat','

Re: OT: This Swift thing

2014-06-07 Thread Alain Ketterlin
Mark Lawrence writes: > On 07/06/2014 09:20, Alain Ketterlin wrote: >> Sturla Molden writes: >>>>>> Many of these students suggest Python as the >>>>>> development language (they learned it and liked it), and the suggestion >>>>>

Re: OT: This Swift thing

2014-06-07 Thread Alain Ketterlin
Sturla Molden writes: > Alain Ketterlin wrote: >> Sturla Molden writes: >> >>> Alain Ketterlin wrote: >>> >>>> Many of these students suggest Python as the >>>> development language (they learned it and liked it), and the suggestio

Re: OT: This Swift thing

2014-06-06 Thread Alain Ketterlin
Sturla Molden 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-06 Thread Alain Ketterlin
Chris Angelico writes: > On Fri, Jun 6, 2014 at 7:23 AM, Mark Lawrence wrote: >> On 05/06/2014 21:07, Alain Ketterlin wrote: >>> >>> Sturla Molden writes: >>> >>>> On 05/06/14 10:14, Alain Ketterlin wrote: >>>> >>>>>

Re: OT: This Swift thing

2014-06-06 Thread Alain Ketterlin
Sturla Molden writes: > Alain Ketterlin 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++. > > And it was almost a

Re: OT: This Swift thing

2014-06-06 Thread Alain Ketterlin
Terry Reedy 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 e

Re: OT: This Swift thing

2014-06-06 Thread Alain Ketterlin
Travis Griggs writes: >> On Jun 5, 2014, at 1:14, Alain Ketterlin 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
Chris Angelico writes: > On Fri, Jun 6, 2014 at 6:07 AM, Alain Ketterlin > 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

Re: OT: This Swift thing

2014-06-05 Thread Alain Ketterlin
Chris Angelico writes: > On Thu, Jun 5, 2014 at 7:42 PM, Alain Ketterlin > wrote: >> Chris Angelico writes: >> >>> On Thu, Jun 5, 2014 at 6:14 PM, Alain Ketterlin >>> wrote: >>>> Swift's memory management is similar to python's (

Re: OT: This Swift thing

2014-06-05 Thread Alain Ketterlin
Sturla Molden 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.) > > Pe

Re: OT: This Swift thing

2014-06-05 Thread Alain Ketterlin
Chris Angelico writes: > On Thu, Jun 5, 2014 at 6:14 PM, Alain Ketterlin > 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 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) for the middle- and b

Re: Fortran

2014-05-14 Thread Alain Ketterlin
Marko Rauhamaa writes: > Alain Ketterlin : > >> 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 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 teste

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

2014-05-12 Thread Alain Ketterlin
Mark H Harris 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 (parall

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

2014-05-11 Thread Alain Ketterlin
Mark H Harris 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 > steroids. It

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: 1.*1e-

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Marko Rauhamaa writes: > Alain Ketterlin : > >> 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 c

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Marko Rauhamaa writes: > Alain Ketterlin : > >> Marko Rauhamaa 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 is to write a t

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Marko Rauhamaa writes: > Alain Ketterlin : > >> 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 it. > > S

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Percy Tambunan writes: > Hai, I would like to parse this multiple root element XML > > [...] > > [...] > 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/sh

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('>'):

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 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 = [somefunc(mn,

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

2013-12-03 Thread Alain Ketterlin
Ben Finney writes: > Chris Angelico writes: > >> On Mon, Dec 2, 2013 at 10:34 PM, iMath 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) -c copy output.wav >> > ffmpeg -f concat -i <(

Re: Basic Python Questions - Oct. 31, 2013

2013-10-31 Thread Alain Ketterlin
Mark Lawrence writes: > On 31/10/2013 13:17, Alain Ketterlin wrote: >> "E.D.G." writes: >> >>>The calculation speed question just involves relatively simple >>> math such as multiplications and divisions and trig calculations such >>

Re: Basic Python Questions - Oct. 31, 2013

2013-10-31 Thread Alain Ketterlin
Chris Angelico writes: > On Fri, Nov 1, 2013 at 12:17 AM, Alain Ketterlin > wrote: >> "E.D.G." writes: >> >>> The calculation speed question just involves relatively simple >>> math such as multiplications and divisions and trig calculation

Re: Basic Python Questions - Oct. 31, 2013

2013-10-31 Thread Alain Ketterlin
"E.D.G." 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 probably go much fas

Re: Tail recursion to while iteration in 2 easy steps

2013-10-08 Thread Alain Ketterlin
Antoon Pardon 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. >

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 trad

Re: Tail recursion to while iteration in 2 easy steps

2013-10-07 Thread Alain Ketterlin
Terry Reedy 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, an

Re: Tail recursion to while iteration in 2 easy steps

2013-10-04 Thread Alain Ketterlin
Mark Janssen 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 bad

Re: Tail recursion to while iteration in 2 easy steps

2013-10-02 Thread Alain Ketterlin
rusi 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. Here it is. > >

Re: Tail recursion to while iteration in 2 easy steps

2013-10-02 Thread Alain Ketterlin
Terry Reedy 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 body recursive

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 defau

Re: Critic my module

2013-07-25 Thread Alain Ketterlin
Devyn Collier Johnson 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 like this Good, but

Re: Best Scripting Language for Embedded Work?

2013-07-09 Thread Alain Ketterlin
David T. Ashley 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 on something e

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

2013-06-01 Thread Alain Ketterlin
Νικόλαος Κούρας 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): http://httpd.apache.org/docs/2.2/suexec.html Rea

Re: subprocess question re waiting

2013-04-08 Thread Alain Ketterlin
loial 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, > stdin=subprocess.PIPE,stdout=subprocess.PIPE, stderr=su

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

2013-03-29 Thread Alain Ketterlin
Victor Hooi 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 the returned match to

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 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 is initialized once,

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 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 option. Another is the u

Re: Split single file into multiple files based on patterns

2012-10-23 Thread Alain Ketterlin
satyam 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 files like > A19

Re: Python does not take up available physical memory

2012-10-19 Thread Alain Ketterlin
Thomas Rachel 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 to 1.5GB (of the 2.23 GB originally showed as available) - >>

Re: ElementTree Issue - Search and remove elements

2012-10-16 Thread Alain Ketterlin
Tharanga Abeyseela 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-) child, and then test explici

Re: pyw program not displaying unicode characters properly

2012-10-14 Thread Alain Ketterlin
Steven D'Aprano 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 whate

Re: pyw program not displaying unicode characters properly

2012-10-14 Thread Alain Ketterlin
jjmeric 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. > In the att

Re: Combinations of lists

2012-10-03 Thread Alain Ketterlin
Steen Lysgaard 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 after result us

  1   2   3   >