Re: problem with the 'math' module in 2.5?

2006-10-14 Thread David Lees
Chris wrote:
> sin(pi*0.5) is what I expected, but I expected to get 0 for sin(pi).
> 


http://docs.python.org/tut/node16.html

david

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


Re: Observation on "Core Python Programming"

2006-10-29 Thread David Lees
John Coleman wrote:
> Greetings,
>My copy of the second edition of Chun's "Core Python Programming"
> just arrived from Amazon on Friday. What really jumped out at me is an
> interesting feature about how it sequences its topics, namely,
> (user-defined) functions are not introduced until chapter 11, fully 400
> pages into the book. This contrasts strongly with a traditional


Pages 48-50 is a section titled: 'Functions' and he gives both a top 
level description and example.  True he does not have a chapter devoted 
to functions still page 400, but he does give examples of usage along 
the way.

david lees

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


Tkinter on Silicon Graphics machine?

2006-12-05 Thread David Lees
Does anyone have advice on installing Tkinter on s Silicon Graphics 
machine (under IRIX 6, I think). The SysAdmin at work build Python 2.4.3 
for me on the SGI box, but it does not have Tkinter.  Are there any 
prebuilt distributions for SGI machines that include Tkinter?

TIA

david lees
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter on Silicon Graphics machine?

2006-12-06 Thread David Lees
[EMAIL PROTECTED] wrote:
> David Lees wrote:
>> Does anyone have advice on installing Tkinter on s Silicon Graphics
>> machine (under IRIX 6, I think). The SysAdmin at work build Python 2.4.3
>> for me on the SGI box, but it does not have Tkinter.  Are there any
>> prebuilt distributions for SGI machines that include Tkinter?
>>
>> TIA
>>
>> david lees
> 
> I don't have the disks in front of me now, but I think the freeware
> disks included with Irix have Python on them. Otherwise, you could
> download it from
> http://freeware.sgi.com/Installable/python-2.1.1-sgipl1.html
> 
> If you want 2.4, the sysadmin could rebuild Python after installing the
> Tcl/Tk libraries (which you will need to use Tkinter anyway.) As long
> as libtcl and libtk are in /usr/lib or /usr/local/lib, Tkinter will be
> built automatically when Python is built.
> 
> Pete
> 

Pete,

Thanks for the advice.  This is quite helpful.  I will pass this on to 
the sysadmin.

David Lees
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: merits of Lisp vs Python

2006-12-08 Thread David Lees
[EMAIL PROTECTED] wrote:
> Okay, since everyone ignored the FAQ, I guess I can too...
> 
> Mark Tarver wrote:
>> How do you compare Python to Lisp?  What specific advantages do you
>> think that one has over the other?
> 
> (Common) Lisp is the only industrial strength language with both pure
> compositionality and a real compiler. What Python has is stupid slogans
> ("It fits your brain." "Only one way to do things.") and an infinite
> community of flies that, for some inexplicable reason, believe these
> stupid slogns. These flies are, however, quite useful because they
> produce infinite numbers of random libraries, some of which end up
> being useful. But consider: Tcl replaced Csh, Perl replaced Tcl, Python
> is rapidly replacing Perl, and Ruby is simultaneously and even more
> rapidly replacing Python. Each is closer to Lisp than the last; the
> world is returning to Lisp and is dragging the flies with it.
> Eventually the flies will descend upon Lisp itself and will bring with
> them their infinite number of random libraries, and then things will be
> where they should have been 20 years ago, but got sidetracked by Tcl
> and other line noise.
> 

Hmmm.  The last time I fooled around with Lisp was 1966 from the Lisp 
1.5 Manual Published by MIT in cloth.  It was interesting and different 
from the other languages I was using, Algol 60, Basic and Macro 
assembler for the GE-235 and GE-635.  When I read some of the over the 
top type hype by Lisp enthusiasts (like the stuff above) it feels like a 
flash back to the mid 60's.  Personally, I never like Lisp syntax; 
Clearly some people, some fanatic judging by this thread :) think easily 
in prefix.  I am not one of them.  Computer languages are tools and 
everyone should pick the ones that they are most comfortable and 
productive with.

Six years ago, when I drifted back into programming, I had to learn 
about Object Oriented programming and C++.  I used Python as a means to 
update my programming skills (limited though they are) by 30 years or 
so.  It was a wonderful intro to OO and served me well.  I ended up 
writing all kinds of little things for work (simple HTTP servers for 
load testing, ECAD hacks for the ASIC guys, even a register level chip 
simulator) Even better, I find it a pleasure to write small utilities, 
to prototype C code and generally do things quickly.  I use it by choice 
to get things done, not because it is mandated.  At my current job as a 
Systems Engineer for a large aerospace firm, I do not program daily, but 
when I need to write a quick hack, I always use Python.

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


Scipy and Mcafee Site Advisor?

2007-07-31 Thread David Lees
I know scipy.org is legit and supplies widely used and useful python 
packages.  Can someone explain why my McAfee SiteAdvisor software, flags 
  scipy.org as a dangerous site?  Pardon my ignorance, but is this a 
temporary error in the SiteAdvisor database or is there some privacy 
consideration involved?  I am wondering if I should remove the 
SiteAdvisor software, because it is not particularly reliable.

Puzzled.

david lees
-- 
http://mail.python.org/mailman/listinfo/python-list


HowTo Use Cython on a Windows XP Box?

2007-08-31 Thread David Lees
August 31, 2007

I just downloaded the current Cython release and have no problem running 
the cpython.py translator on the demo code.  But when I try compiling, I 
get an error complaining that my version of Python (which is the current 
2.5.1 downloaded from python.org) was compiled with Visual C++ 2003.  I 
only have Visual C++ 2005 on my machine and am unable to find a download 
of 2003 on the Microsoft site (no big surprise).  I have never built 
Python from source.  Is it necessary or can someone suggest an alternative?

TIA

david lees
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HowTo Use Cython on a Windows XP Box?

2007-08-31 Thread David Lees
John Machin wrote:
> On Sep 1, 1:40 pm, Paul McGuire <[EMAIL PROTECTED]> wrote:
>> On Aug 31, 9:06 pm, David Lees <[EMAIL PROTECTED]> wrote:
>>
>>> August 31, 2007
>>> I just downloaded the current Cython release and have no problem running
>>> the cpython.py translator on the demo code.  But when I try compiling, I
>>> get an error complaining that my version of Python (which is the current
>>> 2.5.1 downloaded from python.org) was compiled with Visual C++ 2003.  I
>>> only have Visual C++ 2005 on my machine and am unable to find a download
>>> of 2003 on the Microsoft site (no big surprise).  I have never built
>>> Python from source.  Is it necessary or can someone suggest an alternative?
>>> TIA
>>> david lees
>> Unless you are customizing Python (and you can accomplish a *lot*
>> without doing so), it is not necessary to build Python from source.
>> Download one of the pre-built Windows binaries and install it, or get
>> the Win Python distribution from ActiveState and install that.  Then
>> start writing your own Python demo scripts.
>>
> 
> Paul, AFAICT the OP is referring not to CPython, but to Cython, which
> is a Pyrex fork. See http://www.cython.org/
> 
> Building CPython from source is likely to be a red herring. The OP's
> question appears to be "How do I, on Windows, compile C code generated
> by Cython into a pyd that will play happily with the standard-issue
> python.exe and python25.dll?", and is probably best directed to one of
> the 3 forums mentioned on the above-referenced page.
> 
> HTH,
> John
> 
> 
> 
> 
John,

Yes, you are correct in understanding my question.  I thought my post 
was clear, but I guess not.  I will go try the pyrex list.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to efficiently read binary files?

2006-04-30 Thread David Lees
I want to process large binary files (>2GB) in Python.  I have played 
around with prototypes in pure Python and profiled the code.  Most of 
the time seems to be spent converting back and forth to and from strings 
using the struct module.  Is there a way to directly read into an array 
of integers in Python?

TIA

David Lees
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to efficiently read binary files?

2006-04-30 Thread David Lees
Alex Martelli wrote:
> David Lees <[EMAIL PROTECTED]> wrote:
> 
>> I want to process large binary files (>2GB) in Python.  I have played
>> around with prototypes in pure Python and profiled the code.  Most of
>> the time seems to be spent converting back and forth to and from strings
>> using the struct module.  Is there a way to directly read into an array
>> of integers in Python?
> 
>>>> import array
>>>> x=array.array('l')
>>>> help(x.fromfile)
> 
> Help on built-in function fromfile:
> 
> fromfile(...)
> fromfile(f, n)
> 
> Read n objects from the file object f and append them to the end of
> the array.  Also called as read.
> 
> 
> Alex

Thank you.  This is exactly what I was looking for.  I just tried it and 
it works great.

David Lees
-- 
http://mail.python.org/mailman/listinfo/python-list


Looking for suggestions on improving numpy code

2008-02-22 Thread David Lees
I am starting to use numpy and have written a hack for reading in a 
large data set that has 8 columns and millions of rows.  I want to read 
and process a single column.  I have written the very ugly hack below, 
but am sure there is a more efficient and pythonic way to do this.  The 
file is too big to read by brute force and select a column, so it is 
read in chunks and the column selected. Things I don't like in the code:
1. Performing a transpose on a large array
2. Uncertainty about numpy append efficiency

Is there a way to directly read every n'th element from the file into an 
array?

david


from numpy import *
from scipy.io.numpyio import fread

fd = open('testcase.bin', 'rb')
datatype = 'h'
byteswap = 0
M = 100
N = 8
size = M*N
shape = (M,N)
colNum = 2
sf =1.645278e-04*10
z=array([])
for i in xrange(50):
 data = fread(fd, size, datatype,datatype,byteswap)
 data = data.reshape(shape)
 data = data.transpose()
 z = append(z,data[colNum]*sf)

print z.mean()

fd.close()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Book Recomendations

2008-03-02 Thread David Lees
Ira Solomon wrote:
> I am an experienced programmer (40 years).  I've done Algol (if you've
> heard of that you must be old too), PL/1, VB,VBA, a little C, and a
> few other odd languages (e.g. Taskmate).
> I'm interested in learning Python and have downloaded a slew of books.
> Too many.
> I'd like a recommendation as to which books are considered to be the
> cream of the crop.
> I know there are tutorials on the web, but, again, I don't know the
> quality.  I would appreciate recommendations on those as well.
> 
> Thanks
> 
> Ira
Different people have different learning styles.  Two books I like are 
Wesley Chun's Core Python Programming (2nd edition) and Mangnus 
Hetland's Beginning Python.  Have fun with Python.  I discovered it 
about 7 years ago, use it by choice for my intermittent programming 
requirements and find it a pleasure to use.  Also this group is very 
helpful.

(My programming experience also goes back to Algol, Basic and assembler 
circa 1965.  Which makes me middle aged, but not necessarily experienced 
:)  )

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


Very Slow PythonWin 2.6.1 Startup on Windows XP SP3

2008-12-18 Thread David Lees
PythonWin used to startup in a second or two on my Windows XP desktop. 
now it takes around 20 seconds.  I tried turning off Google Desktop 
indexing and Norton AV, but it still takes a long time to start.  Other 
random apps such as Firefox 3.0 (which I just updated to) and 
Thunderbird have normal startup times.


Does anyone have suggestions on how to speed up Python startup?

David Lees
--
http://mail.python.org/mailman/listinfo/python-list


Re: Very Slow PythonWin 2.6.1 Startup on Windows XP SP3

2008-12-19 Thread David Lees

Allan wrote:

David Lees  writes:


PythonWin used to startup in a second or two on my Windows XP
desktop. now it takes around 20 seconds.  I tried turning off Google
Desktop indexing and Norton AV, but it still takes a long time to
start.  Other random apps such as Firefox 3.0 (which I just updated
to) and Thunderbird have normal startup times.

What happens if you just open a Python command window; is it much
faster? On my computer which is seven years old (HP Pavilion desktop,
512 MB RAM) it takes less than ten seconds for PythonWin to open. You
might try reinstalling PythonWin.



I just uninstalled all copies of Python from my system(2.5, 2.6 and 
3.0), along with their corresponding PythonWin.  Then I downloaded and 
installed Python 2.6.1 and PythonWin build 212.  Now Python starts up 
nearly instantly.  Thanks for the suggestion.


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


Re: Can some1 review my code?

2009-04-20 Thread David Lees

zaheer.ag...@gmail.com wrote:

When done all this you might feel it is not necessary to review the code
any more, which is then is a good moment to actually request a review :-)




I'll be happy to have a look at it though you might consider posting it
here, more chance of useful feedback ;-)


Great, Thanks a lot I will make sure that I complete what ever you
have listed here and then
request for a review. Well I understand that refusing to post the code
here in the mailing list might
annoy people and posting code here will only help it making it more
robust and clean. I am just being cautious that I don't break any of
the laws at my workplace.


I would second what another poster recommended.  Post snippets.  My 
experience over the last 8 years is that a short post on a single issue 
elicits very helpful responses.  Also these days there many books on 
Python; find one that suits your learning style.



David Lees
--
http://mail.python.org/mailman/listinfo/python-list


Unable to install Pywin32 for Python 2.6.2

2009-05-11 Thread David Lees
I have no problem installing Python 2.6.2 for windows under XP SP3 and 
IDLE and the command line versions work fine.  When I run the pywin32 
installer downloaded from sourceforge (pywin32-212.win32-py2.6.exe) I 
get the following error message:


Traceback (most recent call last):
  File "", line 565, in 
  File "", line 291, in install
ImportError: Module use of python25.dll conflicts with this version of 
Python.

*** run_installscript: internal error 0x ***

I have tried uninstalling Python 2.6 and reinstalling, but still get the 
same message.  I do have Python 2.5.4 and its associated Pywin32 on the 
same machine, but I have a laptop with pywin32 installed for both python 
2.5 and 2.6.


TIA

David Lees
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Re: Unable to install Pywin32 for Python 2.6.2

2009-05-12 Thread David Lees

Mark Hammond wrote:
Probably some import statement is finding a .pyd module built against 
Python 2.5 instead of Python 2.6; it might be that PYTHONPATH points 
somewhere wrong, or the registry for Python 2.6 is setup wrong, or 
something else entirely...


Cheers,

Mark

On 12/05/2009 3:13 PM, David Lyon wrote:

Hi,

hmmm... that's annoying..

Whilst I don't have an exact answer I have a few hunches...

Perphaps what has happened is that the windows installer between
the versions of pywin32 has installed newer versions of the same
dlls over the top of older ones.

Or, possibly, the installer hasn't wanted to replace older dll's
because they already exist on the system.

This would result in a mismatch.

You may be lucky and find an install log. This might tell you which
files were actually installed. And you could play around with
moving them around.

Good luck with your night vision task

David


On Tue, 12 May 2009 02:22:56 GMT, David Lees
wrote:

I have no problem installing Python 2.6.2 for windows under XP SP3 and
IDLE and the command line versions work fine.  When I run the pywin32
installer downloaded from sourceforge (pywin32-212.win32-py2.6.exe) I
get the following error message:

Traceback (most recent call last):
File "", line 565, in
File "", line 291, in install
ImportError: Module use of python25.dll conflicts with this version of
Python.
*** run_installscript: internal error 0x ***

I have tried uninstalling Python 2.6 and reinstalling, but still get the
same message.  I do have Python 2.5.4 and its associated Pywin32 on the
same machine, but I have a laptop with pywin32 installed for both python
2.5 and 2.6.

TIA

David Lees



Mark and David,

Thanks for the help.  I just got it to install for Python 2.6.  All I 
did was change PYTHONPATH (as suggested by Mark) from 
C:\Python25\Lib\site-packages to C:\Python26\Lib\site-packages


David Lees
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to figure out if the platform is 32bit or 64bit?

2008-07-15 Thread David Lees

[EMAIL PROTECTED] wrote:

I need to know if I'm running on 32bit or 64bit ... so far I haven't
come up with how to get this info via python. sys.platform returns
what python was built on ... but not what the current system is.

I thought platform.uname() or just platform.processor() would have
done it, but python returns an empty string on windows. Any ideas?

Thanks, Ken


On my windows box this works:

>>> platform.architecture()
('32bit', 'WindowsPE')


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


Unable to install pywin32 for Python 2.6.2

2009-09-02 Thread David Lees
I install Python 2.6.2 with no problem, but then run the installer for 
pywin32 from Source Forge and get this message at the end.  IDLE works, 
but Pywin32 does not.


Traceback (most recent call last):
  File "", line 601, in 
  File "", line 313, in install
ImportError: DLL load failed: The specified module could not be found
--
I have uninstalled my Python 2.5.4 and Python 2.6.2 and it does not 
help.  Any suggestions on how to install Pywin32 appreciated.


TIA

David Lees
--
http://mail.python.org/mailman/listinfo/python-list


Re: Unable to install pywin32 for Python 2.6.2

2009-09-02 Thread David Lees

David Lees wrote:
I install Python 2.6.2 with no problem, but then run the installer for 
pywin32 from Source Forge and get this message at the end.  IDLE works, 
but Pywin32 does not.


Traceback (most recent call last):
  File "", line 601, in 
  File "", line 313, in install
ImportError: DLL load failed: The specified module could not be found
--
I have uninstalled my Python 2.5.4 and Python 2.6.2 and it does not 
help.  Any suggestions on how to install Pywin32 appreciated.


TIA

David Lees


Oops, Pardon my posting this.  I should have Googled first and would 
have solved the problem.  I posted this in May, and Mark Hammond solved 
the problem then.  I forgot about it and repeated mistake.


In case anyone else has this problem, my mistake was a PYTHONPATH that 
pointed to my Python 2.5 installation.  I simply changed it to:

C:\Python26\Lib\site-packages
and reran the Pywin32 installer and all is fine.

David Lees
--
http://mail.python.org/mailman/listinfo/python-list