Re: How asyncio works? and event loop vs exceptions

2016-07-23 Thread Terry Reedy
On 7/22/2016 8:27 PM, Marco S. via Python-list wrote: I'm developing a web app based on aiohttp, and I find the event loop concept very interesting. I never programmed with it before, but I know that node.js and GUIs are based on it. What I can't understand is how asyncio make it possible to run

Re: Why not allow empty code blocks?

2016-07-23 Thread Marko Rauhamaa
Steven D'Aprano : > On Sat, 23 Jul 2016 01:33 am, Kent Tong wrote: >> I'm aware that we can use 'pass' as an empty code block. But why >> doesn't python allow a code block to be empty and thus eliminate the >> need for this null statement? > > Because it cannot tell the difference between an empty

Re: Why not allow empty code blocks?

2016-07-23 Thread Chris Angelico
On Sat, Jul 23, 2016 at 9:13 PM, Marko Rauhamaa wrote: >> One less thing to be programmed, one less thing for the user to >> remember. Just require pass any time you have an empty block, rather >> than try to remember where it is required and were it is optional. > > Actually, the requirement of a

Re: Why not allow empty code blocks?

2016-07-23 Thread Marko Rauhamaa
Chris Angelico : > On Sat, Jul 23, 2016 at 9:13 PM, Marko Rauhamaa wrote: >>> One less thing to be programmed, one less thing for the user to >>> remember. Just require pass any time you have an empty block, rather >>> than try to remember where it is required and were it is optional. >> >> Actua

Re: Why not allow empty code blocks?

2016-07-23 Thread D'Arcy J.M. Cain
On Sat, 23 Jul 2016 14:13:46 +0300 Marko Rauhamaa wrote: > > for x in sequence: > > print('loop') > > > > Is that meant to print 'loop' each time around the loop, or just > > once, at the end of the loop? > > I don't see an ambiguity: obviously the print call takes place after > finishing the loo

Detecting the trivial can be non-trivial (was Why not allow empty code blocks?)

2016-07-23 Thread Rustom Mody
On Saturday, July 23, 2016 at 4:44:00 PM UTC+5:30, Marko Rauhamaa wrote: > Steven D'Aprano : > > > On Sat, 23 Jul 2016 01:33 am, Kent Tong wrote: > >> I'm aware that we can use 'pass' as an empty code block. But why > >> doesn't python allow a code block to be empty and thus eliminate the > >> nee

Re: Why not allow empty code blocks?

2016-07-23 Thread Marko Rauhamaa
"D'Arcy J.M. Cain" : > On Sat, 23 Jul 2016 14:13:46 +0300 > Marko Rauhamaa wrote: >> I don't see an ambiguity: obviously the print call takes place after >> finishing the loop. > > It's ambiguous to the reader what was actually meant. Forcing a "pass" > there shows the reader that the empty bloc

Re: Why not allow empty code blocks?

2016-07-23 Thread D'Arcy J.M. Cain
On Sat, 23 Jul 2016 16:13:58 +0300 Marko Rauhamaa wrote: > "D'Arcy J.M. Cain" : > > It's ambiguous to the reader what was actually meant. Forcing a > > "pass" there shows the reader that the empty block was not a > > mistake. > > Just let the syntax speak for itself. The code means what the lang

Re: Why not allow empty code blocks?

2016-07-23 Thread BartC
On 23/07/2016 12:34, Chris Angelico wrote: On Sat, Jul 23, 2016 at 9:13 PM, Marko Rauhamaa wrote: One less thing to be programmed, one less thing for the user to remember. Just require pass any time you have an empty block, rather than try to remember where it is required and were it is optiona

Re: How asyncio works? and event loop vs exceptions

2016-07-23 Thread Ian Kelly
On Fri, Jul 22, 2016 at 6:27 PM, Marco S. via Python-list wrote: > Furthermore I have a question about exceptions in asyncio. If I > understand well how it works, tasks exceptions can be caught only if > you wait for task completion, with yield from, await or > loop.run_until_complete(future). But

Re: Why not allow empty code blocks?

2016-07-23 Thread BartC
On 23/07/2016 14:54, D'Arcy J.M. Cain wrote: On Sat, 23 Jul 2016 16:13:58 +0300 Marko Rauhamaa wrote: "D'Arcy J.M. Cain" : It's ambiguous to the reader what was actually meant. Forcing a "pass" there shows the reader that the empty block was not a mistake. Just let the syntax speak for itse

Re: Why not allow empty code blocks?

2016-07-23 Thread Chris Angelico
On Sun, Jul 24, 2016 at 12:00 AM, BartC wrote: > On 23/07/2016 12:34, Chris Angelico wrote: >> >> On Sat, Jul 23, 2016 at 9:13 PM, Marko Rauhamaa wrote: One less thing to be programmed, one less thing for the user to remember. Just require pass any time you have an empty block, rat

Re: Why not allow empty code blocks?

2016-07-23 Thread Steven D'Aprano
On Sun, 24 Jul 2016 12:06 am, BartC wrote: > pass can only do so much. If doesn't help here: > > for x in sequence: > print("Something") > print("Something else") > > Was the second print meant to be indented as well or not? True. But once you start wondering about code the programmer

Is there a way to invoke remote power shell as Admin.

2016-07-23 Thread Robert Clove
Hi, I am basically trying to solve the following problem http://stackoverflow.com/questions/38540424/open-power-shell-as-admin-on-remote-vm Regards Clove -- https://mail.python.org/mailman/listinfo/python-list

Re: Just starting to learn Python, and encounter a problem

2016-07-23 Thread gst
Heuh case 2 : "String1" or "String2" Evaluates to "String1" ? -- https://mail.python.org/mailman/listinfo/python-list

Re: Just starting to learn Python, and encounter a problem

2016-07-23 Thread MRAB
On 2016-07-23 19:18, gst wrote: Heuh case 2 : "String1" or "String2" Evaluates to "String1" ? Suppose you have: x or y If bool(x) returns True, then the result will be x, else the result will be y. Example 1: bool("String1") returns True, therefore the result of: "String1" or "

Re: Just starting to learn Python, and encounter a problem

2016-07-23 Thread Steven D'Aprano
On Sun, 24 Jul 2016 04:18 am, gst wrote: > Heuh case 2 : > > "String1" or "String2" > > Evaluates to "String1" ? Correct. What did you expect? Have you read the Fine Manual? https://docs.python.org/3/reference/expressions.html#boolean-operations -- Steven “Cheer up,” they said, “things