Re: [Python-ideas] Security: remove "." from sys.path?

2017-06-03 Thread Juancarlo Añez
I'm not comfortable with the subject title of this thread. I'm comfortable with the experiences and solutions proposed by Nick. On Sat, Jun 3, 2017 at 8:16 PM, Greg Ewing wrote: > Soni L. wrote: > >> How about `import self.thing` (where "self" implies same dir as

Re: [Python-ideas] Security: remove "." from sys.path?

2017-06-03 Thread Greg Ewing
Soni L. wrote: How about `import self.thing` (where "self" implies same dir as the current .py That wouldn't provide quite the same functionality, since currently a module alongside the main py file can be imported from anywhere, including .py files inside a package. Also I think it would be

Re: [Python-ideas] Security: remove "." from sys.path?

2017-06-03 Thread Greg Ewing
Is this really much of a security issue? Seems to me that for someone to exploit it, they would have to inject a malicious .py file alongside one of my script files. If they can do that, they can probably do all kinds of bad things directly. -- Greg

Re: [Python-ideas] Defer Statement

2017-06-03 Thread Juancarlo Añez
On Sat, Jun 3, 2017 at 6:59 AM, Daniel Bershatsky wrote: Or with usage defer keyword > > ``` > fin = open(filename) > defer fin.close() > # some stuff > IMHO, a block in which the intention of a `finally: is not well understood, needs refactoring. Some *old*

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Chris Angelico
On Sun, Jun 4, 2017 at 5:02 AM, Thomas Jollans wrote: > On 03/06/17 20:41, Chris Angelico wrote: >> [snip] >> For reference, as well as the 948 Sm, there are 1690 Mn and 5777 So, >> but only these characters are valid from them: >> >> \u1885 Mn MONGOLIAN LETTER ALI GALI BALUDA >>

Re: [Python-ideas] Defer Statement

2017-06-03 Thread Joshua Morton
Its also worth mentioning that the `defer` statement has come up in other contexts, and is already often used as an identifier already (see *https://mail.python.org/pipermail/python-ideas/2017-February/044682.html *), so

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Thomas Jollans
On 03/06/17 21:02, Thomas Jollans wrote: > On 03/06/17 20:41, Chris Angelico wrote: >> [snip] >> For reference, as well as the 948 Sm, there are 1690 Mn and 5777 So, >> but only these characters are valid from them: >> >> \u1885 Mn MONGOLIAN LETTER ALI GALI BALUDA >> \u1886 Mn MONGOLIAN LETTER ALI

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Julien Palard via Python-ideas
Hi, What you are think about adding Unicode aliases for some mathematic names in the math module? ;-) math.π = math.pi math.τ = math.tau math.Γ = math.gamma math.ℯ = math.e Unfortunately we can't use ∞, ∑ and √ as identifiers. :-( It may be the role of editors to do it if one really want it. I

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Ivan Levkivskyi
On 3 June 2017 at 21:55, MRAB wrote: > [...] >> > > Interestingly, '_' doesn't have that property, although Python does allow > identifiers to start with it. Yes, it is special cased: if (!_PyUnicode_IsXidStart(first) && first != 0x5F /* LOW LINE */)

Re: [Python-ideas] π = math.pi

2017-06-03 Thread MRAB
On 2017-06-03 19:50, Thomas Jollans wrote: On 03/06/17 18:48, Steven D'Aprano wrote: On Sun, Jun 04, 2017 at 02:36:50AM +1000, Steven D'Aprano wrote: But Python 3.5 does treat it as an identifier! py> ℘ = 1 # should be a SyntaxError ? py> ℘ 1 There's a bug here, somewhere, I'm just not

Re: [Python-ideas] Security: remove "." from sys.path?

2017-06-03 Thread Todd
On Jun 3, 2017 2:45 PM, "Chris Angelico" wrote: On Sun, Jun 4, 2017 at 12:42 AM, Nick Coghlan wrote: >> But I don't think that running an application from the source without >> installing it is the most common way to run an application. Most users >>

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Thomas Jollans
On 03/06/17 20:41, Chris Angelico wrote: > [snip] > For reference, as well as the 948 Sm, there are 1690 Mn and 5777 So, > but only these characters are valid from them: > > \u1885 Mn MONGOLIAN LETTER ALI GALI BALUDA > \u1886 Mn MONGOLIAN LETTER ALI GALI THREE BALUDA > ℘ Sm SCRIPT CAPITAL P > ℮ So

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Dan Sommers
On Sat, 03 Jun 2017 17:45:43 +, Brett Cannon wrote: > On Fri, 2 Jun 2017 at 15:56 Guido van Rossum wrote: > >> I would love to show how easy it is to write >> >> from math import pi as π, gamma as Γ [...] >> but I had to cheat by copying from the OP since I don't know

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Thomas Jollans
On 03/06/17 18:48, Steven D'Aprano wrote: > On Sun, Jun 04, 2017 at 02:36:50AM +1000, Steven D'Aprano wrote: > >> But Python 3.5 does treat it as an identifier! >> >> py> ℘ = 1 # should be a SyntaxError ? >> py> ℘ >> 1 >> >> There's a bug here, somewhere, I'm just not sure where... > That appears

Re: [Python-ideas] Security: remove "." from sys.path?

2017-06-03 Thread Chris Angelico
On Sun, Jun 4, 2017 at 12:42 AM, Nick Coghlan wrote: >> But I don't think that running an application from the source without >> installing it is the most common way to run an application. Most users >> install applications to use them, no? > > Scripts are very frequently run

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Chris Angelico
On Sun, Jun 4, 2017 at 2:48 AM, Steven D'Aprano wrote: > On Sun, Jun 04, 2017 at 02:36:50AM +1000, Steven D'Aprano wrote: > >> But Python 3.5 does treat it as an identifier! >> >> py> ℘ = 1 # should be a SyntaxError ? >> py> ℘ >> 1 >> >> There's a bug here, somewhere, I'm

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Serhiy Storchaka
03.06.17 20:45, Brett Cannon пише: Since this regularly comes up, why don't we add a note to the math module that you can do the above import(s) to bind various mathematical constants to their traditional symbol counterparts? The note can even start off with something like "While Python's

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Brett Cannon
On Fri, 2 Jun 2017 at 15:56 Guido van Rossum wrote: > I would love to show how easy it is to write > > from math import pi as π, gamma as Γ > > but I had to cheat by copying from the OP since I don't know how to type > these (and even if you were to tell me how I'd forget

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Steven D'Aprano
On Sun, Jun 04, 2017 at 02:36:50AM +1000, Steven D'Aprano wrote: > But Python 3.5 does treat it as an identifier! > > py> ℘ = 1 # should be a SyntaxError ? > py> ℘ > 1 > > There's a bug here, somewhere, I'm just not sure where... That appears to be the only Symbol Math character which is

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Steven D'Aprano
On Sat, Jun 03, 2017 at 03:51:50PM +0300, Serhiy Storchaka wrote: > The rule for Python identifiers already is not easy, there is no simple > regular expression for them, and I'm sure most tools proceeding Python > sources (even the tokenize module and IDLE) do not handle all Python >

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Thomas Jollans
On 01/06/17 20:11, Nikolaus Rath wrote: > On Jun 01 2017, Victor Stinner > wrote: >> 2017-06-01 8:47 GMT+02:00 Serhiy Storchaka : >>> What you are think about adding Unicode aliases for some mathematic names in >>> the

Re: [Python-ideas] Security: remove "." from sys.path?

2017-06-03 Thread Nick Coghlan
On 2 June 2017 at 02:30, Victor Stinner wrote: > Hi, > > Perl 5.26 succeeded to remove the current working directory from the > default include path (our Python sys.path): > >

Re: [Python-ideas] Security: remove "." from sys.path?

2017-06-03 Thread Soni L.
How about `import self.thing` (where "self" implies same dir as the current .py - if it's a dir-based package, then "self" is that dir) and `import super.thing` (where "super" implies parent package *locked to parent dir*. if there isn't any (top level package or main script), fail-by-default

Re: [Python-ideas] Security: remove "." from sys.path?

2017-06-03 Thread Soni L.
How about `import self.thing` (where "self" implies same dir as the current .py - if it's a dir-based package, then "self" is that dir) and `import super.thing` (where "super" implies parent package *locked to parent dir*. if there isn't any (top level package or main script), fail-by-default

Re: [Python-ideas] Security: remove "." from sys.path?

2017-06-03 Thread Chris Angelico
On Sat, Jun 3, 2017 at 8:36 PM, Steven D'Aprano wrote: > On Fri, Jun 02, 2017 at 12:36:59PM +1000, Chris Angelico wrote: > > [...] >> > I expect that moving '' to the end of sys.path will be a less disruptive >> > change than removing it. >> >> This is true. However, anything

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Serhiy Storchaka
03.06.17 03:31, Guido van Rossum пише: OK, I think this discussion is pretty much dead then. We definitely shouldn't allow math operators in identifiers, otherwise in Python 4 or 5 we couldn't introduce them as operators. Sorry. I proposed this idea as a joke. math.π is useless, but mostly

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Todd
Julia lets you define new infix operators directly, including using mathematical symbols as operators. Not that I think that is a good idea, but you can do it. On Jun 3, 2017 2:00 AM, "Joshua Morton" wrote: For reference, haskell is perhaps the closest language to

Re: [Python-ideas] Defer Statement

2017-06-03 Thread Nick Coghlan
On 3 June 2017 at 20:59, Daniel Bershatsky wrote: > Dear Python Developers, > > We have a potential idea for enhancing Python. You will find a kind of draft > bellow. Thank you for taking the time to write this up! > Best regards, > Daniel Bershatsky > > > Abstract >

[Python-ideas] Defer Statement

2017-06-03 Thread Daniel Bershatsky
Dear Python Developers, We have a potential idea for enhancing Python. You will find a kind of draft bellow. Best regards,Daniel Bershatsky  Abstract This PEP proposes the introduction of new syntax to create community standard,readable and clear way to defered function execution in basic

Re: [Python-ideas] Security: remove "." from sys.path?

2017-06-03 Thread Steven D'Aprano
On Fri, Jun 02, 2017 at 12:36:59PM +1000, Chris Angelico wrote: [...] > > I expect that moving '' to the end of sys.path will be a less disruptive > > change than removing it. > > This is true. However, anything that depends on the current behaviour > (intentionally or otherwise) would be just

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Nick Coghlan
On 3 June 2017 at 17:22, Pavol Lisy wrote: > On 6/3/17, Chris Angelico wrote: >> On Sat, Jun 3, 2017 at 3:42 PM, Pavol Lisy wrote: >>> Sorry for probably stupid question! Is something like -> >>> >>> class A: >>> def

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Nick Coghlan
On 3 June 2017 at 15:55, Chris Angelico wrote: > On Sat, Jun 3, 2017 at 3:42 PM, Pavol Lisy wrote: >> Sorry for probably stupid question! Is something like -> >> >> class A: >> def __oper__(self, '⊞', other): >> return

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Pavol Lisy
On 6/3/17, Chris Angelico wrote: > On Sat, Jun 3, 2017 at 3:42 PM, Pavol Lisy wrote: >> Sorry for probably stupid question! Is something like -> >> >> class A: >> def __oper__(self, '⊞', other): >> return something(self.value,

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Stephan Houben
> My humble opinion: I would rather like to see something like: > > from some_wide_used_scientific_library.math_constants import * > > with good acceptance from scientific users before thinking to add it > into stdlib. Agree with this, but note that a similar proposal has once been made to

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Stephan Houben
I use the conceal feature for this purpose, but I use https://github.com/ehamberg/vim-cute-python instead, which is a more toned-down version of the same idea. I personally find x ≤ y, a ∉ B more readable than x <= y, a not in B etc. Especially the conceal lambda => λ is useful for

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Stephan Houben
Hi Joshua, > A `op` B > > is equivalent to > > op(A, B This can of course be faked in Python. https://gist.github.com/stephanh42/a4d6d66b10cfecf935c9531150afb247 Now you can do: @BinopCallable def add(x, y): return x + y print(3 @add@ 5) === Stephan

Re: [Python-ideas] π = math.pi

2017-06-03 Thread Pavol Lisy
On 6/1/17, Serhiy Storchaka wrote: > What you are think about adding Unicode aliases for some mathematic > names in the math module? ;-) > > math.π = math.pi > math.τ = math.tau > math.Γ = math.gamma > math.ℯ = math.e > > Unfortunately we can't use ∞, ∑ and √ as identifiers.