Wednesday, November 20, 2013

comp.lang.python - 26 new messages in 7 topics - digest

comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en

comp.lang.python@googlegroups.com

Today's topics:

* Setting longer default decimal precision - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/2dbf71b35d41c26e?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
* Fwd: parsing RSS XML feed for item value - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/1bebac2a8a72b2e8?hl=en
* Newbie - Trying to Help a Friend - 14 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/e95a74d31bed4070?hl=en
* Automation - 4 messages, 2 authors
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
* Total Python Newbie needs geting started info. - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/38bef19b083508ea?hl=en

==============================================================================
TOPIC: Setting longer default decimal precision
http://groups.google.com/group/comp.lang.python/t/2dbf71b35d41c26e?hl=en
==============================================================================

== 1 of 1 ==
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: 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: Fwd: 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 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.




== 2 of 2 ==
Date: Wed, Nov 20 2013 8:17 am
From: xDog Walker


On Wednesday 2013 November 20 05:44, Larry Wilson wrote:
> {'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'}
Python 2.7.2 (default, Oct 10 2011, 10:47:36)
[GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 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'}
>>> for label, value in w_current.iteritems():
... print label, value
...
pressure 0.0
windspeed 22.2
temperature 20.3
dewpoint 18.6
windgusts 29.6
winddirection SSW
rain 0.6
humidity 90
>>>

--
Yonder nor sorghum stenches shut ladle gulls stopper torque wet
strainers.






==============================================================================
TOPIC: Newbie - Trying to Help a Friend
http://groups.google.com/group/comp.lang.python/t/e95a74d31bed4070?hl=en
==============================================================================

== 1 of 14 ==
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




== 2 of 14 ==
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




== 3 of 14 ==
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




== 4 of 14 ==
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




== 5 of 14 ==
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




== 6 of 14 ==
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.




== 7 of 14 ==
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




== 8 of 14 ==
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 14 ==
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




== 10 of 14 ==
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





== 11 of 14 ==
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




== 12 of 14 ==
Date: Wed, Nov 20 2013 7:36 am
From: Alister


On Wed, 20 Nov 2013 15:35:14 +0000, Alister wrote:

> 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

that seemed fine with multiple instances enabled (only 1 running though)
now trying with just hide in sys tray



--
Our similarities are different. -Dale Berra, son of Yogi




== 13 of 14 ==
Date: Wed, Nov 20 2013 7:34 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




== 14 of 14 ==
Date: Wed, Nov 20 2013 7:34 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: Automation
http://groups.google.com/group/comp.lang.python/t/2cb5aaffece4c4a9?hl=en
==============================================================================

== 1 of 4 ==
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




== 2 of 4 ==
Date: Wed, Nov 20 2013 7:44 am
From: Chris Angelico


On Wed, Nov 20, 2013 at 2:11 AM, Chris Angelico <rosuav@gmail.com> wrote:
> On Wed, Nov 20, 2013 at 2:06 AM, MRAB <python@mrabarnett.plus.com> wrote:
>> You need to distinguish between "Scottish English" and "Scots", the
>> latter being related to English, but isn't English, much as Danish is
>> related to Swedish, but isn't Swedish.
>
> Ah. When I referred to a "Scots" word, I was talking about the Gaelic
> language, which has a number of delightfully expressive terms just
> waiting to be borrowed!

By the way: I've since been corrected, and what I meant was not
actually the Scottish Gaelic language but the one that is actually
referred to as "Scots". My clarification was unhelpfully unclear, and
I apologize.

ChrisA




== 3 of 4 ==
Date: Wed, Nov 20 2013 8:12 am
From: Grant Edwards


On 2013-11-19, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Fri, Nov 15, 2013 at 1:45 PM, Alister <alister.ware@ntlworld.com> wrote:
>> and if you haven't seen it before :-
>>
>> Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in
>> waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht
>> the frist and lsat ltteer be at the rghit pclae. The rset can be a toatl
>> mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae the huamn
>> mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe.
>
> And the obligatory response:
>
> Iltnsegnetiry I'm sdutynig tihs crsrootaivnel pnoheenmon at the
> Dptmnearet of Liuniigctss at Absytrytewh Uivsreitny and my
> exartrnairdoy doisiervecs waleoetderhlhy cndairotct the picsbeliud
> fdnngiis rrgdinaeg the rtlvaeie dfuictlify of ialtnstny ttalrisanng
> sentences. My rsceeerhars deplveeod a cnionevent ctnoiaptorn at
> hnasoa/tw.nartswdbvweos/utrtek:p./il taht dosnatterems that the
> hhpsteyios uuiqelny wrtaarns criieltidby if the aoussmpitn that the
> prreoecandpne of your wrods is not eendetxd is uueniqtolnabse.
> Aoilegpos for aidnoptg a cdocianorttry vwpiienot but, ttoheliacrley
> spkeaing, lgitehnneng the words can mnartafucue an iocnuurgons
> samenttet that is vlrtiauly isbpilechmoenrne.

While I certainly couldn't read that at normal speed, there were only
a few words that I had to stop and actually puzzle over...

--
Grant Edwards grant.b.edwards Yow! ... My pants just went
at on a wild rampage through a
gmail.com Long Island Bowling Alley!!




== 4 of 4 ==
Date: Wed, Nov 20 2013 8:14 am
From: Grant Edwards


On 2013-11-19, Chris Angelico <rosuav@gmail.com> wrote:

> Anyway, we Aussies know more about your geography than you know about
> ours, I reckon. Which of these is not a real place: Parramatta,
> Warrnambool, Cerinabbin, Mordialloc? No fair Googling them, see if you
> can call it.

Next thing you'll be telling us that the Eels are a real rugby team.

--
Grant Edwards grant.b.edwards Yow! If I had a Q-TIP, I
at could prevent th' collapse
gmail.com of NEGOTIATIONS!!





==============================================================================
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>





==============================================================================
TOPIC: Total Python Newbie needs geting started info.
http://groups.google.com/group/comp.lang.python/t/38bef19b083508ea?hl=en
==============================================================================

== 1 of 2 ==
Date: Wed, Nov 20 2013 8:03 am
From: Ev J


I am learning Python and wish to develop GUI applications to run on Windows.
I have installed the Visual Studio integrated shell (Ver. 12.0.21005.1 REL) IDE and the Python 3.3 interpreter. I have gone through some of the 3.3 tutorial available at http://docs.python.org/3.3/tutorial/.

The tutorial is all about using the interactive interrupter and writing little console programs to learn the language.

Before I go too far down this road, I need to know if I can/should use this environment to develop GUI applications. Is there graphical support for this - for example I can I just insert/move/set properties of buttons, combo boxes, etc. using an interface like the one in VBA?

If not, what is the best free IDE for me to use?
What is the best tutorial for the IDE?

I am a bit overwhelmed as to how to get started.

Thanks for any help.






== 2 of 2 ==
Date: Wed, Nov 20 2013 8:14 am
From: Chris Angelico


On Thu, Nov 21, 2013 at 3:03 AM, Ev J <shorepointln@gmail.com> wrote:
> Before I go too far down this road, I need to know if I can/should use this environment to develop GUI applications. Is there graphical support for this - for example I can I just insert/move/set properties of buttons, combo boxes, etc. using an interface like the one in VBA?

Yes, you most certainly can. In the Microsoft world, you get a
language and its one GUI toolkit as a package deal; but in most of the
rest of the world, they're quite separate. Python can be used with
GTK, wx, TK, and a variety of other GUI toolkits; I happen to quite
like GTK, which I also use with Pike, a quite different language, and
can also be used with C and various other languages. So you can get to
know Python, and then later on choose one of several GUI toolkits, and
figure out how you want to lay out your window from there. The
tutorial sticks with the console because it's simple and easy to work
with; adding a GUI adds extra complexity, which can be left for later.

I don't know how much of "an interface like VBA" you'll get, but there
are graphical window builders. Personally, I don't use them; but if
you want them, they do exist.

ChrisA




==============================================================================

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


Real Estate