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

2017-06-01 Thread Greg Ewing
Victor Stinner wrote: How do you write π (pi) with a keyboard on Windows, Linux or macOS? On a Mac, π is Option-p and ∑ is Option-w. -- Greg ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas

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

2017-06-01 Thread Chris Angelico
On Fri, Jun 2, 2017 at 11:05 AM, Steven D'Aprano wrote: > On Fri, Jun 02, 2017 at 09:22:16AM +1000, Chris Angelico wrote: > >> Ultimately, what I would like is for "import random" to be absolutely >> dependably going to grab the stdlib "random" module, or at very least, >>

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

2017-06-01 Thread Steven D'Aprano
On Fri, Jun 02, 2017 at 09:22:16AM +1000, Chris Angelico wrote: > Ultimately, what I would like is for "import random" to be absolutely > dependably going to grab the stdlib "random" module, or at very least, > something that someone *deliberately* is shadowing that module with. > You shouldn't

Re: [Python-ideas] Allow function to return multiple values

2017-06-01 Thread Mark Lawrence via Python-ideas
On 02/06/2017 01:11, Steven D'Aprano wrote: Hi Joannah, and welcome! On Thu, Jun 01, 2017 at 05:17:49PM +0300, joannah nanjekye wrote: [...] My proposal is we provide a way of functions returning multiple values. This has been implemented in languages like Go and I have found many cases where

Re: [Python-ideas] Allow function to return multiple values

2017-06-01 Thread Steven D'Aprano
Hi Joannah, and welcome! On Thu, Jun 01, 2017 at 05:17:49PM +0300, joannah nanjekye wrote: [...] > My proposal is we provide a way of functions returning multiple values. > This has been implemented in languages like Go and I have found many cases > where I needed and used such a functionality.

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

2017-06-01 Thread Chris Angelico
On Fri, Jun 2, 2017 at 8:58 AM, Victor Stinner wrote: >> (AIUI, the *current directory* is never on Python's path, but the > *script directory* is. They're the same thing a lot of the time.) > > Oh, it's very common that I run a script from its directory, so yeah script

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

2017-06-01 Thread Victor Stinner
> (AIUI, the *current directory* is never on Python's path, but the *script directory* is. They're the same thing a lot of the time.) Oh, it's very common that I run a script from its directory, so yeah script directory = current directory on such case. Sorry for the confusion. You are right,

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

2017-06-01 Thread Masayuki YAMAMOTO
Hi Stephan, Nevertheless, I would like to point out that the encoding assumed for a > Python3 source file never depends on the locale. > Yeah, as you pointed out. I'd like to correct my said. > My understanding is that in the default encoding for Python source files > (utf-8), East Asian

Re: [Python-ideas] Allow function to return multiple values

2017-06-01 Thread Terry Reedy
On 6/1/2017 10:17 AM, joannah nanjekye wrote: Today I was writing an example snippet for the book and needed to write a function that returns two values something like this: def return_multiplevalues(num1, num2): return num1, num2 I noticed that this actually returns a tuple of the

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

2017-06-01 Thread Eric Snow
On Thu, Jun 1, 2017 at 10:30 AM, 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] π = math.pi

2017-06-01 Thread Nikolaus Rath
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 math module? ;-) >> >> math.π = math.pi > > How

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

2017-06-01 Thread Koos Zevenhoven
On Thu, Jun 1, 2017 at 9:47 AM, 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 ∞, ∑

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

2017-06-01 Thread David Mertz
I think having math.pi is just for backward compatibility. We all use tau now, I assume. That's why the true definition is: pi = math.tau/2 :-) ... and yes, as someone else comments, adding tau was a bit whimsical in the spirit of 'import antigravity' and the line. On Jun 1, 2017 12:48 AM,

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

2017-06-01 Thread Chris Angelico
On Fri, Jun 2, 2017 at 2:40 AM, Random832 wrote: > On Thu, Jun 1, 2017, at 10:08, Masayuki YAMAMOTO wrote: >> The width of Greek letters is East Asian Ambiguous. Using ambiguous width >> characters possibly will be a reason that is source code layout break on >> specific

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

2017-06-01 Thread Chris Angelico
On Fri, Jun 2, 2017 at 2:30 AM, Victor Stinner wrote: > Perl 5.26 succeeded to remove the current working directory from the > default include path (our Python sys.path): > >

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

2017-06-01 Thread Random832
On Thu, Jun 1, 2017, at 10:08, Masayuki YAMAMOTO wrote: > The width of Greek letters is East Asian Ambiguous. Using ambiguous width > characters possibly will be a reason that is source code layout break on > specific locale. I don't think PEP 8 approves anyway of doing the kind of column

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

2017-06-01 Thread Victor Stinner
Hi, Perl 5.26 succeeded to remove the current working directory from the default include path (our Python sys.path): https://metacpan.org/pod/release/XSAWYERX/perl-5.26.0/pod/perldelta.pod#Removal-of-the-current-directory-(%22.%22)-from-@INC Would it technically possible to make this change in

Re: [Python-ideas] Allow function to return multiple values

2017-06-01 Thread Ethan Furman
On 06/01/2017 07:17 AM, joannah nanjekye wrote: Today I was writing an example snippet for the book and needed to write a function that returns two values something like this: def return_multiplevalues(num1, num2): return num1, num2 I noticed that this actually returns a tuple of the

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

2017-06-01 Thread Stephan Houben
Hi Masayuki, I admit that my understanding of this issue is very limited. Nevertheless, I would like to point out that the encoding assumed for a Python3 source file never depends on the locale. My understanding is that in the default encoding for Python source files (utf-8), East Asian

Re: [Python-ideas] Allow function to return multiple values

2017-06-01 Thread Thomas Nyberg
On 06/01/2017 07:17 AM, joannah nanjekye wrote: > a function that returns two values something like this: > > def return_multiplevalues(num1, num2): > return num1, num2 > > I noticed that this actually returns a tuple of the values which I did > not want in the first place.I wanted python

Re: [Python-ideas] Allow function to return multiple values

2017-06-01 Thread אלעזר
What is the difference between returning a tuple and returning two values? I think at least theoretically it's different wording for precisely the same thing. Elazar בתאריך יום ה׳, 1 ביונ' 2017, 17:21, מאת Markus Meskanen ‏< markusmeska...@gmail.com>: > Why isn't a tuple enough? You can do

Re: [Python-ideas] Allow function to return multiple values

2017-06-01 Thread Markus Meskanen
Why isn't a tuple enough? You can do automatic tuple unpack: v1, v2 = return_multiplevalues(1, 2) On Jun 1, 2017 17:18, "joannah nanjekye" wrote: Hello Team, I am Joannah. I am currently working on a book on python compatibility and publishing it with apress. I

[Python-ideas] Allow function to return multiple values

2017-06-01 Thread joannah nanjekye
Hello Team, I am Joannah. I am currently working on a book on python compatibility and publishing it with apress. I have worked with python for a while we are talking about four years. Today I was writing an example snippet for the book and needed to write a function that returns two values

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

2017-06-01 Thread Masayuki YAMAMOTO
The width of Greek letters is East Asian Ambiguous. Using ambiguous width characters possibly will be a reason that is source code layout break on specific locale. Masayuki 2017-06-01 15:47 GMT+09:00 Serhiy Storchaka : > What you are think about adding Unicode aliases for

Re: [Python-ideas] SealedMock proposal for unittest.mock

2017-06-01 Thread Mario Corchero
Having it part of the existing Mock class might be great. I really like the idea of mock.seal(mock_object). Let me try it out and draft some code and I'll open the issue. Thanks :) On 1 June 2017 at 13:29, Julien Duponchelle wrote: > Perhaps you can set via configure_mock. This

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

2017-06-01 Thread Guyzmo via Python-ideas
On Thu, Jun 01, 2017 at 11:49:43AM +0200, Victor Stinner wrote: > How do you write π (pi) with a keyboard on Windows, Linux or macOS? Use the compose key  for linux: https://help.ubuntu.com/community/ComposeKey for windows: https://github.com/SamHocevar/wincompose for macosx:

Re: [Python-ideas] SealedMock proposal for unittest.mock

2017-06-01 Thread Julien Duponchelle
Perhaps you can set via configure_mock. This will prevent conflict with existing code. Julien On Thu, Jun 1, 2017 at 2:17 PM Victor Stinner wrote: > A stricter mock object cannot be a bad idea :-) I am not sure about your > proposed API: some random code may already

Re: [Python-ideas] SealedMock proposal for unittest.mock

2017-06-01 Thread Victor Stinner
A stricter mock object cannot be a bad idea :-) I am not sure about your proposed API: some random code may already use this attribute. Maybe it can be a seal (mock) function which sets a secret attribute with a less common name? Yeah, please open an issue on bugs.python.org ;-) Victor Le 29

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

2017-06-01 Thread Stephan Houben
Hi Serhiy, For the record, *I* am a complete nobody, it's Guido you will have to convince. I am not sure that presenting it as a joke feature is the road to success, but admittedly it has at least worked once before. Stephan 2017-06-01 12:16 GMT+02:00 Serhiy Storchaka :

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

2017-06-01 Thread Stephan Houben
> This shouldn't be a problem for Greek users. ;-) Well, they still need to switch between keymaps, since presumably they used the Latin keymap to enter `math.` before they can enter π. That is actually another general solution: just install the Greek keymap in addition to your native keymap.

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

2017-06-01 Thread Serhiy Storchaka
01.06.17 12:32, Stephan Houben пише: math.π is a kind of joke too. The point is that tau, being a joke, should not be considered as setting a precedent. If add one joke feature per release, this one looks enough harmless. ___ Python-ideas mailing

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

2017-06-01 Thread Serhiy Storchaka
01.06.17 12:49, Victor Stinner пише: 2017-06-01 8:47 GMT+02:00 Serhiy Storchaka : What you are think about adding Unicode aliases for some mathematic names in the math module? ;-) math.π = math.pi How do you write π (pi) with a keyboard on Windows, Linux or macOS? This

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

2017-06-01 Thread Stephan Houben
> How do you write π (pi) with a keyboard on Windows, Linux or macOS? On macOS, ⌥ P (Option-P) works. On all platforms: 1. Make sure you are using Vim. 2. In insert mode: Ctrl-K *p You can also define abbrev's which will allow you to type pi\ and it gets replaced by π. See:

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

2017-06-01 Thread Victor Stinner
2017-06-01 8:47 GMT+02:00 Serhiy Storchaka : > What you are think about adding Unicode aliases for some mathematic names in > the math module? ;-) > > math.π = math.pi How do you write π (pi) with a keyboard on Windows, Linux or macOS? Victor

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

2017-06-01 Thread Stephan Houben
Hi Serhiy, > math.π is a kind of joke too. The point is that tau, being a joke, should not be considered as setting a precedent. > Honest, it is strange, that Python allows Unicode identifiers, but doesn't > have the one in its stdlib! Actually it is policy:

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

2017-06-01 Thread Serhiy Storchaka
01.06.17 10:53, Stephan Houben пише: Tau was kind of a joke. math.π is a kind of joke too. Honest, it is strange, that Python allows Unicode identifiers, but doesn't have the one in its stdlib! ___ Python-ideas mailing list

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

2017-06-01 Thread Antoine Rozo
Does this really make expressions more readable? More, these characters are difficult to write. 2017-06-01 9:53 GMT+02:00 Stephan Houben : > Tau was kind of a joke. > > Stephan > > Op 1 jun. 2017 09:47 schreef "Serhiy Storchaka" : > > 01.06.17 10:03,

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

2017-06-01 Thread Stephan Houben
Tau was kind of a joke. Stephan Op 1 jun. 2017 09:47 schreef "Serhiy Storchaka" : 01.06.17 10:03, David Mertz пише: It's awfully easy to add in your own code. Since they are simply aliases, I > don't see why bother put the duplication in the standard library. You can >

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

2017-06-01 Thread Serhiy Storchaka
01.06.17 10:03, David Mertz пише: It's awfully easy to add in your own code. Since they are simply aliases, I don't see why bother put the duplication in the standard library. You can even monkey patch if you want it in the 'math' namespace. I'd prefer a bare 'π' in my own code though. As

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

2017-06-01 Thread Oleg Broytman
On Thu, Jun 01, 2017 at 09:47:57AM +0300, 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

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

2017-06-01 Thread Stephan Houben
Or perhaps create a small module: unimath.py== import math __all__ = ["π", "τ", "Γ"] π = math.pi τ = math.tau Γ = math.gamma Then do: from unimath import * Put it on the Python Package index. If it gets wildly popular the case for

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

2017-06-01 Thread Lucas Wiman
I like the aesthetic of the idea, but it seems like this would be a better fit in a library namespace like sympy or jupyter. On Thu, Jun 1, 2017 at 12:19 AM, Sven R. Kunze wrote: > On 01.06.2017 08:47, Serhiy Storchaka wrote: > > What you are think about adding Unicode aliases

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

2017-06-01 Thread Stephan Houben
Or perhaps create a small module: unimath.py== import math __all__ = ["π", "τ", "Γ"] π = math.pi τ = math.tau Γ = math.gamma Then do: from unimath import * Put it on the Python Package index. If it gets wildly popular the case for

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

2017-06-01 Thread Sven R. Kunze
On 01.06.2017 08:47, 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. :-(

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

2017-06-01 Thread Stephan Houben
Hi all, Two remarks: 1. Note that ℯ also doesn't really work. While you can assign to this identifier, it actually gets normalized into a plain "e". 2. Unicode has a Σ : GREEK CAPITAL LETTER SIGMA and a ∑ : N-ARY SUMMATION The first is a valid Python identifier, the second not.

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

2017-06-01 Thread Brice PARENT
Why not simply use from math import pi as π and so on? It makes your math formulas more readable (taking out the "math." entirely), without requiring any change to the module. Le 01/06/17 à 08:47, Serhiy Storchaka a écrit : What you are think about adding Unicode aliases for some mathematic

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

2017-06-01 Thread Ivan Levkivskyi
Although it is trivial, I like the idea (except for math.e maybe). (And it would be cool to be able to also write ∑ = sum, etc.) -- Ivan On 1 June 2017 at 08:47, Serhiy Storchaka wrote: > What you are think about adding Unicode aliases for some mathematic names > in the

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

2017-06-01 Thread David Mertz
It's awfully easy to add in your own code. Since they are simply aliases, I don't see why bother put the duplication in the standard library. You can even monkey patch if you want it in the 'math' namespace. I'd prefer a bare 'π' in my own code though. On May 31, 2017 11:48 PM, "Serhiy Storchaka"

[Python-ideas] π = math.pi

2017-06-01 Thread Serhiy Storchaka
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. :-( ___ Python-ideas