[Python-ideas] Re: String method to check for a float

2021-10-03 Thread Debashish Palit
There are plenty of use cases if you pause to think. The other objections are trivial. Even the simplest usage with the input() function is enough to warrant its inclusion, considering that there are other useless string methods. As I have had no support for the past few days, I quit the discuss

[Python-ideas] Re: Feature request enumerate_with_rest or enumerate with skip or filter callback

2021-10-03 Thread Laurent Lyaudet
Le dim. 3 oct. 2021 à 06:01, Stephen J. Turnbull a écrit : > > Laurent Lyaudet writes: > > Hello, > > > > This is a very simple feature request that does not break anything but > > I don't know if you may find it interesting. > > It would be nice to have a function or method of list objects t

[Python-ideas] Re: Feature request enumerate_with_rest or enumerate with skip or filter callback

2021-10-03 Thread Steven D'Aprano
Hi Laurent, It is not clear to me what you mean by "filter by indices". On Sat, Oct 02, 2021 at 10:25:05PM +0200, Laurent Lyaudet wrote: > The idea is to filter a list by indices : [...] > Since filter() returns an iterator instead of a list, it could do what > is needed... if the callback had a

[Python-ideas] Re: Syntax Sugar for __name__ == "__main__" boilerplate?

2021-10-03 Thread David Mertz, Ph.D.
On Sun, Oct 3, 2021, 1:46 AM Christopher Barker > The if __name__ block is only required for a Python file to be both a > module and a script. > That’s actually a pretty uncommon thing— if it’s a module to be imported > by other modules, then it probably should be part of a package, and if the > f

[Python-ideas] Re: Syntax Sugar for __name__ == "__main__" boilerplate?

2021-10-03 Thread Jonathan Crall
@Marc-Andre One of the motivations of this proposal is to incentivize writing code in a local scope, rather than a global one. People in this thread have made the argument "Python is a scripting language, so it should do that". Ok, fine. Yes `print('hello world')` is more idiomatic than the one in

[Python-ideas] Re: Shorthand syntax for lambda functions that have a single parameter

2021-10-03 Thread Eric Fahlgren
I'm somewhat confused by the term "last item of the set", as sets are not ordered and have no "last" element: >>> {1,3,3,2} {1, 2, 3} On Sat, Oct 2, 2021 at 8:23 PM Abdulla Al Kathiri < [email protected]> wrote: > Then use it with the normal expression lambda: > people.sort(key=p => (p

[Python-ideas] Re: Syntax Sugar for __name__ == "__main__" boilerplate?

2021-10-03 Thread Chris Angelico
On Mon, Oct 4, 2021 at 2:02 AM Jonathan Crall wrote: > > @Marc-Andre > > One of the motivations of this proposal is to incentivize writing code in a > local scope, rather than a global one. People in this thread have made the > argument "Python is a scripting language, so it should do that". Ok,

[Python-ideas] Re: Shorthand syntax for lambda functions that have a single parameter

2021-10-03 Thread Abdulla Al Kathiri
Oh I forgot what if you want to return a set from your lambda? Maybe a lambda set should at least have one assignment statement to qualify it as one. Expressions only inside a set syntax will be just a normal set that doesn’t care about order as you pointed out. But a lambda set will care about

[Python-ideas] Re: More efficient list copying

2021-10-03 Thread Finn Mason
On Sat, Oct 2, 2021, 11:20 PM Christopher Barker wrote: [Snip...] > > But sure, if we can eliminate inefficiencies in Python standard data > types, then why not? > I agree. If we can eliminate inefficiencies in core Python features, that would be great. I don't work with this kind of thing, so

[Python-ideas] Re: Syntax Sugar for __name__ == "__main__" boilerplate?

2021-10-03 Thread Abdur-Rahmaan Janhangeer
Greetings list, > I disagree that "it teaches a lot about how Python works" is a good reason to keep things the way they are. If you applied this principle more broadly, it would seem to be an argument in favour of complexity in most situations, that would imply we should keep syntactic sugar to a