[Python-ideas] Loosen 'as' assignment

2018-06-15 Thread Rin Arakaki
Hi, I'm wondering if it's possible and consistent that loosen 'as' assignment, for example: >>> import psycopg2 as pg >>> import psycopg2.extensions as pg.ex You can't now assign to an attribute in as statement but are there some reasons? To be honest, I'll be satisfied if the statement above be

Re: [Python-ideas] Python Decorator Improvement Idea

2018-06-15 Thread Steven D'Aprano
On Fri, Jun 15, 2018 at 11:54:42PM -0400, Brian Allen Vanderburg II via Python-ideas wrote: > An idea I had is that it could be possible for a decorator function to > declare a parameter which, when the function is called as a decorator, > the runtime can fill in various information in the parame

[Python-ideas] Python Decorator Improvement Idea

2018-06-15 Thread Brian Allen Vanderburg II via Python-ideas
Just a small idea that could possibly be useful for python decorators. An idea I had is that it could be possible for a decorator function to declare a parameter which, when the function is called as a decorator, the runtime can fill in various information in the parameters for the decorator to us

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Cameron Simpson
On 16Jun2018 02:42, Mikhail V wrote: Now I have slightly different idea. How is about special-casing of this as a shortcut for append: L[] = item Namely just use the fact that empty slice is SyntaxError now. Now we're just making typing errors into working code. Also, that isn't an empty sl

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Michael Selik
On Fri, Jun 15, 2018, 6:18 PM Mikhail V wrote: > On Sat, Jun 16, 2018 at 3:47 AM, Michael Selik wrote: > > > One of those links was discussing extend, not append. > > Yes and so what? ... What is different with append? Luckily for extend, it's similar to the "obvious" semantics of ``a += b`` w

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Greg Ewing
Mikhail V wrote: But I see from various posts in the web and SO - people just want to spell it compact, and keep the 'item' part clean of brackets. Where have you seen these posts? -- Greg ___ Python-ideas mailing list Python-ideas@python.org https:/

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Mikhail V
On Sat, Jun 16, 2018 at 3:47 AM, Michael Selik wrote: > One of those links was discussing extend, not append. Yes and so what? Does this makes it automatically not related to the wish to choose more compact spelling, despite it is not recommended way. What is different with append? Similar posts

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Terry Reedy
On 6/15/2018 8:42 PM, Greg Ewing wrote: Mikhail V wrote: It s just very uncommon to see standalone statements like: x.method() for me it came into habit to think that it lacks the left-hand part and =. You must be looking at a very limited and non-typical corpus of Python code. Mutating meth

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Greg Ewing
Michael Selik wrote: The += operator was meant as an alias for ``x = x + 1``. The fact that it mutates a list is somewhat of a surprise. That's very much a matter of opinion. For every person who thinks this is a surprise, you can find another that thinks it's obvious that += should mutate a li

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Michael Selik
One of those links was discussing extend, not append. The other wanted a repeated append, best solved by a list comprehension. Neither makes a good case for your suggestion. On Fri, Jun 15, 2018, 5:40 PM Mikhail V wrote: > On Sat, Jun 16, 2018 at 3:26 AM, Michael Selik wrote: > > > > > > On Fri

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Greg Ewing
Mikhail V wrote: It s just very uncommon to see standalone statements like: x.method() for me it came into habit to think that it lacks the left-hand part and =. You must be looking at a very limited and non-typical corpus of Python code. Mutating method calls are extremely common in most Pyth

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Mikhail V
On Sat, Jun 16, 2018 at 3:26 AM, Michael Selik wrote: > > > On Fri, Jun 15, 2018, 5:24 PM Mikhail V wrote: >> >> there is just nothing against append() method. > > > Then why break the Zen: there should be only one obvious way? I think the question could be applied to 99% proposals >> But I see

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Michael Selik
On Fri, Jun 15, 2018, 5:24 PM Mikhail V wrote: > there is just nothing against append() method. > Then why break the Zen: there should be only one obvious way? But I see from various posts in the web and SO - people just want to spell > it compact, and keep the 'item' part clean of brackets.

Re: [Python-ideas] Approximately equal operator

2018-06-15 Thread Nathaniel Smith
On Fri, Jun 15, 2018 at 3:56 PM, Andre Roberge wrote: > * people doing heavy numerical work and wanting code as readable as possible IME serious numerical work doesn't use approximate equality tests at all, except in test assertions. > * teaching mostly beginners about finite precision for float

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Mikhail V
On Sat, Jun 16, 2018 at 3:02 AM, Chris Angelico wrote: > On Sat, Jun 16, 2018 at 9:42 AM, Mikhail V wrote: >> Now I have slightly different idea. How is about special-casing of this >> as a shortcut for append: >> >> L[] = item >> >> Namely just use the fact that empty slice is SyntaxError now. >

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Chris Angelico
On Sat, Jun 16, 2018 at 9:42 AM, Mikhail V wrote: > Now I have slightly different idea. How is about special-casing of this > as a shortcut for append: > > L[] = item > > Namely just use the fact that empty slice is SyntaxError now. > > I understand this is totally different approach than operator

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Mikhail V
Now I have slightly different idea. How is about special-casing of this as a shortcut for append: L[] = item Namely just use the fact that empty slice is SyntaxError now. I understand this is totally different approach than operator overloading and maybe hard to implement, but I feel like it loo

Re: [Python-ideas] Approximately equal operator

2018-06-15 Thread Andre Roberge
On Fri, Jun 15, 2018 at 3:12 PM Richard Damon wrote: > On 6/15/18 1:38 PM, Andre Roberge wrote: > > I have a suggestion to make inspired by the current discussion about > > trigonometric functions in degrees, and the desire to have them show > > "exact" values in some special cases. > > > > I sug

Re: [Python-ideas] Approximately equal operator

2018-06-15 Thread Richard Damon
On 6/15/18 1:38 PM, Andre Roberge wrote: > I have a suggestion to make inspired by the current discussion about > trigonometric functions in degrees, and the desire to have them show > "exact" values in some special cases. > > I suggest that it would be useful to have operators for performing > **a

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Richard Damon
On 6/15/18 1:25 PM, Mikhail V wrote: > On Fri, Jun 15, 2018 at 6:54 PM, Chris Angelico wrote: >> On Sat, Jun 16, 2018 at 1:48 AM, Mikhail V wrote: >>> On Fri, Jun 15, 2018 at 5:51 AM, Michael Selik wrote: >>> If you would like to prove the need for this operator, one piece of evidence

Re: [Python-ideas] Approximately equal operator

2018-06-15 Thread Antoine Pitrou
On Fri, 15 Jun 2018 14:38:22 -0300 Andre Roberge wrote: > > Here's a sample session for demonstration purpose... > > $ python -m experimental > experimental console version 0.9.5. [Python version: 3.6.1] > > ~~> 0.1 + 0.2 > 0.30004 > ~~> 0.1 + 0.2 == 0.3 > False > ~~> from __exp

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Michael Selik
On Fri, Jun 15, 2018 at 10:25 AM Mikhail V wrote: > very uncommon to see standalone statements like: x.method() > Python has many such mutation methods. It sounds like you're judging the frequency of code patterns across all languages instead of just Python. Even then, I don't think that's true.

[Python-ideas] Approximately equal operator

2018-06-15 Thread Andre Roberge
I have a suggestion to make inspired by the current discussion about trigonometric functions in degrees, and the desire to have them show "exact" values in some special cases. I suggest that it would be useful to have operators for performing **approximate** comparisons. I believe that such operat

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Mikhail V
On Fri, Jun 15, 2018 at 6:54 PM, Chris Angelico wrote: > On Sat, Jun 16, 2018 at 1:48 AM, Mikhail V wrote: >> On Fri, Jun 15, 2018 at 5:51 AM, Michael Selik wrote: >> >>> If you would like to prove the need for this operator, one piece of evidence >>> you can provide is a count of the number of

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Chris Angelico
On Sat, Jun 16, 2018 at 1:48 AM, Mikhail V wrote: > On Fri, Jun 15, 2018 at 5:51 AM, Michael Selik wrote: > >> If you would like to prove the need for this operator, one piece of evidence >> you can provide is a count of the number of times someone writes >> "list.append" for an iterable vs "+="

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Mikhail V
On Fri, Jun 15, 2018 at 5:51 AM, Michael Selik wrote: > If you would like to prove the need for this operator, one piece of evidence > you can provide is a count of the number of times someone writes > "list.append" for an iterable vs "+=" and encloses a str or other type in a > throw-away list t

Re: [Python-ideas] Fwd: Trigonometry in degrees

2018-06-15 Thread Richard Damon
On 6/13/18 7:21 AM, Stephan Houben wrote: > > > Op wo 13 jun. 2018 13:12 schreef Richard Damon > mailto:rich...@damon-family.org>>: > > My first comment is that special casing values like this can lead to > some very undesirable properties when you use the function for > numerical >

Re: [Python-ideas] Allow filtered dir built in

2018-06-15 Thread Steven D'Aprano
On Fri, Jun 15, 2018 at 10:10:19AM +0200, Michel Desmoulin wrote: > Fantastic idea. Would this make sense on var() too ? It's not exactly > the same usage context. No. The point of vars() is to return the actual namespace dict used by an object. It's not primarily an introspection tool, it is th

Re: [Python-ideas] Allow filtered dir built in

2018-06-15 Thread Michel Desmoulin
Le 14/06/2018 à 11:27, Steve Barnes a écrit : > Currently when working with interactive sessions using the dir() or > dir(module) built in is incredibly useful for exploring what > functionality is available in a module. (Especially the regrettable > libraries or modules that add really valuab

Re: [Python-ideas] Give regex operations more sugar

2018-06-15 Thread Michel Desmoulin
Le 14/06/2018 à 07:29, Steven D'Aprano a écrit : > On Wed, Jun 13, 2018 at 10:59:34PM +0200, Michel Desmoulin wrote: > >>> Attaching an entire module to a type is probably worse than >>> adding a slew of extra methods to the type. >>> >> >> Not my point. >> >> str.re would not be the re module,