[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Greg Ewing
On 28/05/20 12:38 pm, Rob Cliffe wrote: why not go further (as the OP suggested as far as I recall) and allow the more concise     def order(eggs = 4, spam ?= Spam()):         etc. That clutters up the header with things that are not part of the function's signature. All the caller needs

[Python-ideas] Re: An HTTP API to list versions of Python

2020-05-28 Thread Serhiy Storchaka
27.05.20 21:10, Christian Heimes пише: Barry and Guido own the Python project on PyPI, https://pypi.org/project/Python/ . There hasn't been an update since 2.5.0 in 2007. There are also https://pypi.org/project/python2/ https://pypi.org/project/python4/ https://pypi.org/project/cPython/

[Python-ideas] Re: Allowing assertEqual etc to take multiple items

2020-05-28 Thread remi . lapeyre
Hi Ram, this is not possible without breaking a lot of code, assertSequenceEqual() already takes a third argument: Help on function assertSequenceEqual in module unittest.case: assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None) An equality assertion for ordered sequences (like

[Python-ideas] Re: Allowing assertEqual etc to take multiple items

2020-05-28 Thread Serhiy Storchaka
28.05.20 11:02, Ram Rachum пише: I recently submitted this PR , and I had to use assertSequenceEqual twice, just because I wanted to compare 3 sequences to each other rather than 2. You have wrote much more text in this message

[Python-ideas] Re: Allowing assertEqual etc to take multiple items

2020-05-28 Thread Ram Rachum
On Thu, May 28, 2020 at 11:42 AM Serhiy Storchaka wrote: > 28.05.20 11:02, Ram Rachum пише: > > I recently submitted this PR > > , and > I > > had to use assertSequenceEqual twice, just because I wanted to compare 3 > > sequences

[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Alex Hall
On Thu, May 28, 2020 at 9:01 AM Greg Ewing wrote: > On 28/05/20 12:38 pm, Rob Cliffe wrote: > > why not go > > further (as the OP suggested as far as I recall) > > and allow the more concise > > > > def order(eggs = 4, spam ?= Spam()): > > etc. > > That clutters up the header with

[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Chris Angelico
On Thu, May 28, 2020 at 5:05 PM Greg Ewing wrote: > > On 28/05/20 12:38 pm, Rob Cliffe wrote: > > why not go > > further (as the OP suggested as far as I recall) > > and allow the more concise > > > > def order(eggs = 4, spam ?= Spam()): > > etc. > > That clutters up the header with

[Python-ideas] Re: An HTTP API to list versions of Python

2020-05-28 Thread M.-A. Lemburg
On 27.05.2020 23:46, Joseph Banks wrote: > The downside to the FTP solution however is that little metadata is > present about the versions > > The FTP pages are primarily for downloading versions which isn't the aim > of the proposal, it's to be able to fetch the metadata. > > Adding some sort

[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Steven D'Aprano
On Thu, May 28, 2020 at 07:00:51PM +1200, Greg Ewing wrote: > On 28/05/20 12:38 pm, Rob Cliffe wrote: > >why not go further (as the OP suggested as far as I recall) > >and allow the more concise > > > >     def order(eggs = 4, spam ?= Spam()): > >         etc. > > That clutters up the header with

[Python-ideas] Python __main__ function

2020-05-28 Thread redradist
Hi all, In Python we often use the following syntax to call the main logic of script when it was ran: ```python def main(): pass # whatever should be done for `python ./script.py` if __name__ == '__main__': main() ``` Maybe it is a time to introduce the new module level function like

[Python-ideas] Allowing assertEqual etc to take multiple items

2020-05-28 Thread Ram Rachum
Hi guys! I'm a unittest newbie, so it's possible there's a better solution than what I'm proposing here. If there is, please let me know. I recently submitted this PR , and I had to use assertSequenceEqual twice, just because I

[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Richard Damon
On 5/28/20 3:00 AM, Greg Ewing wrote: > On 28/05/20 12:38 pm, Rob Cliffe wrote: >> why not go further (as the OP suggested as far as I recall) >> and allow the more concise >> >> def order(eggs = 4, spam ?= Spam()): >>     etc. > > That clutters up the header with things that are not

[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Greg Ewing
On 28/05/20 7:31 pm, Chris Angelico wrote: Is it an implementation detail that 4 will be used for eggs if it isn't passed? That feels different to me somehow. I think it has something to do with declarative vs. procedural stuff. The default value of eggs being 4 is a static fact, but creating

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Jose Veiga
While is possible to use `if __name__ == '__main__':` several times in the same script, your proposed magic function `def __main__()` cannot be redefined. Not to speak about lexical scope differences between one approach and the other. So your proposal is reducing features instead of expanding

[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Greg Ewing
On 28/05/20 8:57 pm, Steven D'Aprano wrote: The default value used by a parameter is certainly important, and one of the most common reasons I call `help(func)` is to see what the default values are. They should be in the signature, and it is an annoyance when all the signature shows is that it

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Paul Sokolovsky
Hello, On Thu, 28 May 2020 09:06:36 - redrad...@gmail.com wrote: > Hi all, > > In Python we often use the following syntax to call the main logic of > script when it was ran: ```python > def main(): > pass # whatever should be done for `python ./script.py` > > if __name__ ==

[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Dan Sommers
On Thursday, May 28, 2020, at 06:47 -0400, Alex Hall wrote: > On Thu, May 28, 2020 at 12:38 PM Greg Ewing > wrote: > >> On 28/05/20 8:57 pm, Steven D'Aprano wrote: >> > The default value used by a parameter is certainly important, and one of >> > the most common reasons I call `help(func)` is

[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Alex Hall
On Thu, May 28, 2020 at 12:38 PM Greg Ewing wrote: > On 28/05/20 8:57 pm, Steven D'Aprano wrote: > > The default value used by a parameter is certainly important, and one of > > the most common reasons I call `help(func)` is to see what the default > > values are. They should be in the

[Python-ideas] Re: Allowing assertEqual etc to take multiple items

2020-05-28 Thread Steven D'Aprano
On Thu, May 28, 2020 at 11:40:52AM +0300, Serhiy Storchaka wrote: > Why do you think it will be faster? `a == b == c` is the same as `a == b > and b == c`, but a tiny bit slower. That surprises me. I thought that the big advantage of chained comparisons is that results are only evaluated once.

[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Steven D'Aprano
On Wed, May 27, 2020 at 05:03:09AM +1000, Chris Angelico wrote: > def foo(): > if False: x = 0 > # what is x now? > > There is no *value* in x, yet x has a state. In Python code, no, it has no state, it's just an unbound name. That's literally a name that has nothing bound to it,

[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Chris Angelico
On Thu, May 28, 2020 at 8:01 PM Steven D'Aprano wrote: > > On Wed, May 27, 2020 at 05:03:09AM +1000, Chris Angelico wrote: > > > def foo(): > > if False: x = 0 > > # what is x now? > > > > There is no *value* in x, yet x has a state. > > In Python code, no, it has no state, it's just an

[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Alex Hall
On Thu, May 28, 2020 at 11:57 AM Steven D'Aprano wrote: > On Wed, May 27, 2020 at 05:03:09AM +1000, Chris Angelico wrote: > > > def foo(): > > if False: x = 0 > > # what is x now? > > > > There is no *value* in x, yet x has a state. > > In Python code, no, it has no state, it's just an

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread jdveiga
redradist@gmail.com wrote: > Hi all, > In Python we often use the following syntax to call the main logic of script > when it > was ran: > def main(): > pass # whatever should be done for `python ./script.py` > > if __name__ == '__main__': > main() > > Maybe it is a time to introduce

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Artemis
> So your proposal is reducing features instead of expanding them. Surely, the `__name__` variable would remain, so if people needed a more powerful way of doing it they could use that? But then, we introduce multiple ways of doing the same thing...

[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Dominik Vilsmeier
On 28.05.20 17:44, Christopher Barker wrote: On Thu, May 28, 2020 at 3:50 AM Alex Hall mailto:alex.moj...@gmail.com>> wrote: On Thu, May 28, 2020 at 12:38 PM Greg Ewing mailto:greg.ew...@canterbury.ac.nz>> wrote: But I'm having trouble thinking of one. I can't remember

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread jdveiga
Artemis wrote: > > So your proposal is reducing features instead of > > expanding them. > > Surely, the __name__ variable would remain, so if people needed a more > > powerful way of doing it they could use that? But then, we introduce > > multiple ways of > > doing the same thing... > > The OP

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread David Mertz
On Thu, May 28, 2020, 12:17 PM wrote: > The OP is proposing as a possibility: "we could require user to have only > one if __name__ == '__main__':". In that case, functionality will be > reduced, won't it? > I don't support the proposal. However, I've also never written a script with multiple

[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Christopher Barker
On Thu, May 28, 2020 at 3:50 AM Alex Hall wrote: > On Thu, May 28, 2020 at 12:38 PM Greg Ewing > wrote: > >> >> But I'm having trouble thinking of one. I can't remember ever >> writing a function with a default argument value that *has* to >> be mutable and *has* to have a new one created on

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread redradist
Cool !! But it disappointed that this proposal was reject ( ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread David Mertz
On Thu, May 28, 2020, 3:06 PM Chris Angelico wrote: > There aren't multiple entry points, though. There would be multiple > blocks of code that are skipped if the module is imported, but > executed if it's run as a script. Remember, Python code is NOT > declarative. That 'def' statement is an

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Chris Angelico
On Fri, May 29, 2020 at 5:54 AM wrote: > > > -Original Message- > > From: Chris Angelico > > > > People can already put all their main logic into a function. If you want > to unit- > > test your main function, that's the best way to do it. > > The trouble is, how much goes into main()

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread tritium-list
(Apologies to Chris, reply vs. replay all error on my part) > -Original Message- > From: Chris Angelico > > People can already put all their main logic into a function. If you want to unit- > test your main function, that's the best way to do it. > The trouble is, how much goes into

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Alex Hall
On Thu, May 28, 2020 at 9:52 PM Paul Sokolovsky wrote: > On Fri, 29 May 2020 05:33:57 +1000 > Chris Angelico wrote: > > People can already put all their main logic into a function. If you > > want to unit-test your main function, that's the best way to do it. > Yes, and I want to make it easy,

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Chris Angelico
On Fri, May 29, 2020 at 2:32 AM David Mertz wrote: > > On Thu, May 28, 2020, 12:17 PM wrote: >> >> The OP is proposing as a possibility: "we could require user to have only >> one if __name__ == '__main__':". In that case, functionality will be >> reduced, won't it? > > > I don't support the

[Python-ideas] Re: An HTTP API to list versions of Python

2020-05-28 Thread Wes Turner
Does there need to be a webapp? Or could it just be a JSON-LD file in a static site; maybe with a GH Action that validates (and maybe generates) the data according to a schema. Here's a rough sketch of a schema for this data: "Generate Misc/NEWS from individual files" (2017)

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Chris Angelico
On Fri, May 29, 2020 at 5:25 AM Alex Hall wrote: > > On Thu, May 28, 2020 at 12:57 PM Paul Sokolovsky wrote: >> >> And in all fairness, all good ideas already came to somebody else years >> ago. There's https://www.python.org/dev/peps/pep-0299/ , successfully >> rejected yet back in 2002. (So,

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Paul Sokolovsky
Hello, On Thu, 28 May 2020 16:05:52 -0400 wrote: [] > People write main entry points that are not exactly this? > > If __name__ == '__main__': > sys.exit(main(sys.argv[1:])) Yes, most of the time, I don't emulate C main function, so I write it as: if __name__ == "__main__": main()

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Paul Sokolovsky
Hello, On Fri, 29 May 2020 05:33:57 +1000 Chris Angelico wrote: [] > People can already put all their main logic into a function. If you > want to unit-test your main function, that's the best way to do it. > The trouble is, how much goes into main() and how much into if > __name__ ==

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Alex Hall
On Thu, May 28, 2020 at 12:57 PM Paul Sokolovsky wrote: > And in all fairness, all good ideas already came to somebody else years > ago. There's https://www.python.org/dev/peps/pep-0299/ , successfully > rejected yet back in 2002. (So, feel free to use it in your own > environment/Python

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Rhodri James
On 28/05/2020 21:05, tritium-l...@sdamon.com wrote: People write main entry points that are not exactly this? If __name__ == '__main__': sys.exit(main(sys.argv[1:])) Mostly I don't write main entry points at all. If I do the dance, it's more likely to be: if __name__ == '__main__':

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Chris Angelico
On Fri, May 29, 2020 at 12:43 PM Jonathan Goble wrote: > > On Thu, May 28, 2020 at 9:03 PM Greg Ewing > wrote: >> >> On 29/05/20 8:05 am, tritium-l...@sdamon.com wrote: >> >> > People write main entry points that are not exactly this? >> > >> > If __name__ == '__main__': >> >

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Christopher Barker
I'm going to note here that it is perfectly reasonable to use Python as a "scripting language" -- to, you know, write scripts. And when I'm writing scripts, I make heavy use of the global namespace :-) Granted, if it's really a quick and dirty script, I'll not bother with if __name__ ==

[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Greg Ewing
On 29/05/20 12:17 am, Richard Damon wrote: But default values for arguments are really part of the responsibility for the caller, not the called function. The classic implementation would be that the caller passes all of the explicitly, I would say that's really a less-than-ideal

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Ethan Furman
On 05/28/2020 01:05 PM, tritium-l...@sdamon.com wrote: People write main entry points that are not exactly this? If __name__ == '__main__': sys.exit(main(sys.argv[1:])) I have never written an entry point that looks like that. -- ~Ethan~ ___

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Jonathan Goble
On Thu, May 28, 2020 at 9:03 PM Greg Ewing wrote: > On 29/05/20 8:05 am, tritium-l...@sdamon.com wrote: > > > People write main entry points that are not exactly this? > > > > If __name__ == '__main__': > > sys.exit(main(sys.argv[1:])) > > It's not clear that exiting with the return value

[Python-ideas] Re: Python __main__ function

2020-05-28 Thread Greg Ewing
On 29/05/20 8:05 am, tritium-l...@sdamon.com wrote: People write main entry points that are not exactly this? If __name__ == '__main__': sys.exit(main(sys.argv[1:])) It's not clear that exiting with the return value of main() is the most Pythonic thing to do -- it's more of a C idiom