Re: python backup script

2013-05-06 Thread MRAB
On 06/05/2013 23:12, m...@socialassets.org wrote: On Monday, May 6, 2013 5:48:44 PM UTC-4, Enrico 'Henryx' Bianchi wrote: Enrico 'Henryx' Bianchi wrote: > cmd2 = subprocess.Popen(['gzip' '-c'], > shell=False, > stdout=filename) Doh, my fault: cmd2 = subprocess.Popen(['gzip' '-c'],

Re: python backup script

2013-05-06 Thread MRAB
On 06/05/2013 23:40, MMZ wrote: On Monday, May 6, 2013 6:12:28 PM UTC-4, Chris Angelico wrote: On Tue, May 7, 2013 at 5:01 AM, MMZ wrote: > username = config.get('client', 'mmz') > password = config.get('client', 'pass1') > hostname = config.get('client', 'localhost') Are 'mmz', 'pass1',

Re: Why sfml does not play the file inside a function in this python code?

2013-05-07 Thread MRAB
On 07/05/2013 10:27, cheirasa...@gmail.com wrote: from tkinter import * import sfml window = Tk() window.minsize( 640, 480 ) def sonido(): file = sfml.Music.from_file('poco.ogg') file.play() test = Button ( window, text = 'Sound test', command=sonido ) test.place ( x = 10, y = 60)

Re: Why sfml does not play the file inside a function in this python code?

2013-05-07 Thread MRAB
On 07/05/2013 14:56, cheirasa...@gmail.com wrote: El martes, 7 de mayo de 2013 12:53:25 UTC+2, MRAB escribió: On 07/05/2013 10:27, cheirasa...@gmail.com wrote: > from tkinter import * > import sfml > > window = Tk() > window.minsize( 640, 480 ) > > def

Re: Making safe file names

2013-05-07 Thread MRAB
On 07/05/2013 20:58, Andrew Berg wrote: Currently, I keep Last.fm artist data caches to avoid unnecessary API calls and have been naming the files using the artist name. However, artist names can have characters that are not allowed in file names for most file systems (e.g., C/A/T has forward s

Re: MySQL Database

2013-05-08 Thread MRAB
On 08/05/2013 19:52, Kevin Holleran wrote: Hello, I want to connect to a MySQL database, query for some records, manipulate some data, and then update the database. When I do something like this: db_c.execute("SELECT a, b FROM Users") for row in db_c.fetchall(): (r,d) = row[0].

Re: help on Implementing a list of dicts with no data pattern

2013-05-08 Thread MRAB
On 09/05/2013 00:47, rlelis wrote: Hi guys, I'm working on this long file, where i have to keep reading and storing different excerpts of text (data) in different variables (list). Once done that i want to store in dicts the data i got from the lists mentioned before. I want them on a list of

Re: Urgent:Serial Port Read/Write

2013-05-09 Thread MRAB
On 09/05/2013 16:35, chandan kumar wrote: Hi all, I'm new to python and facing issue using serial in python.I'm facing the below error *ser.write(port,command)* *NameError: global name 'ser' is not defined* * * Please find the attached script and let me know whats wrong in my script and also

Re: object.enable() anti-pattern

2013-05-09 Thread MRAB
On 09/05/2013 19:21, Steven D'Aprano wrote: On Thu, 09 May 2013 09:07:42 -0400, Roy Smith wrote: In article <518b32ef$0$11120$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: There is no sensible use-case for creating a file without opening it. Sure there is. Sometimes just creating th

Re: Unicode humor

2013-05-10 Thread MRAB
On 10/05/2013 17:07, rusi wrote: On May 10, 8:32 pm, Chris Angelico wrote: On Sat, May 11, 2013 at 1:24 AM, Ned Batchelder wrote: > On 5/10/2013 11:06 AM, jmfauth wrote: >> On 8 mai, 15:19, Roy Smith wrote: >>> Apropos to any of the myriad unicode threads that have been going on >>> recentl

Re: Getting ASCII encoding where unicode wanted under Py3k

2013-05-13 Thread MRAB
On 13/05/2013 16:59, Jonathan Hayward wrote: I have a Py3k script, pasted below. When I run it I get an error about ASCII codecs that can't handle byte values that are too high. The error that I am getting is: |UnicodeEncodeError: 'ascii' codec can't encode character'\u0161' in position 1442

Re: Unicode humor

2013-05-15 Thread MRAB
On 15/05/2013 14:19, Jean-Michel Pichavant wrote: >> >> This reflects a lack of understanding of Unicode. >> >> >> jmf >> >> > And this reflects a lack of a sense of humor. :) >> >> Isn't that a crime in the UK? >> >> ChrisA > > The problem with English humour (as against standard humor) is that

Re: Unicode humor

2013-05-15 Thread MRAB
On 15/05/2013 18:04, Jean-Michel Pichavant wrote: - Original Message - On 15/05/2013 14:19, Jean-Michel Pichavant wrote: This reflects a lack of understanding of Unicode. jmf And this reflects a lack of a sense of humor. :) Isn't that a crime in the UK? ChrisA The problem wi

Re: How to write fast into a file in python?

2013-05-19 Thread MRAB
On 19/05/2013 04:53, Carlos Nepomuceno wrote: Date: Sat, 18 May 2013 22:41:32 -0400 From: da...@davea.name To: python-list@python.org Subject: Re: How to write fast into a file in python? On 05/18/2013 01:00 PM, Carlos Nepomuceno wrote: Python really wr

Re: Accessing Json data (I think I am nearly there) complete beginner

2013-05-23 Thread MRAB
On 23/05/2013 17:09, Andrew Edwards-Adams wrote: Hey guys I think its worth stating that I have been trying to code for 1 week. I am trying to access some Json data. My innitial code was the below: "import mechanize import urllib import re def getData(): post_url = "http://www.tweetnaps.c

Re: Cutting a deck of cards

2013-05-26 Thread MRAB
On 26/05/2013 18:52, RVic wrote: Suppose I have a deck of cards, and I shuffle them import random cards = [] decks = 6 cards = list(range(13 * 4 * decks)) random.shuffle(cards) So now I have an array of cards. I would like to cut these cards at some random point (between 1 and 13 * 4 * decks -

Re: Encodign issue in Python 3.3.1 (once again)

2013-05-28 Thread MRAB
On 28/05/2013 17:00, Νίκος Γκρ33κ wrote: I do not know here to find connections.py Michael. But i do not understand since iam suing the following 2 statements, why a unicode error remains. #needed line, script does *not* work without it sys.stdout = os.fdopen(1, 'w', encoding='utf-8') # conne

Re: The state of pySerial

2013-05-29 Thread MRAB
On 29/05/2013 22:38, Terry Jan Reedy wrote: On 5/29/2013 4:00 PM, William Ray Wing wrote: On May 29, 2013, at 2:23 PM, Ma Xiaojun wrote: Hi, all. pySerial is probably "the solution" for serial port programming. Physical serial port is dead on PC but USB-to-Serial give it a second life. Seria

Re: User Input

2013-05-30 Thread MRAB
On 30/05/2013 12:48, Eternaltheft wrote: On Thursday, May 30, 2013 7:33:41 PM UTC+8, Eternaltheft wrote: Hi, I'm having trouble oh how prompt the user to enter a file name and how to set up conditions. For example, if there's no file name input by the user, a default is returned Thanks for suc

Re: The state of pySerial

2013-05-30 Thread MRAB
On 30/05/2013 02:32, Ma Xiaojun wrote: I've already mailed the author, waiting for reply. For Windows people, downloading a exe get you pySerial 2.5, which list_ports and miniterm feature seems not included. To use 2.6, download the tar.gz and use standard "setup.py install" to install it (assum

Re: How clean/elegant is Python's syntax?

2013-05-30 Thread MRAB
On 30/05/2013 19:44, Chris Angelico wrote: On Fri, May 31, 2013 at 4:36 AM, Ian Kelly wrote: On Wed, May 29, 2013 at 8:49 PM, rusi wrote: On May 30, 6:14 am, Ma Xiaojun wrote: What interest me is a one liner: print '\n'.join(['\t'.join(['%d*%d=%d' % (j,i,i*j) for i in range(1,10)]) for j in

Re: lstrip problem - beginner question

2013-06-04 Thread MRAB
On 04/06/2013 16:21, mstagliamonte wrote: Hi everyone, I am a beginner in python and trying to find my way through... :) I am writing a script to get numbers from the headers of a text file. If the header is something like: h01 = ('>scaffold_1') I just use: h01.lstrip('>scaffold_') and this re

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-05 Thread MRAB
On 05/06/2013 06:40, Michael Torrie wrote: On 06/04/2013 10:15 PM, Νικόλαος Κούρας wrote: One of my Greek filenames is "Ευχή του Ιησού.mp3". Just a Greek filename with spaces. Is there a problem when a filename contain both english and greek letters? Isn't it still a unicode string? All i did i

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-05 Thread MRAB
On 05/06/2013 18:43, Νικόλαος Κούρας wrote: Τη Τετάρτη, 5 Ιουνίου 2013 8:56:36 π.μ. UTC+3, ο χρήστης Steven D'Aprano έγραψε: Somehow, I don't know how because I didn't see it happen, you have one or more files in that directory where the file name as bytes is invalid when decoded as UTF-8, but y

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-06 Thread MRAB
On 06/06/2013 04:43, Νικόλαος Κούρας wrote: Τη Τετάρτη, 5 Ιουνίου 2013 9:43:18 μ.μ. UTC+3, ο χρήστης Νικόλαος Κούρας έγραψε: > Τη Τετάρτη, 5 Ιουνίου 2013 9:32:15 μ.μ. UTC+3, ο χρήστης MRAB έγραψε: > > > On 05/06/2013 18:43, οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ wrote: > &g

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-06 Thread MRAB
On 06/06/2013 13:04, Νικόλαος Κούρας wrote: First of all thank you for helping me MRAB. After make some alternation to your code ia have this: # Give the path as a bytestring so that we'll get the filenames as bytestrings path = b"/home/nikos/p

Re: How to store a variable when a script is executing for next time execution?

2013-06-06 Thread MRAB
On 06/06/2013 16:37, Chris Angelico wrote: On Thu, Jun 6, 2013 at 10:14 PM, Dave Angel wrote: If you're planning on having the files densely populated (meaning no gaps in the numbering), then you could use a binary search to find the last one. Standard algorithm would converge with 10 existence

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-06 Thread MRAB
On 06/06/2013 19:13, Νικόλαος Κούρας wrote: Τη Πέμπτη, 6 Ιουνίου 2013 3:50:52 μ.μ. UTC+3, ο χρήστης MRAB έγραψε: > If you're happy for that change to happen, then go ahead. I have made some modifications to the code you provided me but i think someth

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-06 Thread MRAB
On 06/06/2013 22:07, Lele Gaifax wrote: Νικόλαος Κούρας writes: Tahnks here is what i have up until now with many corrections. I'm afraid many more are needed :-) ... # rename filename form greek bytestreams --> utf-8 bytestreams old_path = b'/home/nikos/pub

Re: trigger at TDM/2 only

2013-06-06 Thread MRAB
On 07/06/2013 01:03, cerr wrote: Hi, I have a process that I can trigger only at a certain time. Assume I have a TDM period of 10min, that means, I can only fire my trigger at the 5th minute of every 10min cycle i.e. at XX:05, XX:15, XX:25... For hat I came up with following algorithm which o

Re: Problems with serial port interface

2013-06-07 Thread MRAB
On 07/06/2013 11:17, lionelgreenstr...@gmail.com wrote: Sorry for my quote, but do you have any suggestion? Il giorno martedì 4 giugno 2013 23:25:21 UTC+2, lionelgr...@gmail.com ha scritto: Hi, i'm programming in python for the first time: i want to create a serial port reader. I'm using pyt

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-07 Thread MRAB
On 07/06/2013 12:53, Νικόλαος Κούρας wrote: [snip] # # Collect filenames of the path dir as bytes greek_filenames = os.listdir( b'/home/nikos/public_html/data/apps/' ) for filename in greek_filenames: # Compute 'path/to/filename' i

Re: Errin when executing a cgi script that sets a cookie in the browser

2013-06-07 Thread MRAB
On 07/06/2013 08:51, Νικόλαος Κούρας wrote: Finally no suexec erros any more after chown all log files to nobody:nobody and thei corresponding paths. Now the error has been transformed to: [Fri Jun 07 10:48:47 2013] [error] [client 79.103.41.173] (2)No such file or directory: exec of '/home/

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-07 Thread MRAB
On 07/06/2013 20:31, Zero Piraeus wrote: : On 7 June 2013 14:52, Νικόλαος Κούρας wrote: File "/home/nikos/public_html/cgi-bin/files.py", line 81 [Fri Jun 07 21:49:33 2013] [error] [client 79.103.41.173] if( flag == 'greek' ) [Fri Jun 07 21:49:33 2013] [error] [client 79.103.41.173]

Re: Errin when executing a cgi script that sets a cookie in the browser

2013-06-07 Thread MRAB
On 07/06/2013 19:24, Νικόλαος Κούρας wrote: Τη Παρασκευή, 7 Ιουνίου 2013 5:32:09 μ.μ. UTC+3, ο χρήστης MRAB έγραψε: Can find what? koukos.py is there inside the cg-bin dir with 755 perms. It's looking for '/home/nikos/public_html/cgi-bin/koukos.py'. Its looking for its se

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-08 Thread MRAB
On 08/06/2013 07:49, Νικόλαος Κούρας wrote: Τη Σάββατο, 8 Ιουνίου 2013 5:52:22 π.μ. UTC+3, ο χρήστης Cameron Simpson έγραψε: On 07Jun2013 11:52, =?utf-8?B?zp3Or866zr/PgiDOk866z4EzM866?= wrote: | ni...@superhost.gr [~/www/cgi-bin]# [Fri Jun 07 21:49:33 2013] [error] [client 79.103.41.173] F

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-08 Thread MRAB
On 08/06/2013 17:53, Νικόλαος Κούρας wrote: Sorry for th delay guys, was busy with other thigns today and i am still reading your resposes, still ahvent rewad them all just Cameron's: Here is what i have now following Cameron's advices: #===

Re: A certainl part of an if() structure never gets executed.

2013-06-11 Thread MRAB
On 11/06/2013 21:20, Νικόλαος Κούρας wrote: [code] if not re.search( '=', name ) and not re.search( '=', month ) and not re.search( '=', year ): cur.execute( '''SELECT * FROM works WHERE clientsID = (SELECT id FROM clients WHERE name = %s) and MONTH(lastv

Re: A certainl part of an if() structure never gets executed.

2013-06-11 Thread MRAB
On 12/06/2013 02:25, nagia.rets...@gmail.com wrote: Τη Τετάρτη, 12 Ιουνίου 2013 1:43:21 π.μ. UTC+3, ο χρήστης MRAB έγραψε: On 11/06/2013 21:20, Νικόλαος Κούρας wrote: [snip] What are the values of 'name', 'month' and 'year' in each of the cases? Printing out

Re: A certainl part of an if() structure never gets executed.

2013-06-12 Thread MRAB
On 12/06/2013 12:17, Νικόλαος Κούρας wrote: As with most of your problems you are barking up the wrong tree. Why not use the actual value you get from the form to check whether you have a valid month? Do you understand why "0" is submitted instead of "=="? Bye, Andreas I have correct

Re: A certainl part of an if() structure never gets executed.

2013-06-12 Thread MRAB
On 12/06/2013 18:13, Νικόλαος Κούρας wrote: On 12/6/2013 7:40 μμ, MRAB wrote: On 12/06/2013 12:17, Νικόλαος Κούρας wrote: As with most of your problems you are barking up the wrong tree. Why not use the actual value you get from the form to check whether you have a valid month? Do you

Re: Version Control Software

2013-06-13 Thread MRAB
On 13/06/2013 07:00, cutems93 wrote: Thank you everyone for such helpful responses! Actually, I have one more question. Does anybody have experience with closed source version control software? If so, why did you buy it instead of downloading open source software? Does closed source vcs have some

Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread MRAB
On 14/06/2013 18:28, Michael Torrie wrote: On 06/14/2013 10:49 AM, Steven D'Aprano wrote: Correct. In Python, all boolean expressions are duck-typed: they aren't restricted to True and False, but to any "true-ish" and "false-ish" value, or as the Javascript people call them, truthy and falsey va

Re: problem uploading docs to pypi

2013-06-14 Thread MRAB
On 14/06/2013 23:53, Irmen de Jong wrote: Hi, I'm experiencing some trouble when trying to upload the documentation for one of my projects on Pypi. I'm getting a Bad Gateway http error message. Anyone else experiencing this? Is this an intermittent issue or is there a problem with Pypi? Downl

Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread MRAB
On 15/06/2013 00:06, Nobody wrote: On Fri, 14 Jun 2013 16:49:11 +, Steven D'Aprano wrote: Unlike Javascript though, Python's idea of truthy and falsey is actually quite consistent: Beyond that, if a user-defined type implements a __nonzero__() method then it determines whether an instance

Re: Fatal Python error: Py_Initialize: can't initialize sys standard streams

2013-06-15 Thread MRAB
On 15/06/2013 23:10, alex23 wrote: On Jun 16, 7:29 am, lucabrasi...@gmail.com wrote: I get this error when I try to save .dxf files in Inkscape: Fatal Python error: Py_Initialize: can't initialize sys standard streams Then it seems to recover but it doesn't really recover. It saves the files a

Re: Updating a filename's counter value failed each time

2013-06-17 Thread MRAB
On 17/06/2013 17:39, Simpleton wrote: Hello again, something simple this time: After a user selects a file from the form, that sleection of his can be found form reading the variable 'filename' If the filename already exists in to the database i want to update its counter and that is what i'm t

Re: Updating a filename's counter value failed each time

2013-06-17 Thread MRAB
On 17/06/2013 19:32, Jens Thoms Toerring wrote: Νίκος wrote: On 17/6/2013 8:54 μμ, Jens Thoms Toerring wrote: > Also take care to check the filename you insert - a malicous > user might cobble together a file name that is actually a SQL > statement and then do nasty things to your database. I.e

Re: Updating a filename's counter value failed each time

2013-06-17 Thread MRAB
On 17/06/2013 21:44, John Gordon wrote: In Alister writes: > #update file's counter if cookie does not exist cur.execute('''UPDATE > files SET hits = hits + 1, host = %s, lastvisit = > %s WHERE url = %s''', (host, lastvisit, filename) ) > > if cur.rowcount: >print( " database has

Re: Why is regex so slow?

2013-06-18 Thread MRAB
On 18/06/2013 17:45, Roy Smith wrote: I've got a 170 MB file I want to search for lines that look like: [2010-10-20 16:47:50.339229 -04:00] INFO (6): songza.amie.history - ENQUEUEING: /listen/the-station-one This code runs in 1.3 seconds: -- import re pattern = re

Re: Why is regex so slow?

2013-06-18 Thread MRAB
On 18/06/2013 20:21, Roy Smith wrote: In article , Mark Lawrence wrote: Out of curiousity have the tried the new regex module from pypi rather than the stdlib version? A heck of a lot of work has gone into it see http://bugs.python.org/issue2636 I just installed that and gave it a shot. I

Re: A few questiosn about encoding

2013-06-20 Thread MRAB
On 20/06/2013 07:26, Steven D'Aprano wrote: On Wed, 19 Jun 2013 18:46:59 -0700, Rick Johnson wrote: On Thursday, June 13, 2013 2:11:08 AM UTC-5, Steven D'Aprano wrote: Gah! That's twice I've screwed that up. Sorry about that! Yeah, and your difficulty explaining the Unicode implementation r

Re: A few questiosn about encoding

2013-06-20 Thread MRAB
On 20/06/2013 17:37, Chris Angelico wrote: On Fri, Jun 21, 2013 at 2:27 AM, wrote: And all these coding schemes have something in common, they work all with a unique set of code points, more precisely a unique set of encoded code points (not the set of implemented code points (byte)). Just wh

Re: Does upgrade from 2.7.3 to 2.7.5 require uninstall?

2013-06-20 Thread MRAB
On 20/06/2013 19:35, Wanderer wrote: Do I need to uninstall Python 2.7.3 before installing Python 2.7.5? No. -- http://mail.python.org/mailman/listinfo/python-list

Re: Default Value

2013-06-21 Thread MRAB
On 21/06/2013 19:26, Rick Johnson wrote: On Friday, June 21, 2013 12:47:56 PM UTC-5, Rotwang wrote: It isn't clear to me from your posts what exactly you're proposing as an alternative to the way Python's default argument binding works. In your version of Python, what exactly would happen when I

Re: Default Value

2013-06-21 Thread MRAB
On 21/06/2013 21:44, Rick Johnson wrote: On Friday, June 21, 2013 2:25:49 PM UTC-5, MRAB wrote: On 21/06/2013 19:26, Rick Johnson wrote: > > The Apathetic Approach: > ===

Re: Default Value

2013-06-21 Thread MRAB
On 22/06/2013 00:51, Rick Johnson wrote: On Friday, June 21, 2013 5:49:51 PM UTC-5, MRAB wrote: I notice that you've omitted any mention of how you'd know that the argument was mutable. My argument has always been that mutables should not be passed into subroutines as default

Re: Default Value

2013-06-21 Thread MRAB
On 22/06/2013 02:40, Chris Angelico wrote: On Sat, Jun 22, 2013 at 11:31 AM, Steven D'Aprano wrote: Thinking about this, I think that the only safe thing to do in Rickython 4000 is to prohibit putting mutable objects inside tuples. Putting a list or a dict inside a tuple is just a bug waiting t

Re: Default Value

2013-06-22 Thread MRAB
On 22/06/2013 03:32, Rick Johnson wrote: On Friday, June 21, 2013 8:54:50 PM UTC-5, MRAB wrote: On 22/06/2013 00:51, Rick Johnson wrote: > On Friday, June 21, 2013 5:49:51 PM UTC-5, MRAB wrote: > My argument has always been that mutables should not be > passed into subroutines a

Re: n00b question on spacing

2013-06-22 Thread MRAB
On 23/06/2013 00:56, Dave Angel wrote: On 06/22/2013 07:37 PM, Chris Angelico wrote: On Sun, Jun 23, 2013 at 9:28 AM, Dave Angel wrote: On 06/22/2013 07:12 PM, Chris Angelico wrote: On Sun, Jun 23, 2013 at 1:24 AM, Rick Johnson wrote: _fmtstr = "Item wrote to MongoDB database {0}, {1}

Re: Looking for a name for a deployment framework...

2013-06-24 Thread MRAB
On 24/06/2013 13:50, Roy Smith wrote: In article <8b0d8931-cf02-4df4-8f17-a47ddd279...@googlegroups.com>, jonathan.slend...@gmail.com wrote: Hi all, Any suggestions for a good name, for a framework that does automatic server deployments? It's like Fabric, but more powerful. It has some simi

Re: [SPAM] Re: Default Value

2013-06-24 Thread MRAB
On 24/06/2013 15:22, Grant Edwards wrote: On 2013-06-22, Ian Kelly wrote: On Fri, Jun 21, 2013 at 7:15 PM, Steven D'Aprano wrote: On Fri, 21 Jun 2013 23:49:51 +0100, MRAB wrote: On 21/06/2013 21:44, Rick Johnson wrote: [...] Which in Python would be the "MutableArgumentWarning&

Re: Is this PEP-able? fwhile

2013-06-24 Thread MRAB
On 24/06/2013 23:35, Chris Angelico wrote: On Tue, Jun 25, 2013 at 8:30 AM, Tim Chase wrote: On 2013-06-25 07:38, Chris Angelico wrote: Python has no issues with breaking out of loops, and even has syntax specifically to complement it (the 'else:' clause). Use break/continue when appropriate.

Re: Python development tools

2013-06-24 Thread MRAB
On 25/06/2013 03:24, rusi wrote: On Tuesday, June 25, 2013 4:41:22 AM UTC+5:30, Ben Finney wrote: rusi writes: > I dont however think that the two philosophies are the same. See > http://www.tcl.tk/doc/scripting.html That essay constrasts “scripting” versus “system programming”, a useful (thou

Re: io module and pdf question

2013-06-25 Thread MRAB
On 25/06/2013 17:15, jyoun...@kc.rr.com wrote: Thank you Rusi and Christian! So it sounds like I should read the pdf data in as binary: import os pdfPath = '~/Desktop/test.pdf' colorlistData = '' with open(os.path.expanduser(pdfPath), 'rb') as f: for i in f:

Re: Parsing soap/xml result

2013-06-25 Thread MRAB
On 25/06/2013 23:28, miguel olivares varela wrote: I try to parse a soap/xml answer like: http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";> http://schemas.xmlsoap.org/soap/encoding/"; xml

Re: re.finditer() skips unicode into selection

2013-06-26 Thread MRAB
On 26/06/2013 20:18, akshay.k...@gmail.com wrote: I am using the following Highlighter class for Spell Checking to work on my QTextEdit. class Highlighter(QSyntaxHighlighter): In Python 2.7, the re module has a somewhat limited idea of what a "word" character is. It recognises 'DEVANAGARI LET

Re: Devnagari Unicode Conversion Issues

2013-06-27 Thread MRAB
On 27/06/2013 16:05, darpan6aya wrote: How can i convert text of the following type नेपाली into devnagari unicode in Python 2.7? Is that a bytestring? In other words, is its type 'str'? If so, you need to decode it. That particular string is UTF-8: >>> print "नेपाà¤

Re: Why is the argparse module so inflexible?

2013-06-29 Thread MRAB
On 29/06/2013 06:28, Steven D'Aprano wrote: On Fri, 28 Jun 2013 18:36:37 -0700, Ethan Furman wrote: On 06/27/2013 03:49 PM, Steven D'Aprano wrote: [rant] I think it is lousy design for a framework like argparse to raise a custom ArgumentError in one part of the code, only to catch it elsewher

Re: MeCab UTF-8 Decoding Problem

2013-06-29 Thread MRAB
On 29/06/2013 12:29, fob...@gmail.com wrote: Hi, I am trying to use a program called MeCab, which does syntax analysis on Japanese text. The problem I am having is that it returns a byte string and if I try to print it, it prints question marks for almost all characters. However, if I try to

Re: math functions with non numeric args

2013-06-30 Thread MRAB
On 30/06/2013 19:53, Andrew Berg wrote: On 2013.06.30 13:46, Andrew Z wrote: Hello, print max(-10, 10) 10 print max('-10', 10) -10 My guess max converts string to number bye decoding each of the characters to it's ASCII equivalent? Where can i read more on exactly how the situations like the

Re: socket data sending problem

2013-07-03 Thread MRAB
On 03/07/2013 23:38, ollietemple...@aol.com wrote: im trying to do a simple socket test program for a school project using the socket module, but im having difficulty in sending data between the client and host program. so far all tutorials and examples have used something along the lines of:

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-04 Thread MRAB
On 04/07/2013 11:38, Νίκος wrote: Στις 4/7/2013 12:50 μμ, ο/η Ulrich Eckhardt έγραψε: Am 04.07.2013 10:37, schrieb Νίκος: I just started to have this error without changing nothing Well, undo the nothing that you didn't change. ;) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-04 Thread MRAB
On 04/07/2013 12:29, Νίκος wrote: Στις 4/7/2013 1:54 μμ, ο/η Chris Angelico έγραψε: On Thu, Jul 4, 2013 at 8:38 PM, � wrote: So you are also suggesting that what gesthostbyaddr() returns is not utf-8 encoded too? What character is 0xb6 anyways? It isn't. It's a byte. Bytes are not chara

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-04 Thread MRAB
On 04/07/2013 12:36, Νίκος wrote: Στις 4/7/2013 2:06 μμ, ο/η MRAB έγραψε: On 04/07/2013 11:38, Νίκος wrote: Στις 4/7/2013 12:50 μμ, ο/η Ulrich Eckhardt έγραψε: Am 04.07.2013 10:37, schrieb Νίκος: I just started to have this error without changing nothing Well, undo the nothing that you

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-04 Thread MRAB
On 04/07/2013 13:52, Νίκος wrote: Στις 4/7/2013 3:07 μμ, ο/η MRAB έγραψε: Also, try printing out ascii(os.environ['REMOTE_ADDR']). '108.162.229.97' is the result of: print( ascii(os.environ['REMOTE_ADDR']) ) Seems perfectly valid. and also have a PTR record, so

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-04 Thread MRAB
On 04/07/2013 13:47, Νίκος wrote: Στις 4/7/2013 3:07 μμ, ο/η MRAB έγραψε: On 04/07/2013 12:36, Νίκος wrote: Στις 4/7/2013 2:06 μμ, ο/η MRAB έγραψε: On 04/07/2013 11:38, Νίκος wrote: Στις 4/7/2013 12:50 μμ, ο/η Ulrich Eckhardt έγραψε: Am 04.07.2013 10:37, schrieb Νίκος: I just started to

Re: Important features for editors

2013-07-04 Thread MRAB
On 04/07/2013 14:22, Tim Chase wrote: On 2013-07-04 05:02, Dave Angel wrote: [snip an excellent list of things to look for in an editor] Also, - the ability to perform changes in bulk, especially across files. Often, this is done with the ability to record/playback macros, though some edi

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-04 Thread MRAB
On 04/07/2013 14:38, Νίκος Γκρ33κ wrote: Στις 4/7/2013 4:34 μμ, ο/η MRAB έγραψε: On 04/07/2013 13:47, Νίκος wrote: Στις 4/7/2013 3:07 μμ, ο/η MRAB έγραψε: On 04/07/2013 12:36, Νίκος wrote: Στις 4/7/2013 2:06 μμ, ο/η MRAB έγραψε: On 04/07/2013 11:38, Νίκος wrote: Στις 4/7/2013 12:50 μμ, ο/η

Re: How to make this faster

2013-07-05 Thread MRAB
On 05/07/2013 16:17, Helmut Jarausch wrote: On Fri, 05 Jul 2013 15:45:25 +0100, Oscar Benjamin wrote: Presumably then you're now down to the innermost loop as a bottle-neck: Possibilities= 0 for d in range(1,10) : if Row_Digits[r,d] or Col_Digits[c,d] or Sqr_Digits[Sq_No,d]

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread MRAB
On 08/07/2013 21:56, Dave Angel wrote: On 07/08/2013 01:53 PM, ferdy.blat...@gmail.com wrote: Hi Steven, thank you for your reply... I really needed another python guru which is also an English teacher! Sorry if English is not my mother tongue... "uncorrect" instead of "incorrect" (I misapplied

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread MRAB
On 08/07/2013 23:02, Joshua Landau wrote: On 8 July 2013 22:38, MRAB wrote: On 08/07/2013 21:56, Dave Angel wrote: Characters do not have a width. [snip] It depends what you mean by "width"! :-) Try this (Python 3): print("A\N{FULLWIDTH LATIN CAPITAL LETTER A}") A

Re: GeoIP2 for retrieving city and region ?

2013-07-12 Thread MRAB
On 12/07/2013 17:32, Νικόλας wrote: I know i have asked before but hwta i get is ISP city not visitors precise city. GeoLiteCity.dat isnt accurate that's why it comes for free. i must somehow get access to GeoIPCity.dat which is the full version. And of course it can be done, i dont want to be

Re: RE Module Performance

2013-07-12 Thread MRAB
On 12/07/2013 23:16, Tim Delaney wrote: On 13 July 2013 03:58, Devyn Collier Johnson mailto:devyncjohn...@gmail.com>> wrote: Thanks for the thorough response. I learned a lot. You should write articles on Python. I plan to spend some time optimizing the re.py module for Unix sys

Re: what thread-synch mech to use for clean exit from a thread

2013-07-15 Thread MRAB
On 15/07/2013 04:04, Steven D'Aprano wrote: On Mon, 15 Jul 2013 10:27:45 +0800, Gildor Oronar wrote: A currency exchange thread updates exchange rate once a minute. If the thread faield to update currency rate for 5 hours, it should inform main() for a clean exit. This has to be done gracefully

Re: Question regarding building Python Windows installer

2013-07-15 Thread MRAB
On 15/07/2013 14:11, Mcadams, Philip W wrote: I’m attempting to create a Python 64-bit Windows Installer. Following the instructions here: http://docs.python.org/2/distutils/builtdist.html I’m to navigate to my Python folder and user command: python setup.py build --plat-name=win-amd64 bdist_wi

Re: help on python regular expression named group

2013-07-16 Thread MRAB
On 16/07/2013 11:18, Mohan L wrote: On Tue, Jul 16, 2013 at 2:12 PM, Joshua Landau mailto:jos...@landau.ws>> wrote: On 16 July 2013 07:55, Mohan L mailto:l.mohan...@gmail.com>> wrote: > > Dear All, > > Here is my script : > > #!/usr/bin/python > import r

Re: Converting a list of lists to a single list

2013-07-23 Thread MRAB
On 23/07/2013 22:52, st...@divillo.com wrote: I think that itertools may be able to do what I want but I have not been able to figure out how. I want to convert an arbitrary number of lists with an arbitrary number of elements in each list into a single list as follows. Say I have three lists

Re: Python Script Hashplings

2013-07-25 Thread MRAB
On 25/07/2013 14:42, Devyn Collier Johnson wrote: If I execute a Python3 script with this haspling (#!/usr/bin/python3.3) and Python3.3 is not installed, but Python3.2 is installed, would the script still work? Would it fall back to Python3.2? Why don't you try it? I hope Dihedral is listenin

Re: Python Script Hashplings

2013-07-26 Thread MRAB
On 26/07/2013 11:43, Chris Angelico wrote: On Fri, Jul 26, 2013 at 11:37 AM, Devyn Collier Johnson wrote: On 07/25/2013 09:54 AM, MRAB wrote: On 25/07/2013 14:42, Devyn Collier Johnson wrote: If I execute a Python3 script with this haspling (#!/usr/bin/python3.3) and Python3.3 is not

Re: RE Module Performance

2013-07-28 Thread MRAB
On 28/07/2013 19:13, wxjmfa...@gmail.com wrote: Le dimanche 28 juillet 2013 05:53:22 UTC+2, Ian a écrit : On Sat, Jul 27, 2013 at 12:21 PM, wrote: > Back to utf. utfs are not only elements of a unique set of encoded > code points. They have an interesting feature. Each "utf chunk" > holds i

Re: FSR and unicode compliance - was Re: RE Module Performance

2013-07-28 Thread MRAB
On 28/07/2013 20:23, wxjmfa...@gmail.com wrote: [snip] Compare these (a BDFL exemple, where I'using a non-ascii char) Py 3.2 (narrow build) Why are you using a narrow build of Python 3.2? It doesn't treat all codepoints equally (those outside the BMP can't be stored in one code unit) and, the

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread MRAB
On 29/07/2013 16:43, Steven D'Aprano wrote: Comparing floats to Fractions gives unexpected results: # Python 3.3 py> from fractions import Fraction py> 1/3 == Fraction(1, 3) False but: py> 1/3 == float(Fraction(1, 3)) True I expected that float-to-Fraction comparisons would convert the Fract

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread MRAB
On 29/07/2013 17:20, Chris Angelico wrote: On Mon, Jul 29, 2013 at 5:09 PM, MRAB wrote: I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats are approximate anyway, and the float value 1/3 is more likely to be Fraction(1, 3) than Fraction(6004799503160661, 180143985094

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread MRAB
On 29/07/2013 17:40, Ian Kelly wrote: On Mon, Jul 29, 2013 at 10:20 AM, Chris Angelico wrote: On Mon, Jul 29, 2013 at 5:09 PM, MRAB wrote: I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats are approximate anyway, and the float value 1/3 is more likely to be Fraction

Re: Bitwise Operations

2013-07-29 Thread MRAB
On 30/07/2013 00:34, Devyn Collier Johnson wrote: On 07/29/2013 05:53 PM, Grant Edwards wrote: On 2013-07-29, Devyn Collier Johnson wrote: On Python3, how can I perform bitwise operations? For instance, I want something that will 'and', 'or', and 'xor' a binary integer. http://www.google.co

Re: RE Module Performance

2013-07-30 Thread MRAB
On 30/07/2013 15:38, Antoon Pardon wrote: Op 30-07-13 16:01, wxjmfa...@gmail.com schreef: I am pretty sure that once you have typed your 127504 ascii characters, you are very happy the buffer of your editor does not waste time in reencoding the buffer as soon as you enter an €, the 125505th cha

Re: RE Module Performance

2013-07-30 Thread MRAB
On 30/07/2013 17:39, Antoon Pardon wrote: Op 30-07-13 18:13, MRAB schreef: On 30/07/2013 15:38, Antoon Pardon wrote: Op 30-07-13 16:01, wxjmfa...@gmail.com schreef: I am pretty sure that once you have typed your 127504 ascii characters, you are very happy the buffer of your editor does not

Re: Conditional decoration

2012-06-18 Thread MRAB
On 18/06/2012 23:16, Roy Smith wrote: Is there any way to conditionally apply a decorator to a function? For example, in django, I want to be able to control, via a run-time config flag, if a view gets decorated with @login_required(). @login_required() def my_view(request): pass A decora

Re: re.finditer with lookahead and lookbehind

2012-06-20 Thread MRAB
On 20/06/2012 14:30, Christian wrote: Hi, i have some trouble to split a pattern like s. Even have this problems with the first and last match. Some greedy problems? Thanks in advance Christian import re s='v1=pattern1&v2=pattern2&v3=pattern3&v4=pattern4&v5=pattern5&x1=patternx' pattern =r'

  1   2   3   4   5   6   7   8   9   10   >