Re: Reading the documentation

2017-08-26 Thread Tim Golden

On 26/08/2017 03:22, Rick Johnson wrote:

Steve D'Aprano wrote:

Rustom Mody wrote:

Ian wrote:

"Larry Martell"  wrote:
9:21 PM Rustom Mody wrote:

Statement 1: Aeroplanes fly. Statement 2: Submarines swim.
Are these two statements equally acceptable?  [Inspired
by a talk by Noam Chomsky]

There should be a corollary of Godwin's law for that
idiot.

[...]

[Larry seems to be angry about/at somethin'… No idea who/what…]


Chomsky challenges the prevailing world-view that the USA
is a force for good, by documenting the many, many, many
ways that the USA's actions are harmful, unjust, illegal
(occasionally all three at once) and in contradiction to
the nation's stated values. Many people don't like it when
you challenge their cherished myths.


Nor when you glorify their most hated enemy.


[... snip ...]

Unusually, I'd like to speak as one of the list owners and ask people to 
continue this thread of conversation elsewhere. We're quite tolerant to 
fairly off-topic side-threads here, but I think this one is going to 
generate more heat than light and it's not even tangentially on-topic.


So please feel free to have a private correspondence or to set 
follow-ups to some political debating group. But let it drop on this list.


Thanks

TJG
--
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-25 Thread Rick Johnson
Steve D'Aprano wrote:
> Rustom Mody wrote:
> > Ian wrote:
> >> "Larry Martell"  wrote:
> >> 9:21 PM Rustom Mody wrote:
> > > > Statement 1: Aeroplanes fly. Statement 2: Submarines swim.
> > > > Are these two statements equally acceptable?  [Inspired
> > > > by a talk by Noam Chomsky]
> > > There should be a corollary of Godwin's law for that
> > > idiot.
> [...]
> > [Larry seems to be angry about/at somethin'… No idea who/what…]
> 
> Chomsky challenges the prevailing world-view that the USA
> is a force for good, by documenting the many, many, many
> ways that the USA's actions are harmful, unjust, illegal
> (occasionally all three at once) and in contradiction to
> the nation's stated values. Many people don't like it when
> you challenge their cherished myths.

Nor when you glorify their most hated enemy. 

Chomsky may be under the impression that heroes are without
flaw, however, many of us do not share such naive beliefs,
As any random historian of "super-hero comic book lore" can
testify, heroes are deeply flawed.

So jump on Chomsky's "Let's all bash America" bandwagon if
you must, but please do remember: that the short history of
America has presented a social transformation the likes of
which this world has never seen. So instead of wasting
energy complaining about past events that cannot be changed,
you and Chomsky, should spend your "energy capital"
convincing people that there is a better way.

And calling people names or engaging in endless emotional
battles is never going to work. Yes, the history of America
has been a dark history of many horrors, but it has also
been, at moments, a bright light illuminating the world with
the ideals of liberty. At some point we must realize that
progress cannot _proceed_ until we bury the hatchet.

And that's why Daryl Davis is one of my personal heroes!

Daryl Davis is the perfect example of a man who is fighting
against the ills of our society in the "right way", by
winning hearts and minds. You should learn about this great
man and watch his documentary titled "Accidental Courtesy:
Daryl Davis, Race & America" -- which you can find on the
American PBS website, or in the following links.

The Man:

https://en.wikipedia.org/wiki/Daryl_Davis

The Documentary:
   
http://accidentalcourtesy.com/
   
https://www.netflix.com/title/80105514
   
http://www.imdb.com/title/tt5390430/

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-25 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes:

>>On Fri, 25 Aug 2017 11:25 am, Ben Bacarisse wrote:
>>With that in mind, "an Integral" is a shorthand for "an Integral value",
>
>   In math, an integral value is called an /integer/.
>   Therefore, in math, it would seem strange to avoid the noun
>   /integer/ using /integral/ as a noun.
>
>   In a programming language with formal types, however,
>   "an integer value" can be something different than 
>   "an Integer value", which in turn can be something 
>   different than "an Integral value".

I think you are agreeing with the text you quote, yes?  (But including
the part you cut that gives meaning to "With that in mind".)  I ask
because I am often not sure if you are making some subtle point I've
missed.


-- 
Ben.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-25 Thread Rustom Mody
On Friday, August 25, 2017 at 11:23:26 PM UTC+5:30, MRAB wrote:
> On 2017-08-25 15:40, Dennis Lee Bieber wrote:
> > On Thu, 24 Aug 2017 21:47:41 -0700 (PDT), Rustom Mody declaimed the 
> > following:
> > 
> > 
> >>This was true of Britain 100 years ago
> >>It was true of Rome 1000 years ago
> > 
> > Rome was still a problem in 1017? That's only 50 years away from the
> > Battle of Hastings and the Norman conquest.
> > 
> Well, the Byzantine Empire still existed.
> 
> > Rome was basically washed up 1500 years ago. The first crusade fell
> > about 900 years ago.
> >

I meant to say: Rome → 2000 years

[And Denis I dont see your mails (thanks to your settings?) unless someone else
quotes them]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-25 Thread MRAB

On 2017-08-25 15:40, Dennis Lee Bieber wrote:

On Thu, 24 Aug 2017 21:47:41 -0700 (PDT), Rustom Mody
 declaimed the following:



This was true of Britain 100 years ago
It was true of Rome 1000 years ago


Rome was still a problem in 1017? That's only 50 years away from the
Battle of Hastings and the Norman conquest.


Well, the Byzantine Empire still existed.


Rome was basically washed up 1500 years ago. The first crusade fell
about 900 years ago.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-25 Thread Ian Kelly
On Thu, Aug 24, 2017 at 11:02 PM, Gene Heskett  wrote:
> On Thursday 24 August 2017 23:21:22 Larry Martell wrote:
>
>> I think Chomsky is a jerk, and I'm angry at media outlets like CNN
>> giving him a forum to spew his idiocies.
>
> I agree Larry, Chomsky can be described in even more flowery terms, but
> since its CNN, what else should we expect?  That site has not been on my
> nightly news tour for at least 18 months.

And I'm also angry with CNN because they give *far* more face time to
noted plagiarist and failed human being Ann Coulter than they give to
one of the most cited scholar in academia.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-25 Thread Paul Moore
On Friday, 25 August 2017 14:16:05 UTC+1, Chris Angelico  wrote:
> Yep. We're in agreement on that. My only point about the confusion was
> the way in which you could get "wrong answers" in binary but "right
> answers" in decimal, leading to the "0.1 + 0.2 != 0.3" problem. That's
> a sum that works flawlessly in decimal but not in binary.

And in practice this *is* the example that causes the most confusion, in terms 
of people thinking what Python does is "wrong". The usual "explanation" is 
something along the lines of "floats aren't exact" or "rounding", neither of 
which is the real explanation (and "floats aren't exact" isn't even true!)

The real explanation is that "0.1" is a textual representation in your source, 
that gets converted into a value in your code that doesn't actually equate to 
what you *meant* by 0.1 (i.e. 1/10). Explaining the difference between the form 
of a literal, and the resulting actual value used in your program, is 
surprisingly hard (I say this after having recently spent rather longer than I 
thought I'd need to explaining the difference between a "date literal" and a 
"date object" to a colleague who's far from being a "dumb newbie").

Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-25 Thread Chris Angelico
On Fri, Aug 25, 2017 at 11:01 PM, Steve D'Aprano
 wrote:
> How did we get onto prime factors of denominators? The point I was making is
> that there are plenty of fractions which are not multiples of 1/5 which
> nevertheless lead to unintuitive "wrong answers" in both Decimal and binary
> floating point. It is not necessary for the fraction to have a denominator
> which is a multiple of 5 to run into issues.

Yep. We're in agreement on that. My only point about the confusion was
the way in which you could get "wrong answers" in binary but "right
answers" in decimal, leading to the "0.1 + 0.2 != 0.3" problem. That's
a sum that works flawlessly in decimal but not in binary.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-25 Thread Steve D'Aprano
On Fri, 25 Aug 2017 04:12 pm, Chris Angelico wrote:

>> And there are numbers which repeat in decimal but not binary, and numbers
>> which repeat in both, and numbers which don't repeat in either.
> 
> Which ones repeat in decimal but not binary? An example, please.

What? No. I never said that, that would be silly. You must be replying to some
other Steven.

*wink*

Quoting Wikipedia:

"A rational number has a terminating sequence after the radix point if all the
prime factors of the denominator of the fully reduced fractional form are also
factors of the base. [...]

A rational number has an infinitely repeating sequence of [digits] if the
reduced fraction's denominator contains a prime factor that is not a factor of
the base."

https://en.wikipedia.org/wiki/Repeating_decimal#Extension_to_other_bases


Fractions will terminate in decimal if their denominator is a power of two, a
power of five, or a multiple of such, e.g.:

2, 4, 8, 16, 32, 64, ...
5, 25, 125, 625, ...
10, 20, 40, 50, 80, 100, ...

and will terminate in binary if their denominator is:

2, 4, 8, 16, 32, ...

so obviously any number which terminates in binary will also terminate in
decimal, but not necessarily vice versa.

Fractions will repeat in decimal if their denominator is a multiple of any of
the following primes:

3, 7, 11, 13, 17, ... 

and fractions will repeat in binary if their denominator is a multiple of:

3, 5, 7, 11, 13, 17, ...

so clearly any number which repeats in decimal will also repeat in binary. Like
I said.[1]



How did we get onto prime factors of denominators? The point I was making is
that there are plenty of fractions which are not multiples of 1/5 which
nevertheless lead to unintuitive "wrong answers" in both Decimal and binary
floating point. It is not necessary for the fraction to have a denominator
which is a multiple of 5 to run into issues.





[1] Just now. What may have been said in the past is the past, and long
forgotten. *wink*

-- 
Steve
“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: Reading the documentation

2017-08-25 Thread Chris Angelico
On Fri, Aug 25, 2017 at 4:26 PM, Paul Rubin  wrote:
> Chris Angelico  writes:
>>> And there are numbers which repeat in decimal but not binary,
>> Which ones repeat in decimal but not binary? An example, please.
>
> That should really have said binary but not decimal, since 2 divides 10.

Well, those that repeat in binary but not decimal are the ones that
have a 5 in the denominator, which loops us right back to what I
originally said :)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Paul Rubin
Chris Angelico  writes:
>> And there are numbers which repeat in decimal but not binary, 
> Which ones repeat in decimal but not binary? An example, please.

That should really have said binary but not decimal, since 2 divides 10.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Chris Angelico
On Fri, Aug 25, 2017 at 4:03 PM, Steve D'Aprano
 wrote:
> On Fri, 25 Aug 2017 03:22 pm, Chris Angelico wrote:
>
>>> py> from decimal import Decimal
>>> py> sum([1/13]*13)
>>> 0.9998
>>> py> sum([Decimal(1)/Decimal(13)]*13)
>>> Decimal('0.9997')
>>
>> Now do the same exercise with pencil and paper. What's 1/13?
>
> Easy: 0.(076923) where the brackets surround the digits which repeat.
>
> I'm not so good at division in binary, but I *think* it should be:
>
> 0b0.(000100111011)
>
> where, again, the repeating bits are in brackets.
>
>
> [...]
>> Two sevenths is 0.285714285714.
>
> No it isn't. The decimal is repeating, so its actually 0.(285714). By 
> truncating
> it to only a finite number of decimal places, you introduce some rounding
> error.

Ask someone to write it down on a piece of paper. I can pretty much
guarantee that they'll truncate or round.

> And there are numbers which repeat in decimal but not binary, and numbers 
> which
> repeat in both, and numbers which don't repeat in either.

Which ones repeat in decimal but not binary? An example, please.

Ones which repeat in neither are easy. Ones which repeat in both are
usually not confusing, as it's easy to explain how the truncation
works.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Steve D'Aprano
On Fri, 25 Aug 2017 03:22 pm, Chris Angelico wrote:

>> py> from decimal import Decimal
>> py> sum([1/13]*13)
>> 0.9998
>> py> sum([Decimal(1)/Decimal(13)]*13)
>> Decimal('0.9997')
> 
> Now do the same exercise with pencil and paper. What's 1/13?

Easy: 0.(076923) where the brackets surround the digits which repeat.

I'm not so good at division in binary, but I *think* it should be:

0b0.(000100111011)

where, again, the repeating bits are in brackets.


[...]
> Two sevenths is 0.285714285714. 

No it isn't. The decimal is repeating, so its actually 0.(285714). By truncating
it to only a finite number of decimal places, you introduce some rounding
error.


> Add seven of those together, and 
> you'll get 0.. If you want to call it "2/7", you can use
> fractions.Fraction, but if you treat it as a decimal fraction, it's
> going to be rounded, just as it will be in a binary fraction (or a
> float). That's what I mean about the confusion - that there are
> numbers that you can write accurately as decimal fractions, but as
> binary fractions, they repeat.

And there are numbers which repeat in decimal but not binary, and numbers which
repeat in both, and numbers which don't repeat in either.

And even among those that don't repeat, sometimes you need more precision than
float (or Decimal) gives, and so there's still rounding error.

Fortunately often the rounding errors cancel rather than reinforce, which is why
floats are so accurate most of the time for the sorts of numbers we mostly care
about.




-- 
Steve
“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: Reading the documentation

2017-08-24 Thread Chris Angelico
On Fri, Aug 25, 2017 at 3:08 PM, Steve D'Aprano
 wrote:
> On Fri, 25 Aug 2017 02:21 pm, Chris Angelico wrote:
>
>> In fact, the ONLY way to create this confusion is to use (some
>> derivative of) one fifth, which is a factor of base 10 but not of base
>> 2. Any other fraction will either terminate in both bases (eg "0.125"
>> in decimal or "0.001" in binary), or repeat in both (any denominator
>> with any other prime number in it). No other rational numbers can
>> produce this apparently-irrational behaviour, pun intended.
>
>
> I think that's a bit strong. A lot strong. Let's take 1/13 for example:
>
>
> py> from decimal import Decimal
> py> sum([1/13]*13)
> 0.9998
> py> sum([Decimal(1)/Decimal(13)]*13)
> Decimal('0.9997')

Now do the same exercise with pencil and paper. What's 1/13?

Actually most people don't know the thirteenths. They might know the
sevenths, let's use them.

> Or 2/7, added 7 times, should be 2:
>
> py> sum([2/7]*7)
> 1.9996
> py> sum([Decimal(2)/Decimal(7)]*7)
> Decimal('2.001')

Two sevenths is 0.285714285714. Add seven of those together, and
you'll get 0.. If you want to call it "2/7", you can use
fractions.Fraction, but if you treat it as a decimal fraction, it's
going to be rounded, just as it will be in a binary fraction (or a
float). That's what I mean about the confusion - that there are
numbers that you can write accurately as decimal fractions, but as
binary fractions, they repeat.

> Besides: the derivative of 1/5 is 0, like that of every other constant.
>
> *wink*

Now that one, I'll grant you :) I never learned calculus.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Gene Heskett
On Thursday 24 August 2017 23:21:22 Larry Martell wrote:

> On Thu, Aug 24, 2017 at 11:08 PM, Rustom Mody  
wrote:
> > On Friday, August 25, 2017 at 8:28:55 AM UTC+5:30, Ian wrote:
> >> On Aug 24, 2017 8:51 PM, "Larry Martell"  wrote:
> >>
> >> On Thu, Aug 24, 2017 at 9:21 PM Rustom Mody wrote:
> >> > Statement 1: Aeroplanes fly
> >> > Statement 2: Submarines swim
> >> >
> >> >
> >> > Are these two statements equally acceptable?
> >> >
> >> > [Inspired by a talk by Noam Chomsky]
> >>
> >> There should be a corollary of Godwin's law for that idiot.
> >>
> >>
> >> Chomsky borrowed it from Dijkstra, I think.
> >>
> >> http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD898.ht
> >>ml
> >
> > I was about to start with the Dijkstra connection but then cut it
> > because irrelevant However I find the two very different
> > I think Dijkstra's "Can a submarine swim?" is almost entirely a
> > mockery of the idea However Chomsky's laconic juxtaposition points
> > to the deep non-rational programming in our subconscious mind of
> > what we accept and what we dont
> >
> > [Larry seems to be angry about/at somethin'… No idea who/what…]
>
> I think Chomsky is a jerk, and I'm angry at media outlets like CNN
> giving him a forum to spew his idiocies.

I agree Larry, Chomsky can be described in even more flowery terms, but 
since its CNN, what else should we expect?  That site has not been on my 
nightly news tour for at least 18 months.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Steve D'Aprano
On Fri, 25 Aug 2017 02:21 pm, Chris Angelico wrote:

> In fact, the ONLY way to create this confusion is to use (some
> derivative of) one fifth, which is a factor of base 10 but not of base
> 2. Any other fraction will either terminate in both bases (eg "0.125"
> in decimal or "0.001" in binary), or repeat in both (any denominator
> with any other prime number in it). No other rational numbers can
> produce this apparently-irrational behaviour, pun intended.


I think that's a bit strong. A lot strong. Let's take 1/13 for example:


py> from decimal import Decimal
py> sum([1/13]*13)
0.9998
py> sum([Decimal(1)/Decimal(13)]*13)
Decimal('0.9997')


Or 2/7, added 7 times, should be 2:

py> sum([2/7]*7)
1.9996
py> sum([Decimal(2)/Decimal(7)]*7)
Decimal('2.001')


Its not just addition that "fails". We can take the reciprocal of the reciprocal
of a number, and expect to get the original number:

py> 1/(1/99)
98.99
py> Decimal(1)/( Decimal(1)/Decimal(99) )
Decimal('99.01')


or we can multiply a fraction by the denominator and expect to get the
numerator:

py> (7/207)*207
6.999
py> (Decimal(7)/Decimal(207))*Decimal(207)
Decimal('6.999')


These are not isolated examples.


You'll note that none of the numbers involved are multiples of 5.



Besides: the derivative of 1/5 is 0, like that of every other constant.

*wink*

-- 
Steve
“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: Reading the documentation

2017-08-24 Thread Rustom Mody
On Friday, August 25, 2017 at 10:18:07 AM UTC+5:30, Rustom Mody wrote:
> On Friday, August 25, 2017 at 9:09:16 AM UTC+5:30, larry@gmail.com wrote:
> > On Thu, Aug 24, 2017 at 11:27 PM, Rustom Mody  wrote:
> > > Chomsky is in the Turing bracket, I wonder where Larry falls wrt CS
> > 
> > I have a degree in Software Engineering from Rochester Institute of
> > Technology. I stared programming when I was 16, and I have worked
> > professionally since I was 19. I am 57 now.
> 
> I was pointing to the link between Chomsky and Computer Science (CS)



… which is to say that if we want to keep discussions here (reasonably!) 
on-topic
we should (try to!) avoid bringing in irrelevant aspects of relevant 
personalities

[Yeah with some super-eminent guys like Chomsky that can be hard!]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Chris Angelico
On Fri, Aug 25, 2017 at 2:37 PM, Rustom Mody  wrote:
> On Friday, August 25, 2017 at 9:58:15 AM UTC+5:30, Chris Angelico wrote:
>> On Fri, Aug 25, 2017 at 1:23 PM, Rustom Mody wrote:
>> > Early in my python classes I show this:
>> >
>> > $ python
>> > Python 2.7.13 (default, Jan 19 2017, 14:48:08)
>> > [GCC 6.3.0 20170118] on linux2
>> > Type "help", "copyright", "credits" or "license" for more information.
>>  .1 + .1 == .2
>> > True
>>  .1 + .1 + .1 == .3
>> > False
>> 
>> > --
>> > https://mail.python.org/mailman/listinfo/python-list
>>
>> Aside from the fact that I show it with Python 3 (or sometimes
>> Node.js) instead, I've demonstrated something similar - but then go on
>> to make the point that 0.1 is not "one tenth". The problem isn't with
>> addition, which is completely correct here; the problem is with the
>> assumption that writing "0.1" in your source code indicates the number
>> "one tenth". If you want the details, Python is very helpful here:
>>
>> >>> "%d/%d" % (0.1).as_integer_ratio()
>> '3602879701896397/36028797018963968'
>> >>> "%d/%d" % (0.2).as_integer_ratio()
>> '3602879701896397/18014398509481984'
>> >>> "%d/%d" % (0.3).as_integer_ratio()
>> '5404319552844595/18014398509481984'
>>
>> Or in hex:
>>
>> >>> "%x/%x" % (0.1).as_integer_ratio()
>> 'd/80'
>> >>> "%x/%x" % (0.2).as_integer_ratio()
>> 'd/40'
>> >>> "%x/%x" % (0.3).as_integer_ratio()
>> '13/40'
>>
>
> Thanks for the hex tip… Useful!

Yes, that makes it really obvious that (a) the denominator is a power
of two, (b) the numerator is repeating, and (c) one of them got
rounded down and the other two got rounded up. The decimal values are
almost completely useless, except for the fairly significant fact that
most people aren't used to writing numbers like
"d/80" !!!

>> Clearly the second one is exactly double the first. And equally
>> clearly, the first two have been rounded up, while the second is
>> rounded down. But you don't need that much detail to understand what's
>> going on; most people can follow this analogy:
>>
>> 0.6667 + 0.6667 + 0.6667 != 2.000
>>
>> since, in grade school, most of us learned that the decimal expansion
>> for two-thirds gets rounded up. It's the same thing, just in binary.
>>
>> In fact, the ONLY way to create this confusion is to use (some
>> derivative of) one fifth, which is a factor of base 10 but not of base
>> 2. Any other fraction will either terminate in both bases (eg "0.125"
>> in decimal or "0.001" in binary), or repeat in both (any denominator
>> with any other prime number in it). No other rational numbers can
>> produce this apparently-irrational behaviour, pun intended.
>
> You almost make that sound like a rare exception 

Heh, worded that way it does sound rare. But people are at least
familiar with one third, one seventh, one ninth, and maybe a few
others, so it's not surprising to them when numbers get rounded.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Rustom Mody
On Friday, August 25, 2017 at 9:09:16 AM UTC+5:30, larry@gmail.com wrote:
> On Thu, Aug 24, 2017 at 11:27 PM, Rustom Mody  wrote:
> > Chomsky is in the Turing bracket, I wonder where Larry falls wrt CS
> 
> I have a degree in Software Engineering from Rochester Institute of
> Technology. I stared programming when I was 16, and I have worked
> professionally since I was 19. I am 57 now.

I was pointing to the link between Chomsky and Computer Science (CS)

Chomsky is at least 3 things

1. A pioneer of CS¹
2. A linguist²
3. A political activist³
4. Much else⁴

1 and 2 are obviously linked
My original reference to Chomsky was wrt 2
Because of 1 he is on-topic on a programming mailing list — hopefully!

You can bring in 3 if you like… I didn't
And then someone is going to red-flag the OT-ness of the discussion

For now I will only say (in response to Steven's)

> Chomsky challenges the prevailing world-view that the USA is a force for good,
> by documenting the many, many, many ways that the USA's actions are harmful,
> unjust, illegal (occasionally all three at once) and in contradiction to the
> nation's stated values. Many people don't like it when you challenge their
> cherished myths.

As one of the 19/20th of the world that is not a US citizen I would have 
thought 
it axiomatic:
When the world's most powerful nation remains that for too long,
its only a question of time before it becomes the world's most lethal
terrorist⁵ organization.

This was true of Britain 100 years ago
It was true of Rome 1000 years ago
And it would be inexorably true for any grouping following from the axiom:
“Power corrupts; Absolute power absolutely corrupts”

Which is why I agree and disagree with Steven's above characterization:
- It is literally true
- Its implication that the current holder of absolute power is somehow special 
is false




¹ http://www.soc.napier.ac.uk/~andrew/co42010/kentucky/languages/langnote.pdf
² http://blog.mangolanguages.com/noam-chomsky-his-contribution-to-linguistics/
³ https://youtu.be/5BXtgq0Nhsc
⁴ eg an anti-Israel jew https://youtu.be/zWaLuVQ_LCc
⁵ The word 'terrorist' today (like 'communist' 50 years ago) is sufficiently 
  overused to be rendered almost meaningless.
  One could do worse than hearing Chomsky on that  https://youtu.be/UWuT8d78yts
  Inter alia it is related to Chomsky being a linguist who's turned political
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Rustom Mody
On Friday, August 25, 2017 at 9:58:15 AM UTC+5:30, Chris Angelico wrote:
> On Fri, Aug 25, 2017 at 1:23 PM, Rustom Mody wrote:
> > Early in my python classes I show this:
> >
> > $ python
> > Python 2.7.13 (default, Jan 19 2017, 14:48:08)
> > [GCC 6.3.0 20170118] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
>  .1 + .1 == .2
> > True
>  .1 + .1 + .1 == .3
> > False
> 
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> 
> Aside from the fact that I show it with Python 3 (or sometimes
> Node.js) instead, I've demonstrated something similar - but then go on
> to make the point that 0.1 is not "one tenth". The problem isn't with
> addition, which is completely correct here; the problem is with the
> assumption that writing "0.1" in your source code indicates the number
> "one tenth". If you want the details, Python is very helpful here:
> 
> >>> "%d/%d" % (0.1).as_integer_ratio()
> '3602879701896397/36028797018963968'
> >>> "%d/%d" % (0.2).as_integer_ratio()
> '3602879701896397/18014398509481984'
> >>> "%d/%d" % (0.3).as_integer_ratio()
> '5404319552844595/18014398509481984'
> 
> Or in hex:
> 
> >>> "%x/%x" % (0.1).as_integer_ratio()
> 'd/80'
> >>> "%x/%x" % (0.2).as_integer_ratio()
> 'd/40'
> >>> "%x/%x" % (0.3).as_integer_ratio()
> '13/40'
> 

Thanks for the hex tip… Useful!
> 
> Clearly the second one is exactly double the first. And equally
> clearly, the first two have been rounded up, while the second is
> rounded down. But you don't need that much detail to understand what's
> going on; most people can follow this analogy:
> 
> 0.6667 + 0.6667 + 0.6667 != 2.000
> 
> since, in grade school, most of us learned that the decimal expansion
> for two-thirds gets rounded up. It's the same thing, just in binary.
> 
> In fact, the ONLY way to create this confusion is to use (some
> derivative of) one fifth, which is a factor of base 10 but not of base
> 2. Any other fraction will either terminate in both bases (eg "0.125"
> in decimal or "0.001" in binary), or repeat in both (any denominator
> with any other prime number in it). No other rational numbers can
> produce this apparently-irrational behaviour, pun intended.

You almost make that sound like a rare exception 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Chris Angelico
On Fri, Aug 25, 2017 at 1:23 PM, Rustom Mody  wrote:
> Early in my python classes I show this:
>
> $ python
> Python 2.7.13 (default, Jan 19 2017, 14:48:08)
> [GCC 6.3.0 20170118] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
 .1 + .1 == .2
> True
 .1 + .1 + .1 == .3
> False

> --
> https://mail.python.org/mailman/listinfo/python-list

Aside from the fact that I show it with Python 3 (or sometimes
Node.js) instead, I've demonstrated something similar - but then go on
to make the point that 0.1 is not "one tenth". The problem isn't with
addition, which is completely correct here; the problem is with the
assumption that writing "0.1" in your source code indicates the number
"one tenth". If you want the details, Python is very helpful here:

>>> "%d/%d" % (0.1).as_integer_ratio()
'3602879701896397/36028797018963968'
>>> "%d/%d" % (0.2).as_integer_ratio()
'3602879701896397/18014398509481984'
>>> "%d/%d" % (0.3).as_integer_ratio()
'5404319552844595/18014398509481984'

Or in hex:

>>> "%x/%x" % (0.1).as_integer_ratio()
'd/80'
>>> "%x/%x" % (0.2).as_integer_ratio()
'd/40'
>>> "%x/%x" % (0.3).as_integer_ratio()
'13/40'


Clearly the second one is exactly double the first. And equally
clearly, the first two have been rounded up, while the second is
rounded down. But you don't need that much detail to understand what's
going on; most people can follow this analogy:

0.6667 + 0.6667 + 0.6667 != 2.000

since, in grade school, most of us learned that the decimal expansion
for two-thirds gets rounded up. It's the same thing, just in binary.

In fact, the ONLY way to create this confusion is to use (some
derivative of) one fifth, which is a factor of base 10 but not of base
2. Any other fraction will either terminate in both bases (eg "0.125"
in decimal or "0.001" in binary), or repeat in both (any denominator
with any other prime number in it). No other rational numbers can
produce this apparently-irrational behaviour, pun intended.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Rustom Mody
On Friday, August 25, 2017 at 9:06:53 AM UTC+5:30, Steve D'Aprano wrote:
> On Fri, 25 Aug 2017 01:27 pm, Rustom Mody wrote:
> 
> > People should be free to dislike who they like to dislike
> > However…
> > Calling Newton an idiot is ok… if you are not a physicist (flat-earther??)
> > Calling Turing an idiot is ok if you dont like computers (Luddite??)
> > Given that for most people who have gone through a (½ decent) CS education
> > Chomsky is in the Turing bracket, I wonder where Larry falls wrt CS
> 
> 
> Newton and Turing where many things, but "idiot" was not one of them.
> 
> Calling Newton an idiot is like calling Barrack Obama a Japanese geisha, or
> Donald Trump a poor black man from the Brazilian favelas.


You may find the etymology of idiot interesting
https://en.wikipedia.org/wiki/Idiot#Etymology
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Larry Martell
On Thu, Aug 24, 2017 at 11:27 PM, Rustom Mody  wrote:
> Chomsky is in the Turing bracket, I wonder where Larry falls wrt CS

I have a degree in Software Engineering from Rochester Institute of
Technology. I stared programming when I was 16, and I have worked
professionally since I was 19. I am 57 now.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Steve D'Aprano
On Fri, 25 Aug 2017 01:27 pm, Rustom Mody wrote:

> People should be free to dislike who they like to dislike
> However…
> Calling Newton an idiot is ok… if you are not a physicist (flat-earther??)
> Calling Turing an idiot is ok if you dont like computers (Luddite??)
> Given that for most people who have gone through a (½ decent) CS education
> Chomsky is in the Turing bracket, I wonder where Larry falls wrt CS


Newton and Turing where many things, but "idiot" was not one of them.

Calling Newton an idiot is like calling Barrack Obama a Japanese geisha, or
Donald Trump a poor black man from the Brazilian favelas.


-- 
Steve
“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: Reading the documentation

2017-08-24 Thread Steve D'Aprano
On Fri, 25 Aug 2017 11:25 am, Ben Bacarisse wrote:

>> Integral \In"te*gral\, a. [Cf. F. int['e]gral. See Integer.]
> 
> For me (and I suspect for BG too) the surprise is in its use as a noun.
> The capital letter is, presumably, significant because it refers to the
> Python class Integral -- a subtype of numbers.

English doesn't just verb nouns and noun verbs, it also nouns adverbs and
adjectives too.

Human, as in human being, is a nouned adjective, as are black and white (as in
people, not in colours). Going back a while, a wireless is a wireless radio. We
eat Chinese or Italian (as in the foods, not the people). You can probably
think of many other examples :-)


> With that in mind, "an Integral" is a shorthand for "an Integral value",
> or more fully, maybe, "an instance of numbers.Integral".

Indeed.

This process of nouning words is common enough that native speakers shouldn't be
surprised by it. Deplore it, perhaps, but not surprised :-)


> The use as a noun is not covered here, though it is only a small step
> from other places where membership of a mathematical set has turned the
> adjective into a noun.  "Rational" and "real" started out as adjectives,
> but their use as nouns is now widespread.  "The function returns a
> real".  "The result is a rational".  It's much less common for complex
> and integral, to the point that it sounds wrong to me.

I agree with "complex", but "integral" as a synonym for integer seems okay to
me. I think it's because "complexes" is awkward.



-- 
Steve
“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: Reading the documentation

2017-08-24 Thread Rustom Mody
On Friday, August 25, 2017 at 8:52:11 AM UTC+5:30, Steve D'Aprano wrote:
> On Fri, 25 Aug 2017 12:47 pm, Larry Martell wrote:
> 
> > On Thu, Aug 24, 2017 at 9:21 PM Rustom Mody wrote:
> > 
> >> Statement 1: Aeroplanes fly
> >> Statement 2: Submarines swim
> >>
> >>
> >> Are these two statements equally acceptable?
> >>
> >> [Inspired by a talk by Noam Chomsky]
> > 
> > There should be a corollary of Godwin's law for that idiot.
> 
> 
> Just because you disagree with him doesn't make him an idiot.

People should be free to dislike who they like to dislike
However…
Calling Newton an idiot is ok… if you are not a physicist (flat-earther??)
Calling Turing an idiot is ok if you dont like computers (Luddite??)
Given that for most people who have gone through a (½ decent) CS education
Chomsky is in the Turing bracket, I wonder where Larry falls wrt CS
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Steve D'Aprano
On Fri, 25 Aug 2017 01:08 pm, Rustom Mody wrote:

> On Friday, August 25, 2017 at 8:28:55 AM UTC+5:30, Ian wrote:
>> On Aug 24, 2017 8:51 PM, "Larry Martell"  wrote:
>> 
>> On Thu, Aug 24, 2017 at 9:21 PM Rustom Mody wrote:
>> 
>> > Statement 1: Aeroplanes fly
>> > Statement 2: Submarines swim
>> >
>> >
>> > Are these two statements equally acceptable?
>> >
>> > [Inspired by a talk by Noam Chomsky]
>> 
>> There should be a corollary of Godwin's law for that idiot.
[...]
> [Larry seems to be angry about/at somethin'… No idea who/what…]

Chomsky challenges the prevailing world-view that the USA is a force for good,
by documenting the many, many, many ways that the USA's actions are harmful,
unjust, illegal (occasionally all three at once) and in contradiction to the
nation's stated values. Many people don't like it when you challenge their
cherished myths.

The story of the Emperor's New Clothes is relevant here. Also known by its
subtitle, "The naughty boy who was sent to bed without his supper for telling
lies about His Majesty".



-- 
Steve
“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: Reading the documentation

2017-08-24 Thread Rustom Mody
On Friday, August 25, 2017 at 8:39:25 AM UTC+5:30, Rustom Mody wrote:
> On Friday, August 25, 2017 at 8:28:55 AM UTC+5:30, Ian wrote:
> > On Aug 24, 2017 8:51 PM, "Larry Martell"  wrote:
> > 
> > On Thu, Aug 24, 2017 at 9:21 PM Rustom Mody wrote:
> > 
> > > Statement 1: Aeroplanes fly
> > > Statement 2: Submarines swim
> > >
> > >
> > > Are these two statements equally acceptable?
> > >
> > > [Inspired by a talk by Noam Chomsky]
> > 
> > There should be a corollary of Godwin's law for that idiot.
> > 
> > 
> > Chomsky borrowed it from Dijkstra, I think.
> > 
> > http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD898.html
> 
> I was about to start with the Dijkstra connection but then cut it because 
> irrelevant
> However I find the two very different
> I think Dijkstra's "Can a submarine swim?" is almost entirely a mockery of 
> the idea
> However Chomsky's laconic juxtaposition points to the deep non-rational 
> programming in our subconscious mind of what we accept and what we dont
> 
> [Larry seems to be angry about/at somethin'… No idea who/what…]

One more juxtaposition(s) to consider:

In Fortran, Pascal the numerics were real and int(eger)
In PL-1 it was Float and Fixed
So a clear choice of underlying model on the one side and machine representation
on the other

It was only C onwards that we started seeing the strange juxtaposition
- for int(eger) emphasize the (math) model
- for real emphasize the float(ing) representation

I vaguely remember someone (Niklaus Wirth??) criticizing this mis-juxtaposition

In retrospect though I find it fine: 

- fixpoint numbers are ok representations of integers most of the time 
- floats as representations of reals are so leaky that remembering the 
difference
sounds like a good idea

Early in my python classes I show this:

$ python
Python 2.7.13 (default, Jan 19 2017, 14:48:08) 
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> .1 + .1 == .2
True
>>> .1 + .1 + .1 == .3
False
>>> 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Steve D'Aprano
On Fri, 25 Aug 2017 12:47 pm, Larry Martell wrote:

> On Thu, Aug 24, 2017 at 9:21 PM Rustom Mody  wrote:
> 
>> Statement 1: Aeroplanes fly
>> Statement 2: Submarines swim
>>
>>
>> Are these two statements equally acceptable?
>>
>> [Inspired by a talk by Noam Chomsky]
> 
> There should be a corollary of Godwin's law for that idiot.


Just because you disagree with him doesn't make him an idiot.

In fact, many people would insist the opposite.


-- 
Steve
“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: Reading the documentation

2017-08-24 Thread Larry Martell
On Thu, Aug 24, 2017 at 11:08 PM, Rustom Mody  wrote:
> On Friday, August 25, 2017 at 8:28:55 AM UTC+5:30, Ian wrote:
>> On Aug 24, 2017 8:51 PM, "Larry Martell"  wrote:
>>
>> On Thu, Aug 24, 2017 at 9:21 PM Rustom Mody wrote:
>>
>> > Statement 1: Aeroplanes fly
>> > Statement 2: Submarines swim
>> >
>> >
>> > Are these two statements equally acceptable?
>> >
>> > [Inspired by a talk by Noam Chomsky]
>>
>> There should be a corollary of Godwin's law for that idiot.
>>
>>
>> Chomsky borrowed it from Dijkstra, I think.
>>
>> http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD898.html
>
> I was about to start with the Dijkstra connection but then cut it because 
> irrelevant
> However I find the two very different
> I think Dijkstra's "Can a submarine swim?" is almost entirely a mockery of 
> the idea
> However Chomsky's laconic juxtaposition points to the deep non-rational
> programming in our subconscious mind of what we accept and what we dont
>
> [Larry seems to be angry about/at somethin'… No idea who/what…]

I think Chomsky is a jerk, and I'm angry at media outlets like CNN
giving him a forum to spew his idiocies.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Rustom Mody
On Friday, August 25, 2017 at 8:28:55 AM UTC+5:30, Ian wrote:
> On Aug 24, 2017 8:51 PM, "Larry Martell"  wrote:
> 
> On Thu, Aug 24, 2017 at 9:21 PM Rustom Mody wrote:
> 
> > Statement 1: Aeroplanes fly
> > Statement 2: Submarines swim
> >
> >
> > Are these two statements equally acceptable?
> >
> > [Inspired by a talk by Noam Chomsky]
> 
> There should be a corollary of Godwin's law for that idiot.
> 
> 
> Chomsky borrowed it from Dijkstra, I think.
> 
> http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD898.html

I was about to start with the Dijkstra connection but then cut it because 
irrelevant
However I find the two very different
I think Dijkstra's "Can a submarine swim?" is almost entirely a mockery of the 
idea
However Chomsky's laconic juxtaposition points to the deep non-rational 
programming in our subconscious mind of what we accept and what we dont

[Larry seems to be angry about/at somethin'… No idea who/what…]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Ian Kelly
On Aug 24, 2017 8:51 PM, "Larry Martell"  wrote:

On Thu, Aug 24, 2017 at 9:21 PM Rustom Mody  wrote:

> Statement 1: Aeroplanes fly
> Statement 2: Submarines swim
>
>
> Are these two statements equally acceptable?
>
> [Inspired by a talk by Noam Chomsky]

There should be a corollary of Godwin's law for that idiot.


Chomsky borrowed it from Dijkstra, I think.

http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD898.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread MRAB

On 2017-08-25 02:58, Ben Bacarisse wrote:

Chris Angelico  writes:


On Fri, Aug 25, 2017 at 11:25 AM, Ben Bacarisse  wrote:

The use as a noun is not covered here, though it is only a small step
from other places where membership of a mathematical set has turned the
adjective into a noun.  "Rational" and "real" started out as adjectives,
but their use as nouns is now widespread.  "The function returns a
real".  "The result is a rational".  It's much less common for complex
and integral, to the point that it sounds wrong to me.


This is a common thing in English (and many other languages). When you
find yourself frequently using similar phrases, you abbreviate them:

* real number -> real
* rational number -> rational
* complex number -> complex

Thus the adjective acquires a new meaning as a noun. As my mother (and
grammar teacher) drummed into me: No word is a part of speech unless
it appears in context.


Yes, we agree on that, but has it become natural(!) yet with complex and
integral?  Not to my ear.  What about yours?

To me, the "adjectiveness" is still so strong that my brain asks "an
integral what?", "a complex what?".  That does not happen in my head
with "a real" or "a rational".


To me, an "integral" is the result of integration.

I'm OK with "real" as a noun, but only because I'm used to its use in 
programming.


"Complex" already has a meaning as a noun, though not mathematical.

But what about "imaginary"?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Larry Martell
On Thu, Aug 24, 2017 at 9:21 PM Rustom Mody  wrote:

> Statement 1: Aeroplanes fly
> Statement 2: Submarines swim
>
>
> Are these two statements equally acceptable?
>
> [Inspired by a talk by Noam Chomsky]

There should be a corollary of Godwin's law for that idiot.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Rustom Mody
On Friday, August 25, 2017 at 6:55:46 AM UTC+5:30, Ben Bacarisse wrote:
> Steve D'Aprano writes:
> 
> > On Fri, 25 Aug 2017 09:41 am, bob gailer wrote:
> >
> >>> Help on built-in function floor in module math:
> >>>
> >>> floor(...)
> >>>  floor(x)
> >>>
> >>>  Return the floor of x as an Integral.
> >>>  This is the largest integer <= x.
> > [...]
> >
> >> I was surprised by the use of "integral". A dictionary search does not
> >> (IMHO) support this usage!
> >
> > Integral \In"te*gral\, a. [Cf. F. int['e]gral. See Integer.]
> 
> For me (and I suspect for BG too) the surprise is in its use as a noun.
> The capital letter is, presumably, significant because it refers to the
> Python class Integral -- a subtype of numbers.
> 
> With that in mind, "an Integral" is a shorthand for "an Integral value",
> or more fully, maybe, "an instance of numbers.Integral".
> 
> >[1913 Webster]
> >1. Lacking nothing of completeness; complete; perfect;
> >   uninjured; whole; entire.
> >   [1913 Webster]
> >
> > A local motion keepeth bodies integral. --Bacon.
> >   [1913 Webster]
> >
> >2. Essential to completeness; constituent, as a part;
> >   pertaining to, or serving to form, an integer; integrant.
> >   [1913 Webster]
> >
> > Ceasing to do evil, and doing good, are the two
> > great integral parts that complete this duty.
> >   --South.
> >   [1913 Webster]
> >
> >3. (Math.)
> >   (a) Of, pertaining to, or being, a whole number or
> >   undivided quantity; not fractional.
> >   (b) Pertaining to, or proceeding by, integration; as, the
> >   integral calculus.
> >   [1913 Webster]
> 
> The use as a noun is not covered here, though it is only a small step
> from other places where membership of a mathematical set has turned the
> adjective into a noun.  "Rational" and "real" started out as adjectives,
> but their use as nouns is now widespread.  "The function returns a
> real".  "The result is a rational".  It's much less common for complex
> and integral, to the point that it sounds wrong to me.

Statement 1: Aeroplanes fly
Statement 2: Submarines swim


Are these two statements equally acceptable?

[Inspired by a talk by Noam Chomsky]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Chris Angelico
On Fri, Aug 25, 2017 at 11:58 AM, Ben Bacarisse  wrote:
> Chris Angelico  writes:
>
>> On Fri, Aug 25, 2017 at 11:25 AM, Ben Bacarisse  wrote:
>>> The use as a noun is not covered here, though it is only a small step
>>> from other places where membership of a mathematical set has turned the
>>> adjective into a noun.  "Rational" and "real" started out as adjectives,
>>> but their use as nouns is now widespread.  "The function returns a
>>> real".  "The result is a rational".  It's much less common for complex
>>> and integral, to the point that it sounds wrong to me.
>>
>> This is a common thing in English (and many other languages). When you
>> find yourself frequently using similar phrases, you abbreviate them:
>>
>> * real number -> real
>> * rational number -> rational
>> * complex number -> complex
>>
>> Thus the adjective acquires a new meaning as a noun. As my mother (and
>> grammar teacher) drummed into me: No word is a part of speech unless
>> it appears in context.
>
> Yes, we agree on that, but has it become natural(!) yet with complex and
> integral?  Not to my ear.  What about yours?
>
> To me, the "adjectiveness" is still so strong that my brain asks "an
> integral what?", "a complex what?".  That does not happen in my head
> with "a real" or "a rational".

Yes, it's comfortable on my ear. But maybe that's because I'm stronger
in programming than in mathematical theory.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Ben Bacarisse
Chris Angelico  writes:

> On Fri, Aug 25, 2017 at 11:25 AM, Ben Bacarisse  wrote:
>> The use as a noun is not covered here, though it is only a small step
>> from other places where membership of a mathematical set has turned the
>> adjective into a noun.  "Rational" and "real" started out as adjectives,
>> but their use as nouns is now widespread.  "The function returns a
>> real".  "The result is a rational".  It's much less common for complex
>> and integral, to the point that it sounds wrong to me.
>
> This is a common thing in English (and many other languages). When you
> find yourself frequently using similar phrases, you abbreviate them:
>
> * real number -> real
> * rational number -> rational
> * complex number -> complex
>
> Thus the adjective acquires a new meaning as a noun. As my mother (and
> grammar teacher) drummed into me: No word is a part of speech unless
> it appears in context.

Yes, we agree on that, but has it become natural(!) yet with complex and
integral?  Not to my ear.  What about yours?

To me, the "adjectiveness" is still so strong that my brain asks "an
integral what?", "a complex what?".  That does not happen in my head
with "a real" or "a rational".

-- 
Ben.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Chris Angelico
On Fri, Aug 25, 2017 at 11:25 AM, Ben Bacarisse  wrote:
> The use as a noun is not covered here, though it is only a small step
> from other places where membership of a mathematical set has turned the
> adjective into a noun.  "Rational" and "real" started out as adjectives,
> but their use as nouns is now widespread.  "The function returns a
> real".  "The result is a rational".  It's much less common for complex
> and integral, to the point that it sounds wrong to me.

This is a common thing in English (and many other languages). When you
find yourself frequently using similar phrases, you abbreviate them:

* real number -> real
* rational number -> rational
* complex number -> complex

Thus the adjective acquires a new meaning as a noun. As my mother (and
grammar teacher) drummed into me: No word is a part of speech unless
it appears in context.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Ben Bacarisse
Steve D'Aprano  writes:

> On Fri, 25 Aug 2017 09:41 am, bob gailer wrote:
>
>>> Help on built-in function floor in module math:
>>>
>>> floor(...)
>>>  floor(x)
>>>
>>>  Return the floor of x as an Integral.
>>>  This is the largest integer <= x.
> [...]
>
>> I was surprised by the use of "integral". A dictionary search does not
>> (IMHO) support this usage!
>
> Integral \In"te*gral\, a. [Cf. F. int['e]gral. See Integer.]

For me (and I suspect for BG too) the surprise is in its use as a noun.
The capital letter is, presumably, significant because it refers to the
Python class Integral -- a subtype of numbers.

With that in mind, "an Integral" is a shorthand for "an Integral value",
or more fully, maybe, "an instance of numbers.Integral".

>[1913 Webster]
>1. Lacking nothing of completeness; complete; perfect;
>   uninjured; whole; entire.
>   [1913 Webster]
>
> A local motion keepeth bodies integral. --Bacon.
>   [1913 Webster]
>
>2. Essential to completeness; constituent, as a part;
>   pertaining to, or serving to form, an integer; integrant.
>   [1913 Webster]
>
> Ceasing to do evil, and doing good, are the two
> great integral parts that complete this duty.
>   --South.
>   [1913 Webster]
>
>3. (Math.)
>   (a) Of, pertaining to, or being, a whole number or
>   undivided quantity; not fractional.
>   (b) Pertaining to, or proceeding by, integration; as, the
>   integral calculus.
>   [1913 Webster]

The use as a noun is not covered here, though it is only a small step
from other places where membership of a mathematical set has turned the
adjective into a noun.  "Rational" and "real" started out as adjectives,
but their use as nouns is now widespread.  "The function returns a
real".  "The result is a rational".  It's much less common for complex
and integral, to the point that it sounds wrong to me.

-- 
Ben.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Steve D'Aprano
On Fri, 25 Aug 2017 05:24 am, Stefan Ram wrote:

>   Is the output of »help(floor)« supposed to be a kind of
>   normative documentation, i.e., /the/ authoritative
>   documentation of »floor«?

No. The output of help() is intended as a short description of the function, not
the authoritative and complete documentation.

For that, see the docs in the website.

>   Is there any hint in the documentation about the type
>   expected of arguments in a call?
> 
>   Is a parameter name »x« (as used above) described
>   somewhere to express the requirement of a real number?

There are various weak conventions for variable names:

x, y - floats or other real values, occasionally anything at all;

i, j, k - integers

s - string, set

a, b, c - three variables of the same kind (e.g. three lists)

o, obj - arbitrary object

L - list

d - dict, occasionally Decimal

spam, eggs, cheese - Pythonic versions of foo, bar, baz


>   It seems, »real« means »int or float«. Is this meaning
>   of »real« documented somewhere?

See the documentation for the numeric tower.




-- 
Steve
“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: Reading the documentation

2017-08-24 Thread Steve D'Aprano
On Fri, 25 Aug 2017 09:41 am, bob gailer wrote:

>> Help on built-in function floor in module math:
>>
>> floor(...)
>>  floor(x)
>>
>>  Return the floor of x as an Integral.
>>  This is the largest integer <= x.
[...]

> I was surprised by the use of "integral". A dictionary search does not
> (IMHO) support this usage!

Integral \In"te*gral\, a. [Cf. F. int['e]gral. See Integer.]
   [1913 Webster]
   1. Lacking nothing of completeness; complete; perfect;
  uninjured; whole; entire.
  [1913 Webster]

A local motion keepeth bodies integral. --Bacon.
  [1913 Webster]

   2. Essential to completeness; constituent, as a part;
  pertaining to, or serving to form, an integer; integrant.
  [1913 Webster]

Ceasing to do evil, and doing good, are the two
great integral parts that complete this duty.
  --South.
  [1913 Webster]

   3. (Math.)
  (a) Of, pertaining to, or being, a whole number or
  undivided quantity; not fractional.
  (b) Pertaining to, or proceeding by, integration; as, the
  integral calculus.
  [1913 Webster]


-- 
Steve
“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: Reading the documentation

2017-08-24 Thread bob gailer

On 8/24/2017 3:24 PM, Stefan Ram wrote:

   This is a transcript:


from math import floor
floor( "2.3" )

Traceback (most recent call last):
   File "", line 1, in 
TypeError: must be real number, not str

help(floor)

Help on built-in function floor in module math:

floor(...)
 floor(x)

 Return the floor of x as an Integral.
 This is the largest integer <= x.

   Is the output of »help(floor)« supposed to be a kind of
   normative documentation, i.e., /the/ authoritative
   documentation of »floor«?

   Is there any hint in the documentation about the type
   expected of arguments in a call?

   Is a parameter name »x« (as used above) described
   somewhere to express the requirement of a real number?

   It seems, »real« means »int or float«. Is this meaning
   of »real« documented somewhere?

in the Python Language Reference
3.2. The standard type hierarchy
    numbers.Real (float)
    These represent machine-level double precision floating point 
numbers.

This  is not the meaning of "real" in mathematics!

I was surprised by the use of "integral". A dictionary search does not 
(IMHO) support this usage!


   Thanks in advance!



--
Image and video hosting by TinyPic
--
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread bob gailer

On 8/24/2017 3:54 PM, Nathan Ernst wrote:

You passed a string to "math.floor", not anything resembling a numeric
type. Try using an actual float, int or Decimal:
It would seem you did not understand the OP's question. It was not "why 
did I get this traceback."

He showed the traceback as leading him to use the help builtin.
He was questioning what help() returned.


Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.

from math import floor
from decimal import Decimal
floor("2.3")

Traceback (most recent call last):
   File "", line 1, in 
TypeError: a float is required


floor(2.3)

2


floor(Decimal("2.3"))

2


floor(2)

2

Remember that Python is strongly typed; you do not get automatic type
conversions from strings to numeric types such as in Perl.

Regards,
Nathan

On Thu, Aug 24, 2017 at 2:24 PM, Stefan Ram  wrote:


   This is a transcript:


from math import floor
floor( "2.3" )

Traceback (most recent call last):
   File "", line 1, in 
TypeError: must be real number, not str

help(floor)

Help on built-in function floor in module math:

floor(...)
 floor(x)

 Return the floor of x as an Integral.
 This is the largest integer <= x.

   Is the output of »help(floor)« supposed to be a kind of
   normative documentation, i.e., /the/ authoritative
   documentation of »floor«?

   Is there any hint in the documentation about the type
   expected of arguments in a call?

   Is a parameter name »x« (as used above) described
   somewhere to express the requirement of a real number?

   It seems, »real« means »int or float«. Is this meaning
   of »real« documented somewhere?

   Thanks in advance!

--
https://mail.python.org/mailman/listinfo/python-list



--
Image and video hosting by TinyPic
--
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Peter Otten
Stefan Ram wrote:

>   This is a transcript:
> 
 from math import floor
 floor( "2.3" )
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: must be real number, not str
 help(floor)
> Help on built-in function floor in module math:
> 
> floor(...)
> floor(x)
> 
> Return the floor of x as an Integral.
> This is the largest integer <= x.
> 
>   Is the output of »help(floor)« supposed to be a kind of
>   normative documentation, i.e., /the/ authoritative
>   documentation of »floor«?

You should consult the documentation

https://docs.python.org/dev/library/math.html#math.floor

which has usually more details. The docstring (i. e. what help() shows) is 
most helpful when you already have an idea about what a function does.

>   Is there any hint in the documentation about the type
>   expected of arguments in a call?

Yes. Everything that features a __floor__() method:

>>> import math
>>> class Foo:
... def __floor__(self): return "yadda"
... 
>>> math.floor(Foo())
'yadda'

So the current implementation doesn't even mandate an int as the result...

>   Is a parameter name »x« (as used above) described
>   somewhere to express the requirement of a real number?
> 
>   It seems, »real« means »int or float«. Is this meaning
>   of »real« documented somewhere?

I don't know if there is something more direct than 

https://docs.python.org/dev/library/numbers.html

and the PEP linked from there.

> 
>   Thanks in advance!
> 


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread MRAB

On 2017-08-24 20:24, Stefan Ram wrote:

   This is a transcript:


from math import floor
floor( "2.3" )

Traceback (most recent call last):
   File "", line 1, in 
TypeError: must be real number, not str

help(floor)

Help on built-in function floor in module math:

floor(...)
 floor(x)

 Return the floor of x as an Integral.
 This is the largest integer <= x.

   Is the output of »help(floor)« supposed to be a kind of
   normative documentation, i.e., /the/ authoritative
   documentation of »floor«?

   Is there any hint in the documentation about the type
   expected of arguments in a call?

   Is a parameter name »x« (as used above) described
   somewhere to express the requirement of a real number?

   It seems, »real« means »int or float«. Is this meaning
   of »real« documented somewhere?

   Thanks in advance!

As the module is called "math", it's not surprising that "floor" expects 
a number and rejects a string.


There's also a "cmath" module, which handles complex numbers.

"real" can be int, float or Decimal, but not complex.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Reading the documentation

2017-08-24 Thread Nathan Ernst
You passed a string to "math.floor", not anything resembling a numeric
type. Try using an actual float, int or Decimal:

Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from math import floor
>>> from decimal import Decimal
>>> floor("2.3")
Traceback (most recent call last):
  File "", line 1, in 
TypeError: a float is required

>>> floor(2.3)
2

>>> floor(Decimal("2.3"))
2

>>> floor(2)
2

Remember that Python is strongly typed; you do not get automatic type
conversions from strings to numeric types such as in Perl.

Regards,
Nathan

On Thu, Aug 24, 2017 at 2:24 PM, Stefan Ram  wrote:

>   This is a transcript:
>
> >>> from math import floor
> >>> floor( "2.3" )
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: must be real number, not str
> >>> help(floor)
> Help on built-in function floor in module math:
>
> floor(...)
> floor(x)
>
> Return the floor of x as an Integral.
> This is the largest integer <= x.
>
>   Is the output of »help(floor)« supposed to be a kind of
>   normative documentation, i.e., /the/ authoritative
>   documentation of »floor«?
>
>   Is there any hint in the documentation about the type
>   expected of arguments in a call?
>
>   Is a parameter name »x« (as used above) described
>   somewhere to express the requirement of a real number?
>
>   It seems, »real« means »int or float«. Is this meaning
>   of »real« documented somewhere?
>
>   Thanks in advance!
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list