Re: logger.info / logger.error with logger.addHandler - how to split streams?

2016-12-28 Thread Alec Taylor
Thanks On Tue, Dec 27, 2016 at 2:57 AM, gst wrote: > Le lundi 26 décembre 2016 10:34:48 UTC-5, Alec Taylor a écrit : > > So I'm putting .info in one StringIO and .error in another StringIO. > > > > How do I stop them from both being put into both? > > > > Code: http://ideone.com/Nj6Asz > > > Hi,

Re: ctypes, memory mapped files and context manager

2016-12-28 Thread Hans-Peter Jansen
On Mittwoch, 28. Dezember 2016 16:53:53 Hans-Peter Jansen wrote: > On Mittwoch, 28. Dezember 2016 15:17:22 Hans-Peter Jansen wrote: > > On Mittwoch, 28. Dezember 2016 13:48:48 Peter Otten wrote: > > > Hans-Peter Jansen wrote: > > > > Dear Peter, > > > > > > > > thanks for taking valuable time to l

Re: Re: Mock object bug with assert_not_called (Steve D'Aprano)

2016-12-28 Thread Steve D'Aprano
On Thu, 29 Dec 2016 10:36 am, Diego Vela wrote: > Re: mock bug. > > Python 2.7.8 > > > I'll provide a sketch of the code since it is from work and I'm not > allowed to share it directly. We don't want to see your entire code base. We want to see the smallest, simplest example that demonstrates

Re: Re: Mock object bug with assert_not_called (Steve D'Aprano)

2016-12-28 Thread Diego Vela
Re: mock bug. Python 2.7.8 I'll provide a sketch of the code since it is from work and I'm not allowed to share it directly. Sketch of Code: @patch('emails.emails.render_to_string') def test_send_email(self, render): context = { 'key': value } emails.send_email() # calls r

Re: ctypes, memory mapped files and context manager

2016-12-28 Thread Hans-Peter Jansen
On Mittwoch, 28. Dezember 2016 21:58:38 Peter Otten wrote: > Hans-Peter Jansen wrote: > > On Mittwoch, 28. Dezember 2016 13:48:48 Peter Otten wrote: > >> Hans-Peter Jansen wrote: > > It leaves the question on why is Python2 acting as one would expect > > related to context managers, and Python3 nee

Re: Parse a Wireshark pcap file

2016-12-28 Thread Michiel Overtoom
> On 2016-12-27, at 20:46, 1991manish.ku...@gmail.com wrote: > > I have a pcap file, I want to parse that file & fetch some information like > Timestamp, Packet Size, Source/Dest IP Address, Source/Dest Port, Source/ > Dest MAC address. pcapy can do this. import pcapy pcap = pcapy.open_offlin

Re: ctypes, memory mapped files and context manager

2016-12-28 Thread Peter Otten
Hans-Peter Jansen wrote: > On Mittwoch, 28. Dezember 2016 13:48:48 Peter Otten wrote: >> Hans-Peter Jansen wrote: >> > Dear Peter, >> > >> > thanks for taking valuable time to look into my issue. >> >> You're welcome! >> >> > It might be related to my distinct silliness, but the problem persist

Re: sorting strings numerically while dealing with missing values

2016-12-28 Thread Ian Kelly
On Wed, Dec 28, 2016 at 2:43 PM, Ian Kelly wrote: > On Wed, Dec 28, 2016 at 2:14 PM, Larry Martell > wrote: >> >> I have a list containing a list of strings that I want to sort >> numerically by one of the fields. I am doing this: >> >> sorted(rows, key=float(itemgetter(sortby))) > > I'm guessin

Re: sorting strings numerically while dealing with missing values

2016-12-28 Thread Ian Kelly
On Wed, Dec 28, 2016 at 2:14 PM, Larry Martell wrote: > > I have a list containing a list of strings that I want to sort > numerically by one of the fields. I am doing this: > > sorted(rows, key=float(itemgetter(sortby))) I'm guessing that you left out a lambda here since the key argument takes a

Re: sorting strings numerically while dealing with missing values

2016-12-28 Thread Peter Otten
Larry Martell wrote: > I have a list containing a list of strings that I want to sort > numerically by one of the fields. I am doing this: > > sorted(rows, key=float(itemgetter(sortby))) > > Which works fine as long as all the sort keys convert to a float. No, that cannot work; unless you have

sorting strings numerically while dealing with missing values

2016-12-28 Thread Larry Martell
I have a list containing a list of strings that I want to sort numerically by one of the fields. I am doing this: sorted(rows, key=float(itemgetter(sortby))) Which works fine as long as all the sort keys convert to a float. Problem is that some are blank or None and those throw an exception. How

Re: ctypes, memory mapped files and context manager

2016-12-28 Thread Hans-Peter Jansen
On Mittwoch, 28. Dezember 2016 15:17:22 Hans-Peter Jansen wrote: > On Mittwoch, 28. Dezember 2016 13:48:48 Peter Otten wrote: > > Hans-Peter Jansen wrote: > > > Dear Peter, > > > > > > thanks for taking valuable time to look into my issue. > > > > You're welcome! > > > > > It might be related to

Re: ctypes, memory mapped files and context manager

2016-12-28 Thread Hans-Peter Jansen
On Mittwoch, 28. Dezember 2016 13:48:48 Peter Otten wrote: > Hans-Peter Jansen wrote: > > Dear Peter, > > > > thanks for taking valuable time to look into my issue. > > You're welcome! > > > It might be related to my distinct silliness, but the problem persists > > with your code as well. > > U

Re: Garbage collection problem with generators

2016-12-28 Thread Haochuan Guo
Sorry about breaking the rule. I'm just curios about this problem. And I'm using this workaround to prevent redundant resource creation. https://gist.githubusercontent.com/wooparadog/16948ca6c8ffb22214bf491a280406da/raw/- On Wed, Dec 28, 2016 at 9:12 PM Chris Angelico wrote: > On Wed, Dec 28,

Re: Garbage collection problem with generators

2016-12-28 Thread Chris Angelico
On Wed, Dec 28, 2016 at 9:03 PM, Haochuan Guo wrote: > Anyone? The script to reproduce this problem is in: > > https://gist.github.com/wooparadog/766f8007d4ef1227f283f1b040f102ef > > On Fri, Dec 23, 2016 at 8:39 PM Haochuan Guo wrote: > >> This is reproducible with python2.7, but not in python3.5

Re: Garbage collection problem with generators

2016-12-28 Thread Haochuan Guo
Anyone? The script to reproduce this problem is in: https://gist.github.com/wooparadog/766f8007d4ef1227f283f1b040f102ef On Fri, Dec 23, 2016 at 8:39 PM Haochuan Guo wrote: > Hi, everyone > > I'm building a http long polling client for our company's discovery > service and something weird happen

Re: ctypes, memory mapped files and context manager

2016-12-28 Thread Peter Otten
Hans-Peter Jansen wrote: > Dear Peter, > > thanks for taking valuable time to look into my issue. You're welcome! > It might be related to my distinct silliness, but the problem persists > with your code as well. Unfortunately I posted the broken toy example rather than the fixed one. Here's

Re: ctypes, memory mapped files and context manager

2016-12-28 Thread Hans-Peter Jansen
Dear Peter, thanks for taking valuable time to look into my issue. It might be related to my distinct silliness, but the problem persists with your code as well. Further comments inlined. On Dienstag, 27. Dezember 2016 21:39:51 Peter Otten wrote: > Hans-Peter Jansen wrote: > > > > def __