Re: Assignment Versus Equality

2016-06-29 Thread Chris Angelico
On Wed, Jun 29, 2016 at 4:45 PM, Steven D'Aprano wrote: > On Wednesday 29 June 2016 15:51, Lawrence D’Oliveiro wrote: > >> On Wednesday, June 29, 2016 at 5:26:46 PM UTC+12, Steven D'Aprano wrote: >>> BUT in Python 3, the distinction between int and long is gone by dropping >>> int and renaming lon

Re: Assignment Versus Equality

2016-06-29 Thread Lawrence D’Oliveiro
On Wednesday, June 29, 2016 at 6:46:04 PM UTC+12, Steven D'Aprano wrote: > On Wednesday 29 June 2016 15:51, Lawrence D’Oliveiro wrote: > >> On Wednesday, June 29, 2016 at 5:26:46 PM UTC+12, Steven D'Aprano wrote: >>> BUT in Python 3, the distinction between int and long is gone by dropping >>> int

I need a pure python module from PyPI without additional packages on my OS.

2016-06-29 Thread Seti Volkylany
I heard about cairo, but it required installed on my computer before. -- https://mail.python.org/mailman/listinfo/python-list

Re: Can math.atan2 return INF?

2016-06-29 Thread Steven D'Aprano
On Sunday 26 June 2016 09:40, Gregory Ewing wrote: > Marko Rauhamaa wrote: >> pdora...@pas-de-pub-merci.mac.com (Pierre-Alain Dorange): >> >>>Near a black hole 3.7 seconds can last an infinite time... >> >> Which phenomenon prevents a black hole from ever forming. Yet >> astronomers keep telling

Re: Assignment Versus Equality

2016-06-29 Thread BartC
On 29/06/2016 06:26, Steven D'Aprano wrote: BUT in Python 3, the distinction between int and long is gone by dropping int and renaming long as "int". So all Python ints are BIGNUMs. In principle Python might use native 32 or 64 bit ints for small values and secretly promote them to BIGNUMs whe

Re: Assignment Versus Equality

2016-06-29 Thread Lawrence D’Oliveiro
On Wednesday, June 29, 2016 at 9:49:23 PM UTC+12, BartC wrote: > Even if Python has extremely efficient string handling, we know that > low-level string ops normally take longer than low-level integer ops. Maybe part of the general principle that, on modern machines, memory is cheap, but accessi

Re: "for/while ... break(by any means) ... else" make sense?

2016-06-29 Thread Victor Savu
There are many posts trying to explain the else after for or while. Here is my take on it: There are three ways of getting out of a (for/while) loop: throw, break or the iterator gets exhausted. The question is, how cab we tell which way we exited? For the throw, we have the except clause. This le

Re: Assignment Versus Equality

2016-06-29 Thread BartC
On 29/06/2016 10:56, Lawrence D’Oliveiro wrote: On Wednesday, June 29, 2016 at 9:49:23 PM UTC+12, BartC wrote: Even if Python has extremely efficient string handling, we know that low-level string ops normally take longer than low-level integer ops. Maybe part of the general principle that, on

Re: Operator Precedence/Boolean Logic

2016-06-29 Thread Rustom Mody
Moved from thread "Assignment Versus Equality" where this is less relevant On Wednesday, June 29, 2016 at 8:06:10 AM UTC+5:30, Steven D'Aprano wrote: > On Tue, 28 Jun 2016 12:10 am, Rustom Mody wrote: > > > Analogy: Python's bool as 1½-class because bool came into python a good > >

Re: Assignment Versus Equality

2016-06-29 Thread Rustom Mody
On Wednesday, June 29, 2016 at 8:06:10 AM UTC+5:30, Steven D'Aprano wrote: > On Tue, 28 Jun 2016 12:10 am, Rustom Mody wrote: > > > Analogy: Python's bool as 1½-class because bool came into python a good > > decade after python and breaking old code is a bigger issue than fixing > > control constr

Re: Can math.atan2 return INF?

2016-06-29 Thread Marko Rauhamaa
Steven D'Aprano : > There's a common myth going around that black holes take an infinite > amount of time to form, That appears to be the case. (Identical discussion points here: http://astronomy.stackexchange.com/questions/2441/does-matter-accumulat e-just-outside-the-event-horizon-of-a-black-ho

Re: Operator Precedence/Boolean Logic

2016-06-29 Thread Chris Angelico
On Wed, Jun 29, 2016 at 8:21 PM, Rustom Mody wrote: > > Please show me how we would define __bool__ for > > 1. Graphs -- the kind mathematicians define with "Let G =(V,E) be a graph..." > > 2. Automata which in a way are special kinds of graphs > > 3. Regular Expressions which mathematically are r

Re: Language improvement: Get more from the `for .. else` clause

2016-06-29 Thread Victor Savu
Sure. Simple use-case: Decorate the yielded values and the return value of a generator. Right now, with `yield from` you can only decorate the return value, whereas with a for loop you can decorate the yielded values, but you sacrifice the returned value altogether. ``` def ret_decorator(target_g

Re: "for/while ... break(by any means) ... else" make sense?

2016-06-29 Thread jfong
Steven D'Aprano at 2016/6/29 UTC+8 10:43:52AM wrote: > The "else" in for...else has nothing to do with any "if" inside the for > block. Yes, the "else" has nothing to do with "break" syntactically in Python language, but semantically in English it cause confusion. When I said "insane", I just wa

Re: Assignment Versus Equality

2016-06-29 Thread Steven D'Aprano
On Wed, 29 Jun 2016 06:09 pm, Chris Angelico wrote: > On Wed, Jun 29, 2016 at 4:45 PM, Steven D'Aprano > wrote: >> On Wednesday 29 June 2016 15:51, Lawrence D’Oliveiro wrote: >> >>> On Wednesday, June 29, 2016 at 5:26:46 PM UTC+12, Steven D'Aprano wrote: BUT in Python 3, the distinction betw

Re: Operator Precedence/Boolean Logic

2016-06-29 Thread Steven D'Aprano
On Wed, 29 Jun 2016 08:21 pm, Rustom Mody wrote: > So if we are in a link-pillow-fight here is a link > https://mail.python.org/pipermail/python-ideas/2016-June/040780.html > in which python-dev Nick Coghlan answers the question: > >> Q: ...supporting arithmetical operations (1+True==2) was a pri

Re: Assignment Versus Equality

2016-06-29 Thread BartC
On 29/06/2016 13:36, Steven D'Aprano wrote: On Wed, 29 Jun 2016 06:09 pm, Chris Angelico wrote: That's not necessarily fair - you're comparing two quite different Python interpreters, so there might be something entirely different that counteracts the integer performance. No, my test doesn'

Re: Operator Precedence/Boolean Logic

2016-06-29 Thread Rustom Mody
On Wednesday, June 29, 2016 at 6:38:16 PM UTC+5:30, Steven D'Aprano wrote: > On Wed, 29 Jun 2016 08:21 pm, Rustom Mody wrote: > > 3. Regular Expressions which mathematically are related to automata > > And pragmatically are (more) present in python than the first two > > Can you even have an emp

Re: Assignment Versus Equality

2016-06-29 Thread Chris Angelico
On Wed, Jun 29, 2016 at 11:24 PM, BartC wrote: > I used this little benchmark: > > def fn(): > n=0 > for i in range(100): > n+=i > > for k in range(100): > fn() Add, up the top: try: range = xrange except NameError: pass Otherwise, your Py2 tests are constructing a milli

Re: Assignment Versus Equality

2016-06-29 Thread Chris Angelico
On Wed, Jun 29, 2016 at 10:36 PM, Steven D'Aprano wrote: >> rosuav@sikorsky:~$ python2.7 -m timeit -s "n = 0" "for i in >> xrange(1): n += i" >> 1 loops, best of 3: 192 usec per loop >> rosuav@sikorsky:~$ python2.7 -m timeit -s "n = 1<<100" "for i in >> xrange(1): n += i" >> 1000 loops

Re: Can math.atan2 return INF?

2016-06-29 Thread Random832
On Wed, Jun 29, 2016, at 05:35, Steven D'Aprano wrote: > Although their perspectives are very different, neither is "more > right" than the other. I think usually the idea that there are "no privileged frames of reference" doesn't go so far as to include ones from which it is impossible to send in

Re: Assignment Versus Equality

2016-06-29 Thread BartC
On 29/06/2016 14:35, Chris Angelico wrote: On Wed, Jun 29, 2016 at 11:24 PM, BartC wrote: I used this little benchmark: def fn(): n=0 for i in range(100): n+=i for k in range(100): fn() Add, up the top: try: range = xrange except NameError: pass Otherwise, your Py2

Re: "for/while ... break(by any means) ... else" make sense?

2016-06-29 Thread Grant Edwards
On 2016-06-29, Steven D'Aprano wrote: [...] > is "insane" too, but still legal. The Python interpreter does not > judge your code. That's what Usenet is for. -- Grant Edwards grant.b.edwardsYow! I'm a nuclear at submarine u

Re: Operator Precedence/Boolean Logic

2016-06-29 Thread Grant Edwards
On 2016-06-29, Steven D'Aprano wrote: > To Nick, having 1+True return 2 is an accident of implementation, My recollection is that it was not an accident of impliementation. It was an intentional descision to provide compatibility with many years worth of programs that were written before there

Re: Operator Precedence/Boolean Logic

2016-06-29 Thread Jon Ribbens
On 2016-06-29, Grant Edwards wrote: > On 2016-06-29, Steven D'Aprano wrote: >> To Nick, having 1+True return 2 is an accident of implementation, > > My recollection is that it was not an accident of impliementation. It > was an intentional descision to provide compatibility with many years > wor

Re: Language improvement: Get more from the `for .. else` clause

2016-06-29 Thread Michael Selik
On Wed, Jun 29, 2016 at 7:11 AM Victor Savu wrote: > Please let me know if you are interested in a more concrete case such as a > domain-specific application (I can think of progress bars, logging, > transfer rate statistics ...). > Yes, please. I'd like to compare the proposed syntax against th

Re: Iteration, while loop, and for loop

2016-06-29 Thread Ian Kelly
On Tue, Jun 28, 2016 at 11:58 AM, Grant Edwards wrote: > On 2016-06-28, Tim Chase wrote: >> On 2016-06-29 01:20, Steven D'Aprano wrote: >>> While loops are great for loops where you don't know how many >>> iterations there will be but you do know that you want to keep >>> going while some conditi

Re: "for/while ... break(by any means) ... else" make sense?

2016-06-29 Thread Terry Reedy
On 6/29/2016 6:01 AM, Victor Savu wrote: There are many posts trying to explain the else after for or while. My take: a while statement *is* a repeated if statement, and that is how it is implemented. while condition: true() is equivalent to and implemented in machine language without a

Re: Operator Precedence/Boolean Logic

2016-06-29 Thread Steven D'Aprano
On Wed, 29 Jun 2016 11:30 pm, Rustom Mody wrote: > The other answers -- graphs and automata -- are questionable and/or wrong > > You may wish to think about them again? You may wish to justify your assertion. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sur

Re: Operator Precedence/Boolean Logic

2016-06-29 Thread Steven D'Aprano
On Thu, 30 Jun 2016 01:00 am, Grant Edwards wrote: > On 2016-06-29, Steven D'Aprano wrote: > >> To Nick, having 1+True return 2 is an accident of implementation, > > My recollection is that it was not an accident of impliementation. It > was an intentional descision to provide compatibility wi

Re: Iteration, while loop, and for loop

2016-06-29 Thread Steven D'Aprano
On Thu, 30 Jun 2016 01:29 am, Ian Kelly wrote: > On Tue, Jun 28, 2016 at 11:58 AM, Grant Edwards > wrote: [...] >>> But then, if you wrap up your "while" loop as a generator that yields >>> things, you can then use it in a "for" loop which seems to me like >>> the Pythonic way to do things. :-) >

Re: Assignment Versus Equality

2016-06-29 Thread Gregory Ewing
Marko Rauhamaa wrote: -- / \ / (almost) \ N |black || | hole |S \/ \ / -- / / compass needle / The compass needle shows that the probe is "frozen" and won'

Re: "for/while ... break(by any means) ... else" make sense?

2016-06-29 Thread Steven D'Aprano
On Wed, 29 Jun 2016 08:01 pm, Victor Savu wrote: > There are many posts trying to explain the else after for or while. Here > is my take on it: > > There are three ways of getting out of a (for/while) loop: throw, break or > the iterator gets exhausted. - reaching the end of the loop - raise (no

Re: "for/while ... break(by any means) ... else" make sense?

2016-06-29 Thread Chris Angelico
On Thu, Jun 30, 2016 at 10:27 AM, Steven D'Aprano wrote: > Following os.abort(), the interpreter exits in the hardest, quickest manner > possible. os.kill(os.getpid(), 9) Now THAT is the hardest way to abort. You ain't comin' back from this one! ChrisA -- https://mail.python.org/mailman/listin

Re: Can math.atan2 return INF?

2016-06-29 Thread Lawrence D’Oliveiro
On Wednesday, June 29, 2016 at 10:55:03 PM UTC+12, Marko Rauhamaa wrote: > No, the fundamental question here is whether it makes scientific sense > to speculate about topics that are beyond the reach of science. Few > scientists speculate about what went on before the Big Bang, for > example. On t

Re: Can math.atan2 return INF?

2016-06-29 Thread Rustom Mody
On Thursday, June 30, 2016 at 7:03:30 AM UTC+5:30, Lawrence D’Oliveiro wrote: > On Wednesday, June 29, 2016 at 10:55:03 PM UTC+12, Marko Rauhamaa wrote: > > No, the fundamental question here is whether it makes scientific sense > > to speculate about topics that are beyond the reach of science. Few

Re: "for/while ... break(by any means) ... else" make sense?

2016-06-29 Thread Rustom Mody
On Thursday, June 30, 2016 at 6:58:42 AM UTC+5:30, Chris Angelico wrote: > On Thu, Jun 30, 2016 at 10:27 AM, Steven D'Aprano wrote: > > Following os.abort(), the interpreter exits in the hardest, quickest manner > > possible. > > os.kill(os.getpid(), 9) > > Now THAT is the hardest way to abort. Y

Re: Can math.atan2 return INF?

2016-06-29 Thread Chris Angelico
On Thu, Jun 30, 2016 at 12:13 PM, Rustom Mody wrote: > ... hotly disputing for more than ½ a century... You keep using that character. Is it just to show off that you can? I was always taught to match the style of the rest of the sentence, so this would be "half a century". Same for most of your

Re: Meta decorator with parameters, defined in explicit functions

2016-06-29 Thread Lawrence D’Oliveiro
On Tuesday, June 28, 2016 at 5:03:08 PM UTC+12, Ben Finney wrote: > There is a clever one-line decorator that has been copy-pasted without > explanation in many code bases for many years:: > > decorator_with_args = lambda decorator: lambda *args, **kwargs: lambda > func: decorator(func, *args

Re: Meta decorator with parameters, defined in explicit functions

2016-06-29 Thread Lawrence D’Oliveiro
On Tuesday, June 28, 2016 at 5:03:08 PM UTC+12, Ben Finney wrote: > decorator_with_args = lambda decorator: lambda *args, **kwargs: lambda > func: decorator(func, *args, **kwargs) Ah, I see why there are 3 lambdas, instead of 2. It’s so that you can write decorator_func = decorator_with_

Re: Assignment Versus Equality

2016-06-29 Thread Steven D'Aprano
On Thu, 30 Jun 2016 10:29 am, Gregory Ewing wrote: > All your experiment shows is that the last information we had > about the magnet is that it was nearly stationary just above > the horizon. > > It doesn't prove that the probe itself is frozen, any more than > the fact that a photograph you too

Re: Meta decorator with parameters, defined in explicit functions

2016-06-29 Thread Steven D'Aprano
On Thu, 30 Jun 2016 12:43 pm, Lawrence D’Oliveiro wrote: > On Tuesday, June 28, 2016 at 5:03:08 PM UTC+12, Ben Finney wrote: >> There is a clever one-line decorator that has been copy-pasted without >> explanation in many code bases for many years:: >> >> decorator_with_args = lambda decorato

Errors in installation of matplotlib and pandas on Macbook

2016-06-29 Thread Madhavan Bomidi
Hello everyone, I am very new to Macbook and python. I have installed python through MacPorts and when I check if all the packages I required are installed properly, I get the following traceback errors for matplotlib and pandas packages. Can anyone suggest me how I can rectify the same? I trie

Re: "for/while ... break(by any means) ... else" make sense?

2016-06-29 Thread Random832
On Wed, Jun 29, 2016, at 22:26, Rustom Mody wrote: > > os.kill(os.getpid(), 9) > > > > Now THAT is the hardest way to abort. You ain't comin' back from > > this one! > > Is it? > > | On Windows, signal() can only be called with SIGABRT, SIGFPE, > | SIGILL, SIGINT, SIGSEGV, or SIGTERM. A ValueError

Re: Errors in installation of matplotlib and pandas on Macbook

2016-06-29 Thread Lawrence D’Oliveiro
On Thursday, June 30, 2016 at 3:51:56 PM UTC+12, Madhavan Bomidi wrote: > Bomidis-MacBook-Pro:~ madhavan$ which python > /usr/local/bin/python Apple already includes a(n obsolete) version of Python with its OS. Trying to override this with a newer version could easily lead to conflicts. -- http

Re: "for/while ... break(by any means) ... else" make sense?

2016-06-29 Thread Steven D'Aprano
On Thu, 30 Jun 2016 11:28 am, Chris Angelico wrote: > On Thu, Jun 30, 2016 at 10:27 AM, Steven D'Aprano > wrote: >> Following os.abort(), the interpreter exits in the hardest, quickest >> manner possible. > > os.kill(os.getpid(), 9) > > Now THAT is the hardest way to abort. You ain't comin' bac

Re: Errors in installation of matplotlib and pandas on Macbook

2016-06-29 Thread Madhavan Bomidi
Can you please suggest me what I shall do to make sure all the libraries that I have indicated above work in python? I don't know how I can get back to obsolete version of Python. Please suggest me the commands or references of previous posts, if any. Thanks and regards, Madhavan -- https://m

Re: "for/while ... break(by any means) ... else" make sense?

2016-06-29 Thread Chris Angelico
On Thu, Jun 30, 2016 at 2:12 PM, Steven D'Aprano wrote: > On Thu, 30 Jun 2016 11:28 am, Chris Angelico wrote: > >> On Thu, Jun 30, 2016 at 10:27 AM, Steven D'Aprano >> wrote: >>> Following os.abort(), the interpreter exits in the hardest, quickest >>> manner possible. >> >> os.kill(os.getpid(), 9

Re: "for/while ... break(by any means) ... else" make sense?

2016-06-29 Thread Zachary Ware
On Wed, Jun 29, 2016 at 11:12 PM, Steven D'Aprano wrote: > On Thu, 30 Jun 2016 11:28 am, Chris Angelico wrote: > >> On Thu, Jun 30, 2016 at 10:27 AM, Steven D'Aprano >> wrote: >>> Following os.abort(), the interpreter exits in the hardest, quickest >>> manner possible. >> >> os.kill(os.getpid(),

Re: Errors in installation of matplotlib and pandas on Macbook

2016-06-29 Thread Chris Angelico
On Thu, Jun 30, 2016 at 1:51 PM, Madhavan Bomidi wrote: > File > "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", > line 475, in _parse_localename > raise ValueError, 'unknown locale: %s' % localename > ValueError: unknown locale: UTF-8 T

How to extract error information after failing to call Py_initialize()

2016-06-29 Thread Tu Marshal
Hello Experts, I sent my issue to Python help email list. Matt from that list suggested me to ask help from "Python list". The link described how to get error information from Python after Python is initialized. It didn't meet my requirement. http://mateusz.loskot.net/posts/2011/12/01/python-

Re: "for/while ... break(by any means) ... else" make sense?

2016-06-29 Thread Random832
On Thu, Jun 30, 2016, at 00:12, Steven D'Aprano wrote: > I tried to find the actual implementation of os.abort(), but I > couldn't work out where it was or what it does. Can somebody > enlighten me? It's in posixmodule.c, it calls abort(), which is a standard C function, equivalent to killing the

Re: Errors in installation of matplotlib and pandas on Macbook

2016-06-29 Thread Madhavan Bomidi
Hello ChrisA, Thanks for your suggestion. My script works fine when I run the command 'export LC_ALL=en_AU.utf8' before starting python. I am from India and using US English and international keyboard. I also tried using the command 'export LC_ALL=en_USA.utf8' and the python script works fine.

Re: Errors in installation of matplotlib and pandas on Macbook

2016-06-29 Thread Chris Angelico
On Thu, Jun 30, 2016 at 3:54 PM, Madhavan Bomidi wrote: > > Thanks for your suggestion. My script works fine when I run the command > 'export LC_ALL=en_AU.utf8' before starting python. > > I am from India and using US English and international keyboard. I also tried > using the command 'export L

Re: Can math.atan2 return INF?

2016-06-29 Thread Gregory Ewing
Marko Rauhamaa wrote: By the time the event horizon hits Tim at the speed of light, Tim will have received all of our Universe's signals at an ever accelerating frequency and increasing power. He will have seen the End of the World before leaving it. I don't think that's right. From the point o

Re: Errors in installation of matplotlib and pandas on Macbook

2016-06-29 Thread Madhavan Bomidi
Hello ChrisA, Thanks for your suggestion. I have typed the following on Terminal: $ locale LANG= LC_COLLATE="C" LC_CTYPE="C" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL="C" How should I modify the profile/configuration of locale permanently? Is it possible to do this on te

Re: Assignment Versus Equality

2016-06-29 Thread Marko Rauhamaa
Gregory Ewing : > All your experiment shows is that the last information we had about > the magnet is that it was nearly stationary just above the horizon. > > It doesn't prove that the probe itself is frozen, any more than the > fact that a photograph you took of something last month doesn't move

Re: Can math.atan2 return INF?

2016-06-29 Thread Marko Rauhamaa
Lawrence D’Oliveiro : > Every time somebody tries to point to an example of a “topic that is > beyond the reach of science”, it seems to get knocked over eventually. Of course, an experiment trumps theory, always. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Can math.atan2 return INF?

2016-06-29 Thread Rustom Mody
On Thursday, June 30, 2016 at 11:54:54 AM UTC+5:30, Marko Rauhamaa wrote: > Lawrence D’Oliveiro : > > Every time somebody tries to point to an example of a “topic that is > > beyond the reach of science”, it seems to get knocked over eventually. > > Of course, an experiment trumps theory, always.

Re: Can math.atan2 return INF?

2016-06-29 Thread Marko Rauhamaa
Gregory Ewing : > Marko Rauhamaa wrote: >> By the time the event horizon hits Tim at the speed of light, Tim will >> have received all of our Universe's signals at an ever accelerating >> frequency and increasing power. He will have seen the End of the World >> before leaving it. > > I don't think