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

2012-06-30 Thread Alain Ketterlin
Thomas Jollans 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: "Form

Re: code review

2012-06-30 Thread Alain Ketterlin
Thomas Jollans 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

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

2012-07-23 Thread Alain Ketterlin
Henrik Faber 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 thi

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

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

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 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", and can be l

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 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', d

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

2012-08-17 Thread Alain Ketterlin
nepaul writes: > ===case1==: > import sqlalchemy > test1 = "631f2f68-8731-4561-889b-88ab1ae7c95a" > cmdTest1 = "select * from analyseresult where uid = " + test1 > engine = > sqlalchemy.create_engine("mssql+pyodbc://DumpResult:123456@localhost/Dum

Re: Comparing strings from the back?

2012-09-04 Thread Alain Ketterlin
Roy Smith 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 length), and you

Re: which a is used?

2012-09-25 Thread Alain Ketterlin
Jayden 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 variable.

Re: parse an environment file

2012-10-01 Thread Alain Ketterlin
Jason Friedman 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. -- http://mail.python.org/mailman/listinfo/python-list

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

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

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: Formate a number with commas

2012-02-09 Thread Alain Ketterlin
noydb writes: > How do you format a number to print with commas? import locale locale.setlocale(locale.LC_ALL, "") This sets the locale according to the environment (typically LANG---I'm talking about linux, don't know others). locale.format('%d', 2348721, True) > '2,348,721' T

Re: subtraction of floating point numbers

2012-02-24 Thread Alain Ketterlin
Jaroslav Dobrek writes: > when I have Python subtract floating point numbers it yields weird > results. Example: > > 4822.40 - 4785.52 = 36.87992 We've had this discussion here one or two days ago... The usual answer is: please read "What Every Computer Scientist Should Know About Float

Re: Is it technically possible to give Python option of naming process of running script?

2012-03-14 Thread Alain Ketterlin
Terry Reedy writes: > On 3/14/2012 12:02 PM, Grant Edwards wrote: > >> It seems like an excellent thing to add to the "os" module. > > If 'prctl' is a standard POSIX system call, then it should be a > candidate for inclusion in the os module if someone opens a tracker > enhancement issue and pres

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

2012-04-03 Thread Alain Ketterlin
python 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) > ... if(g23tag.get(key))

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

2012-04-03 Thread Alain Ketterlin
nn 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: >>     g23tag.setdefault(item[0],[]).

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

2012-04-04 Thread Alain Ketterlin
Steven D'Aprano 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 doesn't copy the FIL

Re: Python Gotcha's?

2012-04-05 Thread Alain Ketterlin
Miki Tebeka 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 r(self): return x

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

2012-04-09 Thread Alain Ketterlin
Janis 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 -15? Exit status is

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

2012-04-16 Thread Alain Ketterlin
Jaroslav Dobrek 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 finished after 5

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

2012-04-20 Thread Alain Ketterlin
dmitrey 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

Re: tiny script has memory leak

2012-05-17 Thread Alain Ketterlin
gry 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 crumble. > > #!/usr/bin/

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 comparis

Re: ./configure

2012-06-03 Thread Alain Ketterlin
Janet Heath 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 > configure:3375: checking for cc >

Re: Help needed with nested parsing of file into objects

2012-06-04 Thread Alain Ketterlin
richard 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 > List of 2 A

Re: Help needed with nested parsing of file into objects

2012-06-05 Thread Alain Ketterlin
richard 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 far. Any help will be

Re: Help needed with nested parsing of file into objects

2012-06-05 Thread Alain Ketterlin
richard 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 >> >  

Re: Compare 2 times

2012-06-06 Thread Alain Ketterlin
Alain Ketterlin writes: > loial 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.get

Re: [newbie] Equivalent to PHP?

2012-06-12 Thread Alain Ketterlin
Gilles 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 server (short runni

Re: Something is rotten in Denmark...

2011-06-02 Thread Alain Ketterlin
Steven D'Aprano 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 quick phrase that can be missed

Re: Something is rotten in Denmark...

2011-06-03 Thread Alain Ketterlin
Gregory Ewing 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,

Re: Standard Deviation One-liner

2011-06-03 Thread Alain Ketterlin
Billy Mays 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 d)/(1.*(len(d)-1)))**

Re: Standard Deviation One-liner

2011-06-03 Thread Alain Ketterlin
Alain Ketterlin 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
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, but l

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

2011-06-07 Thread Alain Ketterlin
Chris Gonnerman 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 been considered a sc

Re: where the function has problem? n = 900 is OK , but n = 1000 is ERROR

2011-08-02 Thread Alain Ketterlin
Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9...@myhashismyemail.com> writes: > On 08/01/2011 06:06 PM, Steven D'Aprano wrote: >> Does your definition of "fixed" mean "gives wrong results for n>= 4 "? > Well, I don't know if you're trolling or just dumb: Steven is right, and you look dumb.

Re: Early binding as an option

2011-08-02 Thread Alain Ketterlin
Chris Angelico writes: > As I understand it, Python exclusively late-binds names; when you > define a function, nothing is ever pre-bound. This allows a huge > amount of flexibility (letting you "reach into" someone else's > function and change its behaviour), but it's flexibility that most > pro

Re: Early binding as an option

2011-08-03 Thread Alain Ketterlin
Chris Angelico writes: [...] > The only actual data I have on the subject is the perfect-numbers > search the other day; Pike managed the same task in a fraction of the > time that Python spent on it. Pike has a single integer type that > quietly switches from small to large at 2**32, with a noti

Re: Java is killing me! (AKA: Java for Pythonheads?)

2011-08-12 Thread Alain Ketterlin
kj writes: [...] >def quant(xs, nlevels=MAXN, xlim=MAXX): [...] > My Java implementation of it already requires at least 8 method > definitions, with signatures: (BTW, your approach won't work if several optionals have the same type.) [...] - use Integer, Float, etc. everywhere. The compile

Re: testing if a list contains a sublist

2011-08-16 Thread Alain Ketterlin
Roy Smith writes: >> what is the best way to check if a given list (lets call it l1) is >> totally contained in a second list (l2)? [...] > import re > > def sublist(l1, l2): > s1 = ''.join(map(str, l1)) > s2 = ''.join(map(str, l2)) > return re.search(s1, s2) This is complete nonsen

Re: testing if a list contains a sublist

2011-08-16 Thread Alain Ketterlin
Laszlo Nagy writes: > def sublist(lst1, lst2): >> s1 = ','.join(map(str, lst1)) >> s2 = ','.join(map(str, lst2)) >> return False if s2.find(s1)==-1 else True >> >> I don't know about best, but it works for the examples given. >> > For numbers, it will always work. I'm not even

Re: pairwise combination of two lists

2011-08-18 Thread Alain Ketterlin
Yingjie Lin writes: > I have two lists: > > li1 = ['a', 'b'] > li2 = ['1', '2'] > > and I wish to obtain a list like this > > li3 = ['a1', 'a2', 'b1', 'b2'] > > Is there a handy and efficient function to do this, especially when > li1 and li2 are long lists. It's not difficult to write your own

Re: List spam

2011-08-18 Thread Alain Ketterlin
"Jason Staudenmayer" writes: > I really like this list as part of my learning tools but the amount of > spam that I've been getting from it is CRAZY. Doesn't anything get > scanned before it sent to the list? I'm using nntp to read this newsgroup (through an academic server). No spam at all. --

Re: List spam

2011-08-18 Thread Alain Ketterlin
Ghodmode writes: [...] > Make an effort to curb the spam even if it means killing the newsgroup > availability. Choose mailman or Google Groups, or another single > solution. Make it members only, but allow anyone to register with an > automated confirmation email and a CAPTCHA. Appoint a list

Re: List spam

2011-08-18 Thread Alain Ketterlin
gene heskett writes: >> Or save work and find a public nntp server (or setup one, or ask your >> provider), and use a news reader to follow the list (even thunderbird >> can do this). No spam, no need to store messages on your machine, >> auto-purge after a configurable delay, etc. > That is ask

Re: Help with regular expression in python

2011-08-19 Thread Alain Ketterlin
Matt Funk writes: > thanks for the suggestion. I guess i had found another way around the > problem as well. But i really wanted to match the line exactly and i > wanted to know why it doesn't work. That is less for the purpose of > getting the thing to work but more because it greatly annoys me

Re: Why doesn't threading.join() return a value?

2011-09-02 Thread Alain Ketterlin
Adam Skutt writes: > On Sep 2, 10:53 am, Roy Smith wrote: >> I have a function I want to run in a thread and return a value.  It >> seems like the most obvious way to do this is to have my target >> function return the value, the Thread object stash that someplace, and >> return it as the return

Re: Why doesn't threading.join() return a value?

2011-09-03 Thread Alain Ketterlin
Adam Skutt writes: > On Sep 2, 2:23 pm, Alain Ketterlin > wrote: >> Sorry, you're wrong, at least for POSIX threads: >> >> void pthread_exit(void *value_ptr); >> int pthread_join(pthread_t thread, void **value_ptr); >> >> pthread_exit can pass

Re: Why doesn't threading.join() return a value?

2011-09-03 Thread Alain Ketterlin
Alain Ketterlin writes: >> Passing a void* is not equivalent to passing anything, not even in C. >> Moreover, specific values are still reserved, like PTHREAD_CANCELLED. > > Thread cancellation is program logic (pthread_cancel), it doesn't mean > you thread crashed, it

Re: Can't use subprocess.Popen() after os.chroot() - why?

2011-09-04 Thread Alain Ketterlin
Erik writes: > import os > from subprocess import Popen, PIPE > > os.chroot("/tmp/my_chroot") > p = Popen("/bin/date", stdin=PIPE, stdout=PIPE, stderr=PIPE) > stdout_val, stderr_val = p.communicate() > print stdout_val > > but the Popen call is dying with the following exception: > > Traceback (m

Re: Parsing numeric ranges

2011-02-25 Thread Alain Ketterlin
Seldon 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 for doing such

Re: Get Path of current Script

2011-03-14 Thread Alain Ketterlin
Alexander Schatten 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 containing the script t

Re: DOCTYPE + SAX

2011-04-09 Thread Alain Ketterlin
jdownie writes: > I'm trying to get xml.sax to interpret a file that begins with… > > 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 > external entity reference > > …although… > > time curl http://www.w3.org/TR/html4/

Re: 3.1.4 release candidate 1

2011-05-30 Thread Alain Ketterlin
Raymond Hettinger writes: > On May 29, 3:44 pm, Benjamin Peterson 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 of Python :-) And 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: 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

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

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

  1   2   3   >