Re: How to check the date validity?

2013-12-23 Thread Andreas Perstinger
Jason Friedman wrote: >Would this not work? >import re >if re.search(r"\d{1,2}:\d{2}:\d{2}(.\d{1,3})?", "12:55:55.705"): ># It's a time No, because this regexp also matches stuff like "99:99:99.999". Checking for the number of digits is not enough, because not all combinations of two digits a

Re: [OT]Royal pardon for codebreaker Turing

2013-12-23 Thread Steven D'Aprano
On Tue, 24 Dec 2013 00:32:31 +, Mark Lawrence wrote: > Maybe of interest to some of you > http://www.bbc.co.uk/news/technology-25495315 While I'm happy for Alan Turing, may he rest in peace, I think the thousands of other homosexuals who have been prosecuted for something which shouldn't be

Re: cascading python executions only if return code is 0

2013-12-23 Thread Roy Smith
In article <52b90263$0$30003$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Roy Smith wrote: > > > So, here's the deeper question.  Is your issue strictly that -O elides > > assert statements? That's a purely mechanical issue that could be > > solved by using the rather more ve

Re: python socket query

2013-12-23 Thread Chris Angelico
On Tue, Dec 24, 2013 at 2:33 PM, wrote: > Thanks Chris.I have put bind call but it did not work. > Even telnet hangs if i tried to connect to the same IP and port manually. Is > there a workaround to fix this issue? > > If the socket gets closed at the other end. How can we get around with the

Re: cascading python executions only if return code is 0

2013-12-23 Thread Steven D'Aprano
Roy Smith wrote: > So, here's the deeper question.  Is your issue strictly that -O elides > assert statements? That's a purely mechanical issue that could be > solved by using the rather more verbose: > > if not condition: > raise AssertionError("") > > Would you feel differently then?

Re: python socket query

2013-12-23 Thread smilesonisamal
On Monday, December 23, 2013 8:49:30 AM UTC+5:30, Chris Angelico wrote: > On Mon, Dec 23, 2013 at 2:05 PM, wrote: > > > I wrote a small program which creates the socket, bind to the socket, > > connect to socket and send() close(). I see that there is no reply coming > > from server and the TC

Re: How to check the date validity?

2013-12-23 Thread Jason Friedman
> In this file I have 3 different kind of fields: one consist of the > sole date, one - sole time and one - datetime. The time includes > milliseconds, i.e. "12:55:55.705" > All fields of the file including those 3 I am reading as the string. > All those strings after validating will go into mySQL

Re: [OT]Royal pardon for codebreaker Turing

2013-12-23 Thread Tim Johnson
* Mark Lawrence [131223 15:39]: > Maybe of interest to some of you > http://www.bbc.co.uk/news/technology-25495315 I note the following """ "Dr Alan Turing was an exceptional man with a brilliant mind," said Mr Grayling. He said the research Turing carried out during the war at Blet

Re: How to check the date validity?

2013-12-23 Thread Mark Lawrence
On 24/12/2013 00:30, Igor Korot wrote: Hi, ALL, I'm working on the python script which reads the data from the csv file. In this file I have 3 different kind of fields: one consist of the sole date, one - sole time and one - datetime. The time includes milliseconds, i.e. "12:55:55.705" All fields

Re: How to check the date validity?

2013-12-23 Thread Chris Angelico
On Tue, Dec 24, 2013 at 11:30 AM, Igor Korot wrote: > So, my question is: since there is a simple way of inserting > preformatted string into the datetime field of mySQL, how do I > validate the date string? Well, the easiest way would be to simply attempt the SQL query. If it comes back with an

[OT]Royal pardon for codebreaker Turing

2013-12-23 Thread Mark Lawrence
Maybe of interest to some of you http://www.bbc.co.uk/news/technology-25495315 -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list

How to check the date validity?

2013-12-23 Thread Igor Korot
Hi, ALL, I'm working on the python script which reads the data from the csv file. In this file I have 3 different kind of fields: one consist of the sole date, one - sole time and one - datetime. The time includes milliseconds, i.e. "12:55:55.705" All fields of the file including those 3 I am readi

Re: Please stop the trolling

2013-12-23 Thread Mark Lawrence
On 23/12/2013 20:53, Terry Reedy wrote: On 12/23/2013 2:05 PM, wxjmfa...@gmail.com wrote: Le lundi 23 décembre 2013 18:59:41 UTC+1, Wolfgang Keller a écrit : [me] I'll note that Python core developers do care about memory leaks. And that's a really good thing. Memory? Let me laugh! [snip

Re: Deamonify my python script on Android

2013-12-23 Thread Ben Finney
Kevin Peterson writes: > I want to daemonify my python script on Android device. That is, it > should be automatically invoked on boot up. Those aren't the same thing. To daemonise a program is independent of whether the program starts automatically; it can start automatically without detaching

Please stop the trolling

2013-12-23 Thread Terry Reedy
On 12/23/2013 2:05 PM, wxjmfa...@gmail.com wrote: Le lundi 23 décembre 2013 18:59:41 UTC+1, Wolfgang Keller a écrit : [me] I'll note that Python core developers do care about memory leaks. And that's a really good thing. Memory? Let me laugh! [snip repeated (for about the 5th time) posting

Re: Using asyncio in event-driven network library

2013-12-23 Thread Terry Reedy
On 12/23/2013 11:47 AM, Chris Angelico wrote: On Mon, Dec 23, 2013 at 10:50 PM, Tobias M. wrote: I am currently writing an event-driven client library for a network protocol [1] and chose to use the new asyncio module. I have no experience with asynchronous IO and don't understand all the conce

RE: cascading python executions only if return code is 0

2013-12-23 Thread Nick Cash
> assert assertions_working() # refuse to run in -O mode > > Can't imagine why that wouldn't work.. Why overthink this? assert not sys.flags.optimize is clearly the one, and only one, obvious way to do it. Of course, it works about as well as the rest of these solutions. Which is to sa

Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-23 Thread Dan Stromberg
On Sat, Dec 14, 2013 at 4:25 AM, Chris Angelico wrote: > On Sat, Dec 14, 2013 at 11:12 PM, Jai wrote: >> GUI:-want to learn GUI programming in python , how should i proceed. >> >> There are lots of book here so I am confuse which book i should refer so >> that i don't waste time . please answ

Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-23 Thread Mark Lawrence
On 23/12/2013 19:14, Chris Angelico wrote: On Tue, Dec 24, 2013 at 6:05 AM, wrote: Memory? Let me laugh! Is it a crime to hijack an already-hijacked thread? ChrisA Yes, especially when written with our favourite bug ridden pile of garbage. Perhaps we should write up something for the P

Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-23 Thread Chris Angelico
On Tue, Dec 24, 2013 at 6:05 AM, wrote: > Memory? Let me laugh! > Is it a crime to hijack an already-hijacked thread? ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: cascading python executions only if return code is 0

2013-12-23 Thread Chris Angelico
On Tue, Dec 24, 2013 at 6:03 AM, Roy Smith wrote: > [2] In which case, we would just add some middleware which did: > > assert "-O" not in sys.argv Aside from the fact that this wouldn't work, it won't work :) By the time you see argv, the -O option has been eaten. But why stop at that? def asse

Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-23 Thread wxjmfauth
Le lundi 23 décembre 2013 18:59:41 UTC+1, Wolfgang Keller a écrit : > > > On an actual operating system, the attitude of the developers (do > > > > they actually care or just don't give a darn) is *the* critical > > > > issue for end-user productivity. If a developer makes a statement > > > > su

Re: cascading python executions only if return code is 0

2013-12-23 Thread Roy Smith
On Monday, December 23, 2013 12:05:22 PM UTC-5, Steven D'Aprano wrote: > Roy Smith wrote: > > And, yes, I know that assertions get turned off with -O (frankly, I > > think that's a design flaw).  We don't run with -O. > > > Until such time as somebody decides they can speed up your code by 5% by

Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-23 Thread Wolfgang Keller
> > On an actual operating system, the attitude of the developers (do > > they actually care or just don't give a darn) is *the* critical > > issue for end-user productivity. If a developer makes a statement > > such as of "just get a faster computer" or "just get more RAM", > > then (s)he probably

Re: cascading python executions only if return code is 0

2013-12-23 Thread Peter Otten
Ethan Furman wrote: >> Sigh. Sometimes I'm not sure which is worse. The anti-assertion >> zealotry on this list, or the anti-regex zealotry. > > I am not a zealot (I'm not! Really!! ;) . I just find it alarming to > have major pieces of software rely on a feature that can be so easily > tuned

Re: cascading python executions only if return code is 0

2013-12-23 Thread Steven D'Aprano
Dennis Lee Bieber wrote: > On Mon, 23 Dec 2013 13:33:08 +1100, Steven D'Aprano > declaimed the following: > >>Roy Smith wrote: >> >> >>> else: >>> assert 0, "can't create picker (classes = %s)" % classes >> >>¡Ay, caramba! I was with you until the very last line. The above co

Re: cascading python executions only if return code is 0

2013-12-23 Thread Ethan Furman
On 12/23/2013 07:10 AM, Roy Smith wrote: In article , Ethan Furman wrote: On 12/22/2013 08:57 PM, Roy Smith wrote: In article <52b7a0e4$0$29994$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: Anyway, I may be completely misinterpreting what I'm reading. Perhaps the asserti

Re: cascading python executions only if return code is 0

2013-12-23 Thread Steven D'Aprano
Roy Smith wrote: > Sigh.  Sometimes I'm not sure which is worse.  The anti-assertion > zealotry on this list, or the anti-regex zealotry. I'm not anti-assertions. I love assertions. I wouldn't be surprised if I use assert more than you do. What I dislike is people misusing assertions. > And, yes

Re: [OT] vnc-problem with idle running as sudo on raspberry pi

2013-12-23 Thread Jean Dubois
Op maandag 23 december 2013 16:29:09 UTC+1 schreef Michael Torrie: > On 12/23/2013 07:06 AM, Jean Dubois wrote: > > I thought this would be something python-people are familiar with, after > > all idle is a Python IDE and running it as a root sometimes is necessary. > > On most desktop distros like

Re: Using asyncio in event-driven network library

2013-12-23 Thread Chris Angelico
On Mon, Dec 23, 2013 at 10:50 PM, Tobias M. wrote: > I am currently writing an event-driven client library for a network protocol > [1] and chose to use the new asyncio module. I have no experience with > asynchronous IO and don't understand all the concepts in asyncio yet. So I'm > not sure if as

Re: urllib and authentication script integration

2013-12-23 Thread Chris Angelico
On Tue, Dec 24, 2013 at 12:47 AM, Jeff James wrote: > I have some simple code I would like to share with someone that can assist > me in integrating authentication script into. I'm sure it's an easy answer > for any of you. I am still researching, but on this particular project, > time is of the

Re: Google Groups + this list

2013-12-23 Thread Chris Angelico
On Mon, Dec 23, 2013 at 10:48 PM, Ned Batchelder wrote: > I suggest the following: > > 1) Don't fault newcomers for using Google Groups. Politely suggest > alternatives, but only if you are also helping them, or if they have already > gotten help. > > 2) Be careful how you rail against Google Gro

Re: Airplane mode control using Python?

2013-12-23 Thread Chris Angelico
On Mon, Dec 23, 2013 at 5:09 PM, wrote: > On Sunday, December 22, 2013 10:37:35 PM UTC-7, Chris Angelico wrote: >> Actually, formatting errors ARE often caused by Google Groups. Maybe >> it wasn't in this instance, but I have seen several cases of GG >> mangling code formatting, so this was a per

Re: [OT] vnc-problem with idle running as sudo on raspberry pi

2013-12-23 Thread Michael Torrie
On 12/23/2013 07:06 AM, Jean Dubois wrote: > I thought this would be something python-people are familiar with, after > all idle is a Python IDE and running it as a root sometimes is necessary. On most desktop distros like Fedora, sudo idle would indeed work. The fact that it's not working on you

Re: cascading python executions only if return code is 0

2013-12-23 Thread Mark Lawrence
On 23/12/2013 15:12, Dennis Lee Bieber wrote: On Mon, 23 Dec 2013 13:33:08 +1100, Steven D'Aprano declaimed the following: Roy Smith wrote: else: assert 0, "can't create picker (classes = %s)" % classes ¡Ay, caramba! I was with you until the very last line. The above

Re: cascading python executions only if return code is 0

2013-12-23 Thread Roy Smith
In article , Ethan Furman wrote: > On 12/22/2013 08:57 PM, Roy Smith wrote: > > In article <52b7a0e4$0$29994$c3e8da3$54964...@news.astraweb.com>, > > Steven D'Aprano wrote: > > > >> Anyway, I may be completely misinterpreting what I'm reading. Perhaps the > >> assertion is checking a function

Re: Deamonify my python script on Android

2013-12-23 Thread Larry Martell
On Sun, Dec 22, 2013 at 10:22 PM, Kevin Peterson wrote: > Hi, > > I want to daemonify my python script on Android device. That is, it should be > automatically invoked on boot up. > > Appreciate your help. I don't know anything about Android programming, but for Linux i followed the advice on t

RE: urllib and authentication script integration

2013-12-23 Thread Jeff James
I have some simple code I would like to share with someone that can assist me in integrating authentication script into. I'm sure it's an easy answer for any of you. I am still researching, but on this particular project, time is of the essence and this is the only missing piece of the puzzle for

Re: [OT] vnc-problem with idle running as sudo on raspberry pi

2013-12-23 Thread Jean Dubois
Op zondag 22 december 2013 18:06:39 UTC+1 schreef Michael Torrie: > On 12/22/2013 06:27 AM, Jean Dubois wrote: > > I was wrong writing idle_as_root worked this way. As a matter of fact, > > this method also does not work as expected, as can be seen from this > > message: > > > > X11 connection rej

Re: Airplane mode control using Python?

2013-12-23 Thread Ned Batchelder
On 12/23/13 7:45 AM, Kevin Peterson wrote: Hi Ned, I havenot named it as android.py and there are no .pyc files in my directory. Here is the snapshot $ python Python 2.7.2 (default, Jul 20 2013, 22:54:57) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more informatio

Re: cascading python executions only if return code is 0

2013-12-23 Thread Ethan Furman
On 12/22/2013 06:33 PM, Steven D'Aprano wrote: Roy Smith wrote: else: assert 0, "can't create picker (classes = %s)" % classes ¡Ay, caramba! I was with you until the very last line. The above code is possibly buggy and inappropriately designed. [...] First, the bug: the

Re: python socket query

2013-12-23 Thread Piet van Oostrum
smilesonisa...@gmail.com writes: > Hi, >I am trying to write a TCP socket program in python. I am using python 2.6 > in linux. > > I referred following link: > http://www.ibm.com/developerworks/linux/tutorials/l-pysocks/section4.html > I am actually writing the client-side stream socket. > I

Re: cascading python executions only if return code is 0

2013-12-23 Thread Mark Lawrence
On 23/12/2013 12:45, Ethan Furman wrote: Considering how easy it is to disable assertions, a circle in the sand is an amazingly appropriate metaphor. :) -- ~Ethan~ It might be easy, but surely it's far more fun providing an itertools solution :) -- My fellow Pythonistas, ask not what our

Re: cascading python executions only if return code is 0

2013-12-23 Thread Ethan Furman
On 12/22/2013 08:57 PM, Roy Smith wrote: In article <52b7a0e4$0$29994$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: Anyway, I may be completely misinterpreting what I'm reading. Perhaps the assertion is checking a function invariant ("one of the strategies will always succeed")

Re: Airplane mode control using Python?

2013-12-23 Thread Kevin Peterson
Hi Ned, I havenot named it as android.py and there are no .pyc files in my directory. Here is the snapshot $ python Python 2.7.2 (default, Jul 20 2013, 22:54:57) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import android >>> droid = android.And

Re: cascading python executions only if return code is 0

2013-12-23 Thread Mark Lawrence
On 22/12/2013 23:57, Rick Johnson wrote: On Sunday, December 22, 2013 5:02:51 PM UTC-6, Mark Lawrence wrote: On 22/12/2013 22:51, Chris Angelico wrote: if a() == 0: if b() == 0: c() I can only see one way that you can possibly intepret it. [snip molehill turned into Him

Re: cascading python executions only if return code is 0

2013-12-23 Thread Ned Batchelder
On 12/22/13 6:57 PM, Rick Johnson wrote: Even IF you are presented with a small snippet of code that include the identifier for the return value, you still cannot be certain that extrapolating meaning from an identifier*alone* will give you the insight to remove all ambiguity. For example, let'

Re: how to develop code using a mix of an existing python-program and console-commands

2013-12-23 Thread Jean-Michel Pichavant
- Original Message - > Am 18.12.13 21:17, schrieb Jean Dubois: > > I have a python-program which I want to perform its task first, > > then > > switch to > > the python console to experiment with further commands, using what > > was > > already > > defined in the python-program. > > Excell

Re: cascading python executions only if return code is 0

2013-12-23 Thread Rick Johnson
On Sunday, December 22, 2013 5:02:51 PM UTC-6, Mark Lawrence wrote: > On 22/12/2013 22:51, Chris Angelico wrote: > if a() == 0: > > if b() == 0: > > c() > > I can only see one way that you can possibly intepret it. Hmm, I guess i should not assume color vision to be ubiquitous. > [

Using asyncio in event-driven network library

2013-12-23 Thread Tobias M.
Hello, I am currently writing an event-driven client library for a network protocol [1] and chose to use the new asyncio module. I have no experience with asynchronous IO and don't understand all the concepts in asyncio yet. So I'm not sure if asyncio is actually the right choice . My goal:

Google Groups + this list

2013-12-23 Thread Ned Batchelder
On 12/22/13 11:52 PM, ru...@yahoo.com wrote: Come on Chris, it is just as easy to make typo or copy-and- paste errors in any other software as GG, there is no evidence that it was GG's fault. Can we agree that it's not great to respond to a new poster with *just* "please don't use GG, it's bad

Re: Airplane mode control using Python?

2013-12-23 Thread Mark Lawrence
On 23/12/2013 06:09, ru...@yahoo.com wrote: On Sunday, December 22, 2013 10:37:35 PM UTC-7, Chris Angelico wrote: Actually, formatting errors ARE often caused by Google Groups. Maybe it wasn't in this instance, but I have seen several cases of GG mangling code formatting, so this was a perfectly

Re: Airplane mode control using Python?

2013-12-23 Thread rurpy
On Sunday, December 22, 2013 10:37:35 PM UTC-7, Chris Angelico wrote: > Actually, formatting errors ARE often caused by Google Groups. Maybe > it wasn't in this instance, but I have seen several cases of GG > mangling code formatting, so this was a perfectly reasonable theory. What sort of formatt

Re: How can i return more than one value from a function to more than one variable

2013-12-23 Thread Gary Herron
On 12/22/2013 02:54 PM, dec...@msn.com wrote: basically what I wanna do is this : x = 4 y = 7 def switch (z,w): ***this will switch z to w and vice verca*** c= z z=w w=c print 'Now x =', w, 'and y = ' , z return w x = switch(x,y) How am I supposed to do so I can

Re: Trouble writing lines into file with line feeds- Python Newb

2013-12-23 Thread Jussi Piitulainen
daniel.t.he...@gmail.com writes: - - > Problem: The file only contains P2. It always overwrites the first > line. I can send 20 strings and the file will always contain the > last string received. - - > while True: > rawcode=ser.readline() > codelog=open('/home/pi/avdms/codes.log','

Re: How can i return more than one value from a function to more than one variable

2013-12-23 Thread Rick Johnson
On Sunday, December 22, 2013 4:54:46 PM UTC-6, dec...@msn.com wrote: > basically what I wanna do is this : > x = 4 > > y = 7 > def switch (z,w): > ***this will switch z to w and vice verca*** > c= z > z=w > w=c > print 'Now x =', w, 'and y = ' , z > return w > x = switch(x

Deamonify my python script on Android

2013-12-23 Thread Kevin Peterson
Hi, I want to daemonify my python script on Android device. That is, it should be automatically invoked on boot up. Appreciate your help. Thanks, Kevin Peterson -- https://mail.python.org/mailman/listinfo/python-list

Re: How can i return more than one value from a function to more than one variable

2013-12-23 Thread Simon Hayward
> basically what I wanna do is this : > > x = 4 > y = 7 > def switch (z,w): > ***this will switch z to w and vice verca*** > c= z > z=w > w=c > print 'Now x =', w, 'and y = ' , z > return w > x = switch(x,y) > > How am I supposed to do so I can return also a value to th

Re: Airplane mode control using Python?

2013-12-23 Thread Mark Lawrence
On 23/12/2013 08:46, Chris Angelico wrote: On Mon, Dec 23, 2013 at 5:59 PM, wrote: On Sunday, December 22, 2013 10:37:35 PM UTC-7, Chris Angelico wrote: Actually, formatting errors ARE often caused by Google Groups. Maybe it wasn't in this instance, but I have seen several cases of GG manglin

How can i return more than one value from a function to more than one variable

2013-12-23 Thread dec135
basically what I wanna do is this : x = 4 y = 7 def switch (z,w): ***this will switch z to w and vice verca*** c= z z=w w=c print 'Now x =', w, 'and y = ' , z return w x = switch(x,y) How am I supposed to do so I can return also a value to the variable y WITHOUT printi

Trouble writing lines into file with line feeds- Python Newb

2013-12-23 Thread daniel . t . healy
Overview: I'm attempting to read strings from a serial port. Each string ends with a carriage return and line feed. I want to write those strings to a file, like a log file. So, if I send P1 and the P2 on a new line, I would expect to open this file and find (line 1) P1 (line 2) P2. Problem: T

Re: Airplane mode control using Python?

2013-12-23 Thread Chris Angelico
On Mon, Dec 23, 2013 at 5:59 PM, wrote: > On Sunday, December 22, 2013 10:37:35 PM UTC-7, Chris Angelico wrote: >> Actually, formatting errors ARE often caused by Google Groups. Maybe >> it wasn't in this instance, but I have seen several cases of GG >> mangling code formatting, so this was a per

Re: 2nd Try: Trouble writing lines to file that include line feeds - Newbie

2013-12-23 Thread Gary Herron
On 12/22/2013 04:55 PM, Dan Healy wrote: Overview: I'm attempting to read strings from a serial port. Each string ends with a carriage return and line feed. I want to write those strings to a file, like a log file. So, if I send P1 and the P2 on a new line, I would expect to open this file and

Re: Airplane mode control using Python?

2013-12-23 Thread rurpy
On Sunday, December 22, 2013 10:37:35 PM UTC-7, Chris Angelico wrote: > Actually, formatting errors ARE often caused by Google Groups. Maybe > it wasn't in this instance, but I have seen several cases of GG > mangling code formatting, so this was a perfectly reasonable theory. And you have determi

Re: Newbie question. Are those different objects ?

2013-12-23 Thread Duncan Booth
Gregory Ewing wrote: > rusi wrote: >> Good idea. Only you were beaten to it by about 2 decades. > > More than 2, I think. > > Algol: x := y Wher := is pronounced 'becomes'. -- Duncan Booth http://kupuguy.blogspot.com -- https://mail.python.org/mailman/listinfo/python-list

2nd Try: Trouble writing lines to file that include line feeds - Newbie

2013-12-23 Thread Dan Healy
Overview: I'm attempting to read strings from a serial port. Each string ends with a carriage return and line feed. I want to write those strings to a file, like a log file. So, if I send P1 and the P2 on a new line, I would expect to open this file and find (line 1) P1 (line 2) P2. Problem: T