Re: Modern recommended exception handling practices?

2015-11-02 Thread Chris Angelico
On Tue, Nov 3, 2015 at 6:22 PM, Steven D'Aprano wrote: > A lot can happen in the few microseconds between > checking for the existence of the file and actually opening it -- the file > could be renamed or deleted. And a lot of microseconds can happen between two opcodes, too. Even inside a Python

Re: Modern recommended exception handling practices?

2015-11-02 Thread Steven D'Aprano
On Tue, 3 Nov 2015 06:16 pm, Chris Angelico wrote: > Not to mention having race condition possibilities. Arrggghhh! I knew there was something else I wanted to say. You're right. Sometimes you *have* to use exception handling code. Take this for example: if os.path.exists(pathname): f = op

Re: Regular expressions

2015-11-02 Thread Steven D'Aprano
On Tue, 3 Nov 2015 03:23 pm, ru...@yahoo.com wrote: > Regular expressions should be learned by every programmer or by anyone > who wants to use computers as a tool.  They are a fundamental part of > computer science and are used in all sorts of matching and searching > from compilers down to your

Re: Modern recommended exception handling practices?

2015-11-02 Thread Chris Angelico
On Tue, Nov 3, 2015 at 5:47 PM, Steven D'Aprano wrote: > On Fri, 30 Oct 2015 04:43 am, vasudevram wrote: > >> Are there any modern (i.e. for current versions of Python 2 and 3) >> recommended exception handling practices? > > When you say "modern", it sounds like you want to contrast them with "ol

Re: Unbuffered stderr in Python 3

2015-11-02 Thread Nobody
On Mon, 02 Nov 2015 18:52:55 +1100, Steven D'Aprano wrote: > In Python 2, stderr is unbuffered. > > In most other environments (the shell, C...) stderr is unbuffered. > > It is usually considered a bad, bad thing for stderr to be buffered. What > happens if your application is killed before the

Re: Modern recommended exception handling practices?

2015-11-02 Thread Steven D'Aprano
Hi Vasudev, and welcome. Sorry for the delay in replying to your questions. My answers inline, below. On Fri, 30 Oct 2015 04:43 am, vasudevram wrote: > Are there any modern (i.e. for current versions of Python 2 and 3) > recommended exception handling practices? When you say "modern", it sound

Re: Puzzled

2015-11-02 Thread Michael Torrie
On 11/02/2015 08:52 AM, Robinson, Wendy wrote: > [cid:image001.png@01D11543.5ED11D50] Just FYI this mailing list group is tied with with a system called USENET which is plain text only, so most of us can't see your attachment. This may help you copy the text to your messages in plain text form:

Re: Regular expressions

2015-11-02 Thread Michael Torrie
On 11/02/2015 09:23 PM, rurpy--- via Python-list wrote: >> My completely unsolicited advice is that regular expressions shouldn't be >> very high on the list of things to learn. They are very useful, and very >> tricky and prone many problems that can and should be learned to be >> resolved with m

Re: Regular expressions

2015-11-02 Thread Michael Torrie
On 11/02/2015 09:23 PM, rurpy--- via Python-list wrote: > On 11/02/2015 08:51 PM, Michael Torrie wrote: >> [...] >> Indeed, sometimes Jamie Zawinski's is often quite appropriate: >> >> Some people, when confronted with a problem, think "I know, I'll use >> regular expressions." Now they have tw

Re: Regular expressions

2015-11-02 Thread rurpy--- via Python-list
On Monday, November 2, 2015 at 8:58:45 PM UTC-7, Joel Goldstick wrote: > On Mon, Nov 2, 2015 at 10:17 PM, Seymore4Head > wrote: > > > On Mon, 2 Nov 2015 20:42:37 -0600, Tim Chase > > wrote: > > > > >On 2015-11-02 20:09, Seymore4Head wrote: > > >> How do I make a regular expression that returns t

Re: Regular expressions

2015-11-02 Thread rurpy--- via Python-list
On 11/02/2015 08:51 PM, Michael Torrie wrote: >[...] > Indeed, sometimes Jamie Zawinski's is often quite appropriate: > > Some people, when confronted with a problem, think "I know, I'll use > regular expressions." Now they have two problems. Or its sometimes heard paraphrase: Some people,

Re: Regular expressions

2015-11-02 Thread Joel Goldstick
On Mon, Nov 2, 2015 at 10:17 PM, Seymore4Head wrote: > On Mon, 2 Nov 2015 20:42:37 -0600, Tim Chase > wrote: > > >On 2015-11-02 20:09, Seymore4Head wrote: > >> How do I make a regular expression that returns true if the end of > >> the line is an asterisk > > > >Why use a regular expression? > >

Re: Regular expressions

2015-11-02 Thread Michael Torrie
On 11/02/2015 07:42 PM, Tim Chase wrote: > On 2015-11-02 20:09, Seymore4Head wrote: >> How do I make a regular expression that returns true if the end of >> the line is an asterisk > > Why use a regular expression? > > if line[-1] == '*': > yep(line) > else: > nope(line) Indeed, some

Re: Detection of a specific sound

2015-11-02 Thread Michael Torrie
On 10/25/2015 06:17 PM, Montana Burr wrote: > I'm looking for a library that will allow Python to listen for the shriek > of a smoke alarm. Once it detects this shriek, it is to notify someone. > Ideally, specificity can be adjusted for the user's environment. For > example, I expect to need modera

Re: Regular expressions

2015-11-02 Thread Seymore4Head
On Tue, 3 Nov 2015 01:19:34 +, MRAB wrote: >On 2015-11-03 01:09, Seymore4Head wrote: >> How do I make a regular expression that returns true if the end of the >> line is an asterisk >> >To match an asterisk: \* > >To match the end of a line: $ > >To match an asterisk at the end of a line: \*$

Re: Regular expressions

2015-11-02 Thread Seymore4Head
On Mon, 2 Nov 2015 20:42:37 -0600, Tim Chase wrote: >On 2015-11-02 20:09, Seymore4Head wrote: >> How do I make a regular expression that returns true if the end of >> the line is an asterisk > >Why use a regular expression? > > if line[-1] == '*': >yep(line) > else: >nope(line) > >-tkc

Re: Regular expressions

2015-11-02 Thread Tim Chase
On 2015-11-02 20:09, Seymore4Head wrote: > How do I make a regular expression that returns true if the end of > the line is an asterisk Why use a regular expression? if line[-1] == '*': yep(line) else: nope(line) -tkc -- https://mail.python.org/mailman/listinfo/python-list

Re: Regular expressions

2015-11-02 Thread MRAB
On 2015-11-03 01:09, Seymore4Head wrote: How do I make a regular expression that returns true if the end of the line is an asterisk To match an asterisk: \* To match the end of a line: $ To match an asterisk at the end of a line: \*$ -- https://mail.python.org/mailman/listinfo/python-list

Regular expressions

2015-11-02 Thread Seymore4Head
How do I make a regular expression that returns true if the end of the line is an asterisk -- https://mail.python.org/mailman/listinfo/python-list

Re: GoPiGo script

2015-11-02 Thread Robin Koch
Am 02.11.2015 um 22:06 schrieb Larry Hudson: [snip a lot of text, also using the word intend...] The word you want is indent not intend. Oops. Of course you are right. You might have noticed, english isn't my native language. Not an excuse, but an explanation. ;-) I can only hope, that Loek

Re: Detection of a specific sound

2015-11-02 Thread Lorenzo Sutton
On 26/10/15 01:17, Montana Burr wrote: I'm looking for a library that will allow Python to listen for the shriek of a smoke alarm. Once it detects this shriek, it is to notify someone. Ideally, specificity can be adjusted for the user's environment. For example, I expect to need moderate specific

Re: GoPiGo script

2015-11-02 Thread Larry Hudson via Python-list
On 11/02/2015 11:31 AM, Robin Koch wrote: Am 02.11.2015 um 15:32 schrieb input/ldompel...@casema.nl: Thank you for the explanation for it. I must tell you that i yust beginning with python. I bought the book beginning programming with python. Have you programming experience with other langua

Re: How to handle exceptions properly in a pythonic way?

2015-11-02 Thread Ian Kelly
On Mon, Nov 2, 2015 at 12:24 PM, wrote: > I have read some articles that returning None is not a good approach, so I am > confused. > > How to handle exceptions properly in a pythonic way? I'm having a hard time understanding what question you're asking. You have a lot of discussion about where

Re: How to handle exceptions properly in a pythonic way?

2015-11-02 Thread John Gordon
In <4b303213-62e2-42d4-b2f6-4fc1f6025...@googlegroups.com> zljubi...@gmail.com writes: > Let's say that I have the following simple function: > def get_html(url): > wpage = requests.get(url) > > return wpage.text > How to handle exceptions properly that can arise during execution

Re: GoPiGo script

2015-11-02 Thread Robin Koch
Am 02.11.2015 um 15:32 schrieb input/ldompel...@casema.nl: Thank you for the explanation for it. I must tell you that i yust beginning with python. I bought the book beginning programming with python. Have you programming experience with other languages? Well, the very first thing you should

How to handle exceptions properly in a pythonic way?

2015-11-02 Thread zljubisic
Let's say that I have the following simple function: def get_html(url): wpage = requests.get(url) return wpage.text How to handle exceptions properly that can arise during execution of the requests.get(url)? If I call this function with try: html = get_html('www.abc.com/index

Re: need help understanding a python program

2015-11-02 Thread Ben Finney
Lee Bradley writes: > http://pastebin.com/ndDYjYe1 We much prefer to discuss code in the context of plain text messages right here, because this forum is archived longer than the expected lifetime of content hosted on other services. > For now I am looking for someone who can dig into this code

need help understanding a python program

2015-11-02 Thread Lee Bradley
http://pastebin.com/ndDYjYe1 The above link takes you to a very interesting way of solving the classic game of Bulls and Cows. It uses an entropy-based decision algorithm. I realize this is asking a lot but I am not yet proficient enough in python to follow some of the methods. There is a fair

RE: Puzzled

2015-11-02 Thread Robinson, Wendy
[cid:image001.png@01D11543.5ED11D50] Wendy Robinson Audit Analyst (916) 566-4994 phone NOTICE OF CONFIDENTIALITY: This email is for the sole use of the intended recipient and may contain material that is confidential and protected by state and federal regulations. If you are not the

Re: installer user interface glitch ?

2015-11-02 Thread rurpy--- via Python-list
On Sunday, November 1, 2015 at 2:48:58 PM UTC-7, Laura Creighton wrote: > Actually, adding the XP - do not look here -- > message for several webpages has been on the pydotorg > todo list for more than a week now. > > Not sure why it hasn't happened. > > Thank you for the reminder. You're welcom

Re: GoPiGo script

2015-11-02 Thread hakugin . gin
On Monday, November 2, 2015 at 10:21:46 AM UTC-5, MRAB wrote: > On 2015-11-02 14:28, input/ldom...@casema.nl wrote: > > He mike, > > > > Thank you or making this script. > > Only I get errors for sleep. > > I also tried to change it to time.sleep() but that also gives errors. > > > > File "test05.p

Re: GoPiGo script

2015-11-02 Thread MRAB
On 2015-11-02 14:28, input/ldompel...@casema.nl wrote: He mike, Thank you or making this script. Only I get errors for sleep. I also tried to change it to time.sleep() but that also gives errors. File "test05.py", line 23 sleep(2) ^ SyntaxError: invalid syntax

Re: GoPiGo script

2015-11-02 Thread hakugin . gin
On Monday, November 2, 2015 at 9:28:35 AM UTC-5, input/ld...@casema.nl wrote: > He mike, > > Thank you or making this script. > Only I get errors for sleep. > I also tried to change it to time.sleep() but that also gives errors. > > File "test05.py", line 23 > sleep(2) > ^ > SyntaxErr

Re: help

2015-11-02 Thread Ian Kelly
On Nov 2, 2015 7:31 AM, "Gabe Clark" wrote: > > i am currently running python 3.5 in my programming class and when ever i > go to open one of my saved files or a file saved by some one else this new > tab pops up and says modify, repair, or uninstall i have uninstalled and > repaired it multiple t

Re: GoPiGo script

2015-11-02 Thread input/ldompeling
Thank you for the explanation for it. I must tell you that i yust beginning with python. I bought the book beginning programming with python. In reply to "Dennis Lee Bieber" who wrote the following: > On Mon, 02 Nov 2015 13:29:04 GMT, input/ldompel...@casema.nl declaimed the > following:

Re: same problem even after repair

2015-11-02 Thread Sibylle Koczian
Am 02.11.2015 um 13:35 schrieb Daniel Joffe: Didn't you see the answers to your first posting? All of them earlier than this. Sibylle -- https://mail.python.org/mailman/listinfo/python-list

Re: GoPiGo script

2015-11-02 Thread input/ldompeling
He mike, Thank you or making this script. Only I get errors for sleep. I also tried to change it to time.sleep() but that also gives errors. File "test05.py", line 23 sleep(2) ^ SyntaxError: invalid syntax ---

help

2015-11-02 Thread Gabe Clark
i am currently running python 3.5 in my programming class and when ever i go to open one of my saved files or a file saved by some one else this new tab pops up and says modify, repair, or uninstall i have uninstalled and repaired it multiple times to no success please help -- https://mail.python.

Re: Python 2 vs Python 3 for teaching

2015-11-02 Thread Chris Angelico
On Tue, Nov 3, 2015 at 12:15 AM, beliavsky--- via Python-list wrote: > I think Python 2.x is still used more than Python 3.x in scientific > computing. The Python books I have in this area, such as "Python for Finance: > Analyze Big Financial Data" and "Python for Data Analysis", still use Pytho

Re: GoPiGo script

2015-11-02 Thread hakugin . gin
On Monday, November 2, 2015 at 8:45:35 AM UTC-5, hakug...@gmail.com wrote: > On Monday, November 2, 2015 at 8:29:26 AM UTC-5, input/ld...@casema.nl wrote: > > I tried to use def loop(): now for to restart the script. > > but its only restart "fwd()" print ("forward 1x") and then stop. > > It does n

Re: GoPiGo script

2015-11-02 Thread hakugin . gin
On Monday, November 2, 2015 at 8:29:26 AM UTC-5, input/ld...@casema.nl wrote: > I tried to use def loop(): now for to restart the script. > but its only restart "fwd()" print ("forward 1x") and then stop. > It does not look further for the if function. > Is there another way to restart this script

Re: GoPiGo script

2015-11-02 Thread input/ldompeling
I tried to use def loop(): now for to restart the script. but its only restart "fwd()" print ("forward 1x") and then stop. It does not look further for the if function. Is there another way to restart this script ? I also tried with (while True:) but that does nothing. Thanks ---

Re: Python 2 vs Python 3 for teaching

2015-11-02 Thread beliavsky--- via Python-list
I think Python 2.x is still used more than Python 3.x in scientific computing. The Python books I have in this area, such as "Python for Finance: Analyze Big Financial Data" and "Python for Data Analysis", still use Python 2.x . An aspiring computational scientist, data scientist, or financial q

same problem even after repair

2015-11-02 Thread Daniel Joffe
-- https://mail.python.org/mailman/listinfo/python-list

Re: Problem in implementing Romania Map using Paython Script

2015-11-02 Thread Terry Reedy
On 11/2/2015 12:45 AM, Ben Finney wrote: amn...@gmail.com writes: I need a help in completing the Class Roaming problem using Euclidean function , Completing the Class Node . I think you need to research how to solve this algorithm, and only *then* think about how to code it in Python. I

Re: Unbuffered stderr in Python 3

2015-11-02 Thread Wolfgang Maier
On 02.11.2015 11:48, Wolfgang Maier wrote: Since Python3.3, the print function has a flush keyword argument that accepts a boolean and lets you do just this. Rewrite your example as: import sys, time def test(): # Simulate a slow calculation that prints status and/or error # messages to stderr

Re: Unbuffered stderr in Python 3

2015-11-02 Thread Wolfgang Maier
On 02.11.2015 08:52, Steven D'Aprano wrote: In Python 2, stderr is unbuffered. In most other environments (the shell, C...) stderr is unbuffered. It is usually considered a bad, bad thing for stderr to be buffered. What happens if your application is killed before the buffer fills up? The error

Re: python doesn't install

2015-11-02 Thread Chris Warrick
On 2 November 2015 at 09:28, Dave Farrance wrote: > Yes, I've read the justifications. Why list all the non-supported OSs? > And the explanation about each version of Python being supported just > for the supported versions of Windows upon its release is in the > documentation -- somewhere. But i

Re: python doesn't install

2015-11-02 Thread Tim Golden
On 02/11/2015 06:16, Tim Golden wrote: > On 02/11/2015 00:08, Daniel Joffe wrote: >> WinXP...32 bits...professional >> >> I keep getting message >> >> >> note also that there is no place on the install box to start...you just >> click somewhere, and the install started. >> > > I'm afraid you've be

Re: python doesn't install

2015-11-02 Thread Dave Farrance
Tim Golden wrote: >I'm afraid you've been bitten by the fact that we no longer support >Windows XP and haven't communicated this very well. We have a new >version of the installer almost ready for release which indicates this >much earlier (and more obviously). I'm afraid if you're on XP you'r

Unbuffered stderr in Python 3

2015-11-02 Thread Steven D'Aprano
In Python 2, stderr is unbuffered. In most other environments (the shell, C...) stderr is unbuffered. It is usually considered a bad, bad thing for stderr to be buffered. What happens if your application is killed before the buffer fills up? The errors in the buffer will be lost. So how come P