[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-26 Thread Richard Musil
I gave it some thought over the weekend and came to the conclusion that I am not going to go further with it (where "it" means my or anyone else's idea). The reason is that I totally lost any motivation. I however feel some more elaborate answer might be due and I will try to give one. The other d

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-26 Thread Paul Moore
On Mon, 26 Aug 2019 at 09:47, Richard Musil wrote: > > I gave it some thought over the weekend and came to the conclusion that I am > not going to go further with it (where "it" means my or anyone else's idea). > The reason is that I totally lost any motivation. I however feel some more > elabo

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-26 Thread Richard Musil
Paul, thanks for an insightful reflection from "the other side", I really appreciate it. It feels like we share some understanding after all. Richard ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to python-ideas-l

[Python-ideas] [new idea] dynamic return with using function argument

2019-08-26 Thread HUANG YUWEI
Dear Python community, I am a heavy python user in numerical simulation. In python 3.8, we will have a new syntax `:=` that could assign values to variables as part of larger expression like, ``` if (n:=len(a)) > 10: ``` On the other hand, I also think that it would be useful if `:=` co

[Python-ideas] Re: [new idea] dynamic return with using function argument

2019-08-26 Thread Guido van Rossum
I think you're talking about call-by-reference (Google it). What would be your use case? Do you know you can return multiple values from a function using a tuple? E.g. def foo(): return 3, 42 x, y = foo() print(x) # 3 print(y) # 42 --Guido On Mon, Aug 26, 2019 at 5:57 AM HUANG YUWEI wr

[Python-ideas] Re: [new idea] dynamic return with using function argument

2019-08-26 Thread Calvin Spealman
This also looks a lot like Out Parameters in C# ( https://www.c-sharpcorner.com/article/out-parameter-in-c-sharp-7/) They have a similar dichotomy of declaration and call time semantics using the `out` keyword rather than an assignment operator. On Mon, Aug 26, 2019 at 10:50 AM Guido van Rossum

[Python-ideas] Re: [new idea] dynamic return with using function argument

2019-08-26 Thread HUANG YUWEI
Dear Mr. Guido and Mr. Spealman, Thanks for your quick reply. Yes, something like "Out Parameters in C#" is exactly what I mentioned. "calling by reference" is very close, except that - with "calling by reference", the object is initialized before the function is called, and then being passed to

[Python-ideas] Re: [new idea] dynamic return with using function argument

2019-08-26 Thread Guido van Rossum
Sorry, there is no way to leverage the implementation or syntax of := for this purpose. You must be misunderstanding how they it works. You are right that the initial value of the variable at the call site is irrelevant (but there must be some initial value, e.g. None, to be able to identify the v

[Python-ideas] Re: [new idea] dynamic return with using function argument

2019-08-26 Thread HUANG YUWEI
Dear Mr. Guido, Ok, I see. Thank you for your prompt reply. Best regards, Huang Y.W Guido van Rossum 于2019年8月27日周二 上午12:38写道: > Sorry, there is no way to leverage the implementation or syntax of := for > this purpose. You must be misunderstanding how they it works. > > You are right that the i

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-26 Thread Andrew Barnert via Python-ideas
On Aug 26, 2019, at 01:47, Richard Musil wrote: > > I gave it some thought over the weekend and came to the conclusion that I am > not going to go further with it (where "it" means my or anyone else's idea). > The reason is that I totally lost any motivation. I however feel some more > elabor

[Python-ideas] Re: [new idea] dynamic return with using function argument

2019-08-26 Thread Andrew Barnert via Python-ideas
On Aug 26, 2019, at 08:38, Guido van Rossum wrote: > > Sorry, there is no way to leverage the implementation or syntax of := for > this purpose. You must be misunderstanding how they it works. > > You are right that the initial value of the variable at the call site is > irrelevant (but there

[Python-ideas] Re: [new idea] dynamic return with using function argument

2019-08-26 Thread Guido van Rossum
I'd love to squash this conversation (because I don't think it'll lead anywhere) but you've nerd-sniped me a little bit. In 3.8, foo(a := 42) is in fact valid syntax, meaning the same as foo((a := 42)). If you wanted to do this with explicit syntax, you can just pass any mutable object. We have a

[Python-ideas] Re: [new idea] dynamic return with using function argument

2019-08-26 Thread Andrew Barnert via Python-ideas
On Aug 26, 2019, at 10:51, Guido van Rossum wrote: > > I'd love to squash this conversation (because I don't think it'll lead > anywhere) but you've nerd-sniped me a little bit. Well, you started it by saying it was impossible. :) > > In 3.8, foo(a := 42) is in fact valid syntax, meaning the s

[Python-ideas] Re: [new idea] dynamic return with using function argument

2019-08-26 Thread Greg Ewing
HUANG YUWEI wrote: # calling func() with using the karg_return argument output = func(2,3,karg1=4,a:=karg_return) This would be ambiguoius, because a:=karg_return is valid as an ordinary expression with an embedded assignment. -- Greg ___ Python-ide

[Python-ideas] Re: [new idea] dynamic return with using function argument

2019-08-26 Thread Greg Ewing
HUANG YUWEI wrote: the number of return variables could be many. Then it would look like ``` res0, res1, res2, res3, res4, res5, res6, res7, ..., resN = high_level_function() At that point you're better off returning an object with named attributes, such as a namedtuple or a class designed for

[Python-ideas] Custom string prefixes

2019-08-26 Thread stpasha
In Python strings are allowed to have a number of special prefixes: b'', r'', u'', f'' + their combinations. The proposal is to allow arbitrary (or letter-only) user-defined prefixes as well. Essentially, a string prefix would serve as a decorator for a string, allowing the user to imp

[Python-ideas] Re: Custom string prefixes

2019-08-26 Thread Robert Vanden Eynde
On Another Subject, we could also have a language change staying that those two lines are equivalent : something"hello" something("hello") So that, any callable in the context can be used as a prefix ? On Tue, Aug 27, 2019, 01:11 wrote: > In Python strings are allowed to have a number of speci

[Python-ideas] Re: Custom string prefixes

2019-08-26 Thread Andrew Barnert via Python-ideas
On Aug 26, 2019, at 16:03, [email protected] wrote: > > In Python strings are allowed to have a number of special prefixes: > >b'', r'', u'', f'' >+ their combinations. > > The proposal is to allow arbitrary (or letter-only) user-defined prefixes as > well. > Essentially, a string pref

[Python-ideas] Re: Custom string prefixes

2019-08-26 Thread MRAB
On 2019-08-27 00:03, [email protected] wrote: In Python strings are allowed to have a number of special prefixes: b'', r'', u'', f'' + their combinations. The proposal is to allow arbitrary (or letter-only) user-defined prefixes as well. Essentially, a string prefix would serve as a

[Python-ideas] Re: [new idea] dynamic return with using function argument

2019-08-26 Thread HUANG YUWEI
> In 3.8, foo(a := 42) is in fact valid syntax, meaning the same as foo((a > := 42)). > Yes, I ignored that assign operator is actually a valid syntax in function calling, and what I need is new syntax. Although the "dynamic return" could be implemented, I agree that it is unworthy and namedtuple

[Python-ideas] Re: Custom string prefixes

2019-08-26 Thread stpasha
Thanks, Andrew, for your feedback. I didn't even think about string **suffixes**, but clearly they can be implemented together with the prefixes for additional flexibility. And your idea that ` ` is conceptually no different than ` ` is absolutely insightful. Speaking of string suffixes, flags o

[Python-ideas] Re: Custom string prefixes

2019-08-26 Thread Steven D'Aprano
On Mon, Aug 26, 2019 at 11:03:38PM -, [email protected] wrote: > In Python strings are allowed to have a number of special prefixes: > > b'', r'', u'', f'' > + their combinations. > > The proposal is to allow arbitrary (or letter-only) user-defined prefixes as > well. > Essentially,

[Python-ideas] Re: Custom string prefixes

2019-08-26 Thread Andrew Barnert via Python-ideas
> On Aug 26, 2019, at 18:41, [email protected] wrote: > > Thanks, Andrew, for your feedback. I didn't even think about string > **suffixes**, but > clearly they can be implemented together with the prefixes for additional > flexibility. What about _instead of_ rather than _together with_? Half

[Python-ideas] Re: Custom string prefixes

2019-08-26 Thread Serhiy Storchaka
27.08.19 06:38, Andrew Barnert via Python-ideas пише: * JSON (register the stdlib or simplejson or ujson), What if the JSON suffix for? JSON is virtually a subset of Python except that that it uses true, false and null instead of True, False and None. If you set these three variables you ca