[Python-ideas] Re: zip(x, y, z, strict=True)

2020-05-07 Thread Kirill Balunov
On Thu, May 7, 2020 at 3:07 AM Christopher Barker wrote: > On Wed, May 6, 2020 at 1:42 PM Kirill Balunov > wrote: > >> I'm totally agree with everything you said here. From my perspective, >> comparing three main cases: >> 1. zip(*iters, strict= (False | Tr

[Python-ideas] Re: PEP 618: Add Optional Length-Checking To zip

2020-05-07 Thread Kirill Balunov
On Thu, May 7, 2020 at 10:56 AM Alex Hall wrote: > On Thu, May 7, 2020 at 9:48 AM Kirill Balunov > wrote: > >> Sorry for off topic. Isn't this chain.from_iterable just a historical >> legacy... now we have PEP 448 and I see no differences* between >> chain(*itera

[Python-ideas] Re: PEP 618: Add Optional Length-Checking To zip

2020-05-07 Thread Kirill Balunov
Sorry for off topic. Isn't this chain.from_iterable just a historical legacy... now we have PEP 448 and I see no differences* between chain(*iterable) vs chain.from_iterable(iterable). Are there? * chain.from_iterable is a little bit faster for small iterables, but if at that time we had PEP 448,

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-05-06 Thread Kirill Balunov
On Wed, May 6, 2020 at 6:49 PM Christopher Barker wrote: > On Tue, May 5, 2020 at 5:43 PM Steven D'Aprano > wrote: > >> Christopher's quoting is kinda messed up and I can't be bothered fixing >> it, sorry, so you'll just have to guess who said what :-) >> > > Ideally, we are evaluating ideas

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-25 Thread Kirill Balunov
But you also can always make such a switch with functools.partial. -gdg On Sat, Apr 25, 2020 at 8:59 PM Chris Angelico wrote: > On Sun, Apr 26, 2020 at 3:53 AM Kirill Balunov > wrote: > > > > > > > > On Sat, Apr 25, 2020 at 8:11 PM David Mertz wrote: > >

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-25 Thread Kirill Balunov
On Sat, Apr 25, 2020 at 8:11 PM David Mertz wrote: > I have no objection to adding a zip_strict() or zip_exact() to itertools. > I am used to the current behavior, and am apparently in minority in not > usually assuming common length iterators. Say +0 on a new function. > > But I'm definitely -1

[Python-ideas] Re: Argumenting in favor of first()

2019-12-07 Thread Kirill Balunov
сб, 7 дек. 2019 г. в 03:45, Steven D'Aprano : > This is how I would implement the function in Python: > > def first(iterable, default=None): > return next(iter(iterable), default) > A somewhat related discussion was somewhere inside November 2017

[Python-ideas] Re: Allow kwargs in __{get|set|del|}item__

2019-10-07 Thread Kirill Balunov
Are you aware of PEP 472 https://www.python.org/dev/peps/pep-0472 ? Maybe you have something different in mind, but for me your idea looks pretty the same. While the PEP 472 is in Rejected, Abandoned section, I do not remember any serious criticism of this idea. It’s just that the authors of that

[Python-ideas] Re: [Python-Dev] strip behavior provides inconsistent results with certain strings

2019-07-01 Thread Kirill Balunov
> > This was quite extensively discussed on python-ideas recently: > > > https://mail.python.org/archives/list/python-ideas@python.org/thread/RJARZSUKCXRJIP42Z2YBBAEN5XA7KEC3/#WIRID57ESUFUAQQQ6ZUY2RK5PKQQYSJ3 > > (I'm finding it hard to find a good thread view in the new interface -- > but that

Re: [Python-ideas] More alternate constructors for builtin type

2019-05-06 Thread Kirill Balunov
пн, 6 мая 2019 г. в 19:48, Antoine Pitrou : > On Mon, 6 May 2019 19:39:39 +0300 > Serge Matveenko wrote: > > On Mon, May 6, 2019 at 7:29 PM Guido van Rossum > wrote: > > > > > > On Mon, May 6, 2019 at 11:14 AM Serhiy Storchaka > wrote: > > >> I do not propose to change the current behavior. I

Re: [Python-ideas] Sorted lists

2019-04-08 Thread Kirill Balunov
Basically, I like this idea and of course theoretically it has use cases. But in the proposed form, it feels strongly curtailed. In practice, what does it mean to be sorted? [('a', 1),('b', 2),('bb', 4),('aaa', 3)] # Is this list sorted? [('a', 1),('aaa', 3),('b', 2),('bb', 4)] # or this?

Re: [Python-ideas] New explicit methods to trim strings

2019-03-31 Thread Kirill Balunov
, Kirill Balunov : > > > вс, 31 мар. 2019 г. в 11:45, Kirill Balunov : > >> >> >> вс, 31 мар. 2019 г. в 11:36, Steven D'Aprano : >> >>> There's a slight problem with that: what happens if more than one suffix >>> matches? E.g. given: >>> &

Re: [Python-ideas] New explicit methods to trim strings

2019-03-31 Thread Kirill Balunov
вс, 31 мар. 2019 г. в 11:45, Kirill Balunov : > > > вс, 31 мар. 2019 г. в 11:36, Steven D'Aprano : > >> There's a slight problem with that: what happens if more than one suffix >> matches? E.g. given: >> >> "musical".lcut(('al', 'ical')) >>

Re: [Python-ideas] New explicit methods to trim strings

2019-03-31 Thread Kirill Balunov
вс, 31 мар. 2019 г. в 11:36, Steven D'Aprano : > There's a slight problem with that: what happens if more than one suffix > matches? E.g. given: > > "musical".lcut(('al', 'ical')) > > should the suffix "al" be removed, leaving "music"? (First match wins.) > > Or should the suffix "ical" be

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Kirill Balunov
сб, 16 мар. 2019 г. в 16:02, Kirill Balunov : > Thank you for this very thoughtful message! It reminded me of my first > experience with the old Fortran code. You probably know that earlier in > Fortran there were no cryptic shortcuts for writing relational operators: > instead of `

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Kirill Balunov
Thank you for this very thoughtful message! It reminded me of my first experience with the old Fortran code. You probably know that earlier in Fortran there were no cryptic shortcuts for writing relational operators: instead of `A >= B`, you had to write `A .GE. B`, or as many often wrote this

Re: [Python-ideas] Vectorization [was Re: Add list.join() please]

2019-02-04 Thread Kirill Balunov
вс, 3 февр. 2019 г. в 21:23, David Mertz : > > I think the principled thing to do here is add the minimal number of > methods to Vector itself, and have everything else pass through as > vectorized calls. Most of that minimal number are "magic method": > __len__(), __contains__(), __str__(),

Re: [Python-ideas] Vectorization [was Re: Add list.join() please]

2019-02-02 Thread Kirill Balunov
сб, 2 февр. 2019 г. в 07:33, Steven D'Aprano : > > I didn't say anything about a vector type. > > I agree you did not say. But since you started a new thread from the one where the vector type was a little discussed, it seemed to me that it is appropriate to mention it here. Sorry about that.

Re: [Python-ideas] Vectorization [was Re: Add list.join() please]

2019-02-01 Thread Kirill Balunov
пт, 1 февр. 2019 г. в 02:24, Steven D'Aprano : > On Thu, Jan 31, 2019 at 09:51:20AM -0800, Chris Barker via Python-ideas > wrote: > > > I do a lot of numerical programming, and used to use MATLAB and now > numpy a > > lot. So I am very used to "vectorization" -- i.e. having operations that > >

Re: [Python-ideas] Add .= as a method return value assignment operator

2018-09-27 Thread Kirill Balunov
As I see it, you are mixing very different things. Augmented operators in Python work on objects, generally trying to mutate them in-place. So usually after these operations you have the same object (with the same type, with the same name and etc.) as before these operations. Of course there are

Re: [Python-ideas] "while:" for the loop

2018-09-26 Thread Kirill Balunov
On Wed, Sep 26, 2018, 19:30 David Mertz wrote: > We also have: > > from itertools import count > for i in count(): > ... > > If you want to keep track of how close to infinity you are. :-) > We also have: from itertools import repeat for i in repeat(...): ... with kind regards, -gdg

Re: [Python-ideas] Unpacking iterables for augmented assignment

2018-08-26 Thread Kirill Balunov
вс, 26 авг. 2018 г. в 14:53, Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp>: > [...] > > This isn't consistent with the normal behavior of Python sequences: > > $ python3.6 > >>> (1,2) + (3,4) > (1, 2, 3, 4) > > That is, "+" means something different for sequences. Furthermore, > the

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-21 Thread Kirill Balunov
пн, 20 авг. 2018 г. в 17:23, Steven D'Aprano : > On Sun, Aug 19, 2018 at 06:18:56PM +0300, Kirill Balunov wrote: > [...] > [Kirill] > > Let me disagree with you. While CPython is only one of the > implementations > > of the Python language, it is the most common one and

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-19 Thread Kirill Balunov
вс, 19 авг. 2018 г. в 17:51, Chris Angelico : > On Mon, Aug 20, 2018 at 12:43 AM, Kirill Balunov > wrote: > > > [...] > > I have the same feeling and already have asked the same question before > > https://mail.python.org/pipermail/python-list/2018-February/731241.htm

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-19 Thread Kirill Balunov
чт, 16 авг. 2018 г. в 22:37, Chris Barker via Python-ideas < python-ideas@python.org>: > > I wonder why locals doesn't return a Mapping Proxy, or other read-only > mapping object? > > If it's not guaranteed to be THE locals dict, and changes *may* not affect > the real one (but may), a read-only

Re: [Python-ideas] "Assignment expression" with function call-alike syntax

2018-05-26 Thread Kirill Balunov
2018-05-24 4:21 GMT+03:00 Steven D'Aprano <st...@pearwood.info>: > On Wed, May 23, 2018 at 12:32:36AM +0300, Kirill Balunov wrote: > > > Just one more variation on "assignment exression" syntax to make the list > > more complete :) Sorry, if something

Re: [Python-ideas] ternary without else

2018-05-25 Thread Kirill Balunov
2018-05-25 13:06 GMT+03:00 Jacco van Dorp : > [...] > > I would very much like to write: > > >>> do_something if cond > > and be done with it. Like a ternary expression but without the else clause. > > If it is an expression, what should `do_something if cond` return on

Re: [Python-ideas] "Assignment expression" with function call-alike syntax

2018-05-23 Thread Kirill Balunov
2018-05-23 17:54 GMT+03:00 Mike Miller <python-id...@mgmiller.net>: > > On 2018-05-22 14:32, Kirill Balunov wrote: > >> # in global scope everything works ok since locals is globals >> >>> while len( this( val = dummy() ) ) >= 0: >> ...

Re: [Python-ideas] "Assignment expression" with function call-alike syntax

2018-05-23 Thread Kirill Balunov
2018-05-23 14:19 GMT+03:00 Masayuki YAMAMOTO : > FYI, I found a package [*] which binds a value by function keyword (I'm > not the author). Note that the package writes a value in the global (or > raise an error if the name already exists in local) unlike your idea. > >

Re: [Python-ideas] "Assignment expression" with function call-alike syntax

2018-05-23 Thread Kirill Balunov
2018-05-23 9:05 GMT+03:00 Terry Reedy <tjre...@udel.edu>: > On 5/22/2018 5:32 PM, Kirill Balunov wrote: > >> Just one more variation on "assignment exression" syntax to make the list >> more complete :) Sorry, if something similar has already been suggested. >

[Python-ideas] "Assignment expression" with function call-alike syntax

2018-05-22 Thread Kirill Balunov
Just one more variation on "assignment exression" syntax to make the list more complete :) Sorry, if something similar has already been suggested. The idea is to use function's call-like syntax in the from: `this( name = expr )`. I'm not sure that such idea will find its supporters and whether it

Re: [Python-ideas] Modern language design survey for "assign and compare" statements

2018-05-19 Thread Kirill Balunov
2018-05-19 3:54 GMT+03:00 Mike Miller : > Background: > > While the previous discussions about assignment-expressions (PEP 572) > (abbreviated AE below) have been raging one thing that was noticeable is > that > folks have been looking back to C for a solution. > > But

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-11 Thread Kirill Balunov
2018-05-11 17:06 GMT+03:00 Clint Hepner : > > > (This reminds that I wish ``iter`` could take a predicate instead of a > sentinel as its second argument. Then > you could just write > > for cmd in iter(get_command, lambda x: x.token == CMD_QUIT): >

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-10 Thread Kirill Balunov
2018-05-10 16:44 GMT+03:00 Guido van Rossum : > I'm sorry, but unless there's a sudden landslide of support for 'given' in > favor of ':=', I'm really not going to consider it. > > I'd pronounce "if (x := y) > 0" as either "if y (assigned to x) is greater > than zero" or "if x

Re: [Python-ideas] A "local" pseudo-function

2018-04-29 Thread Kirill Balunov
2018-04-29 17:52 GMT+03:00 MRAB : > > >> How about these: > > local m1, m2: > m1 = regexp1.match(line) > m2 = regexp2.match(line): > if m1 and m2: > ... > Is it possible to do the same thing, but with the help of `with`

Re: [Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)

2018-04-16 Thread Kirill Balunov
[Guido] 2018-04-15 20:19 GMT+03:00 Guido van Rossum <gu...@python.org>: > On Sun, Apr 15, 2018 at 4:05 AM, Kirill Balunov <kirillbalu...@gmail.com> > wrote: > >> [...] For me personally, `: =` looks and feels just like normal >> assignment statement which can be

Re: [Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)

2018-04-16 Thread Kirill Balunov
2018-04-15 23:22 GMT+03:00 Chris Angelico : > > > 0. > > > > while (items[i := i+1] := read_next_item()) is not None: > > print(r'%d/%d' % (i, len(items)), end='\r') > > > > 1. > > > > while (read_next_item() -> items[(i+1) -> i]) is not None: > > print(r'%d/%d' % (i,

Re: [Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)

2018-04-15 Thread Kirill Balunov
2018-04-15 18:58 GMT+03:00 Steven D'Aprano : > > [...] > > But this time we don't care about the name. Its the value we care about: > > result = some_func(don't care, >don't care -> don't care >don't care -> don't care >

Re: [Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)

2018-04-15 Thread Kirill Balunov
2018-04-15 15:21 GMT+03:00 Chris Angelico <ros...@gmail.com>: > On Sun, Apr 15, 2018 at 7:19 PM, Kirill Balunov <kirillbalu...@gmail.com> > wrote: > >> === Expression first, 'as' keyword === > >> > >> while (read_next_item() as value)

Re: [Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)

2018-04-15 Thread Kirill Balunov
2018-04-15 12:41 GMT+03:00 Mikhail V : > > Exactly, all forms invites this and other questions. > > First of all, coming back to original spelling choice arguments > [Sorry in advance if I've missed some points in this huge thread] > > citation from PEP: > "Differences

Re: [Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)

2018-04-15 Thread Kirill Balunov
2018-04-15 6:08 GMT+03:00 Nick Coghlan : > > It's not completely off topic. as it's due to the fact we use "," to > separate both context managers and items in a tuple, so "with (cm1, > cm2, cm3):" is currently legal syntax that means something quite > different from "with

Re: [Python-ideas] PEP 572: Assignment Expressions (post #4)

2018-04-12 Thread Kirill Balunov
2018-04-12 12:48 GMT+03:00 Jacco van Dorp : > Wouldn't these local name bindings make the current "as" clause of > "with f(x) as y" completely obsolete ? > > It's probably good to know my background, and my background is that I > know completely nothing of the

Re: [Python-ideas] PEP 572: Assignment Expressions (post #4)

2018-04-11 Thread Kirill Balunov
2018-04-11 18:01 GMT+03:00 Kirill Balunov <kirillbalu...@gmail.com>: > > > 2018-04-11 16:50 GMT+03:00 Chris Angelico <ros...@gmail.com>: > >> >> Can you give an example of how your syntax is superior to the more >> general option of sim

Re: [Python-ideas] PEP 572: Assignment Expressions (post #4)

2018-04-11 Thread Kirill Balunov
2018-04-11 16:50 GMT+03:00 Chris Angelico : > > Can you give an example of how your syntax is superior to the more > general option of simply allowing "as" bindings in any location? > > This is not my syntax :) And not even my idea. I just do not understand, and even a little

Re: [Python-ideas] PEP 572: Assignment Expressions (post #4)

2018-04-11 Thread Kirill Balunov
Great work Chris! Thank you! I do not know whether this is good or bad, but this PEP considers so many different topics, although closely interrelated with each other. 2018-04-11 8:32 GMT+03:00 Chris Angelico : > > Alterations to comprehensions > -

Re: [Python-ideas] Start argument for itertools.accumulate() [Was: Proposal: A Reduce-Map Comprehension and a "last" builtin]

2018-04-08 Thread Kirill Balunov
2018-04-08 8:19 GMT+03:00 Nick Coghlan : > A name like "first_result" would also make it clearer to readers that > passing that parameter has an impact on the length of the output > series (since you're injecting an extra result), and also that the > production of the first

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-26 Thread Kirill Balunov
2018-03-26 14:18 GMT+03:00 Steven D'Aprano : > That was probably my response to Nick: > > https://mail.python.org/pipermail/python-ideas/2018-March/049472.html > > I compared four possible choices: > > target = default if (expression as name) is None else name >

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-26 Thread Kirill Balunov
Hi Chris, would you mind to add this syntactic form `(expr -> var)` to alternative syntax section, with the same semantics as `(expr as var)`. It seems to me that I've seen this form previously in some thread (can't find where), but it does not appear in alt. syntax section. As for me this form

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Kirill Balunov
2018-03-24 17:14 GMT+03:00 Nick Coghlan : > > > They can be distinguished, just not at module or function scope. To give a > concrete example: > > == > >>> class C: > ... sequence = range(10) > ... listcomp = [x for x in sequence] > ... def

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings

2018-02-28 Thread Kirill Balunov
The PEP says: > Omitting the parentheses from this PEP's proposed syntax introduces many > syntactic ambiguities. > and: As the name's scope extends to the full current statement, even a block > statement, this can be used to good effect in the header of an if or while > statement Will the

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings

2018-02-28 Thread Kirill Balunov
2018-02-28 16:49 GMT+03:00 Serhiy Storchaka : > 28.02.18 00:27, Chris Angelico пише: > >> Example usage >> = >> >> These list comprehensions are all approximately equivalent:: >> >> # Calling the function twice >> stuff = [[f(x), f(x)] for x in

Re: [Python-ideas] Coming up with an alternative to PEP 505's None-aware operators

2018-02-16 Thread Kirill Balunov
What about (| val = get_value(x) |) assignment expression which will be True if success, and None if not? So it will be value = f() if (| f = calculate |) else default…The idea is inspired from C’s assignment, but needs some special treatment for anything which is False in boolean context. With

[Python-ideas] Decorator for creating enumeration?

2017-12-10 Thread Kirill Balunov
Since PEP 557 "Data Classes"[1] and PEP 526 "Syntax for Variable Annotations"[2] are accepted and become part of the language. Is it worth writing a proposal about decorator-version for creating an enumeration? Something like: from enum import enum @enum(unique=True, int_=False, flag=False,

Re: [Python-ideas] How assignment should work with generators?

2017-12-01 Thread Kirill Balunov
2017-11-29 22:33 GMT+03:00 Steve Barnes : > > Just a thought but what about a syntax something along the lines of: > > a, b, *remainder = iterable > > Where remainder becomes the iterable with the first two values consumed > by assigning to a & b. If the iterator has less

Re: [Python-ideas] [Python-Dev] What's the status of PEP 505: None-aware operators?

2017-11-29 Thread Kirill Balunov
2017-11-29 11:14 GMT+03:00 Nick Coghlan : > It's OK to say "the use case exists, but I still > don't want that particular syntax for it in Python" (I'm personally > inclined to agree with you on that front). It's not OK to try to claim > there are no use cases where the

Re: [Python-ideas] How assignment should work with generators?

2017-11-28 Thread Kirill Balunov
2017-11-28 22:50 GMT+03:00 Guido van Rossum <gu...@python.org>: > On Tue, Nov 28, 2017 at 11:44 AM, Kirill Balunov <kirillbalu...@gmail.com> > wrote: > >> Although I have never used Python 2, the idea to distinguish fixed-sized >> and something la

Re: [Python-ideas] How assignment should work with generators?

2017-11-28 Thread Kirill Balunov
2017-11-28 10:06 GMT+03:00 C Anthony Risinger : > > If not already considered, what if the RHS had to be explicitly unpacked? > > Something like: > > a, b, c = *iterator > > Which would essentially be: > > a, b, c = (*iterator,) > > This enables lazy assignment by

Re: [Python-ideas] How assignment should work with generators?

2017-11-27 Thread Kirill Balunov
2017-11-28 0:52 GMT+03:00 Chris Angelico : > On Tue, Nov 28, 2017 at 8:49 AM, Guido van Rossum > wrote: > > My PEP queue for Python 3.7 is full though, so I would like to put this > off > > until 3.8. > > > > Yeah, I don't think this could reasonably be raced

Re: [Python-ideas] How assignment should work with generators?

2017-11-27 Thread Kirill Balunov
2017-11-27 19:23 GMT+03:00 Paul Moore : > It should be reasonably easy > to do a code search for something like "=.*islice", to find code > that's a candidate for using the proposed syntax. I suspect there's > very little code like that. While isclice is something

Re: [Python-ideas] How assignment should work with generators?

2017-11-27 Thread Kirill Balunov
While I was more optimistic when I proposed this idea, moving on I gradually become less and less optimistic. I did not underestimate how much this would change the semantics. At present, if the lhs is comma-separated list of targets, the rhs is evaluated, and only then if they match the

Re: [Python-ideas] How assignment should work with generators?

2017-11-27 Thread Kirill Balunov
2017-11-27 17:14 GMT+03:00 Chris Angelico : > > > Nah, far easier: > > x, y = iter(it) > Yes, you are right. >> 2. Readable and not so verbose code > >> 3. Optimized case for x,y,*z = iterator > > > > The semantics of that are already set: the first two items are

Re: [Python-ideas] How assignment should work with generators?

2017-11-27 Thread Kirill Balunov
2017-11-27 15:39 GMT+03:00 Paul Moore <p.f.mo...@gmail.com>: > On 27 November 2017 at 12:31, Kirill Balunov <kirillbalu...@gmail.com> > wrote: > > As I can see at the moment, these cases should behave differently: > > > >>>> x, y = [1,2,3,4]

Re: [Python-ideas] How assignment should work with generators?

2017-11-27 Thread Kirill Balunov
> In terms of language proposals, you can't just say "don't need values > for"; the semantics have to be EITHER "consume and discard" OR "don't > consume". We already have a perfectly good way of spelling "consume > and discard": > > x, y, _ = iter > You mean ( x, y, *_ = iter ) ? Since this has

Re: [Python-ideas] Make bytes __repr__ and __str__ representation different?

2017-11-21 Thread Kirill Balunov
2017-11-21 20:22 GMT+03:00 Chris Barker wrote: > But the way you did your example indicates that: > > bytes((42, 43, 44, 45, 46)) > > would be an even better __repr__, if the goal is to make it clear and easy > that it is a "container of integers from 0 to 255" > > I've

[Python-ideas] Make bytes __repr__ and __str__ representation different?

2017-11-21 Thread Kirill Balunov
Currently, __repr__ and __str__ representation of bytes is the same. Perhaps it is worth making them different, this will make it easier to visually perceive them as a container of integers from 0 to 255, instead of a mixture of printable and non-printable ascii characters. It is proposed: a)

Re: [Python-ideas] Should Python have user-defined constants?

2017-11-21 Thread Kirill Balunov
> > It is not set in stone, but it looks like most people like Final (although > the initial proposal was Const, see https://github.com/python/ > mypy/issues/1214) > Ivan, you mean this thread "Can't index named tuple by defined constant" ? With kind

Re: [Python-ideas] Star assignment in iterator way?

2017-11-21 Thread Kirill Balunov
May be the first thing which I should do is to improve my English:) My main point was that in many cases (in my experience) it is a waste of memory to store entire list for star variable (*b) instead of some kind of iterator or deferred evaluation. How do you defer evaluating the second and

Re: [Python-ideas] Star assignment in iterator way?

2017-11-21 Thread Kirill Balunov
> Your implementation iterates seq multiple times. But iterable unpacking > syntax works with an arbitrary iterable, and iterates it only once. > Oh sorry, I know that my implementation iterates seq multiple times, I only provide this to show the idea. It can be much optimized at C level. I just

[Python-ideas] Star assignment in iterator way?

2017-11-21 Thread Kirill Balunov
Hello. Currently during star assignement the new list is created. What was the idea to produce new list instead of returning an iterator? It seems to me that returning an iterator more suited to the spirit of Python 3. There are three cases: 1. a,b,c,*d = something_iterable 2. *a,b,c,d =