Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Marko Rauhamaa
"Frank Millman" : > "Marko Rauhamaa" wrote in message news:87vaulitxe@elektro.pacujo.net... >> >> "Frank Millman" : >> >> > I changed 'await self.close()', to > >> 'asyncio.ensure_future(self.close())'. >> > >> > Problem solved. >> >> A nice insight. >> >> However, shouldn't somebody somewher

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:87vaulitxe@elektro.pacujo.net... "Frank Millman" : > I changed 'await self.close()', to > 'asyncio.ensure_future(self.close())'. > > Problem solved. A nice insight. However, shouldn't somebody somewhere in your code be keeping track of the returne

Re: Wrong release date in 3.6 whats new docs?

2016-12-14 Thread Nick Sarbicki
I'm aware of the the schedule in the PEP. But if the date at the top of the What's New page is the last day it was updated and not the release date then that is what has caused the confusion. On Wed, 14 Dec 2016, 22:58 , wrote: > On Wednesday, December 14, 2016 at 2:09:22 PM UTC, Nick Sarbicki

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Marko Rauhamaa
"Frank Millman" : > I changed 'await self.close()', to 'asyncio.ensure_future(self.close())'. > > Problem solved. A nice insight. However, shouldn't somebody somewhere in your code be keeping track of the returned task? Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmoFyJqYw4G_kNo5Sn=ULyjgm=kexqrqvwubr87evbz...@mail.gmail.com... When you work with threads, it's pretty straight-forward to spin off another thread: you start it. Your current thread continues, and the other one runs in parallel. What's the most str

Re: Running python from pty without prompt

2016-12-14 Thread Michael Torrie
On 12/14/2016 09:29 PM, Samuel Williams wrote: > Here are some examples of different languages: > > https://github.com/ioquatix/script-runner/blob/master/examples/python-eot.py Okay so it looks like you're just opening a pipe to a subprocess and feeding it a script and input. So there's no pty i

Re: Python3, column names from array - numpy or pandas

2016-12-14 Thread Miki Tebeka
You can do this with pandas: import pandas as pd from io import StringIO io = StringIO('''\ idABCDE 10010000 10101100 10210

Re: Running python from pty without prompt

2016-12-14 Thread Samuel Williams
Here are some examples of different languages: https://github.com/ioquatix/script-runner/blob/master/examples/python-eot.py -- https://mail.python.org/mailman/listinfo/python-list

Python3, column names from array - numpy or pandas

2016-12-14 Thread renjith madhavan
I have a dataset in the below format. id A B C D E 100 1 0 0 0 0 101 0 1 1 0 0 102 1 0 0 0 0 103 0 0 0 1 1 I would like to convert this into below: 100, A 1

Re: Running python from pty without prompt

2016-12-14 Thread Steve D'Aprano
On Thu, 15 Dec 2016 01:28 am, Random832 wrote: > On Tue, Dec 13, 2016, at 19:10, Steve D'Aprano wrote: >> Can you show a simple demonstration of what you are doing? >> >> I'm having difficulty following this thread because I don't know >> what "script run on a tty" means. > > The question is lit

Re: Wrong release date in 3.6 whats new docs?

2016-12-14 Thread breamoreboy
On Wednesday, December 14, 2016 at 2:09:22 PM UTC, Nick Sarbicki wrote: > Afternoon everyone. > > Might be missing something obvious but the 3.6 What's New docs point to the > release date being the 12th. > > https://docs.python.org/3.6/whatsnew/3.6.html#what-s-new-in-python-3-6 > > I got the te

Re: Parsing a potentially corrupted file

2016-12-14 Thread Paul Rubin
Paul Moore writes: > I'm looking for a reasonably "clean" way to parse a log file that > potentially has incomplete records in it. Basically trial and error. Code something reasonable, run your program til it crashes on a record that it doesn't know what to do with, add code to deal with that,

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Chris Angelico
On Thu, Dec 15, 2016 at 7:53 AM, Ian Kelly wrote: > On Wed, Dec 14, 2016 at 12:53 PM, Chris Angelico wrote: >> On Thu, Dec 15, 2016 at 6:27 AM, Marko Rauhamaa wrote: >>> Chris Angelico : >>> asyncio.spin_off(parallel()) # ??? [...] What code should go on the "???" li

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Ian Kelly
On Wed, Dec 14, 2016 at 12:53 PM, Chris Angelico wrote: > On Thu, Dec 15, 2016 at 6:27 AM, Marko Rauhamaa wrote: >> Chris Angelico : >> >>> asyncio.spin_off(parallel()) # ??? >>> >>> [...] >>> >>> What code should go on the "???" line to accomplish this? >> >> asyncio.ensure_future(parallel()

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Chris Angelico
On Thu, Dec 15, 2016 at 7:25 AM, Marko Rauhamaa wrote: > What version of Python are you running? > >Changed in version 3.5.1: The function accepts any awaitable object. > 3.7 :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Marko Rauhamaa
Chris Angelico : > On Thu, Dec 15, 2016 at 6:27 AM, Marko Rauhamaa wrote: >> Chris Angelico : >> >>> asyncio.spin_off(parallel()) # ??? >>> >>> [...] >>> >>> What code should go on the "???" line to accomplish this? >> >> asyncio.ensure_future(parallel()) > > Hmm. I tried that but it didn't w

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Chris Angelico
On Thu, Dec 15, 2016 at 6:27 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> asyncio.spin_off(parallel()) # ??? >> >> [...] >> >> What code should go on the "???" line to accomplish this? > > asyncio.ensure_future(parallel()) Hmm. I tried that but it didn't work in the full program (it hung

Re: Parsing a potentially corrupted file

2016-12-14 Thread MRAB
On 2016-12-14 11:43, Paul Moore wrote: I'm looking for a reasonably "clean" way to parse a log file that potentially has incomplete records in it. The basic structure of the file is a set of multi-line records. Each record starts with a series of fields delimited by [...] (the first of which i

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Marko Rauhamaa
Chris Angelico : > asyncio.spin_off(parallel()) # ??? > > [...] > > What code should go on the "???" line to accomplish this? asyncio.ensure_future(parallel()) Marko -- https://mail.python.org/mailman/listinfo/python-list

Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Chris Angelico
When you work with threads, it's pretty straight-forward to spin off another thread: you start it. Your current thread continues, and the other one runs in parallel. What's the most straight-forward way to do this in asyncio? I know this has been asked before, but threads keep devolving, and I can

Re: OT - "Soft" ESC key on the new MacBook Pro

2016-12-14 Thread Skip Montanaro
On Wed, Dec 14, 2016 at 11:40 AM, Peter Pearson wrote: > Train your fingers to use C-[. As I recall, the location of the Ctrl key was one of the differences between Sun and PC101 keyboards. Doesn't matter so much now, as Sun has gone the way of the dodo, but it moved around more for me than ESC o

Re: OT - "Soft" ESC key on the new MacBook Pro

2016-12-14 Thread Skip Montanaro
> If you need a full time ESC key then you are just "typing it wrong" as Steve > Jobs > would say if he wasn't dead. Shouldn't the use of ESC, C-[, Alt, or some other mapped key be treated as a valid personal preference? I've been using some variety of Emacs (there have been many) since the earl

Re: OT - "Soft" ESC key on the new MacBook Pro

2016-12-14 Thread Peter Pearson
On Tue, 13 Dec 2016 19:06:45 -0600, Skip Montanaro wrote: > I know this isn't a Python-specific question, but [snip] > Yes, I know I can use C-[ or the Alt key instead of ESC. I know this isn't the sort of answer you wanted, but . . . Train your fingers to use C-[. I did, decades ago, because

Re: OT - "Soft" ESC key on the new MacBook Pro

2016-12-14 Thread Jon Ribbens
On 2016-12-14, mm0fmf wrote: > On 14/12/2016 02:40, Paul Rubin wrote: >> Skip Montanaro writes: >>> Does the lack of a physical ESC key create problems for people, especially >>> Emacs users? >> >> Not a Mac user and I rarely use ESC instead of ALT while editing with >> Emacs on a local computer,

Re: OT - "Soft" ESC key on the new MacBook Pro

2016-12-14 Thread mm0fmf
On 14/12/2016 02:40, Paul Rubin wrote: Skip Montanaro writes: Does the lack of a physical ESC key create problems for people, especially Emacs users? Not a Mac user and I rarely use ESC instead of ALT while editing with Emacs on a local computer, but when editing remotely I do have to use ESC

Re: OT - "Soft" ESC key on the new MacBook Pro

2016-12-14 Thread Michael Torrie
On 12/13/2016 09:22 PM, Gregory Ewing wrote: > Paul Rubin wrote: >> First it was the hipster Mac users >> with the Beatnik black berets and turtlenecks, and now this. > > Once you're in the clutches of Apple, there is no Escape. That's so not true! I've escaped dozens of times! ;) -- https://m

Re: Wrong release date in 3.6 whats new docs?

2016-12-14 Thread Ned Batchelder
On Wednesday, December 14, 2016 at 9:09:22 AM UTC-5, Nick Sarbicki wrote: > Afternoon everyone. > > Might be missing something obvious but the 3.6 What's New docs point to the > release date being the 12th. > > https://docs.python.org/3.6/whatsnew/3.6.html#what-s-new-in-python-3-6 > > I got the

Re: OT - "Soft" ESC key on the new MacBook Pro

2016-12-14 Thread John Gordon
In Gregory Ewing writes: > Once you're in the clutches of Apple, there is no Escape. Ha! -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb

Re: Running python from pty without prompt

2016-12-14 Thread Random832
On Tue, Dec 13, 2016, at 19:20, Steve D'Aprano wrote: > sys.flags.interactive will tell you whether or not your script was > launched > with the -i flag. > > hasattr(sys, 'ps1') or hasattr(sys, 'ps2') will tell you if you are > running > in the REPL (interactive interpreter). The ps1 and ps2 varia

Re: Running python from pty without prompt

2016-12-14 Thread Random832
On Tue, Dec 13, 2016, at 19:10, Steve D'Aprano wrote: > Can you show a simple demonstration of what you are doing? > > I'm having difficulty following this thread because I don't know > what "script run on a tty" means. The question is literally about the input/script being the tty and not redire

Re: Name mangling vs qualified access to class attributes

2016-12-14 Thread Steve D'Aprano
On Wed, 14 Dec 2016 07:27 am, paoli...@gmail.com wrote: > The official Python tutorial at > > https://docs.python.org/3/tutorial/classes.html#private-variables > > says that "name mangling is helpful for letting subclasses override > methods without breaking intraclass method calls" and makes an

Re: Parsing a potentially corrupted file

2016-12-14 Thread Paul Moore
On Wednesday, 14 December 2016 12:57:23 UTC, Chris Angelico wrote: > Is the "[Component]" section something you could verify? (That is - is > there a known list of components?) If so, I would include that as a > secondary check. Ditto anything else you can check (I'm guessing the > [level] is one

Wrong release date in 3.6 whats new docs?

2016-12-14 Thread Nick Sarbicki
Afternoon everyone. Might be missing something obvious but the 3.6 What's New docs point to the release date being the 12th. https://docs.python.org/3.6/whatsnew/3.6.html#what-s-new-in-python-3-6 I got the team excited about Friday's release so that caused some confusion here. Guessing it's a t

Re: Parsing a potentially corrupted file

2016-12-14 Thread alister
On Wed, 14 Dec 2016 03:43:44 -0800, Paul Moore wrote: > I'm looking for a reasonably "clean" way to parse a log file that > potentially has incomplete records in it. > > The basic structure of the file is a set of multi-line records. Each > record starts with a series of fields delimited by [...

Re: Parsing a potentially corrupted file

2016-12-14 Thread Chris Angelico
On Wed, Dec 14, 2016 at 10:43 PM, Paul Moore wrote: > This is a messy format to parse, but it's manageable. However, there's a > catch. Because the logging software involved is broken, I can occasionally > get a log record prematurely terminated with a new record starting > mid-stream. So some

Parsing a potentially corrupted file

2016-12-14 Thread Paul Moore
I'm looking for a reasonably "clean" way to parse a log file that potentially has incomplete records in it. The basic structure of the file is a set of multi-line records. Each record starts with a series of fields delimited by [...] (the first of which is always a date), optionally separated b

Re: Is there a way to insert hooks into a native dictionary type to see when a query arrives and what's looked up?

2016-12-14 Thread Steven D'Aprano
On Wednesday 14 December 2016 17:11, Veek M wrote: > I know that with user classes one can define getattr, setattr to handle > dictionary lookup. Is there a way to hook into the native dict() type > and see in real time what's being queried. Not easily, and maybe not at all. There are two obviou

Re: Name mangling vs qualified access to class attributes

2016-12-14 Thread dieter
paoli...@gmail.com writes: > The official Python tutorial at > > https://docs.python.org/3/tutorial/classes.html#private-variables > > says that "name mangling is helpful for letting subclasses override methods > without breaking intraclass method calls" and makes an interesting example: > > clas