Re: how do I retry a command only for a specific exception / error

2018-03-15 Thread Steven D'Aprano
On Fri, 16 Mar 2018 11:04:22 +0530, Ganesh Pal wrote: > All that I am trying to do here is write a generic function that will > re-retry > the command few more times before failing the test Something like this should do it. It gives up immediately on fatal errors and tries again on temporary

how do I retry a command only for a specific exception / error

2018-03-15 Thread Ganesh Pal
import time from functools import wraps from qa.utils.easy_popen import run def retry(ExceptionToCheck, tries=4, delay=5, backoff=2, logger=None): """ Retry calling the decorated function """ def deco_retry(f): @wraps(f) def f_retry(*args, **kwargs):

Re: macOS specific - reading calendar information

2018-03-15 Thread Ned Deily
On 2018-03-15 03:58, Christian Gollwitzer wrote: > Am 15.03.18 um 08:32 schrieb Jan Erik Moström: >> I would like to read what calendar events I have on a range of days. I >> would like to get the data from whatever storage Calendar use, in my >> personal case I sync to iCloud. [...] > The native s

Re: urllib.request.urlopen fails with https

2018-03-15 Thread Ned Deily
On 2018-03-14 18:04, Irv Kalb wrote: > File > "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", > line 1320, in do_open > raise URLError(err) > urllib.error.URLError: certificate verify failed (_ssl.c:749)> If you are using Python 3.6 for macOS from a py

Re: Python gotcha of the day

2018-03-15 Thread Python
On Thu, Mar 15, 2018 at 10:21:24AM +0100, Thomas Jollans wrote: > On 2018-03-15 07:11, Ben Finney wrote: > > Steven D'Aprano writes: > > > >> py> """\"" [...] > Then riddle me this: > > if """\"" is equivalent to "" + "\"" + "" + "", then why isn't > """ \""" """ equivalent to "" + " \""

Re: number of loops

2018-03-15 Thread Dan Stromberg
On Thu, Mar 15, 2018 at 8:25 AM, Bob Gailer wrote: > On Mar 15, 2018 9:30 AM, wrote: >> >> I would like to have this offer 6 guesses, but instead it gives one guess > and prints the if statement/output 6 timesany ideas where I went wrong? > > I suggest you conduct a walk-through. That means p

Re: Python installer hangs in Windows 7

2018-03-15 Thread simon . wonng
On Monday, December 4, 2017 at 12:44:48 PM UTC-8, christian...@gmail.com wrote: > Same with me, except that I tried to install Python 3.6.3. Unchecking > "Install launcher for all users" helped, however. This worked for me, thanks! -- https://mail.python.org/mailman/listinfo/python-list

Re: List slicing on Python 2.7

2018-03-15 Thread Ned Batchelder
On 3/15/18 12:35 PM, Peter Otten wrote: Ned Batchelder wrote: On 3/15/18 9:57 AM, Vlastimil Brom wrote: 2018-03-15 12:54 GMT+01:00 Arkadiusz Bulski : I have a custom class (a lazy list-like container) that needs to support slicing. The __getitem__ checks if index is of slice type, and does a

Re: Context manager on method call from class

2018-03-15 Thread Joseph L. Casale
From: Python-list on behalf of Rob Gaddi Sent: Thursday, March 15, 2018 12:47 PM To: python-list@python.org Subject: Re: Context manager on method call from class   > from contextlib import contextmanager. > > Then you just use the @contextmanager decorator on a function, have it > set up,

Re: Python gotcha of the day

2018-03-15 Thread Ben Finney
Thomas Jollans writes: > Then riddle me this: > > if """\"" is equivalent to "" + "\"" + "" + "", then why isn't > """ \""" """ equivalent to "" + " \"" + " " + ""? Who can say? I was only asked for an explanation, not a consistent one :-) Perhaps it's a micro-optimisation, to create more e

Re: Context manager on method call from class

2018-03-15 Thread Rob Gaddi
On 03/15/2018 11:17 AM, Joseph L. Casale wrote: I have a class which implements a context manager, its __init__ has a signature and the __enter__ returns an instance of the class. Along with several methods which implement functionality on the instance, I have one method which itself must open a

Context manager on method call from class

2018-03-15 Thread Joseph L. Casale
I have a class which implements a context manager, its __init__ has a signature and the __enter__ returns an instance of the class. Along with several methods which implement functionality on the instance, I have one method which itself must open a context manager against a call on an instance att

Re: List slicing on Python 2.7

2018-03-15 Thread Peter Otten
Ned Batchelder wrote: > On 3/15/18 9:57 AM, Vlastimil Brom wrote: >> 2018-03-15 12:54 GMT+01:00 Arkadiusz Bulski : >>> I have a custom class (a lazy list-like container) that needs to support >>> slicing. The __getitem__ checks if index is of slice type, and does a >>> list comprehension over indi

Re: List slicing on Python 2.7

2018-03-15 Thread Arkadiusz Bulski
Found the answer on stack overflow. Some types on some runtimes (builtins and on Python 2) use another method __getslice__ instead of __getitem__. https://docs.python.org/2/reference/datamodel.html#object.__getslice__ czw., 15 mar 2018 o 12:54 użytkownik Arkadiusz Bulski napisał: > I have a cus

Re: urllib.request.urlopen fails with https

2018-03-15 Thread Irv Kalb
On Mar 14, 2018, at 9:54 PM, Gregory Ewing wrote: > > Chris Angelico wrote: >> That means going back to the original problem: "how do we get a usable >> stock price API?". > > Does it have to be stock prices in particular? > Or just some simple piece of data that demonstrates > the principles of

Re: number of loops

2018-03-15 Thread Bob Gailer
On Mar 15, 2018 9:30 AM, wrote: > > I would like to have this offer 6 guesses, but instead it gives one guess and prints the if statement/output 6 timesany ideas where I went wrong? I suggest you conduct a walk-through. That means pointing using a pencil or a mouse pointer at each statement a

Re: List slicing on Python 2.7

2018-03-15 Thread Ned Batchelder
On 3/15/18 9:57 AM, Vlastimil Brom wrote: 2018-03-15 12:54 GMT+01:00 Arkadiusz Bulski : I have a custom class (a lazy list-like container) that needs to support slicing. The __getitem__ checks if index is of slice type, and does a list comprehension over individual integer indexes. The code work

Re: List slicing on Python 2.7

2018-03-15 Thread Vlastimil Brom
2018-03-15 12:54 GMT+01:00 Arkadiusz Bulski : > I have a custom class (a lazy list-like container) that needs to support > slicing. The __getitem__ checks if index is of slice type, and does a list > comprehension over individual integer indexes. The code works fine on > Python 3 but fails on 2.7,

number of loops

2018-03-15 Thread michealmancini
I would like to have this offer 6 guesses, but instead it gives one guess and prints the if statement/output 6 timesany ideas where I went wrong? import random number_of_guesses = 0 print ('Hello! what is your name?') my_name=input() print (my_name + " " + 'sounds like the name of my next

Re: Enumerating all 3-tuples

2018-03-15 Thread Denis Kasak
On 2018-03-13 23:56, Denis Kasak wrote: On 2018-03-10 02:13, Steven D'Aprano wrote: But I've stared at this for an hour and I can't see how to extend the result to three coordinates. I can lay out a grid in the order I want: 1,1,1 1,1,2 1,1,3 1,1,4 ... 2,1,1 2,1,2 2,1,3 2,1,4 .

List slicing on Python 2.7

2018-03-15 Thread Arkadiusz Bulski
I have a custom class (a lazy list-like container) that needs to support slicing. The __getitem__ checks if index is of slice type, and does a list comprehension over individual integer indexes. The code works fine on Python 3 but fails on 2.7, both CPython and PyPy. The print inside __getitem__ do

Re: Enumerating all 3-tuples (Posting On Python-List Prohibited)

2018-03-15 Thread Ben Bacarisse
Lawrence D’Oliveiro writes: > On Thursday, March 15, 2018 at 2:56:24 PM UTC+13, Ben Bacarisse wrote: >> >> Lawrence D’Oliveiro writes: >> >>> On Wednesday, March 14, 2018 at 2:18:24 PM UTC+13, Ben Bacarisse wrote: >>> Lawrence D’Oliveiro writes: The original problem -- triples of

Re: Homebrew changed default Python to python 3!

2018-03-15 Thread INADA Naoki
FYI, they reverted python->python3 symlink. python command is now Python 2 again. https://discourse.brew.sh/t/python-and-pep-394/1813 Even though this revert, it is significant step: * many formulas dropped `depends_on "python"`. Python 2 was installed often by dependency before but it's rare

Re: Python gotcha of the day

2018-03-15 Thread Thomas Jollans
On 2018-03-15 07:11, Ben Finney wrote: > Steven D'Aprano writes: > >> py> """\"" >> '"' > > That's an empty string delimited by ‘"’; followed by a double-quote > character, escaped, delimited by ‘"’; followed by two more empty > strings. They concatenate to a single one-character string. >

Re: macOS specific - reading calendar information

2018-03-15 Thread Christian Gollwitzer
Am 15.03.18 um 08:32 schrieb Jan Erik Moström: I would like to read what calendar events I have on a range of days. I would like to get the data from whatever storage Calendar use, in my personal case I sync to iCloud. An example would be something along these lines x = getcalendarevents('201

Re: macOS specific - reading calendar information

2018-03-15 Thread Jan Erik Moström
On 14 Mar 2018, at 21:40, Larry Martell wrote: I've been trying to find some example of how to read calendar info on macOS but I haven't found anything ... I'm probably just bad at searching !! What I want to do is to read calendar info for a date range. Does anyone know of an example of ho