Re: [Python-ideas] Contraction for "for x in range()"

2017-02-14 Thread Mikhail V
On 15 February 2017 at 00:41, Nick Timkovich wrote: > Make some shim object that you can index into to get that functionality, > could even call it Z (for the set of all integers). Short, and requires no > new syntax. > > class IndexableRange: > def __getitem__(self,

Re: [Python-ideas] Contraction for "for x in range()"

2017-02-14 Thread Nick Timkovich
Make some shim object that you can index into to get that functionality, could even call it Z (for the set of all integers). Short, and requires no new syntax. class IndexableRange: def __getitem__(self, item): if isinstance(item, slice): start = item.start if item.start

Re: [Python-ideas] Contraction for "for x in range()"

2017-02-14 Thread Mikhail V
On 14 February 2017 at 22:41, MRAB wrote: > On 2017-02-14 21:09, Zachary Ware wrote: > >> On Tue, Feb 14, 2017 at 3:06 PM, Mikhail V wrote: >> >>> I have a small syntax idea. >>> In short, contraction of >>> >>> for x in range(a,b,c) : >>> >>>

Re: [Python-ideas] Contraction for "for x in range()"

2017-02-14 Thread Nick Timkovich
for i in range(...) is *sometimes* indicative of code smell, especially when then doing x[i], though it has its uses. I've never had a need to shorten a for...range line though. Other than it being "cute", do you have an example where it's definitively better? On Tue, Feb 14, 2017 at 4:03 PM,

Re: [Python-ideas] Contraction for "for x in range()"

2017-02-14 Thread Todd
On Tue, Feb 14, 2017 at 4:41 PM, MRAB wrote: > On 2017-02-14 21:09, Zachary Ware wrote: > >> On Tue, Feb 14, 2017 at 3:06 PM, Mikhail V wrote: >> >>> I have a small syntax idea. >>> In short, contraction of >>> >>> for x in range(a,b,c) : >>>

Re: [Python-ideas] Contraction for "for x in range()"

2017-02-14 Thread Abe Dillon
I would be surprised if this hasn't been suggested many times before. It's similar to Matlab's syntax: for x = start:step:finish end Any such change would represent a large departure from normal python syntax for dubious gain. In general, you can put any expression after the `in` keyword so

Re: [Python-ideas] Contraction for "for x in range()"

2017-02-14 Thread Zachary Ware
On Tue, Feb 14, 2017 at 3:06 PM, Mikhail V wrote: > I have a small syntax idea. > In short, contraction of > > for x in range(a,b,c) : > > to > > for x in a,b,c : > > I really think there is something cute in it. > So like a shortcut for range() which works only in for-in

[Python-ideas] Contraction for "for x in range()"

2017-02-14 Thread Mikhail V
I have a small syntax idea. In short, contraction of for x in range(a,b,c) : to for x in a,b,c : I really think there is something cute in it. So like a shortcut for range() which works only in for-in statement. So from syntactical POV, do you find it nice syntax? Visually it seems to me less