[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Andrew Barnert via Python-ideas
On Nov 14, 2019, at 13:23, MRAB wrote: > >> On 2019-11-14 19:51, Andrew Barnert via Python-ideas wrote: >> On Nov 14, 2019, at 11:21, Random832 wrote: On Thu, Nov 14, 2019, at 13:12, Andrew Barnert wrote: And then you can run it on a whole mess of code and verify that it’s only

[Python-ideas] Re: Adding fixed-point decimals as an option to replace floating-point

2019-11-14 Thread Wes Turner
FWIW, bigfloat (GNU MPFR) has arbitrary precision and rounding that can be set with `with` context managers: https://pythonhosted.org/bigfloat/ On Thursday, November 14, 2019, Greg Ewing wrote: > On 15/11/19 7:39 am, Chris Angelico wrote: >> >> But in your >> source code, if you type 4.1, you

[Python-ideas] Re: Adding fixed-point decimals as an option to replace floating-point

2019-11-14 Thread Chris Angelico
On Fri, Nov 15, 2019 at 9:53 AM Greg Ewing wrote: > > On 15/11/19 7:39 am, Chris Angelico wrote: > > But in your > > source code, if you type 4.1, you are asking for the floating-point > > value > > The idea of providing decimal literals comes up from time to > time, but so far it hasn't gotten

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Greg Ewing
Another idea -- use semicolons to separate "as" clauses in a with statement, and allow newlines after them. with open(name1) as f1; open(name2) as f2; open(name3) as f3: ... -- Greg ___ Python-ideas mailing list --

[Python-ideas] Re: Adding fixed-point decimals as an option to replace floating-point

2019-11-14 Thread Greg Ewing
On 15/11/19 7:39 am, Chris Angelico wrote: But in your source code, if you type 4.1, you are asking for the floating-point value The idea of providing decimal literals comes up from time to time, but so far it hasn't gotten anywhere. The problem is that it would make the core interpreter

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Greg Ewing
On 15/11/19 5:54 am, Paul Moore wrote: On Thu, 14 Nov 2019 at 16:42, Random832 wrote: So, uh... what if we didn't need backslashes for statements that begin with a keyword and end with a colon? Not sure about ambiguity, but it would require a much more powerful parser than Python currently

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Random832
On Thu, Nov 14, 2019, at 16:23, MRAB wrote: > On 2019-11-14 19:51, Andrew Barnert via Python-ideas wrote: > > And that raises a point: the if keyword can appear in other places besides > > the start of a compound statement. Does tokenize.py have enough info to > > handle that properly? I don’t

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread MRAB
On 2019-11-14 19:51, Andrew Barnert via Python-ideas wrote: On Nov 14, 2019, at 11:21, Random832 wrote: On Thu, Nov 14, 2019, at 13:12, Andrew Barnert wrote: And then you can run it on a whole mess of code and verify that it’s only different in the cases where you want it to be different

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Guido van Rossum
Maybe. But in the past we've tweaked the syntax to be able to use parentheses (e.g. for long import statements). On Thu, Nov 14, 2019 at 12:08 PM Andrew Barnert wrote: > On Nov 14, 2019, at 10:33, Guido van Rossum wrote: > > > > I would not be a fan of this approach (even though I agree it's >

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Andrew Barnert via Python-ideas
On Nov 14, 2019, at 10:33, Guido van Rossum wrote: > > I would not be a fan of this approach (even though I agree it's technically > feasible). The problem is that if a user simply forgets the colon at the end > of a line (surely a common mistake), the modified parser would produce a much >

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Andrew Barnert via Python-ideas
On Nov 14, 2019, at 11:21, Random832 wrote: > >> On Thu, Nov 14, 2019, at 13:12, Andrew Barnert wrote: >> And then you can run it on a whole mess of code and verify that it’s >> only different in the cases where you want it to be different (what >> used to be an ERRORTOKEN or NEWLINE is now an

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Random832
On Thu, Nov 14, 2019, at 13:12, Andrew Barnert wrote: > And then you can run it on a whole mess of code and verify that it’s > only different in the cases where you want it to be different (what > used to be an ERRORTOKEN or NEWLINE is now an NL because we’re in the > middle of a with compound

[Python-ideas] Re: Adding fixed-point decimals as an option to replace floating-point

2019-11-14 Thread Chris Angelico
On Fri, Nov 15, 2019 at 4:04 AM wrote: > > Does decimal make this: > 4.1 + 0.1 > produce 4.2 instead of 4.18? The decimal module means that Decimal("4.1") is equal to 41/10 rather than 2308094809027379/562949953421312, and Decimal("0.1") is equal to 1/10 rather than

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Guido van Rossum
I would not be a fan of this approach (even though I agree it's technically feasible). The problem is that if a user simply forgets the colon at the end of a line (surely a common mistake), the modified parser would produce a much more confusing error on a subsequent line. With the PEG parser we

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Gabriel Kabbe
I'm glad to see so many reponses to my initial post! But to be fair, I can also see that this is a not so important feature and changing the parser for this is probably not worth it. Anyway, I will just keep following this discussion and see what comes out of it :-) Am 14-Nov-2019 19:13:16

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Andrew Barnert via Python-ideas
On Nov 14, 2019, at 09:53, Andrew Barnert via Python-ideas wrote: > > Yeah, it seems like this should be doable in basically the same way bracketed > multiline expressions are. I’m not sure how much of a change that would > require. But it seems like it’s worth fiddling with the CPython

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Andrew Barnert via Python-ideas
On Nov 14, 2019, at 09:05, Random832 wrote: > >> On Thu, Nov 14, 2019, at 11:54, Paul Moore wrote: >>> On Thu, 14 Nov 2019 at 16:42, Random832 wrote: >>> >>> So, uh... what if we didn't need backslashes for statements that begin with >>> a keyword and end with a colon? There's no syntactic

[Python-ideas] Re: Adding fixed-point decimals as an option to replace floating-point

2019-11-14 Thread MRAB
On 2019-11-14 17:10, Brett Cannon wrote: On Thu, Nov 14, 2019 at 9:04 AM > wrote: Does decimal make this: 4.1 + 0.1 produce 4.2 instead of 4.18? Yes, see https://docs.python.org/3/library/decimal.html#module-decimal. If you're talking

[Python-ideas] Re: Adding fixed-point decimals as an option to replace floating-point

2019-11-14 Thread Brett Cannon
On Thu, Nov 14, 2019 at 9:04 AM wrote: > Does decimal make this: > 4.1 + 0.1 > produce 4.2 instead of 4.18? > Yes, see https://docs.python.org/3/library/decimal.html#module-decimal. > ___ > Python-ideas mailing list --

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Random832
On Thu, Nov 14, 2019, at 11:54, Paul Moore wrote: > On Thu, 14 Nov 2019 at 16:42, Random832 wrote: > > > So, uh... what if we didn't need backslashes for statements that begin with > > a keyword and end with a colon? There's no syntactic ambiguity there, > > right? Honestly, adding this would

[Python-ideas] Re: Adding fixed-point decimals as an option to replace floating-point

2019-11-14 Thread awesomecronk
Does decimal make this: 4.1 + 0.1 produce 4.2 instead of 4.18? ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Paul Moore
On Thu, 14 Nov 2019 at 16:42, Random832 wrote: > So, uh... what if we didn't need backslashes for statements that begin with a > keyword and end with a colon? There's no syntactic ambiguity there, right? > Honestly, adding this would make me less annoyed with the error I get when I > forget

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Random832
On Thu, Nov 14, 2019, at 03:57, Paul Moore wrote: > with \ > open(fname1) as f1, \ > open(fname2) as f2, \ > open(fname3) as f3, \ > open(fname4) as f4: So, uh... what if we didn't need backslashes for statements that begin with a keyword and end with a colon?

[Python-ideas] Re: Adding fixed-point decimals as an option to replace floating-point

2019-11-14 Thread Jonathan Goble
On Thu, Nov 14, 2019 at 8:49 AM wrote: > > An ideal improvement to python would be the introduction of fixed point > decimals. Maybe make them adjustable with os.system(). To adjust, you would > call os.system with the parameters ‘fixed’, 3, 15 to dictate fixed point > math, three integer

[Python-ideas] Adding fixed-point decimals as an option to replace floating-point

2019-11-14 Thread awesomecronk
An ideal improvement to python would be the introduction of fixed point decimals. Maybe make them adjustable with os.system(). To adjust, you would call os.system with the parameters ‘fixed’, 3, 15 to dictate fixed point math, three integer places, and 15 decimal places. Might be good for

[Python-ideas] Re: Please consider adding of functions file system operations to pathlib

2019-11-14 Thread Steve Jorgensen
Michel Desmoulin wrote: > +1 > We already merged, os.path and glob with pathlib. Let's do all os and > shutil. > It's weird enough for beginners to even sumble upon that many ways of > doing thing for FS. > Le 20/02/2018 à 23:11, George Fischhof a écrit : > > Good day all, > > as a continuation of

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Paul Moore
On Thu, 14 Nov 2019 at 06:45, Greg Ewing wrote: > > > On Nov 13, 2019, at 10:26, gabriel.ka...@mail.de wrote: > >> with ( > >> open(fname1) as f1, > >> open(fname2) as f2, > >> open(fname3) as f3, > >> open(fname4) as f4 > >> ): > > Maybe you should be able to do something like >