Re: Numeric root-finding in Python

2012-02-20 Thread David Monaghan
On Sun, 12 Feb 2012 10:20:17 -0500, inq1ltd inq1...@inqvista.com wrote:



I don't know the first thing about this math problem however,

if I were to code this I might try ;

   except ZeroDivisionError:
 assert w = -1

rather than;

   except ZeroDivisionError:
 assert w == -1

Why?

DM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MOST COMMON QUESTIONS ASKED BY NON-MUSLIMS ?????????

2012-01-07 Thread David Monaghan
On Tue, 3 Jan 2012 09:57:50 -0800 (PST), John Ladasky lada...@my-deja.com
wrote:

On Jan 3, 7:40 am, BV bv5bv5...@yahoo.com wrote:
 MOST COMMON QUESTIONS ASKED BY NON-MUSLIMS

Q0. Why do thousand-line religious posts appear in comp.lang.python?

You know, I would never have seen this post if you hadn't authenticated it
by starting a thread around it.

DaveM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spamming PyPI with stupid packages

2012-01-02 Thread David Monaghan
On Mon, 2 Jan 2012 02:52:06 -0500, Devin Jeanpierre jeanpierr...@gmail.com
wrote:

 Perhaps I'm just slow, but what is sexist about this package? Do you even
 know what the package does?

The dependencies are car, house, and money (and workhard, of
course). The joke being that women only care about how wealthy you
are.

That's not a joke, it's a stereotype - and a stereotype with a biological
truth in it.

DaveM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need A script to open a excel file and extract the data using autofilter

2011-10-04 Thread David Monaghan
On Tue, 04 Oct 2011 19:42:06 +0100, Chris Withers ch...@simplistix.co.uk
wrote:

On 01/10/2011 23:00, David Monaghan wrote:
 after opening the text.xls file i need to filter all the rows in which
 the status column is passed and copy the whole sheet to another sheet

 I don't do this often enough to have it to mind, so what I normally do is
 record a Macro, convert it to VBS and then convert that to Python.

Ouch! Slow, error prone and Windows only ;-)

Please consider using xlrd and described on http://www.python-excel.org

All true! The reason I usually do it like that is I normally only need to do
very simple things and I usually stop at the VBS stage. And I wasn't aware
of xlrd - I'll give it a look.

DaveM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need A script to open a excel file and extract the data using autofilter

2011-10-01 Thread David Monaghan
On Sat, 1 Oct 2011 10:35:06 -0700 (PDT), Prakash prakash...@gmail.com
wrote:

On Oct 1, 10:25 pm, Prakash prakash...@gmail.com wrote:
 Need  A script to open a excel file and extract the data using
 autofilter and write it in a new sheet or new file like I have to
 select all rows in which all the columns contain pass as status

from win32com.client import Dispatch
xlApp = Dispatch(Excel.Application)
xlApp.Workbooks.Open(r'C:\Users\Administrator\Desktop\test.xls')
xlApp.Visible = 1

after opening the text.xls file i need to filter all the rows in which
the status column is passed and copy the whole sheet to another sheet

I don't do this often enough to have it to mind, so what I normally do is
record a Macro, convert it to VBS and then convert that to Python.

I'll leave the final step for you to complete yourself, but this will do
what you ask up to the point of copying the selected lines:

from win32com.client import Dispatch
xlApp = Dispatch(Excel.Application)
xlWbook = xlApp.Workbooks.Open(rC:\Users\Administrator\Desktop\test.xls)
xlApp.Visible = 1
xlWorksheet = xlWbook.Worksheets(1)
xlWorksheet.Columns(A:V).Select() 
xlApp.Selection.AutoFilter( 2, pass) # column number, filter criteria
xlApp.Selection.AutoFilter( 3, pass)
xlApp.Selection.AutoFilter( 4, pass)
xlApp.Selection.AutoFilter( 5, pass)
#etc, etc - up to column 22 in this case
xlApp.Selection.Copy()

DaveM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need A script to open a excel file and extract the data using autofilter

2011-10-01 Thread David Monaghan
On Sat, 01 Oct 2011 23:00:07 +0100, David Monaghan
monaghand.da...@gmail.com wrote:

from win32com.client import Dispatch
xlApp = Dispatch(Excel.Application)
xlWbook = xlApp.Workbooks.Open(rC:\Users\Administrator\Desktop\test.xls)
xlApp.Visible = 1
xlWorksheet = xlWbook.Worksheets(1)
xlWorksheet.Columns(A:V).Select() 
xlApp.Selection.AutoFilter( 2, pass) # column number, filter criteria
xlApp.Selection.AutoFilter( 3, pass)
xlApp.Selection.AutoFilter( 4, pass)
xlApp.Selection.AutoFilter( 5, pass)
#etc, etc - up to column 22 in this case
xlApp.Selection.Copy()

Or rather:

from win32com.client import Dispatch
xlApp = Dispatch(Excel.Application)
xlWbook = xlApp.Workbooks.Open(r'C:\Users\Administrator\Desktop\test.xls')
xlApp.Visible = 1
xlWorksheet = xlWbook.Worksheets(1)
xlWorksheet.Columns(A:V).Select()
for column in range(2,23):
xlApp.Selection.AutoFilter(column, pass) 
xlApp.Selection.Copy()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ten rules to becoming a Python community member.

2011-08-16 Thread David Monaghan
On Tue, 16 Aug 2011 13:13:10 -0700 (PDT), rantingrick
rantingr...@gmail.com wrote:

If conciseness is all you seek then perhaps you prefer the following?

ORIGINAL: I used to wear wooden shoes
CONCISE:  I wore wooden shoes

ORIGINAL: I have become used to wearing wooden shoes
CONCISE:  I like wearing wooden shoes

However as you can see much of the rich information is missing. 

Indeed. Neither of your two concise examples has the same meaning of the
originals. 

Good communication requires that we use clear and articulate words (and
phrases) that will re-create a similar thought (if not perfect clone of!) 
in the mind of your listener[s].

Different phrasings of all but the most basic sentences often have subtle
differences of meaning which native speakers intend and understand. 1984 has
been and gone. Shame on you!

DaveM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ten rules to becoming a Python community member.

2011-08-16 Thread David Monaghan
On Tue, 16 Aug 2011 16:12:53 -0700 (PDT), rantingrick
rantingr...@gmail.com wrote:

On Aug 16, 4:55 pm, David Monaghan monaghand.da...@gmail.com wrote:
 On Tue, 16 Aug 2011 13:13:10 -0700 (PDT), rantingrick

 rantingr...@gmail.com wrote:
 If conciseness is all you seek then perhaps you prefer the following?

 ORIGINAL: I used to wear wooden shoes
 CONCISE:  I wore wooden shoes
 ORIGINAL: I have become used to wearing wooden shoes
 CONCISE:  I like wearing wooden shoes
 However as you can see much of the rich information is missing.

 Indeed. Neither of your two concise examples has the same meaning of the
 originals.

Really? Are you sure?

Yes.

 ORIGINAL1: I used to wear wooden shoes

There's an implicit corollary to this sentence: ...but I don't any more,
which is missing from your concise sentence:

CONCISE_1a: I wore wooden shoes

 ORIGINAL_2: I have become used to wearing wooden shoes

This carries the meaning, I wasn't always comfortable/accustomed to wearing
wooden shoes, but I am now. This is a totally different meaning from:

CONCISE_2a:  I like wearing wooden shoes

which refers only to the present and is much more positive. 

In fact, now I consider it, these examples are so clearly different that you
can't be a native English speaker. Either that, or I've just fed a troll.
Damn.

DaveM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Coolest Python recipe of all time

2011-05-02 Thread David Monaghan
On Mon, 2 May 2011 10:33:31 -0700 (PDT), Raymond Hettinger pyt...@rcn.com
wrote:

I think it is time to give some visibility to some of the instructive
and very cool recipes in ActiveState's python cookbook.

My vote for the coolest recipe of all time is:


 http://code.activestate.com/recipes/365013-linear-equations-solver-in-3-lines/

Really cool, but wrong. x = 3234.667, not 3236.0

DaveM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Coolest Python recipe of all time

2011-05-02 Thread David Monaghan
On Mon, 2 May 2011 14:58:50 -0600, Ian Kelly ian.g.ke...@gmail.com wrote:

On Mon, May 2, 2011 at 2:48 PM, David Monaghan
monaghand.da...@gmail.com wrote:
 On Mon, 2 May 2011 10:33:31 -0700 (PDT), Raymond Hettinger pyt...@rcn.com
 wrote:

I think it is time to give some visibility to some of the instructive
and very cool recipes in ActiveState's python cookbook.

My vote for the coolest recipe of all time is:

    
 http://code.activestate.com/recipes/365013-linear-equations-solver-in-3-lines/

 Really cool, but wrong. x = 3234.667, not 3236.0

Nope, I get 3236.  Maybe you made a mistake somewhere.

Oops. What a plonker .Three times I checked and got the same result each
time. Now it works fine. Sorry!

DaveM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python to exe

2010-03-14 Thread David Monaghan
On Sun, 14 Mar 2010 13:10:32 -0600, John Bokma j...@castleamber.com wrote:

David Monaghan monaghand.da...@gmail.com writes:

 of Google. If they haven't used it, I don't really consider the gentle
 reminder that LMGTFY gives too harsh. If you do, you're too much of a gentle
 soul to be on the internet at all; someone might say Boo to you at any
 moment. Beware.

Sorry. That last comment of mine was uncalled for.

I've no problem with lmgtfy. I *do* have a problem with hiding it behing
a tinyurl. Why use 2 levels of obfuscating in a group that's about
programming in a language that promotes clear coding?

The message would have been the same if the OP had just copy pasted the
Google link. But hey, that's way less funny.

Good point, although one could argue the unhidden response is just rude, but
the masking does make it genuinely funny.

DaveM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python to exe

2010-03-13 Thread David Monaghan
On Sat, 13 Mar 2010 12:52:39 -0600, John Bokma j...@castleamber.com wrote:

Steven D'Aprano st...@remove-this-cybersource.com.au writes:

 As the old proverb goes: give a man a fish, and you feed him for a day. 
 Teach him how to fish, and he has food forever.

True, but you don't teach someone fishing by poking an eye out with a
fishing rod.

 I'm an old-fashioned kind of guy, and don't like LMGTFY because it is 
 tiresome and requires Javascript. I prefer:

My reply had little to do with lmgtfy and all to do with hiding it behind
tinyurl. But even then, why not do what you just did: give a URL to
google directly.

For quite some time I thought that comp.lang.perl.misc was quite
unfriendly because of a certain attitude. comp.lang.python was quite a
refreshment for a while: very newbie friendly, less pissing contests,
etc. (but way more fanboism). 

Yesterday was a sady day: I finally had to conclude that it was only
wishful thinking on my part; there is no difference.

There was a time, when the internet was young and most newbies couldn't find
their own backsides with both hands, that your conclusions would be well
placed.That time has long passed: Newsgroups are a long way down the
hierarchy since those times and anyone turning up here nowadays _has_ heard
of Google. If they haven't used it, I don't really consider the gentle
reminder that LMGTFY gives too harsh. If you do, you're too much of a gentle
soul to be on the internet at all; someone might say Boo to you at any
moment. Beware.

DaveM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3 minor irritation

2010-02-04 Thread David Monaghan
On Thu, 04 Feb 2010 00:39:01 +, David Monaghan
monaghand.da...@gmail.com wrote:

I have a small program which reads files from the directory in which it
resides. It's written in Python 3 and when run through IDLE or PythonWin
works fine. If I double-click the file, it works fine in Python 2.6, but in
3 it fails because it looks for the files to load in the Python31 folder,
not the one the script is in.

It's not a big deal, but browsing around I haven't found why the behaviour
has been changed or any comment about it (That might be my poor search
technique, I suppose).

The program fails at:

try:
tutdoc = minidom.parse(.//Myfile.xml)
except IOError:
snip

I very much appreciate all the help offered on this, but feel a bit of an
idiot now as I can't reproduce the behaviour (it had happened on two
separate machines).

What I am still getting is a similar problem on my work computer with the
program on a network hard drive. Not always - it'll run on repeated
attempts, then fail for a few, then work again. When it failed I ran the
script as suggested:

import os
print(curdir=, os.getcwd())
print(__file__=, __file__)
input()

and got the response:

curdir= H:\
__file__= H:\FRCR\FRCR2010\Course documents\FRCR2009\Script1.py

so it's 'sticking' at H:

For interest, I ran the script from IDLE, too, and PythonWin, on three
separate computers (2 Python3, 1 Python2.6)

With that I get a NameError for __file__

curdir= H:\FRCR\FRCR2010\Course documents\FRCR2009
Traceback (most recent call last):
  File H:\FRCR\FRCR2010\Course documents\FRCR2009\Script1.py, line 3,
in module
print(__file__=, __file__)
NameError: name '__file__' is not defined

What have I done wrong?

DaveM
-- 
http://mail.python.org/mailman/listinfo/python-list


Python 3 minor irritation

2010-02-03 Thread David Monaghan
I have a small program which reads files from the directory in which it
resides. It's written in Python 3 and when run through IDLE or PythonWin
works fine. If I double-click the file, it works fine in Python 2.6, but in
3 it fails because it looks for the files to load in the Python31 folder,
not the one the script is in.

It's not a big deal, but browsing around I haven't found why the behaviour
has been changed or any comment about it (That might be my poor search
technique, I suppose).

The program fails at:

try:
tutdoc = minidom.parse(.//Myfile.xml)
except IOError:
snip

DaveM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Office Word and Python (Win XP)

2010-01-09 Thread David Monaghan
On Sat, 9 Jan 2010 11:18:12 -0800 (PST), 3lvss0...@gmail.com
3lvss0...@gmail.com wrote:

Dennis Lee Bieber: Im not familiar with python, also Im not
programmer.

What you want to do isn't complicated, but it isn't simple either, unless
you're familiar with VBA/VBS. I approach these problems by first getting the
VBA code by recording a macro within Word. I then convert it to VB Script,
which is a learning process in itself. Converting that script to Python com
is another learning process and then putting the whole thing together with
file finding and saving is another job.

When you've done that, you won't feel able to say you're not a programmer -
and you should feel familiar with Python, too.

DaveM
-- 
http://mail.python.org/mailman/listinfo/python-list