Re: Handling exceptions with Py2 and Py3

2016-05-27 Thread Pavlos Parissis
On 27/05/2016 02:51 μμ, Steven D'Aprano wrote: > On Fri, 27 May 2016 10:24 pm, Pavlos Parissis wrote: > >> Hi, >> >> So, we have ConnectionRefusedError in Python3 but not in Python2. >> Six module doesn't provide a wrapper about this. >> >> What

Handling exceptions with Py2 and Py3

2016-05-27 Thread Pavlos Parissis
Hi, So, we have ConnectionRefusedError in Python3 but not in Python2. Six module doesn't provide a wrapper about this. What is most efficient way to handle this situation in a try-catch block? Cheers, Pavlos signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mail

Re: intermittent ValueErrors from subprocess

2016-05-15 Thread Pavlos Parissis
On 16/05/2016 12:59 πμ, Chris Angelico wrote: > On Mon, May 16, 2016 at 8:32 AM, Pavlos Parissis > wrote: >>> Searching the CPython sources for that exception shows one hit: >>> selectors.py, where it converts a file object to an integer file >>> descriptor. (You

Re: intermittent ValueErrors from subprocess

2016-05-15 Thread Pavlos Parissis
On 16/05/2016 12:08 πμ, Chris Angelico wrote: > On Mon, May 16, 2016 at 1:49 AM, Pavlos Parissis > wrote: >> I use subprocess.check_output like this: >> >> cmd = [ >> '/sbin/ip', >> 'address', >> 'show'

intermittent ValueErrors from subprocess

2016-05-15 Thread Pavlos Parissis
Hi, I get intermittent ValueErrors[1] from subprocess when I check if an IP is assigned to loopback interface by running: /sbin/ip address show dev lo to 10.52.12.2/32 I use subprocess.check_output like this: cmd = [ '/sbin/ip', 'address', 'show', 'dev', "{}".format(self.con

asyncio for UNIX socket

2015-12-16 Thread Pavlos Parissis
Hi, I am trying to write UNIX socket client which sends 1 cmd and saves the received data to a file. Based on what I found on documentation I came up with:: import asyncio class UnixProtocol(asyncio.Protocol): def __init__(self, loop): self.cmd = 'show stat\n' self.loop = loop

Re: subclassing collections.Counter

2015-12-15 Thread Pavlos Parissis
On 15/12/2015 06:55 μμ, Ian Kelly wrote: > On Tue, Dec 15, 2015 at 10:43 AM, Pavlos Parissis > wrote: >>> If you want your metrics container to act like a dict, then my >>> suggestion would be to just use a dict, with pseudo-collections for >>> the values as abo

Re: subclassing collections.Counter

2015-12-15 Thread Pavlos Parissis
On 15/12/2015 06:22 μμ, Ian Kelly wrote: > On Tue, Dec 15, 2015 at 9:20 AM, Pavlos Parissis > wrote: >> On 15/12/2015 05:11 μμ, Ian Kelly wrote: >>> On Tue, Dec 15, 2015 at 8:49 AM, Pavlos Parissis >>> wrote: >>>> Hi, >>>> >>>>

Re: subclassing collections.Counter

2015-12-15 Thread Pavlos Parissis
On 15/12/2015 05:18 μμ, Pavlos Parissis wrote: > On 15/12/2015 05:08 μμ, Peter Otten wrote: >> Pavlos Parissis wrote: >> >>> I need to store values for metrics and return the average for some >>> and the sum for the rest. Thus, I thought I could extend >>&

Re: subclassing collections.Counter

2015-12-15 Thread Pavlos Parissis
On 15/12/2015 05:11 μμ, Ian Kelly wrote: > On Tue, Dec 15, 2015 at 8:49 AM, Pavlos Parissis > wrote: >> Hi, >> >> I need to store values for metrics and return the average for some >> and the sum for the rest. Thus, I thought I could extend >> collections.Cou

Re: subclassing collections.Counter

2015-12-15 Thread Pavlos Parissis
On 15/12/2015 05:08 μμ, Peter Otten wrote: > Pavlos Parissis wrote: > >> I need to store values for metrics and return the average for some >> and the sum for the rest. Thus, I thought I could extend >> collections.Counter class by returning averages for some keys. >

subclassing collections.Counter

2015-12-15 Thread Pavlos Parissis
Hi, I need to store values for metrics and return the average for some and the sum for the rest. Thus, I thought I could extend collections.Counter class by returning averages for some keys. My class modifies the update() to increment a counter and the __getitem__ to perform the calculation. But,

Re: list slice and generators

2015-11-25 Thread Pavlos Parissis
On 25/11/2015 11:07 πμ, Peter Otten wrote: > Pavlos Parissis wrote: > >> Hi, >> >> Do you see any possible dangerous hidden bug in the below code(using >> python2.7 and python3.4)? >> >> My goal is to avoid go through the metrics list twice. But, I don

list slice and generators

2015-11-24 Thread Pavlos Parissis
Hi, Do you see any possible dangerous hidden bug in the below code(using python2.7 and python3.4)? My goal is to avoid go through the metrics list twice. But, I don't know if there will be a problem with doing in place replace of list elements using 2 generators. # metrics = ['', '0', '10']