comp.lang.python - 26 new messages in 10 topics - digest
comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en
comp.lang.python@googlegroups.com
Today's topics:
* zip list, variables - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/81860c58ce83bf0a?hl=en
* Newbie - Trying to Help a Friend - 13 messages, 4 authors
http://groups.google.com/group/comp.lang.python/t/e95a74d31bed4070?hl=en
* If you continue being rude i will continue doing this - 2 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/51a1cfddd55b86bb?hl=en
* parsing RSS XML feed for item value - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/1bebac2a8a72b2e8?hl=en
* Setting longer default decimal precision - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/2dbf71b35d41c26e?hl=en
* How to install pip for python3 on OS X? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/73ad3df8a1a9d356?hl=en
* Suggest an open-source issue tracker, with github integration and kanban
boards? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/e316be1fe7a9af24?hl=en
* run command line on Windows without showing DOS console window - 2 messages,
2 authors
http://groups.google.com/group/comp.lang.python/t/5e7dd1371d043b3b?hl=en
* Automation - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/2cb5aaffece4c4a9?hl=en
* Using try-catch to handle multiple possible file types? - 1 messages, 1
author
http://groups.google.com/group/comp.lang.python/t/e060d0401829c029?hl=en
==============================================================================
TOPIC: zip list, variables
http://groups.google.com/group/comp.lang.python/t/81860c58ce83bf0a?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Nov 20 2013 2:45 am
From: Jussi Piitulainen
flebber <flebber.crue@gmail.com> writes:
> If
>
> c = map(sum, zip([1, 2, 3], [4, 5, 6]))
>
> c
> Out[7]: [5, 7, 9]
>
> why then can't I do this?
>
> a = ([1, 2], [3, 4])
>
> b = ([5, 6], [7, 8])
>
> c = map(sum, zip(a, b))
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
> <ipython-input-3-cc046c85514b> in <module>()
> ----> 1 c = map(sum, zip(a, b))
>
> TypeError: unsupported operand type(s) for +: 'int' and 'list'
The error message comes from sum(([1,2],[5,6])), where start defaults
to 0. A way to understand what is happening is to inspect zip(a,b),
notice that the first element of zip(a,b) is ([1,2],[5,6]), and then
find out what sum(([1,2],[5,6])) is. The extra parentheses may seem a
bit subtle, and at least in Python 3, zip and map return opaque
objects, so it does take a bit to get used to all the details,
The offending operands to '+' are 0 and [1,2].
> How can I do this legally?
I think the easiest is [ x + y for x, y in zip(a,b) ] if you want
concatenation, and something like the following if you want a nested
numerical addition:
>>> [ [ x + y for x, y in zip(x,y) ] for x, y in zip(a,b) ]
[[6, 8], [10, 12]]
There is probably a way to use map and sum for this, together with the
mechanisms that change arguments to lists or vice versa (the syntax
involves *), and partial application to specify a different start for
sum if you want concatenation, but I doubt you can avoid some sort of
nesting in the expression, and I doubt it will be clearer than the
above suggestions. But someone may well show a way. (Sorry if this
paragraph sounds like so much gibberish.)
==============================================================================
TOPIC: Newbie - Trying to Help a Friend
http://groups.google.com/group/comp.lang.python/t/e95a74d31bed4070?hl=en
==============================================================================
== 1 of 13 ==
Date: Wed, Nov 20 2013 3:38 am
From: Duncan Booth
Denis McMahon <denismfmcmahon@gmail.com> wrote:
> 1) Find all the numbers less than n that are not divisible by a, b, or c.
>
> ask the user for x;
> assign the value 0 to some other variable i;
> while i is not greater than than x do the following [
> if i is not divisible by a and i is not divisible by b and i is not
> divisible by c then display i to the user;
> add 1 to i;
> ]
>
The question didn't ask to find all the numbers, it asked to count how many
there are. Also even if you change this to count instead of print, it could
be very inefficient for large values of x.
If x is greater than a*b*c, find how many numbers up to a*b*c are not
divisible by a, b, or c. (Depending on your interpretation of the English
language for 2, 3, 5 this is either 8 or 1, you could check whether the
system is set to Australian English to determine the correct action here.)
You may then store these numbers in a list for easy reference.
Now the answer you want is the length of that list times the integer part
of x divided by a*b*c plus the number of values in the list that are less
than the remainder you get when dividing x by a*b*c.
If x is less than a*b*c then just find how many numbers up to x are not
divisible by a, b, or c, which would be a case of re-using some of the
above code.
For extra credit, calculate and use the least common multiple of a,b and c
instead of just using their product.
--
Duncan Booth
== 2 of 13 ==
Date: Wed, Nov 20 2013 5:57 am
From: Mark Lawrence
On 20/11/2013 09:29, Alister wrote:
> On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:
>
>> On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info>
>> wrote:
>>> 2 does count because it isn't divisible by 3. The question states,
>>> "[count] how many positive integers less than N are not divisible
>> by 2,3
>>> or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is
>> true,
>>> so two gets counted.
>>
>>> The first number which is divisible by *all* of 2, 3 and 5 (i.e.
>> fails
>>> the test, and therefore doesn't get counted) is 30. The next few
>> that
>>> fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
>>> Remember, these are the numbers which should not be counted.
>>
>>>> I count 1, not 6
>>
>>> Out of curiosity, which number did you count?
>>
>> 1 of course. It's the only one that's not divisible by any of the
>> factors.
>>
>> Apparently we disagree about precedence and associativity in English.
>> I believe the not applies to the result of (divisible by 2, 3, or 5),
>> so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be 49.
>>
>> If I were trying to get the series you describe, I'd phrase it as
>> "Not divisible by 2, and not divisible by 3, and not divisible by 5"
>
> This ambiguity is a great example of why teachers (and enayone else
> responsible for specifying a programming project) should take greater
> care when specifying tasks.
> if it is to late to ask for clarification (the correct step in a real
> world case) I suggest you write 2 programs 1 for each interpretation, it
> will be good for your personal learning even if the teacher does not give
> any extra credit.
>
Ambiguity is the reason that some of the most expensive language lessons
in the world are at places like Sandhurst and West Point. Giving
crystal clear orders, whether verbally or in writing, is considered
quite important in the military.
By the way, this is double posted and there were four identical messages
from you yesterday, finger trouble or what? :)
--
Python is the second best programming language in the world.
But the best has yet to be invented. Christian Tismer
Mark Lawrence
== 3 of 13 ==
Date: Wed, Nov 20 2013 6:51 am
From: Alister
On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote:
> On 20/11/2013 09:29, Alister wrote:
>> On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:
>>
>>> On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info>
>>> wrote:
>>>> 2 does count because it isn't divisible by 3. The question states,
>>>> "[count] how many positive integers less than N are not divisible
>>> by 2,3
>>>> or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is
>>> true,
>>>> so two gets counted.
>>>
>>>> The first number which is divisible by *all* of 2, 3 and 5 (i.e.
>>> fails
>>>> the test, and therefore doesn't get counted) is 30. The next few
>>> that
>>>> fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
>>>> Remember, these are the numbers which should not be counted.
>>>
>>>>> I count 1, not 6
>>>
>>>> Out of curiosity, which number did you count?
>>>
>>> 1 of course. It's the only one that's not divisible by any of the
>>> factors.
>>>
>>> Apparently we disagree about precedence and associativity in English.
>>> I believe the not applies to the result of (divisible by 2, 3, or 5),
>>> so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be 49.
>>>
>>> If I were trying to get the series you describe, I'd phrase it as
>>> "Not divisible by 2, and not divisible by 3, and not divisible by
>>> 5"
>>
>> This ambiguity is a great example of why teachers (and enayone else
>> responsible for specifying a programming project) should take greater
>> care when specifying tasks.
>> if it is to late to ask for clarification (the correct step in a real
>> world case) I suggest you write 2 programs 1 for each interpretation,
>> it will be good for your personal learning even if the teacher does not
>> give any extra credit.
>>
>>
> Ambiguity is the reason that some of the most expensive language lessons
> in the world are at places like Sandhurst and West Point. Giving
> crystal clear orders, whether verbally or in writing, is considered
> quite important in the military.
>
> By the way, this is double posted and there were four identical messages
> from you yesterday, finger trouble or what? :)
I don't think the problem is at my end. I am only sending once to the
best of my knowledge
(using Pan newsreader to Comp.lang.python)
--
Thou shalt not put policy into the kernel.
- Al Viro on linux-kernel
== 4 of 13 ==
Date: Wed, Nov 20 2013 6:49 am
From: Alister
On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote:
> On 20/11/2013 09:29, Alister wrote:
>> On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:
>>
>>> On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info>
>>> wrote:
>>>> 2 does count because it isn't divisible by 3. The question states,
>>>> "[count] how many positive integers less than N are not divisible
>>> by 2,3
>>>> or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is
>>> true,
>>>> so two gets counted.
>>>
>>>> The first number which is divisible by *all* of 2, 3 and 5 (i.e.
>>> fails
>>>> the test, and therefore doesn't get counted) is 30. The next few
>>> that
>>>> fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
>>>> Remember, these are the numbers which should not be counted.
>>>
>>>>> I count 1, not 6
>>>
>>>> Out of curiosity, which number did you count?
>>>
>>> 1 of course. It's the only one that's not divisible by any of the
>>> factors.
>>>
>>> Apparently we disagree about precedence and associativity in English.
>>> I believe the not applies to the result of (divisible by 2, 3, or 5),
>>> so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be 49.
>>>
>>> If I were trying to get the series you describe, I'd phrase it as
>>> "Not divisible by 2, and not divisible by 3, and not divisible by
>>> 5"
>>
>> This ambiguity is a great example of why teachers (and enayone else
>> responsible for specifying a programming project) should take greater
>> care when specifying tasks.
>> if it is to late to ask for clarification (the correct step in a real
>> world case) I suggest you write 2 programs 1 for each interpretation,
>> it will be good for your personal learning even if the teacher does not
>> give any extra credit.
>>
>>
> Ambiguity is the reason that some of the most expensive language lessons
> in the world are at places like Sandhurst and West Point. Giving
> crystal clear orders, whether verbally or in writing, is considered
> quite important in the military.
>
> By the way, this is double posted and there were four identical messages
> from you yesterday, finger trouble or what? :)
I don't think the problem is at my end. I am only sending once to the
best of my knowledge
(using Pan newsreader to Comp.lang.python)
--
Thou shalt not put policy into the kernel.
- Al Viro on linux-kernel
== 5 of 13 ==
Date: Wed, Nov 20 2013 6:50 am
From: Alister
On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote:
> On 20/11/2013 09:29, Alister wrote:
>> On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:
>>
>>> On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info>
>>> wrote:
>>>> 2 does count because it isn't divisible by 3. The question states,
>>>> "[count] how many positive integers less than N are not divisible
>>> by 2,3
>>>> or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is
>>> true,
>>>> so two gets counted.
>>>
>>>> The first number which is divisible by *all* of 2, 3 and 5 (i.e.
>>> fails
>>>> the test, and therefore doesn't get counted) is 30. The next few
>>> that
>>>> fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
>>>> Remember, these are the numbers which should not be counted.
>>>
>>>>> I count 1, not 6
>>>
>>>> Out of curiosity, which number did you count?
>>>
>>> 1 of course. It's the only one that's not divisible by any of the
>>> factors.
>>>
>>> Apparently we disagree about precedence and associativity in English.
>>> I believe the not applies to the result of (divisible by 2, 3, or 5),
>>> so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be 49.
>>>
>>> If I were trying to get the series you describe, I'd phrase it as
>>> "Not divisible by 2, and not divisible by 3, and not divisible by
>>> 5"
>>
>> This ambiguity is a great example of why teachers (and enayone else
>> responsible for specifying a programming project) should take greater
>> care when specifying tasks.
>> if it is to late to ask for clarification (the correct step in a real
>> world case) I suggest you write 2 programs 1 for each interpretation,
>> it will be good for your personal learning even if the teacher does not
>> give any extra credit.
>>
>>
> Ambiguity is the reason that some of the most expensive language lessons
> in the world are at places like Sandhurst and West Point. Giving
> crystal clear orders, whether verbally or in writing, is considered
> quite important in the military.
>
> By the way, this is double posted and there were four identical messages
> from you yesterday, finger trouble or what? :)
I don't think the problem is at my end. I am only sending once to the
best of my knowledge
(using Pan newsreader to Comp.lang.python)
--
Thou shalt not put policy into the kernel.
- Al Viro on linux-kernel
== 6 of 13 ==
Date: Wed, Nov 20 2013 6:50 am
From: Alister
On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote:
> On 20/11/2013 09:29, Alister wrote:
>> On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:
>>
>>> On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info>
>>> wrote:
>>>> 2 does count because it isn't divisible by 3. The question states,
>>>> "[count] how many positive integers less than N are not divisible
>>> by 2,3
>>>> or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is
>>> true,
>>>> so two gets counted.
>>>
>>>> The first number which is divisible by *all* of 2, 3 and 5 (i.e.
>>> fails
>>>> the test, and therefore doesn't get counted) is 30. The next few
>>> that
>>>> fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
>>>> Remember, these are the numbers which should not be counted.
>>>
>>>>> I count 1, not 6
>>>
>>>> Out of curiosity, which number did you count?
>>>
>>> 1 of course. It's the only one that's not divisible by any of the
>>> factors.
>>>
>>> Apparently we disagree about precedence and associativity in English.
>>> I believe the not applies to the result of (divisible by 2, 3, or 5),
>>> so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be 49.
>>>
>>> If I were trying to get the series you describe, I'd phrase it as
>>> "Not divisible by 2, and not divisible by 3, and not divisible by
>>> 5"
>>
>> This ambiguity is a great example of why teachers (and enayone else
>> responsible for specifying a programming project) should take greater
>> care when specifying tasks.
>> if it is to late to ask for clarification (the correct step in a real
>> world case) I suggest you write 2 programs 1 for each interpretation,
>> it will be good for your personal learning even if the teacher does not
>> give any extra credit.
>>
>>
> Ambiguity is the reason that some of the most expensive language lessons
> in the world are at places like Sandhurst and West Point. Giving
> crystal clear orders, whether verbally or in writing, is considered
> quite important in the military.
>
> By the way, this is double posted and there were four identical messages
> from you yesterday, finger trouble or what? :)
I don't think the problem is at my end. I am only sending once to the
best of my knowledge
(using Pan newsreader to Comp.lang.python)
--
Thou shalt not put policy into the kernel.
- Al Viro on linux-kernel
== 7 of 13 ==
Date: Wed, Nov 20 2013 7:05 am
From: Chris Angelico
On Thu, Nov 21, 2013 at 1:49 AM, Alister <alister.ware@ntlworld.com> wrote:
> On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote:
>
>> On 20/11/2013 09:29, Alister wrote:
>>> On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:
>> By the way, this is double posted and there were four identical messages
>> from you yesterday, finger trouble or what? :)
>
> I don't think the problem is at my end. I am only sending once to the
> best of my knowledge
> (using Pan newsreader to Comp.lang.python)
Exactly four again.
https://mail.python.org/pipermail/python-list/2013-November/660769.html
https://mail.python.org/pipermail/python-list/2013-November/660770.html
https://mail.python.org/pipermail/python-list/2013-November/660771.html
https://mail.python.org/pipermail/python-list/2013-November/660772.html
Might be a problem with the mail<->news gateway, or might be that
something's sending through by multiple routes for redundancy. The
timestamps differ, not sure if that helps track it down.
ChrisA
== 8 of 13 ==
Date: Wed, Nov 20 2013 7:06 am
From: Alister
On Wed, 20 Nov 2013 14:49:59 +0000, Alister wrote:
> On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote:
>
>> On 20/11/2013 09:29, Alister wrote:
>>> On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:
>>>
>>>> On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info>
>>>> wrote:
>>>>> 2 does count because it isn't divisible by 3. The question states,
>>>>> "[count] how many positive integers less than N are not divisible
>>>> by 2,3
>>>>> or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is
>>>> true,
>>>>> so two gets counted.
>>>>
>>>>> The first number which is divisible by *all* of 2, 3 and 5 (i.e.
>>>> fails
>>>>> the test, and therefore doesn't get counted) is 30. The next few
>>>> that
>>>>> fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
>>>>> Remember, these are the numbers which should not be counted.
>>>>
>>>>>> I count 1, not 6
>>>>
>>>>> Out of curiosity, which number did you count?
>>>>
>>>> 1 of course. It's the only one that's not divisible by any of the
>>>> factors.
>>>>
>>>> Apparently we disagree about precedence and associativity in English.
>>>> I believe the not applies to the result of (divisible by 2, 3, or 5),
>>>> so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be
>>>> 49.
>>>>
>>>> If I were trying to get the series you describe, I'd phrase it as
>>>> "Not divisible by 2, and not divisible by 3, and not divisible by
>>>> 5"
>>>
>>> This ambiguity is a great example of why teachers (and enayone else
>>> responsible for specifying a programming project) should take greater
>>> care when specifying tasks.
>>> if it is to late to ask for clarification (the correct step in a real
>>> world case) I suggest you write 2 programs 1 for each interpretation,
>>> it will be good for your personal learning even if the teacher does
>>> not give any extra credit.
>>>
>>>
>> Ambiguity is the reason that some of the most expensive language
>> lessons in the world are at places like Sandhurst and West Point.
>> Giving crystal clear orders, whether verbally or in writing, is
>> considered quite important in the military.
>>
>> By the way, this is double posted and there were four identical
>> messages from you yesterday, finger trouble or what? :)
>
> I don't think the problem is at my end. I am only sending once to the
> best of my knowledge (using Pan newsreader to Comp.lang.python)
Ok this is now silly
Apologies to everyone I am monitoring my network connection to confirm
that i am not sending multiple times.
--
T-1's congested due to porn traffic to the news server.
== 9 of 13 ==
Date: Wed, Nov 20 2013 7:09 am
From: Alister
On Wed, 20 Nov 2013 15:06:44 +0000, Alister wrote:
> On Wed, 20 Nov 2013 14:49:59 +0000, Alister wrote:
>
>> On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote:
>>
>>> On 20/11/2013 09:29, Alister wrote:
>>>> On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:
>>>>
>>>>> On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info>
>>>>> wrote:
>>>>>> 2 does count because it isn't divisible by 3. The question states,
>>>>>> "[count] how many positive integers less than N are not divisible
>>>>> by 2,3
>>>>>> or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is
>>>>> true,
>>>>>> so two gets counted.
>>>>>
>>>>>> The first number which is divisible by *all* of 2, 3 and 5 (i.e.
>>>>> fails
>>>>>> the test, and therefore doesn't get counted) is 30. The next few
>>>>> that
>>>>>> fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
>>>>>> Remember, these are the numbers which should not be counted.
>>>>>
>>>>>>> I count 1, not 6
>>>>>
>>>>>> Out of curiosity, which number did you count?
>>>>>
>>>>> 1 of course. It's the only one that's not divisible by any of the
>>>>> factors.
>>>>>
>>>>> Apparently we disagree about precedence and associativity in
>>>>> English.
>>>>> I believe the not applies to the result of (divisible by 2, 3, or
>>>>> 5),
>>>>> so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be
>>>>> 49.
>>>>>
>>>>> If I were trying to get the series you describe, I'd phrase it as
>>>>> "Not divisible by 2, and not divisible by 3, and not divisible by
>>>>> 5"
>>>>
>>>> This ambiguity is a great example of why teachers (and enayone else
>>>> responsible for specifying a programming project) should take greater
>>>> care when specifying tasks.
>>>> if it is to late to ask for clarification (the correct step in a real
>>>> world case) I suggest you write 2 programs 1 for each interpretation,
>>>> it will be good for your personal learning even if the teacher does
>>>> not give any extra credit.
>>>>
>>>>
>>> Ambiguity is the reason that some of the most expensive language
>>> lessons in the world are at places like Sandhurst and West Point.
>>> Giving crystal clear orders, whether verbally or in writing, is
>>> considered quite important in the military.
>>>
>>> By the way, this is double posted and there were four identical
>>> messages from you yesterday, finger trouble or what? :)
>>
>> I don't think the problem is at my end. I am only sending once to the
>> best of my knowledge (using Pan newsreader to Comp.lang.python)
>
> Ok this is now silly Apologies to everyone I am monitoring my network
> connection to confirm that i am not sending multiple times.
that last one seemed good
must be a strange quirk of pan & turned off hide to system tray & allow
multiple instances.
not sure why either of them should cause the problem, I only have 1 copie
running
--
Next to being shot at and missed, nothing is really quite as satisfying
as an income tax refund.
-- F. J. Raymond
== 10 of 13 ==
Date: Wed, Nov 20 2013 7:06 am
From: Alister
On Wed, 20 Nov 2013 14:49:59 +0000, Alister wrote:
> On Wed, 20 Nov 2013 13:57:30 +0000, Mark Lawrence wrote:
>
>> On 20/11/2013 09:29, Alister wrote:
>>> On Wed, 20 Nov 2013 00:54:28 -0500, Dave Angel wrote:
>>>
>>>> On 20 Nov 2013 03:52:10 GMT, Steven D'Aprano <steve@pearwood.info>
>>>> wrote:
>>>>> 2 does count because it isn't divisible by 3. The question states,
>>>>> "[count] how many positive integers less than N are not divisible
>>>> by 2,3
>>>>> or 5". Two is not divisible by 3, so "not divisible by 2,3 or 5" is
>>>> true,
>>>>> so two gets counted.
>>>>
>>>>> The first number which is divisible by *all* of 2, 3 and 5 (i.e.
>>>> fails
>>>>> the test, and therefore doesn't get counted) is 30. The next few
>>>> that
>>>>> fail the test are 60, 90, 120, 150, 180, 210, 240, 270, 300, ...
>>>>> Remember, these are the numbers which should not be counted.
>>>>
>>>>>> I count 1, not 6
>>>>
>>>>> Out of curiosity, which number did you count?
>>>>
>>>> 1 of course. It's the only one that's not divisible by any of the
>>>> factors.
>>>>
>>>> Apparently we disagree about precedence and associativity in English.
>>>> I believe the not applies to the result of (divisible by 2, 3, or 5),
>>>> so I'd count 1, 7, 11, 13, 17, 19, 23. The first nonprime would be
>>>> 49.
>>>>
>>>> If I were trying to get the series you describe, I'd phrase it as
>>>> "Not divisible by 2, and not divisible by 3, and not divisible by
>>>> 5"
>>>
>>> This ambiguity is a great example of why teachers (and enayone else
>>> responsible for specifying a programming project) should take greater
>>> care when specifying tasks.
>>> if it is to late to ask for clarification (the correct step in a real
>>> world case) I suggest you write 2 programs 1 for each interpretation,
>>> it will be good for your personal learning even if the teacher does
>>> not give any extra credit.
>>>
>>>
>> Ambiguity is the reason that some of the most expensive language
>> lessons in the world are at places like Sandhurst and West Point.
>> Giving crystal clear orders, whether verbally or in writing, is
>> considered quite important in the military.
>>
>> By the way, this is double posted and there were four identical
>> messages from you yesterday, finger trouble or what? :)
>
> I don't think the problem is at my end. I am only sending once to the
> best of my knowledge (using Pan newsreader to Comp.lang.python)
Ok this is now silly
Apologies to everyone I am monitoring my network connection to confirm
that i am not sending multiple times.
--
T-1's congested due to porn traffic to the news server.
== 11 of 13 ==
Date: Wed, Nov 20 2013 7:14 am
From: Chris Angelico
On Thu, Nov 21, 2013 at 2:09 AM, Alister <alister.ware@ntlworld.com> wrote:
> must be a strange quirk of pan & turned off hide to system tray & allow
> multiple instances.
Hmm. Hard to know, but I can imagine that having multiple instances
MIGHT cause a problem. But if that's confirmed (maybe fire up three
copies and then post to a test newsgroup??), I'd be reporting that as
a bug in Pan.
ChrisA
== 12 of 13 ==
Date: Wed, Nov 20 2013 7:24 am
From: Mark Lawrence
On 20/11/2013 15:06, Alister wrote:
>
> Ok this is now silly
> Apologies to everyone I am monitoring my network connection to confirm
> that i am not sending multiple times.
>
Still arriving multiple times, shoot the messenger? :)
--
Python is the second best programming language in the world.
But the best has yet to be invented. Christian Tismer
Mark Lawrence
== 13 of 13 ==
Date: Wed, Nov 20 2013 7:35 am
From: Alister
On Thu, 21 Nov 2013 02:14:12 +1100, Chris Angelico wrote:
> On Thu, Nov 21, 2013 at 2:09 AM, Alister <alister.ware@ntlworld.com>
> wrote:
>> must be a strange quirk of pan & turned off hide to system tray & allow
>> multiple instances.
>
> Hmm. Hard to know, but I can imagine that having multiple instances
> MIGHT cause a problem. But if that's confirmed (maybe fire up three
> copies and then post to a test newsgroup??), I'd be reporting that as a
> bug in Pan.
>
> ChrisA
As a quick test lets see how may times this one arrives
--
You can fool all the people all of the time if the advertising is right
and the budget is big enough.
-- Joseph E. Levine
==============================================================================
TOPIC: If you continue being rude i will continue doing this
http://groups.google.com/group/comp.lang.python/t/51a1cfddd55b86bb?hl=en
==============================================================================
== 1 of 2 ==
Date: Wed, Nov 20 2013 3:55 am
From: Ferrous Cranus
Thank you rurpy.
== 2 of 2 ==
Date: Wed, Nov 20 2013 3:57 am
From: Ferrous Cranus
Τη Δευτέρα, 18 Νοεμβρίου 2013 4:24:53 μ.μ. UTC+2, ο χρήστης Piet van Oostrum έγραψε:
> Ferrous Cranus <nikos.gr33k@gmail.com> writes:
>
>
>
> > No i haven't broke it at all.
>
> > Everything work as they should.
>
> >
>
> > The refusal of 'pygeoip' to install turned out to be the local setting in my new VPS.
>
> >
>
> > So i have changes it to:
>
> >
>
> > export LANG = en_US.UTF-8
>
> >
>
> > and then 'pip install pygeoip' was successful.
>
> >
>
> > Trying to figure out how to install-setup EPEL repository along with
>
> > python3 && python3-pip and 2 extra modules my script needed in my new
>
> > VPS have costed 4-5 of my life and of my mental health, while if you
>
> > just helped a bit these would have been done in a couple of hours.
>
>
>
> How could anyone have known that this was the problem? AFIAK you didn't even tell about the VPS. And moreover this wasn't a Python problem, so off topic here.
>
> --
>
> Piet van Oostrum <piet@vanoostrum.org>
>
> WWW: http://pietvanoostrum.com/
>
> PGP key: [8DAE142BE17999C4]
I had specified that i was using CentOS 6.4 and described the problem i had with installing python and pip and 2 modules.
I received no help at all.
==============================================================================
TOPIC: parsing RSS XML feed for item value
http://groups.google.com/group/comp.lang.python/t/1bebac2a8a72b2e8?hl=en
==============================================================================
== 1 of 2 ==
Date: Wed, Nov 20 2013 5:44 am
From: Larry Wilson
>>> feed.entries[0].w_current
{'temperature': u'20.3', 'dewpoint': u'18.6', 'windgusts': u'29.6', 'rain': u'0.6', 'humidity': u'90', 'pressure': u'0.0', 'windspeed': u'22.2', 'winddirection': u'SSW'}
>>>
in the above I get the subitem as shown. How do I extract the label, values pairs?
== 2 of 2 ==
Date: Wed, Nov 20 2013 6:48 am
From: Neil Cerutti
Larry Wilson itdlw1@gmail.com via python.org
10:39 PM (10 hours ago) wrote:
>
> Wanting to parse out the the temperature value in the
> "<w:current" element, just after the guid element using
> ElementTree or xml.sax.
Since you aren't building up a complex data structure, xml.sax
will be an OK choice.
Here's a quick and dirty job:
import io
import xml.sax as sax
the_xml = io.StringIO("""SNIPPED XML""")
class WeatherHandler(sax.handler.ContentHandler):
def startDocument(self):
self.temperatures = []
def startElement(self, name, attrs):
if name == 'w:current': # Nice namespace handling, eh?
self.temperatures.append(attrs)
handler = WeatherHandler()
sax.parse(the_xml, handler)
for temp in handler.temperatures:
for key, val in temp.items():
print("{}: {}".format(key, val))
Output (from your example):
windGusts: 29.6
dewPoint: 18.6
pressure: 0.0
windDirection: SSW
humidity: 90
rain: 0.6
temperature: 20.3
windSpeed: 22.2
For most jobs you would want to keep track of your nesting level, but
that's left out here. I didn't try to capture location or info you
might want but didn't specify, either; left that as an exercise.
==============================================================================
TOPIC: Setting longer default decimal precision
http://groups.google.com/group/comp.lang.python/t/2dbf71b35d41c26e?hl=en
==============================================================================
== 1 of 2 ==
Date: Wed, Nov 20 2013 6:02 am
From: Steven D'Aprano
Hi Kay,
You emailed me off-list, but your email address is bouncing or invalid,
so I have no way to email you back.
Unless you have something private or personal to say, you should keep
replies on the list here so that others can either answer your questions
or learn from the responses. If you do have something private to say, you
should use a real email address that accepts replies :-)
I'm taking the liberty of republishing your comments to me here:
[you wrote]
Okay,but after I import "math" and "decimal",
py> decimal.getcontext().prec=75
py> print decimal.Decimal(math.atan(1))
0.78539816339744827899949086713604629039764404296875
though I set precision to 75, it only did the trig function to 50
places AND it is only right to 16 places,
0.785398163397448309615660845819875721049292349843776...(actual).
[end quote]
Here, you calculate the atan of 1 using floating point maths, that is, to
the precision of C doubles (about 17 decimal places). After the
calculation is performed using float, you then convert it to a Decimal,
but it is too late, you can't retroactively regain precision.
In a perfect world, this would work:
math.atan(Decimal(1))
but alas, all the functions in the math module convert their arguments to
float first, so even though your Decimal(1) could perform calculations to
75 decimal places, the math.atan function downgrades it to a regular
float.
Unfortunately, Decimals don't support high-precision trig functions. If
you study the decimal.py module, you could possibly work out how to add
support for trig functions, but they have no current support for them.
You could try this third-party module:
http://code.google.com/p/mpmath/
which claims to be arbitrary-precision maths for Python, but I've never
used it.
--
Steven
== 2 of 2 ==
Date: Wed, Nov 20 2013 6:40 am
From: Oscar Benjamin
On 20 November 2013 14:02, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
>
> but alas, all the functions in the math module convert their arguments to
> float first, so even though your Decimal(1) could perform calculations to
> 75 decimal places, the math.atan function downgrades it to a regular
> float.
>
> Unfortunately, Decimals don't support high-precision trig functions. If
> you study the decimal.py module, you could possibly work out how to add
> support for trig functions, but they have no current support for them.
The documentation has examples for how to make high precision sin()
and cos() functions that work with Decimals.
http://docs.python.org/2/library/decimal.html#recipes
The basic idea is to sum terms of the Maclaurin series until it
converges. For atan(x) the Maclaurin series is
atan(x) = x - (1/3)x**3 + (1/5)x**5 - (1/7)x**7 + (1/9)x**9 + ...
The nth term is given by f(n) = ((-1)**n)*(1/(2n+1))*x**(2n+1).
The ratio test gives that that |f(n+1)/f(n)| = (2(n+1)+1)/(2n + 1) *
x**2 which has a limiting value of x**2 so the series converges for
|x| < 1 (unlike sin() and cos() that converge for all x). For values
outside this range you can use the identity arctan(1/x) ==
sign(x)*pi/2 - arctan(x) to map the values back into the convergent
range. This may still be problematic when x is close to 1 in which
case an alternate Taylor series around x=1 could be used. You'd need
to ensure that you were using enough digits for pi as well if you
wanted to make this work.
It's probably easiest just to use the mpmath library as Steven
suggested (or gmpy2, or sympy which includes mpmath).
Oscar
==============================================================================
TOPIC: How to install pip for python3 on OS X?
http://groups.google.com/group/comp.lang.python/t/73ad3df8a1a9d356?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Nov 20 2013 6:01 am
From: Mark Lawrence
On 20/11/2013 06:55, Travis Griggs wrote:
> OSX (Mavericks) has python2.7 stock installed. But I do all my own
> personal python stuff with 3.3. I just flushed my 3.3.2 install and
> installed the new 3.3.3. So I need to install pyserial again.
Just idle curiosity but why do you have to do this? On Windows I just
whack 3.3.3 over the top of 3.3.2, job done.
--
Python is the second best programming language in the world.
But the best has yet to be invented. Christian Tismer
Mark Lawrence
==============================================================================
TOPIC: Suggest an open-source issue tracker, with github integration and
kanban boards?
http://groups.google.com/group/comp.lang.python/t/e316be1fe7a9af24?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Nov 20 2013 6:36 am
From: Alec Taylor
I actually did end up finding one; but now need bitbucket integration also.
Anyway, here is the link: https://github.com/rauhryan/huboard
On Mon, Nov 18, 2013 at 5:47 AM, Kevin Walzer <kw@codebykevin.com> wrote:
> On 11/13/13, 7:46 AM, Alec Taylor wrote:
>>
>> Started to build this on my own; then was like, hang on! - This is
>> probably something very commonly requested…
>>
>> Can you recommend an open source project (or two) written in Python;
>> which covers multi project + sub project issue tracking linked across
>> github repositories?
>>
>> [on the github side, want to be able to reference "commit <hash>
>> solved by patch from issue #"; fine to have that extra annotation only
>> present on my server]
>>
>> Also would be perfect if it has kanban board support, issue
>> prioritisation and distribution/assignment amongst team members; as
>> well as related analytics.
>>
>> Thanks for all suggestions! =)
>
>
>
> Not written in Python, but Fossil (http://www.fossil-scm.org/) offers an
> all-in-one, lightweight DCVS/issue-tracking/wiki/blog package. Written the
> author of SQLite.
>
> --Kevin
>
> --
> Kevin Walzer
> Code by Kevin/Mobile Code by Kevin
> http://www.codebykevin.com
> http://www.wtmobilesoftware.com
> --
> https://mail.python.org/mailman/listinfo/python-list
==============================================================================
TOPIC: run command line on Windows without showing DOS console window
http://groups.google.com/group/comp.lang.python/t/5e7dd1371d043b3b?hl=en
==============================================================================
== 1 of 2 ==
Date: Wed, Nov 20 2013 6:44 am
From: iMath
is there anyway to run command line on Windows without showing DOS console window ?
can you use the following command line to give a little example ?
wget -r -np -nd http://example.com/packages/
the path to wget is C:\Program Files\GnuWin32\bin\wget.exe
== 2 of 2 ==
Date: Wed, Nov 20 2013 6:49 am
From: Tim Golden
On 20/11/2013 14:44, iMath wrote:
>
>
> is there anyway to run command line on Windows without showing DOS console window ?
>
> can you use the following command line to give a little example ?
>
> wget -r -np -nd http://example.com/packages/
>
> the path to wget is C:\Program Files\GnuWin32\bin\wget.exe
>
subprocess.call(["wget", "-r", "-np", "-nd", "http://example.com"])
TJG
==============================================================================
TOPIC: Automation
http://groups.google.com/group/comp.lang.python/t/2cb5aaffece4c4a9?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Nov 20 2013 6:52 am
From: Chris Angelico
Here's a response from a full-blooded Scot on the subject.
On Wed, Nov 20, 2013 at 8:29 PM, Derrick McCLURE <j.d.mcclure@virgin.net> wrote:
> No, Chris, you haven't been led astray. The language is referred to as
> Scots, not Scottish. There is an academic journal called Scottish Language,
> which I edited for many years, but the meaning of that is "language in
> Scotland" - it publishes articles on Scots, Gaelic, and English as used in
> Scotland.
So there you are. Your piece of random linguistics trivia for the day. :)
Enjoy!
ChrisA
==============================================================================
TOPIC: Using try-catch to handle multiple possible file types?
http://groups.google.com/group/comp.lang.python/t/e060d0401829c029?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Nov 20 2013 7:05 am
From: Neil Cerutti
Steven D'Aprano steve+comp.lang.python@pearwood.info via python.org
8:56 PM (12 hours ago) wrote:
> Write a helper function:
>
> def process(opener):
> with opener('blah.txt', 'rb') as f:
> for line in f:
> print(line)
As another option, you can enter the context manager after you decide.
try:
f = gzip.open('blah.txt', 'rb')
except IOError:
f = open('blah.txt', 'rb')
with f:
# processing
for line in f:
print(line)
contextlib.ExitStack was designed to handle cases where entering
context is optional, and so also works for this use case.
with contextlib.ExitStack() as stack:
try:
f = gzip.open('blah.txt', 'rb')
except IOError:
f = open('blah.txt', 'rb')
stack.enter_context(f)
for line in f:
print(line)
--
Neil Cerutti
On Tue, Nov 19, 2013 at 8:56 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Tue, 19 Nov 2013 16:30:46 -0800, Victor Hooi wrote:
>
>> Hi,
>>
>> Is either approach (try-excepts, or using libmagic) considered more
>> idiomatic? What would you guys prefer yourselves?
>
> Specifically in the case of file types, I consider it better to use
> libmagic. But as a general technique, using try...except is a reasonable
> approach in many situations.
>
>
>> Also, is it possible to use either approach with a context manager
>> ("with"), without duplicating lots of code?
>>
>> For example:
>>
>> try:
>> with gzip.open('blah.txt', 'rb') as f:
>> for line in f:
>> print(line)
>> except IOError as e:
>> with open('blah.txt', 'rb') as f:
>> for line in f:
>> print(line)
>>
>> I'm not sure of how to do this without needing to duplicating the
>> processing lines (everything inside the with)?
>
> Write a helper function:
>
> def process(opener):
> with opener('blah.txt', 'rb') as f:
> for line in f:
> print(line)
>
>
> try:
> process(gzip.open)
> except IOError:
> process(open)
>
>
> If you have many different things to try:
>
>
> for opener in [gzip.open, open, ...]:
> try:
> process(opener)
> except IOError:
> continue
> else:
> break
>
>
>
> [...]
>> Also, on another note, python-magic will return a string as a result,
>> e.g.:
>>
>> gzip compressed data, was "blah.txt", from Unix, last modified: Wed Nov
>> 20 10:48:35 2013
>>
>> I suppose it's enough to just do a?
>>
>> if "gzip compressed data" in results:
>>
>> or is there a better way?
>
> *shrug*
>
> Read the docs of python-magic. Do they offer a programmable API? If not,
> that kinda sucks.
>
>
>
> --
> Steven
> --
> https://mail.python.org/mailman/listinfo/python-list
--
Neil Cerutti <mr.cerutti+python@gmail.com>
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.python"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.python?hl=en
To unsubscribe from this group, send email to comp.lang.python+unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.python/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home