Re: seeking deeper (language theory) reason behind Python design choice

2018-05-08 Thread Chris Angelico
On Wed, May 9, 2018 at 3:44 PM, Steven D'Aprano wrote: > On Tue, 08 May 2018 22:48:52 -0500, Python wrote: >> I've always felt that this mentality was insulting to the programmer: >> "You're too stupid to get this right." Sure, I've created that bug in >> other languages (or rather its inverse) b

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-08 Thread Chris Angelico
On Wed, May 9, 2018 at 3:36 PM, Ian Kelly wrote: > > while True: > if we_are_done(): > break > # do some stuff > ... > if error_occurred(): > break > notify_user() > > > Fixed, using idiomatic Python and without needing to use assignment in > an expression. Why is

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-08 Thread Steven D'Aprano
On Tue, 08 May 2018 22:48:52 -0500, Python wrote: > On Tue, May 08, 2018 at 12:45:29AM +, Steven D'Aprano wrote: >> Currently, the real reason is that lambda expressions are limited to a >> single expression as the body of the function, and binding operations >> in Python are statements. > >

Re: Problem/bug with class definition inside function definition

2018-05-08 Thread Gregory Ewing
Alexey Muranov wrote: x = 42 class C: x = x # Works I'd say it kind of works by accident, and is not really an intended feature. if Python does not allow to refer "simultaneously" to variables from different scopes if they have the same name. It seems perfectly reasonable to

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-08 Thread Ian Kelly
On Tue, May 8, 2018 at 9:48 PM, Python wrote: > On Tue, May 08, 2018 at 12:45:29AM +, Steven D'Aprano wrote: >> since = in a statement on its own is not dangerous. People *almost never* >> intend to write == for the side-effects only: > > Seriously? I do this--not every day, but more than occ

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-08 Thread Chris Angelico
On Wed, May 9, 2018 at 1:48 PM, Python wrote: >> since = in a statement on its own is not dangerous. People *almost never* >> intend to write == for the side-effects only: > > Seriously? I do this--not every day, but more than occasionally, not > just in Python. > > flag = (spam == arg) > vs.

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-08 Thread Python
On Tue, May 08, 2018 at 12:45:29AM +, Steven D'Aprano wrote: > Currently, the real reason is that lambda expressions are limited to a > single expression as the body of the function, and binding operations in > Python are statements. ...which begs the question, why shouldn't assignments be

Re: Suggestion for a "data" object syntax

2018-05-08 Thread Steven D'Aprano
On Tue, 08 May 2018 23:16:23 +0300, Mikhail V wrote: > I don't propose to remove spaces, And that is why the syntax will be ambiguous. So long as whitespace is *allowed* but not *required* around operators, there will be ambiguity between a - b and a - b with no way to tell whether they are in

Re: Suggestion for a "data" object syntax

2018-05-08 Thread Mikhail V
On Wed, May 9, 2018 at 3:14 AM, Ben Finney wrote: > Mikhail V writes: > >> On Wed, May 9, 2018 at 12:33 AM, Chris Angelico wrote: >> > On Wed, May 9, 2018 at 7:15 AM, Mikhail V wrote: >> >> Just admit it, you try to troll me (or just pretend, I don't know). >> > >> > No, I am not trolling you.

Re: Suggestion for a "data" object syntax

2018-05-08 Thread Ben Finney
Mikhail V writes: > On Wed, May 9, 2018 at 12:33 AM, Chris Angelico wrote: > > On Wed, May 9, 2018 at 7:15 AM, Mikhail V wrote: > >> Just admit it, you try to troll me (or just pretend, I don't know). > > > > No, I am not trolling you. > > I don't believe you. If that's true – if you believe C

Re: Suggestion for a "data" object syntax

2018-05-08 Thread Mikhail V
On Wed, May 9, 2018 at 12:33 AM, Chris Angelico wrote: > On Wed, May 9, 2018 at 7:15 AM, Mikhail V wrote: >> On Tue, May 8, 2018 at 5:25 PM, Chris Angelico wrote: >>> On Tue, May 8, 2018 at 10:52 PM, Mikhail V wrote: Right? Your issues with tabs aside, I think it is impossible to ignore th

Re: Suggestion for a "data" object syntax

2018-05-08 Thread Mark Lawrence
On 08/05/18 22:33, Chris Angelico wrote: On Wed, May 9, 2018 at 7:15 AM, Mikhail V wrote: On Tue, May 8, 2018 at 5:25 PM, Chris Angelico wrote: On Tue, May 8, 2018 at 10:52 PM, Mikhail V wrote: Right? Your issues with tabs aside, I think it is impossible to ignore the the readability improv

Re: Suggestion for a "data" object syntax

2018-05-08 Thread Chris Angelico
On Wed, May 9, 2018 at 7:15 AM, Mikhail V wrote: > On Tue, May 8, 2018 at 5:25 PM, Chris Angelico wrote: >> On Tue, May 8, 2018 at 10:52 PM, Mikhail V wrote: >>> Right? Your issues with tabs aside, I think it is impossible to ignore the >>> the readability improvement. Not even speaking of how >

Re: Suggestion for a "data" object syntax

2018-05-08 Thread Mikhail V
On Tue, May 8, 2018 at 5:25 PM, Chris Angelico wrote: > On Tue, May 8, 2018 at 10:52 PM, Mikhail V wrote: >> Right? Your issues with tabs aside, I think it is impossible to ignore the >> the readability improvement. Not even speaking of how >> many commas and bracket you need to type in the first

Re: Suggestion for a "data" object syntax

2018-05-08 Thread Chris Angelico
On Wed, May 9, 2018 at 6:16 AM, Mikhail V wrote: > Also I don't know what kind of human thinks that this: > a + b > is two elements "a" and "+ b" > What is "+ b"? Unary plus applied to whatever value 'b' is. > And who writes "- b" with a space in unary minus? > I don't. Nobody does. Is it allo

Re: Suggestion for a "data" object syntax

2018-05-08 Thread Mikhail V
On Tue, May 8, 2018 at 6:20 PM, Steven D'Aprano wrote: > On Tue, 08 May 2018 15:52:12 +0300, Mikhail V wrote: > >>> Last time you brought up this idea, you were told that it is ambiguous. >>> Using whitespace alone, it is impossible to distinguish between >>> >>> a + b >>> >>> and >>> >>>

Re: Module, Package

2018-05-08 Thread Sharan Basappa
On Tuesday, 8 May 2018 13:05:58 UTC+5:30, Steven D'Aprano wrote: > On Mon, 07 May 2018 09:53:45 -0700, Sharan Basappa wrote: > > > I am a bit confused between module and package in Python. Does a module > > contain package or vice versa? When we import something in Python, do we > > import a modu

Re: problem in compiling C API in mingw

2018-05-08 Thread m.overmeyer--- via Python-list
On Tuesday, 26 July 2011 23:53:36 UTC, llw...@gmail.com wrote: > Hi all again, > I wonder if so far only Python 2.5.x support c extension. I try the > MSVC 2010 and 2008, also try mingw (gcc 4.x.x) and swig. But even I try > the simplest example, it said > > example_wrap.o:example_wrap.c:(.te

Re: Suggestion for a "data" object syntax

2018-05-08 Thread Steven D'Aprano
On Tue, 08 May 2018 15:52:12 +0300, Mikhail V wrote: >> Last time you brought up this idea, you were told that it is ambiguous. >> Using whitespace alone, it is impossible to distinguish between >> >> a + b >> >> and >> >> a + b >> >> >> Can you see the difference? Of course not. That's th

Re: Suggestion for a "data" object syntax

2018-05-08 Thread Liste guru
Il 08/05/2018 14:52, Mikhail V ha scritto: ... What editor do you use? My editor can toggle tabs highlighting as arrows, and I suppose almost any editor has good support for highlighting of characters by search, etc. For NPP there are even plugins like Regex helper.     I like to 'type pr

Re: Suggestion for a "data" object syntax

2018-05-08 Thread Chris Angelico
On Tue, May 8, 2018 at 10:52 PM, Mikhail V wrote: > Right? Your issues with tabs aside, I think it is impossible to ignore the > the readability improvement. Not even speaking of how > many commas and bracket you need to type in the first case. That's incredibly subjective. Or else straight-up wr

Re: Suggestion for a "data" object syntax

2018-05-08 Thread Mikhail V
On Tue, May 8, 2018 at 10:15 AM, Steven D'Aprano wrote: > On Tue, 08 May 2018 06:45:05 +0300, Mikhail V wrote: > >> *Example 3. Two-dimensional tuple.* >> >> data === T/T : >> 123"hello" >> ab c + de f >> >> is a synonym for: >> >> data = ( >> (1, 2, 3, "hel

Re: Problem/bug with class definition inside function definition

2018-05-08 Thread Ned Batchelder
On 5/8/18 3:55 AM, Alexey Muranov wrote: Sorry, i was confused.  I would say that this mostly works as expected, though the difference between    x = 42    class C:    x = x  # Works and    def f2(a):    class D:    a = a  # Does not work <    return D is still surpr

Re: itemgetter with default arguments

2018-05-08 Thread Antoon Pardon
On 07-05-18 17:45, Peter Otten wrote: > Antoon Pardon wrote: > >> On 05-05-18 09:33, Peter Otten wrote: >>> I think you have established that there is no straight-forward way to >>> write this as a lambda. But is adding a default to itemgetter the right >>> conclusion? >>> >>> If there were an exce

Re: Problem/bug with class definition inside function definition

2018-05-08 Thread Alexey Muranov
Sorry, i was confused. I would say that this mostly works as expected, though the difference between x = 42 class C: x = x # Works and def f2(a): class D: a = a # Does not work < return D is still surprising to me. Otherwise, probably the solu

Re: Module, Package

2018-05-08 Thread Steven D'Aprano
On Mon, 07 May 2018 09:53:45 -0700, Sharan Basappa wrote: > I am a bit confused between module and package in Python. Does a module > contain package or vice versa? When we import something in Python, do we > import a module or a package? The term "module" in Python has multiple meanings: - a pa

Re: Suggestion for a "data" object syntax

2018-05-08 Thread Steven D'Aprano
On Tue, 08 May 2018 06:45:05 +0300, Mikhail V wrote: > *Example 3. Two-dimensional tuple.* > > data === T/T : > 123"hello" > ab c + de f > > is a synonym for: > > data = ( > (1, 2, 3, "hello") , > (a, b, c + d, e, f ) ) Last time you brought up this