Re: Can math.atan2 return INF?

2016-06-30 Thread Steven D'Aprano
On Thursday 30 June 2016 17:16, Lawrence D’Oliveiro wrote: > The definition of “random” is “unknowable”. It really isn't. What Julius Caesar had for breakfast on the day after his 15th birthday is unknowable. To the best of our knowledge, the collapse of a quantum wave function is random.

Re: Can math.atan2 return INF?

2016-06-30 Thread Steven D'Aprano
On Thu, 30 Jun 2016 08:11 pm, Andreas Rc3b6hler wrote: > > > On 30.06.2016 10:24, Steven D'Aprano wrote: >> On Thursday 30 June 2016 12:13, Rustom Mody wrote: >> >> >> The irrational and emotional psychological forces that inspire >> mathematicians ca

Re: Operator Precedence/Boolean Logic

2016-06-30 Thread Steven D'Aprano
On Fri, 1 Jul 2016 02:01 am, Rustom Mody wrote: > On Thursday, June 30, 2016 at 5:10:41 AM UTC+5:30, Steven D'Aprano wrote: >> On Wed, 29 Jun 2016 11:30 pm, Rustom Mody wrote: >> >> > The other answers -- graphs and automata -- are questionable and/or >> >

Re: Can math.atan2 return INF?

2016-06-30 Thread Steven D'Aprano
On Fri, 1 Jul 2016 01:28 am, Rustom Mody wrote: > On Thursday, June 30, 2016 at 1:55:18 PM UTC+5:30, Steven D'Aprano wrote: > >> you state that Turing "believes in souls" and that he "wishes to >> put the soul into the machine" -- what do his re

Re: Were is a great place to Share your finished projects?

2016-06-30 Thread Steven D'Aprano
On Thu, 30 Jun 2016 11:09 pm, Christian Gollwitzer wrote: > The best place these days to publish software is on github. http://nedbatchelder.com/blog/201405/github_monoculture.html -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got wo

Re: Creating a calculator

2016-07-01 Thread Steven D'Aprano
ion* is another story. Raising exceptions is not a crash, it is the interpreter working as expected. This statement: line_number, keyword, expr = "20 END".split(' ', 2) is SUPPOSED to raise an exception, if it didn't, the interpreter would be broken. To call that a "crash&

Namespaces are one honking great idea

2016-07-01 Thread Steven D'Aprano
ss advertising: @staticmethod def spam(a, b, c): ... This has the disadvantage that functions in the class cannot call each other directly, but must use the dotted names. This is the Python equivalent of the "Java utility class" pattern, or arguably anti-pattern[2], where you create a class with little or no state and populate it with a number of static methods. [1] http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html [2] http://www.yegor256.com/2014/05/05/oop-alternative-to-utility-classes.html -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Namespaces are one honking great idea

2016-07-01 Thread Steven D'Aprano
On Sat, 2 Jul 2016 02:00 am, Ethan Furman wrote: > On 07/01/2016 07:13 AM, Steven D'Aprano wrote: > > I like the idea, but I have a couple questions about the design choices. Thanks! > Comments below. [...] >> Despite the "class" statement (a limitat

Re: Namespaces are one honking great idea

2016-07-01 Thread Steven D'Aprano
On Sat, 2 Jul 2016 12:49 am, BartC wrote: > On 01/07/2016 15:13, Steven D'Aprano wrote: > >> Sometimes we have a group of related functions and variables that belong >> together, but are not sufficiently unrelated to the rest of the module >> that we want to spl

Re: Namespaces are one honking great idea

2016-07-01 Thread Steven D'Aprano
On Sat, 2 Jul 2016 05:29 am, Ethan Furman wrote: > On 07/01/2016 10:10 AM, Steven D'Aprano wrote: >> On Sat, 2 Jul 2016 02:00 am, Ethan Furman wrote: > >>> Did you mean for this to go to -Ideas? >> >> Not yet. I wanted some initial feedback to see if anyon

Re: Namespaces are one honking great idea

2016-07-02 Thread Steven D'Aprano
ed functions. > Regardless, all use cases you've listed are already satisfied by use of > the static and class method decorators. Methods decorated with these do > not require an instance initialization to use. And are significantly less easy to use, as the functions MUST refer to ea

Re: Namespaces are one honking great idea

2016-07-02 Thread Steven D'Aprano
t = spam(5) Everything written inside the namespace object could have started as top level module code. I select the code, hit my editor's "Indent" command, and insert a single line at the top to turn it into a namespace. If I decide to move the code into a separate file, I j

Re: Lost in descriptor land

2016-07-03 Thread Steven D'Aprano
types import MethodType instance.method = MethodType(method, instance) Now calling it works fine: py> instance.method() method called from self <__main__.Test object at 0xb79fcf14> -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Special attributes added to classes on creation

2016-07-03 Thread Steven D'Aprano
if I check the newly created Q, I see the same keys K has: py> sorted(Q.__dict__.keys()) ['__dict__', '__doc__', '__module__', '__weakref__', 'x'] Is there any documentation for exactly what keys are added to classes when? -- Steven “Cheer up,” t

Re: Lost in descriptor land

2016-07-03 Thread Steven D'Aprano
On Mon, 4 Jul 2016 09:59 am, eryk sun wrote: > On Sun, Jul 3, 2016 at 3:32 PM, Steven D'Aprano > wrote: >> >> But if you prepare the method ahead of time, it works: >> >> from types import MethodType >> instance.method = MethodType(method, instance) >

Re: Well, I finally ran into a Python Unicode problem, sort of

2016-07-03 Thread Steven D'Aprano
ented, then finally raise a runtime TypeError('undefined operator ∇'). But I don't think this will ever be part of Python. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Well, I finally ran into a Python Unicode problem, sort of

2016-07-03 Thread Steven D'Aprano
thesis". And it doesn't help you one bit when it comes to: a = √(4x²y - 3xy² + 2xy - 1) Personally, I'm not convinced about using the very limited number of superscript code points to represent exponentiation. Using √ as an unary operator looks cute, but I don't know that it add

Re: Namespaces are one honking great idea

2016-07-04 Thread Steven D'Aprano
On Mon, 4 Jul 2016 09:23 pm, jmp wrote: > On 07/01/2016 04:13 PM, Steven D'Aprano wrote: >> But classes are not like the others: they must be instantiated before >> they can be used, and they are more than just a mere namespace grouping >> related entities. Classes su

Nested class doesn't see class scope

2016-07-04 Thread Steven D'Aprano
;var' is not defined I expected that `var` would be available during the construction of B, just as it was available inside A, but not to methods inside B. Obviously my expectations are invalid. Can anyone explain the actual behaviour? -- Steven “Cheer up,” they said, “things could be worse

Re: Namespaces are one honking great idea

2016-07-04 Thread Steven D'Aprano
On Tue, 5 Jul 2016 12:58 pm, Chris Angelico wrote: > On Tue, Jul 5, 2016 at 12:34 PM, Steven D'Aprano > wrote: >> *** IF *** you are willing to push the code out into its own separate .py >> file, you can use a module and write your code in a more natural form: >&

Re: Nested class doesn't see class scope

2016-07-04 Thread Steven D'Aprano
On Tuesday 05 July 2016 14:41, Ian Kelly wrote: > Class definitions don't create closures like functions do. When Python > executes a class definition, the metaclass creates a dict, and then > the interpreter execs the class body using that dict as the locals. > The body of class A has one locals

Re: How well do you know Python?

2016-07-04 Thread Steven D'Aprano
On Tuesday 05 July 2016 14:02, Chris Angelico wrote: > After some discussion with a Ruby on Rails programmer about where Ruby > ends and where Rails begins (and it's definitely not where I'd have > expected... Rails does a ton of monkey-patching, including of built-in > types, to provide functiona

Re: Namespaces are one honking great idea

2016-07-04 Thread Steven D'Aprano
On Tuesday 05 July 2016 13:47, Chris Angelico wrote: > On Tue, Jul 5, 2016 at 1:35 PM, Steven D'Aprano wrote: >>> If you push your code into a separate .py file, you can reference the >>> original module by importing it. Is that also the normal way to use >>>

Re: py2exe crashes on simple program

2016-07-04 Thread Steven D'Aprano
On Tuesday 05 July 2016 14:06, John Nagle wrote: > I'm trying to create an executable with py2exe. > The program runs fine in interpretive mode. But > when I try to build an executable, py2exe crashes with > an assertion error. See below. [...] > Building shared code archive 'dist\library.zip'.

Re: How well do you know Python?

2016-07-04 Thread Steven D'Aprano
On Tuesday 05 July 2016 14:02, Chris Angelico wrote: > After some discussion with a Ruby on Rails programmer about where Ruby > ends and where Rails begins (and it's definitely not where I'd have > expected... Rails does a ton of monkey-patching, including of built-in > types, to provide functiona

Re: How well do you know Python?

2016-07-05 Thread Steven D'Aprano
On Tuesday 05 July 2016 16:38, Chris Angelico wrote: > On Tue, Jul 5, 2016 at 4:33 PM, Steven D'Aprano > wrote: >> What happens in this code snippet? >> >> L = [1] >> t = (L,) >> t[0] += 1 >> >> Explain what value t has, and why. &

Re: Making Classes Subclassable

2016-07-05 Thread Steven D'Aprano
On Monday 04 July 2016 18:34, Lawrence D’Oliveiro wrote: > On Monday, July 4, 2016 at 7:58:07 PM UTC+12, dieter wrote: >> --> "type(obj)" or "obj.__class__" (there are small differences) >> give you the type/class of "obj". > > When would it not be the same? class X(object): def __getattrib

Re: How well do you know Python?

2016-07-05 Thread Steven D'Aprano
n, so the order of identical sets/dicts running in identical code will vary from one run to another. [steve@ando 3.6]$ ./python -c "print({'a', 'b', 'c', 'd'})" {'c', 'b', 'd', 'a'} [steve@ando 3.6]$ ./p

Re: How well do you know Python?

2016-07-05 Thread Steven D'Aprano
he exact same line >> of code multiple times and get different results. It's a coin toss. > > Oh, nice, a new way to generate random bits in shell scripts. O_o You're joking, right? I'll just leave this here... https://docs.python.org/3.6/library/secrets.html -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Improved nestedmodule decorator implementation

2016-07-05 Thread Steven D'Aprano
on I posted before > actually crashes if you try to refer to a name in an outer > nestedmodule from an inner nestedmodule. > > Here's an improved version that fully supports nesting to > any depth. That's impressive. And scary. And I fear not portable, since it uses byte-

Two curious errors when function globals are manipulated

2016-07-05 Thread Steven D'Aprano
both bugs. Does anyone disagree? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Making Classes Subclassable

2016-07-05 Thread Steven D'Aprano
On Wed, 6 Jul 2016 12:41 am, Ian Kelly wrote: > On Tue, Jul 5, 2016 at 2:31 AM, Steven D'Aprano > wrote: >> On Monday 04 July 2016 18:34, Lawrence D’Oliveiro wrote: >> >>> On Monday, July 4, 2016 at 7:58:07 PM UTC+12, dieter wrote: >>>> -->

Re: Making Classes Subclassable

2016-07-05 Thread Steven D'Aprano
ance gets adopted by class B, after which it behaves like any other B instance. Again, I stress that A and B must be compatible (and written in Python, you can't do it with classes written in C), otherwise their methods won't find the attributes they expect. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Two curious errors when function globals are manipulated

2016-07-05 Thread Steven D'Aprano
On Wed, 6 Jul 2016 01:27 am, eryk sun wrote: > On Tue, Jul 5, 2016 at 2:46 PM, Steven D'Aprano > wrote: >> I've come across two curious behaviours of a function using custom >> globals. In both cases, I have a function where __globals__ is set to a >> Chai

Re: Appending an asterisk to the end of each line

2016-07-05 Thread Steven D'Aprano
nk catches fire." "That's okay, we can just pave over the factory grounds and get rid of the puddles." Your script "catches fire" when given input containing non-ASCII characters. You don't really know why, and you haven't fixed it, but you've "solve

Re: Two curious errors when function globals are manipulated

2016-07-05 Thread Steven D'Aprano
On Wed, 6 Jul 2016 02:13 am, eryk sun wrote: > On Tue, Jul 5, 2016 at 3:50 PM, Steven D'Aprano > wrote: >> It works with exec: [...] > No, actually it doesn't work. Remember that when you store to a > variable, it's implicitly a local variable, for which CPython

Re: Clean Singleton Docstrings

2016-07-07 Thread Steven D'Aprano
ule [...] (Emphasis added.) So, no, reading the docstrings from individual objects is not supported by pydoc's command line interface. You could possibly add that functionality, but I don't know how much effort it would be. -- Steven “Cheer up,” they said, “things could be wo

Re: Clean Singleton Docstrings

2016-07-08 Thread Steven D'Aprano
module. So all you need is to ensure that your Registry > evaluates to True in a boolean context, e. g. by putting something into > it: Nicely spotted! I had seen the test but hadn't realised the implications. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered u

Quick poll: gmean or geometric_mean

2016-07-08 Thread Steven D'Aprano
r that the arithmetic mean is just called "mean". http://bugs.python.org/issue27181 -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Quick poll: gmean or geometric_mean

2016-07-10 Thread Steven D'Aprano
n discussing the different kinds of mean, A, G and H are used for arithmetic, geometric and harmonic means. (Other means are rarely discussed.) I don't think I've ever seen gµ or hµ. They're sort of backwards... I'd expect µ subscript-g or subscript-h, not the other way. -- S

Re: Quick poll: gmean or geometric_mean

2016-07-10 Thread Steven D'Aprano
On Sun, 10 Jul 2016 07:24 pm, Michael Selik wrote: > On Sun, Jul 10, 2016, 4:56 AM Steven D'Aprano wrote: > >> On Sun, 10 Jul 2016 05:28 pm, Rustom Mody wrote: >> >> > From fuzzy memory of sitting in statistics classes decades ago >> > filled with μ-σ

Re: the best online course

2016-07-10 Thread Steven D'Aprano
On Monday 11 July 2016 13:07, Rustom Mody wrote: > Python is good for black-box – us the ‘batteries included’ without worrying > too much how they are made > Scheme, assembly language, Turing machines etc are at the other end of the > spectrum I would put it the other way. Python is excellent fo

Visualising relationships between packages

2016-07-10 Thread Steven D'Aprano
https://kozikow.com/2016/07/10/visualizing-relationships-between-python-packages-2/ -- Steve -- https://mail.python.org/mailman/listinfo/python-list

Re: Curious Omission In New-Style Formats

2016-07-11 Thread Steven D'Aprano
f precision is "00123". And we can combine that with the overall length to pad the result with spaces as well. It seems to me that it would be reasonable to support this for format() too. > It may happen to do what you want in the printf-style format, but > calling the field

Re: Compression of random binary data

2016-07-11 Thread Steven D'Aprano
e, or a scrap of paper with the title of a book written on it: "See Lord Of The Rings, by J.R.R. Tolkien" That's a lot smaller than the actual book: eight words, instead of who knows how many tens of thousands. But you can't call it compression: you can't sit down w

Re: Curious Omission In New-Style Formats

2016-07-11 Thread Steven D'Aprano
oast more closely, I'd get a different number. So the more leading zeroes, the less accurate your measurement is likely to be. But interesting as this is, for most purposes either we're not measuring a curve, or we are but pretend we're not and ignore the fractal dimension. But as I

Re: What is precision of a number representation? (was: Curious Omission In New-Style Formats)

2016-07-11 Thread Steven D'Aprano
ion of four decimal places? 0001 1 1. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: What is precision of a number representation?

2016-07-11 Thread Steven D'Aprano
On Tuesday 12 July 2016 08:17, Ethan Furman wrote: > So, so far there is no explanation of why leading zeroes make a number > more precise. Obviously it doesn't, just as trailing zeroes doesn't make a number more precise. Precision in the sense used by scientists is a property of how the measu

Re: subprocess: xterm -c cat, need to send data to cat and have it displayed in the xterm window

2016-07-11 Thread Steven D'Aprano
On Tuesday 12 July 2016 16:27, Steven D'Aprano wrote: > On Tuesday 12 July 2016 13:20, Veek. M wrote: > >> Script grabs some image data and runs imagemagick on it to extract some >> chinese. Then tesseract OCR to get the actual unicode. >> >> I then need to

Re: subprocess: xterm -c cat, need to send data to cat and have it displayed in the xterm window

2016-07-11 Thread Steven D'Aprano
On Tuesday 12 July 2016 13:20, Veek. M wrote: > Script grabs some image data and runs imagemagick on it to extract some > chinese. Then tesseract OCR to get the actual unicode. > > I then need to get it translated which also works and then display in > XTerm using cat. Why not just print it? Why

Re: pocketsphinx no module named pocketsphinx found

2016-07-12 Thread Steven D'Aprano
On Tuesday 12 July 2016 18:47, [email protected] wrote: > Op dinsdag 12 juli 2016 10:00:51 UTC+2 schreef [email protected]: >> I try to run an example python file for pocketsphinx but I get this error: >> >> File "continuous_test.py", line 5, in >> from pocketsphinx.pocketsphinx import *

Re: pocketsphinx no module named pocketsphinx found

2016-07-12 Thread Steven D'Aprano
timeError: new_Decoder returned -1 That's a pocketsphinx error. Try reading the docs, or asking on the pocketsphinx forums. You might be lucky and find somebody here who knows pocketsphinx, but your best chance will come from a specialist pocketsphinx forum. -- Steven “Cheer up,” they s

Re: What is precision of a number representation?

2016-07-12 Thread Steven D'Aprano
On Tue, 12 Jul 2016 07:50 pm, Antoon Pardon wrote: > Op 12-07-16 om 06:19 schreef Steven D'Aprano: >> On Tue, 12 Jul 2016 07:51 am, Chris Angelico wrote: >> >>> say, 2,147 >>> millimeters, with a precision of four significant digits >> >>

Re: Compression of random binary data

2016-07-12 Thread Steven D'Aprano
On Wed, 13 Jul 2016 12:24 am, [email protected] wrote: > Den måndag 11 juli 2016 kl. 20:38:51 UTC+2 skrev Steven D'Aprano: >> On Tue, 12 Jul 2016 03:52 am, [email protected] wrote: >> >> > What kind of statistic law or mathematical conjecture or is i

Re: Compression of random binary data

2016-07-12 Thread Steven D'Aprano
On Wed, 13 Jul 2016 12:29 am, [email protected] wrote: > Den tisdag 12 juli 2016 kl. 05:01:20 UTC+2 skrev Lawrence D’Oliveiro: >> On Tuesday, July 12, 2016 at 5:52:27 AM UTC+12, [email protected] >> wrote: >> >> > What kind of statistic law or mathematical conjecture or is it even a >

Re: Quick poll: gmean or geometric_mean

2016-07-12 Thread Steven D'Aprano
okay, they charge you more to make up for it being smaller. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Compression of random binary data

2016-07-12 Thread Steven D'Aprano
cannot put 10*100 pigeons into 10**6 pigeon holes without doubling up (which makes your compression lossly). So either some numbers cannot be compressed, or some numbers are compressed to the same result, and you can't tell which was the original. That's your choice: a lossless encoder means some numbers can't be compressed, a lossy encoder means you can't reverse the process exactly. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Were is a great place to Share your finished projects?

2016-07-12 Thread Steven D'Aprano
On Wednesday 13 July 2016 15:11, Chris Angelico wrote: > You're welcome to take a 100% philosophical stance It's not a philosophical stance to avoid vendor lockin, nor to avoid incipient monopolies, nor to avoid rewarding companies that behave badly. It's not for philosophical reasons that we s

Re: Were is a great place to Share your finished projects?

2016-07-13 Thread Steven D'Aprano
On Wednesday 13 July 2016 17:00, Chris Angelico wrote: > On Wed, Jul 13, 2016 at 4:44 PM, Steven D'Aprano > wrote: >> Even if Github was 100% open source with no proprietary extensions, and the >> *technical* cost of leaving was low, the single-network effect would stil

Re: Curious Omission In New-Style Formats

2016-07-13 Thread Steven D'Aprano
On Wednesday 13 July 2016 17:05, Lawrence D’Oliveiro wrote: > On Wednesday, July 13, 2016 at 6:22:31 PM UTC+12, Ian wrote: > >> I never claimed it's not useful. I don't really have a problem with >> format supporting it, either. But if it does, then don't call it >> "precision". > > Like it or n

Re: Compression of random binary data

2016-07-13 Thread Steven D'Aprano
to just 10**6 outputs without any loss of information. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Compression of random binary data

2016-07-13 Thread Steven D'Aprano
lynomials and structure is just cheap talk. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Byte Code Hacking

2016-07-14 Thread Steven D'Aprano
On Thursday 14 July 2016 10:14, Ian Kelly wrote: > On Wed, Jul 13, 2016 at 12:48 PM, Vijay Kumar > wrote: >> Hi Everyone, >> I wrote an article on Python byte code hacking. The article is available >> from http://www.bravegnu.org/blog/python-byte-code-hacks.html The article >> uses an incremental

Re: Curious Omission In New-Style Formats

2016-07-14 Thread Steven D'Aprano
On Thursday 14 July 2016 15:18, Ian Kelly wrote: > Side note, neither do floating point numbers, really; what is often > called the mantissa is more properly known as the significand. But > integers don't have that either. Er, then what's a mantissa if it's not what people call a float's mantiss

Compression

2016-07-14 Thread Steven D'Aprano
I thought I'd experiment with some of Python's compression utilities. First I thought I'd try compressing some extremely non-random data: py> import codecs py> data = "something non-random."*1000 py> len(data) 21000 py> len(codecs.encode(data, 'bz2')) 93 py> len(codecs.encode(data, 'zip')) 99

Re: Were is a great place to Share your finished projects?

2016-07-14 Thread Steven D'Aprano
of code. (If I'd been paid for this code I didn't write, I wouldn't mind so much...) -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Were is a great place to Share your finished projects?

2016-07-14 Thread Steven D'Aprano
osed source repo. I watched the discussion on Python-Dev that decided to move to github, and there were completely viable open source hg alternatives. Although nobody was quite crass enough to come right out and say it, the alternatives were all dismissed because they weren't Github, because

Re: Curious Omission In New-Style Formats

2016-07-15 Thread Steven D'Aprano
f knowledge? That's equivalent to swapping the X and Y axes: Cx o x sx t · x o r · t x i m e + Knowledge gained That's not the conventional layout of the axis, but it does make sense, and it's more likely that people have this reversed layout i

math.frexp

2016-07-15 Thread Steven D'Aprano
m1, e1 = math.frexp(a) m2, e2 = math.frexp(prod) scale += (e1 + e2) prod *= (m1*m2) return (prod * 2.0**scale) py> product_scaled([2.5, 3.5]) # expected 8.75 2.734375 What am I doing wrong? -- Steven “Cheer up,” they said, “things could be worse.” S

Re: Curious Omission In New-Style Formats

2016-07-15 Thread Steven D'Aprano
On Fri, 15 Jul 2016 11:13 pm, Jussi Piitulainen wrote: > Steven D'Aprano writes: > > [in response to my attempt to understand "steep learning curve"] > >> "Learning curve" or "experience curve" is not just an metaphor, it is >> an ac

Re: Curious Omission In New-Style Formats

2016-07-15 Thread Steven D'Aprano
poor hungry child asks for the two-hand slice, they get a slice so thin > that it needs to be held with both hands. That's mean. Ha, that's exactly the same story my grandmother (who was Estonian-Russian) used to tell me. If you don't mind me asking, what nationality are you?

Re: math.frexp

2016-07-15 Thread Steven D'Aprano
to within a relative error of 1e-14 of the correct answer, 2**950: py> geometric_mean([2.0**900, 2.0**920, 2.0**960, 2.0**980, 2.0**990]) 9.516908214257811e+285 py> 2.0**950 9.516908214257812e+285 Here's one that's exact: py> geometric_mean([2e300, 4e300, 8e300, 16e300, 3

Re: Clean Singleton Docstrings

2016-07-16 Thread Steven D'Aprano
robably a lot we could do to improve the ability to duck-type numbers in Python. For instance, it is a nuisance that we write: math.isfinite(x) for floats, but x.is_finite() for Decimals. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Operator Precedence/Boolean Logic

2016-07-16 Thread Steven D'Aprano
define your graph type that way. As an internal application-only class, that's probably okay, but as a generic graph type in a library, it's probably a bad idea. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Clean Singleton Docstrings

2016-07-16 Thread Steven D'Aprano
lt, and the inexact flag is set, that doesn't mean that 1.0 is the wrong answer -- it may be that the errors have cancelled and 1.0 is the exact answer. Or it may be that the error bound is 1.0 ± 1, and the calculation has diverged so far from the correct result that it is useless.

Re: Operator Precedence/Boolean Logic

2016-07-16 Thread Steven D'Aprano
On Sat, 16 Jul 2016 03:48 pm, Rustom Mody wrote: > On Thursday, June 30, 2016 at 10:52:50 PM UTC+5:30, Steven D'Aprano wrote: >> Okay, if you think that automata cannot be empty, I'll accept that. In >> that case, then I'll change my answer and say that __bool__

Re: math.frexp

2016-07-16 Thread Steven D'Aprano
On Sat, 16 Jul 2016 06:24 am, Paul Rubin wrote: > Steven D'Aprano writes: >> But this can give some protection against overflow of intermediate >> values. > > Might be simplest to just add the logarithms. Look up Kahan summation > for how to do that while

Re: Operator Precedence/Boolean Logic

2016-07-16 Thread Steven D'Aprano
On Sat, 16 Jul 2016 08:46 pm, Chris Angelico wrote: > As Steven says, > the default is that they're all truthy, and onus is on the implementer > to demonstrate that this object is functionally equivalent to 0 or an > empty collection. (And it's possible for ANYONE

Re: Operator Precedence/Boolean Logic

2016-07-16 Thread Steven D'Aprano
tion of code for every feature? (4) Or something else? If so, what is your basis for claiming that this is not straightforward? What part, or parts, is not straightforward? -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Operator Precedence/Boolean Logic

2016-07-16 Thread Steven D'Aprano
to graphs with one or more nodes) should be truthy. If you disagree, well, Rustom, it's YOUR class, you tell me under what conditions you think an automation object should be considered truthy or falsey. Mu is not an option. You have to pick one or the other. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread Steven D'Aprano
single-threaded queue class, because it has deque. (As a comp sci undergrad, you have probably heard of double-ended queues.) Python already has a thread-safe queue. *Maybe* there's a use-case for a self-balancing tree structure in Python, but which one? How often do you need to use keys tha

Re: Operator Precedence/Boolean Logic

2016-07-17 Thread Steven D'Aprano
ruthiness; - a mere collection of objects which happen to be arbitrarily treated as truthy or falsey (like Ruby and Javascript?), lacking any consistent metaphor, is in some ways the worst of both worlds. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure

Re: Clean Singleton Docstrings

2016-07-17 Thread Steven D'Aprano
ly good and exact number, precisely equal to: Fraction(3275345183542178, 36028797018963968) + Fraction(1, 36028797018963968) among many other exact calculations. So I would like to know how you justify claiming that one number is exact and the other is not? -- Steven “Cheer up,” they sa

Re: python IDLE display with a 13.3-inch screen

2016-07-17 Thread Steven D'Aprano
ame looking for him" [syn: police, police force, constabulary, law] I think you mean a different word, but I have no idea what. > I like > to use IDLE with my students but I am unable to solve the problem. If > someone can do an update for its screens. Thank you. Cordially. --

Re: SyntaxError: Non-ASCII character

2016-07-17 Thread Steven D'Aprano
/dev/peps/pep-0263/ for details I'm not sure. I think the Python 2 version is less useful: it doesn't show you the line, you have to go look for it yourself. Then you have to work out what character is \xe2, which is generally not easy because your editor is unlikely to show the escape code

Re: Operator Precedence/Boolean Logic

2016-07-17 Thread Steven D'Aprano
straightforward. You keep insisting that it isn't, but haven't told us in what way it is not. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: SyntaxError: Non-ASCII character

2016-07-17 Thread Steven D'Aprano
t a path also for to find the modules No, but you do have to install pyaudio separately for each version of Python you have. So if you have installed Python 2.7 and 3.4, and Python 2.7 has pyaudio installed, Python 3.4 cannot use the same one. -- Steven “Cheer up,” they said, “things could be wors

Re: SyntaxError: Non-ASCII character

2016-07-17 Thread Steven D'Aprano
er=CHUNK) > NameError: name 'TRUE' is not defined Try using input=True instead. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: can't add variables to instances of built-in classes

2016-07-17 Thread Steven D'Aprano
nused __dict__ can be wasteful. But note that in recent versions of Python, there is less need to use __slots__, and a much smaller benefit. The reason is that the instance dicts can now share storage for their keys. https://www.python.org/dev/peps/pep-0412/ __slots__ is not obsolete, but 99% of the

Re: Operator Precedence/Boolean Logic

2016-07-17 Thread Steven D'Aprano
nt of chance, the protocol is completely deterministic and documented. There's a preferred API, __nonzero__ in Python 2 and __bool__ in Python 3, if that isn't defined there's a fallback using __len__, if that's not defined then the usual rules of inheritance apply and you inherit f

Re: Operator Precedence/Boolean Logic

2016-07-17 Thread Steven D'Aprano
On Mon, 18 Jul 2016 01:58 am, Steven D'Aprano wrote: > All objects > can be coerced to strings, using either str() or repr(). If you define > only one of __str__ or __repr__, Python will use the other. Er, sorry, that was incoherent. I hit Send too quick, without editing. What

Re: Python code change

2016-07-17 Thread Steven D'Aprano
database, you might be able to remove the password from it so that there is no need for authentication, but first you have to get access to the database. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: What exactly is "exact" (was Clean Singleton Docstrings)

2016-07-18 Thread Steven D'Aprano
On Monday 18 July 2016 14:16, Rustom Mody wrote: > On Saturday, July 16, 2016 at 3:16:48 PM UTC+5:30, Steven D'Aprano wrote: >> But that's *wrong*. Numbers are never inexact. (You can have interval >> arithmetic using "fuzzy numbers", but they're ALWAYS i

Re: What exactly is "exact" (was Clean Singleton Docstrings)

2016-07-18 Thread Steven D'Aprano
On Tue, 19 Jul 2016 01:25 am, Ian Kelly wrote: > On Mon, Jul 18, 2016 at 3:29 AM, Steven D'Aprano > wrote: >> On Monday 18 July 2016 14:16, Rustom Mody wrote: >>> In short one could think of inexact and exact — in scheme's intended >>> semantics — as bett

Re: Request for help

2016-07-18 Thread Steven D'Aprano
On Tue, 19 Jul 2016 06:20 am, alister wrote: > I suggest next time you stay awake during lessons. That's an uncalled for nasty comment. You don't know the O.P's issues or why he is having difficulty. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered u

Re: What exactly is "exact" (was Clean Singleton Docstrings)

2016-07-18 Thread Steven D'Aprano
t; case of general relativity.) But it's an interesting hypothetical: what if the power wasn't 2 exactly? -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: What exactly is "exact" (was Clean Singleton Docstrings)

2016-07-18 Thread Steven D'Aprano
t "exact" or "inexact" (but only calculations), then adding an "exact" attribute to the number makes as much sense as adding attributes "colour", "weight", or "flavour". -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: What exactly is "exact" (was Clean Singleton Docstrings)

2016-07-18 Thread Steven D'Aprano
e an inexact comparison. Why do I check for a relative error of 1e-13, rather than 1e-12 or 2.5e-14? *shrug* I can't give an objective reason for it. It just seems right to me: if the relative error was much bigger, I'd say that the geometric mean function was too inaccurate. If it were much smaller, it's too hard for me to have the tests pass. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Request for help

2016-07-19 Thread Steven D'Aprano
th the "class" keyword: class Myclass: pass To give it a constructor method, you need to use the __init__ method, or sometimes __new__. In this case, I think __init__ is what you want. Do you know how to define methods inside a class? Remember that __init__ is spelled with TWO underscore

Floating point equality [was Re: What exactly is "exact" (was Clean Singleton Docstrings)]

2016-07-19 Thread Steven D'Aprano
On Tuesday 19 July 2016 14:58, Rustom Mody wrote: > So I again ask: You say «"Never compare floats for equality" is a pernicious > myth» It is the word *never* which makes it superstition. If people said "Take care with using == for floats, its often not what you want" I would have no argument

<    32   33   34   35   36   37   38   39   40   41   >