Re: Python Portability--Not very portable?

2010-08-06 Thread W. eWatson

On 8/6/2010 10:31 AM, geremy condra wrote:

On Fri, Aug 6, 2010 at 8:00 AM, W. eWatsonwolftra...@invalid.com  wrote:



I would think there are some small time and big time Python players who
sell
executable versions of their programs for profit?


Yes. What's your point?


That someone must know how to distribute them without having the source code
ripped off.


I've never seen a code obfuscation scheme I thought did the job the
whole way, including compiling C, and Python bytecode is significantly
easier to turn back into something resembling the original source
(YMMV, I suppose). Also, if you don't know about common tools like
distutils, the odds are pretty good that it isn't your code itself
that is valuable to you- you're probably more interested in protecting
your idea about what the code should do. At least for now, that's
outside of the scope of technical solutions- discuss it with a lawyer,
not a programmer.




disutils. Sounds familiar. I'm pretty sure I was using Py2Exe, and
disutils
might have been part of it.


distutils.

http://docs.python.org/library/distutils.html


I don't see ;how distutils is going to solve this problem. Are you
suggesting the program should be packaged? Why? I can just send it to him as
py code. distutils looks like it's for library modules, e.g., functions like
math.


...no. Distutils is handy because you could just bundle your
dependencies and hand them an easy-to-install package, which would be
a quick way to get everybody on the same page. Of course, depending on
the licenses those dependencies are under you might want to do even
more talking to a lawyer than I've previously suggested before you go
about trying to sell that bundle- I'm sure you wouldn't want to 'rip
off' great free projects like python and numpy.

Geremy Condra
Yes, code reversal programs have been around for many, many decades. Try 
one on MS Word or Adobe Acrobat. :-)


Is there a complete illustration of using disutils? Our only 
dependencies are on Python Org material. We use no commercial or 
licensed code.

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


Re: [Tutor] Finding the version # of a module, and py module problem

2010-08-06 Thread W. eWatson

I must be missing something. I tried this. (Windows, IDLE, Python 2.5)
# Try each module
import sys
import numpy
import scipy
import string

dependencies = numyp, scipy
for dependency in dependencies:
try:
__import__(dependency.name)
except ImportError:
# Uh oh!
dependency.installed = None
else:
# The module loaded OK. Get a handle to it and try to extract
# version info.
# Many Python modules follow the convention of providing their
# version as a string in a __version__ attribute.
module = sys.modules[dependency.name]

# This is what I default to.
dependency.installed = [version unknown]

for attribute_name in (__version__, __VERSION__, VERSION,
   version):
if hasattr(module, attribute_name):
dependency.installed = getattr(module, attribute_name)
break

The result was this.
Traceback (most recent call last):
  File 
C:/Users/Wayne/Sandia_Meteors/Trajectory_Estimation/dependency_code, 
line 10, in module

__import__(dependency.name)
AttributeError: 'str' object has no attribute 'name'
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] Finding the version # of a module, and py module problem

2010-08-05 Thread W. eWatson
It's been awhile since I've used python, and I recall there is a way to 
find the version number from the IDLE command line  prompt. dir, help, 
__version.__?


I made the most minimal change to a program, and it works for me, but 
not my partner. He gets


Traceback (most recent call last):
  File C:\Documents and 
Settings\HP_Administrator.DavesDesktop\Desktop\NC-FireballReport20100729.py, 
line 40, in module

from scipy import stats as stats # scoreatpercentile
  File C:\Python25\lib\site-packages\scipy\stats\__init__.py, line 7, 
in module

from stats import *
  File C:\Python25\lib\site-packages\scipy\stats\stats.py, line 191, 
in module

import scipy.special as special
  File C:\Python25\lib\site-packages\scipy\special\__init__.py, line 
22, in module

from numpy.testing import NumpyTest
ImportError: cannot import name NumpyTest

Here are the first few lines of code.

import sys, os, glob
import string
from numpy import *
from datetime import datetime, timedelta
import time
from scipy import stats as stats # scoreatpercentile

I'm pretty sure he has the same version of Python, 2.5, but perhaps not 
the numpy or scipy modules. I need to find out his version numbers.


--
   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
  Obz Site:  39° 15' 7 N, 121° 2' 32 W, 2700 feet

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


Re: [Tutor] Finding the version # of a module, and py module problem

2010-08-05 Thread W. eWatson

On 8/5/2010 6:13 PM, Steven D'Aprano wrote:

On Thu, 05 Aug 2010 17:55:30 -0700, W. eWatson wrote:


I'm pretty sure he has the same version of Python, 2.5, but perhaps not
the numpy or scipy modules. I need to find out his version numbers.


It's only a convention, but the usual way is to check the __version__
attribute. It works for Numpy:


import numpy
numpy.__version__

'1.0.3'




It is now written in my Py book. Thanks.
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] Finding the version # of a module, and py module problem

2010-08-05 Thread W. eWatson

On 8/5/2010 6:23 PM, MRAB wrote:

W. eWatson wrote:

It's been awhile since I've used python, and I recall there is a way
to find the version number from the IDLE command line prompt. dir,
help, __version.__?

I made the most minimal change to a program, and it works for me, but
not my partner. He gets

Traceback (most recent call last):
File C:\Documents and
Settings\HP_Administrator.DavesDesktop\Desktop\NC-FireballReport20100729.py,
line 40, in module
from scipy import stats as stats # scoreatpercentile
File C:\Python25\lib\site-packages\scipy\stats\__init__.py, line 7,
in module
from stats import *
File C:\Python25\lib\site-packages\scipy\stats\stats.py, line 191,
in module
import scipy.special as special
File C:\Python25\lib\site-packages\scipy\special\__init__.py, line
22, in module
from numpy.testing import NumpyTest
ImportError: cannot import name NumpyTest

Here are the first few lines of code.

import sys, os, glob
import string
from numpy import *
from datetime import datetime, timedelta
import time
from scipy import stats as stats # scoreatpercentile

I'm pretty sure he has the same version of Python, 2.5, but perhaps
not the numpy or scipy modules. I need to find out his version numbers.


Try:

import numpy
help(numpy.version)

BTW, on Python 2.6 I can see that there's numpytest but not
NumpyTest.
I have to stick with 2.5 for comparability with my partner. He's 
non-Python but was able to get Python 2.5 working. I think he somehow 
bumped ahead to a later version of numpy than I have.

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


Python Portability--Not very portable?

2010-08-05 Thread W. eWatson
In my on-again-off-again experience with Python for 18 months, 
portability seems an issue.


As an example, my inexperienced Python partner 30 miles away has gotten 
out of step somehow. I think by installing a different version of numpy 
than I use. I gave him a program we both use months ago, and he had no 
trouble. (We both use IDLE on 2.5). I made a one character change to it 
and sent him the new py file. He can't execute it. I doubt he has 
changed anything in the intervening period.


A further example. Months ago I decided to see if I could compile a 
program to avoid such problems as above. I planned to satisfy that need, 
and see if I could distribute some simple programs to non-Python 
friends. I pretty well understand the idea,and got it working with a 
small program. It seemed like a lot of manual labor to do it.

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


Re: Python Portability--Not very portable?

2010-08-05 Thread W. eWatson

On 8/5/2010 7:45 PM, geremy condra wrote:

On Thu, Aug 5, 2010 at 6:50 PM, W. eWatsonwolftra...@invalid.com  wrote:

In my on-again-off-again experience with Python for 18 months, portability
seems an issue.

As an example, my inexperienced Python partner 30 miles away has gotten out
of step somehow. I think by installing a different version of numpy than I
use. I gave him a program we both use months ago, and he had no trouble. (We
both use IDLE on 2.5). I made a one character change to it and sent him the
new py file. He can't execute it. I doubt he has changed anything in the
intervening period.


Portability doesn't mean you can use different versions of your
dependencies and be A-OK. It should be fairly obvious that if the
behavior of your dependencies changes, your code needs to change to
ensure that it demonstrates the same behavior. Portability also
doesn't mean that any given one-character change is valid, so that may
be your issue as well.


A further example. Months ago I decided to see if I could compile a program
to avoid such problems as above. I planned to satisfy that need, and see if
I could distribute some simple programs to non-Python friends. I pretty well
understand the idea,and got it working with a small program. It seemed like
a lot of manual labor to do it.


What, why were you compiling a program? And why not just use distutils?

Geremy Condra


I checked the one char change on my system thoroughly. I looked around 
on some forums and NGs 4 months ago, and found no one even had a simple 
compiled program available to even demonstrate some simple example.


I would think there are some small time and big time Python players who 
sell executable versions of their programs for profit?


disutils. Sounds familiar. I'm pretty sure I was using Py2Exe, and 
disutils might have been part of it.


So how does one keep a non-Python user in lock step with my setup, so 
these problems don't arise? I don't even want to think about having him 
uninstall and re-install. :-) Although maybe he could do it without 
making matters worse.

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


Re: Why this Difference in Importing NumPy 1.2 vs 1.4?

2010-03-29 Thread W. eWatson

Add/Remove under Control Panel. It's a numpy problem.

On 3/28/2010 9:20 AM, W. eWatson wrote:

I wrote a program in Python 2.5 under Win7 and it runs fine using Numpy
1.2 , but not on a colleague's machine who has a slightly newer 2.5 and
uses NumPy 1.4. We both use IDLE to execute the program. During import
he gets this:

 
Traceback (most recent call last):
File C:\Documents and Settings\HP_Administrator.DavesDesktop\My
Documents\Astro\Meteors\NC-FireballReport.py, line 38, in module
from scipy import stats as stats # scoreatpercentile
File C:\Python25\lib\site-packages\scipy\stats\__init__.py, line 7, in
module
from stats import *
File C:\Python25\lib\site-packages\scipy\stats\stats.py, line 191, in
module
import scipy.special as special
File C:\Python25\lib\site-packages\scipy\special\__init__.py, line 22,
in module
from numpy.testing import NumpyTest
ImportError: cannot import name NumpyTest
 

Comments?

It looks as though the problem is in NumPy 1.4. If it's either in NumPy
or SciPy, how does my colleague back out to an earlier version to agree
with mine? Does he just pull down 1.3 or better 1.2 (I use it.), and
install it? How does he somehow remove 1.4? Is it as easy as going to
IDLE's path browser and removing, under site-packages, numpy? (I'm not
sure that's even possible. I don't see a right-click menu.)


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


Why this Difference in Importing NumPy 1.2 vs 1.4?

2010-03-28 Thread W. eWatson
I wrote a program in Python 2.5 under Win7 and it runs fine using Numpy 
1.2 , but not on a colleague's machine who has a slightly newer 2.5 and 
uses NumPy 1.4. We both use IDLE to execute the program. During import 
he gets this:



Traceback (most recent call last):
  File C:\Documents and Settings\HP_Administrator.DavesDesktop\My 
Documents\Astro\Meteors\NC-FireballReport.py, line 38, in module

from scipy import stats as stats # scoreatpercentile
  File C:\Python25\lib\site-packages\scipy\stats\__init__.py, line 7, 
in module

from stats import *
  File C:\Python25\lib\site-packages\scipy\stats\stats.py, line 191, 
in module

import scipy.special as special
  File C:\Python25\lib\site-packages\scipy\special\__init__.py, line 
22, in module

from numpy.testing import NumpyTest
ImportError: cannot import name NumpyTest


Comments?

It looks as though the problem is in NumPy 1.4. If it's either in NumPy 
or SciPy, how does my colleague back out to an earlier version to agree 
with mine? Does he just pull down 1.3 or better 1.2 (I use it.), and 
install it? How does he somehow remove 1.4? Is it as easy as going to 
IDLE's path browser and removing, under site-packages, numpy? (I'm not 
sure that's even possible. I don't see a right-click menu.)

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


Re: Verifying My Troublesome Linkage Claim between Python and Win7

2010-03-01 Thread W. eWatson

On 2/23/2010 6:04 PM, Aahz wrote:

In articlehm0jn4$tn...@news.eternal-september.org,
W. eWatsonwolftra...@invalid.com  wrote:


My claim is that if one creates a program in a folder that reads a file
in the folder it and then copies it to another folder, it will read  the
data file in the first folder, and not a changed file in the new folder.
I'd appreciate it if some w7 users could try this, and let me know what
they find.

My experience is that if one checks the properties of the copied file,
it will point to the original py file and execute it and not the copy.


I've no time to verify your specific claim and have no readily available
proof for mine, but I've seen similar issues on Win7.  AFAIK, this has
nothing to do with Python.
I've been away for several days and have no idea if anyone above figured 
this out. Likely not,since your post is at the end.


Interesting about 'similar'. I'm pretty much done exploring every nook 
and cranny on this problem. It can be worked around. I will say that if 
I look at the properties of the copied file, it shows a shortcut tab 
that leads back to the original file. I have no recollection of making a 
shortcut, and always use Copy and Paste. Further, if I do create 
shortcut in W7, it adds -shortcut to the file suffix. I do not ever 
recall seeing that anywhere. I just tried it in XP, and it puts it in 
front of the name.

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


Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread W. eWatson
In the last day, I posted a message titled What's Going on between 
Python and win7? I'd appreciate it if someone could verify my claim. A 
sample program to do this is below. I'm using IDLE in Win7 with Py 2.5.


My claim is that if one creates a program in a folder that reads a file 
in the folder it and then copies it to another folder, it will read  the 
data file in the first folder, and not a changed file in the new folder. 
I'd appreciate it if some w7 users could try this, and let me know what 
they find.


My experience is that if one checks the properties of the copied file, 
it will point to the original py file and execute it and not the copy.



# Test program. Examine strange link in Python under Win7
# when copying py file to another folder.
# Call the program vefifywin7.py
# To verify my situation use IDLE, save and run this program there.
# Put this program into a folder along with a data file
# called verify.txt. Create a single text line with a few characters in it
# Run this program and note if the output
# Copy the program and txt file to another folder
# Change the contents of the txt file
# Run it again, and see if the output is the same as in the other folder
track_file = open(verify.txt)
aline = track_file.readline();
print aline
track_file.close()
--
http://mail.python.org/mailman/listinfo/python-list


Bay Area PUG Meeting Thursday in Mountain View, CA

2010-02-23 Thread W. eWatson
Anyone here going to the meeting,Subject? As far as I can tell, it meets 
from 7:30 to 9 pm. Their site shows no speaker yet, and there seems to 
be an informal group dinner at 6 pm at some place yet unknown. Comments?

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


Re: Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread W. eWatson

On 2/23/2010 8:26 AM, Rick Dooling wrote:

No telling what Windows will do. :)

I am a mere hobbyist programmer, but I think real programmers will
tell you that it is a bad habit to use relative paths. Use absolute
paths instead and remove all doubt.

http://docs.python.org/library/os.path.html

RD
You may be right. The actual 300 line program just reads the folder 
without specifying any path. I'm not that familiar with os path, but 
have seen it used.

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


Re: Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread W. eWatson

On 2/23/2010 11:14 AM, Gib Bogle wrote:

W. eWatson wrote:

On 2/23/2010 8:26 AM, Rick Dooling wrote:

No telling what Windows will do. :)

I am a mere hobbyist programmer, but I think real programmers will
tell you that it is a bad habit to use relative paths. Use absolute
paths instead and remove all doubt.

http://docs.python.org/library/os.path.html

RD

You may be right. The actual 300 line program just reads the folder
without specifying any path. I'm not that familiar with os path, but
have seen it used.


How do you invoke the program? Do you use a Command Prompt window?

IDLE, but I'm prett sure I tried it (300 lines) with Cprompt.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Bay Area PUG Meeting [Speaker] Thursday in Mountain View, CA?

2010-02-23 Thread W. eWatson

On 2/23/2010 7:49 AM, W. eWatson wrote:

Anyone here going to the meeting,Subject? As far as I can tell, it meets
from 7:30 to 9 pm. Their site shows no speaker yet, and there seems to
be an informal group dinner at 6 pm at some place yet unknown. Comments?


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


Re: Bay Area PUG Meeting Thursday in Mountain View, CA

2010-02-23 Thread W. eWatson

On 2/23/2010 2:50 PM, Aahz wrote:

In articlehm0tdp$la...@news.eternal-september.org,
W. eWatsonwolftra...@invalid.com  wrote:


Anyone here going to the meeting,Subject? As far as I can tell, it meets
from 7:30 to 9 pm. Their site shows no speaker yet, and there seems to
be an informal group dinner at 6 pm at some place yet unknown. Comments?


Subscribe to http://mail.python.org/mailman/listinfo/baypiggies


Thanks. I'd appreciate it if you tell me what topic is. I belong to too 
many mail lists. Thursday will be my first meeting. Perhaps I'll change 
my mind about ML after a meeting. Can you describe anything more than 
the topic? Do they have books, videos, tutorials (live), casual Q/A, 
person-to-person chat before the speaker?

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


Re: Bay Area PUG Meeting Thursday in Mountain View, CA

2010-02-23 Thread W. eWatson

On 2/23/2010 2:50 PM, Aahz wrote:

In articlehm0tdp$la...@news.eternal-september.org,
W. eWatsonwolftra...@invalid.com  wrote:


Anyone here going to the meeting,Subject? As far as I can tell, it meets
from 7:30 to 9 pm. Their site shows no speaker yet, and there seems to
be an informal group dinner at 6 pm at some place yet unknown. Comments?


Subscribe to http://mail.python.org/mailman/listinfo/baypiggies


Thanks. I'd appreciate it if you tell me what topic is. I belong to too 
many mail lists. Thursday will be my first meeting. Perhaps I'll change 
my mind about ML after a meeting. Can you describe anything more than 
the topic? Do they have books, videos, tutorials (live), casual Q/A, 
person-to-person chat before the speaker?

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


Re: The Disappearing Program? (py2exe, graphics)

2010-02-22 Thread W. eWatson
This apparently is not quite as easy as the py2exe tutorial suggests 
when MPL is involved. See http://www.py2exe.org/index.cgi/MatPlotLib. 
It looks like I have some reading and work to do.

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


What's Going on between Python and win7?

2010-02-22 Thread W. eWatson
Last night I copied a program from folder A to folder B. It inspects the 
contents of files in a folder. When I ran it in B, it gave the results 
for A! Out of frustration I changed the name in A, and fired up the 
program in B. Win7 went into search mode for the file. I looked at 
properties for the B program, and it was clearly pointing to folder A.


Anyone have this happen to them?

Another anomaly. I have the files track.py and trackstudy.py in the same 
folder along with 100 or so other py and txt data files. When I did a 
search from the folder window in the upper right corner, search only 
found one of the two. I called HP tech support about it, and they could 
see it for themselves via remote control. They had no idea, but agreed 
to  contact MS. In this case, I noted that this search box has some sort 
of filter associated with it. Possibly, in my early stages of learning 
to navigate in Win7, I accidentally set the filter.


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


Re: What's Going on between Python and win7?

2010-02-22 Thread W. eWatson

On 2/22/2010 8:29 AM, Grant Edwards wrote:

On 2010-02-22, W. eWatsonwolftra...@invalid.com  wrote:


Last night I copied a program from folder A to folder B.


[tail of various windows breakages elided]


Comments?


Switch to Linux?

Or at least install Cygwin?

Yes, definitely not related, but maybe some W7 user has a similar 
experience here. It seems a natural place to look, since it should be 
reasonably common.


I have Cygwin.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's Going on between Python and win7?

2010-02-22 Thread W. eWatson
So what's the bottom line? This link notion is completely at odds with 
XP, and produces what I would call something of a mess to the unwary 
Python/W7 user. Is there a simple solution?


How do I get out of this pickle? I just want to duplicate the  program 
in another folder, and not link to an ancestor.


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


Re: What's Going on between Python and win7?

2010-02-22 Thread W. eWatson

On 2/22/2010 6:39 PM, David Robinow wrote:

On Mon, Feb 22, 2010 at 8:25 PM, W. eWatsonwolftra...@invalid.com  wrote:

How do I get out of this pickle? I just want to duplicate the  program in
another folder, and not link to an ancestor.

Ask in an appropriate forum. I'm not sure where that is but you might
try http://www.sevenforums.com/

Not in my NG list.

If the way this is going is that it occurs on W7, not just in my case, 
then it will impact many Python users.

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


Re: What's Going on between Python and win7?

2010-02-22 Thread W. eWatson

On 2/22/2010 8:50 PM, Alf P. Steinbach wrote:

* W. eWatson:

So what's the bottom line? This link notion is completely at odds with
XP,


Well, Windows NT has always had *hardlinks*. g

I found it a bit baffling that that functionality is documented as not
implemented for Windows in the Python standard library.

But OK, it was non-trivial to do prior to Windows 2000; you had to sort
of hack it using the backup APIs since the functionality was not exposed
through the ordinary file APIs.




and produces what I would call something of a mess to the unwary
Python/W7 user. Is there a simple solution?

How do I get out of this pickle? I just want to duplicate the program
in another folder, and not link to an ancestor.


Copy and paste.


Cheers  hth.,

- Alf

I thought that's what I did. Is there some other way?
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's Going on between Python and win7?

2010-02-22 Thread W. eWatson

On 2/22/2010 8:50 PM, Alf P. Steinbach wrote:

* W. eWatson:

So what's the bottom line? This link notion is completely at odds with
XP,


Well, Windows NT has always had *hardlinks*. g

I found it a bit baffling that that functionality is documented as not
implemented for Windows in the Python standard library.

But OK, it was non-trivial to do prior to Windows 2000; you had to sort
of hack it using the backup APIs since the functionality was not exposed
through the ordinary file APIs.




and produces what I would call something of a mess to the unwary
Python/W7 user. Is there a simple solution?

How do I get out of this pickle? I just want to duplicate the program
in another folder, and not link to an ancestor.


Copy and paste.


Cheers  hth.,

- Alf

Alf? Hello,Norway. My wife is Norwegian and that was her father's name.

I thought that's what I did. Is there some other way?

Tusin Tak (That's about the size of my vocabulary and spelling ability! 
1000 thanks. What is the correct spelling?)

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


Re: What's Going on between (Verify) Python and win7?

2010-02-22 Thread W. eWatson

Maybe someone could verify my result?

open file
read file line
print line
close file

data 1234

Execute it in a folder

Create another folder and copy the program to it.
put in a new data file as

data 4567

Execute the copied program
Does it give
data1234?

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


The Disappearing Program?

2010-02-19 Thread W. eWatson
I've successfully compiled several small python programs on Win XP into 
executables using py2exe. A program goes from a name like snowball.py to 
snowball. A dir in the command prompt window finds snowball.py but not 
snowball. If I type in snowball, it executes. What's up with that?

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


Re: The Disappearing Program?

2010-02-19 Thread W. eWatson

On 2/19/2010 7:16 AM, Mark Lawrence wrote:

Andre Engels wrote:

On Fri, Feb 19, 2010 at 3:19 PM, Mark Lawrence
breamore...@yahoo.co.uk wrote:

Andre Engels wrote:

On Fri, Feb 19, 2010 at 12:20 PM, W. eWatson wolftra...@invalid.com

...
tories, or even the whole hard drive, for snowball.*. Then the OP

would know exactly what he has or hasn't got.

HTH.

Mark Lawrence


Here's the answer. Consider this folder.

Afolder
  abc.py
  hello.py

I now apply py2exe steps to produce an  executable for abc. The folder 
now changes to


Afolder
  build
  dist
  abc.py
  hello.py

build are two new folders. dist contains abc.exe.

Somehow when I type abc at the command prompt, this follows a path to 
dist, and finds abc.exe, where it executes properly.

Cute, eh? I have no explanation for it.

I have no idea what build is for, but dist contains a bunch of other 
files that possible apply to doing this with other files in the Afolder. 
hello.py maybe. The details seem to be shrouded. Possible a Google might 
provide a full explanation.

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


Re: The Disappearing Program?

2010-02-19 Thread W. eWatson

On 2/19/2010 10:56 AM, CM wrote:

On Feb 19, 12:21 pm, W. eWatsonwolftra...@invalid.com  wrote:

On 2/19/2010 7:16 AM, Mark Lawrence wrote:  Andre Engels wrote:

On Fri, Feb 19, 2010 at 3:19 PM, Mark Lawrence
breamore...@yahoo.co.uk  wrote:

Andre Engels wrote:

On Fri, Feb 19, 2010 at 12:20 PM, W. eWatsonwolftra...@invalid.com


...
tories, or even the whole hard drive, for snowball.*. Then the OP  would know 
exactly what he has or hasn't got.


HTH.



Mark Lawrence


Here's the answer. Consider this folder.

Afolder
abc.py
hello.py

I now apply py2exe steps to produce an  executable for abc. The folder
now changes to

Afolder
build
dist
abc.py
hello.py

build are two new folders. dist contains abc.exe.

Somehow when I type abc at the command prompt, this follows a path to
dist, and finds abc.exe, where it executes properly.
Cute, eh? I have no explanation for it.


Are you sure it's executing abc.exe?  If you are at a Python command
prompt within the DOS shell and you just type just abc, I think what
is happening is you are running abc.py, NOT abc.exe.

py2exe creates a dist folder (short for distributables) by default
and puts your .exe into it along with whatever other files are needed
to run your application.  Depending on how you set the bundling
options, this may be a lot of things or just 1-2 other things.

Che
Well, you are right. What proof do I have? In fact, I just tried to run 
a program that was not converted, and left off py. It worked.


So maybe the only way to execute the compiled code is to to to dist?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Updating Packages in 2.5 (win/numpy) and Related Matters (the latest)

2010-02-17 Thread W. eWatson

 On 17 February 2010 07:25,  josef.p...@gmail.com wrote:
  On Wed, Feb 17, 2010 at 12:10 AM, Wayne Watson
  sierra_mtnv...@sbcglobal.net wrote:
  Hi, I'm working on a 1800+ line program that uses tkinter. Here 
are the
  messages I started getting recently. (I finally figured out how 
to copy

  them.). The program goes merrily on its way despite them.
 
 
  s\sentusersentuser_20080716NoiseStudy7.py
  C:\Python25\lib\site-packages\scipy\misc\__init__.py:25:
  DeprecationWarning: Num
  pyTest will be removed in the next release; please update your 
code to

  use nose
  or unittest
test = NumpyTest().test
 
  DeprecationWarnings mean some some functionality in numpy (or scipy)
  has changed and the old way of doing things will be removed and be
  invalid in the next version.
 
  During depreciation the old code still works, but before you upgrade
  you might want to check whether and how much you use these functions
  and switch to the new behavior.
 
  In the case of numpy.test, it means that if you have tests written
  that use the numpy testing module, then you need to switch them to the
  new nose based numpy.testing. And you need to install nose for running
  numpy.test()
Wayne - The DeprecationWarnings are being raised by SciPy, not by your
code. You probably don't have a recent version of SciPy installed. The
most recent release of SciPy is 0.7.1 and works with NumPy 1.3.0. I
don't think you will see the warnings if you upgrade SciPy and NumPy
on your system.

Check your NumPy and SciPy versions at a python prompt as follows:

  import numpy as np
  print np.__version__
  import scipy as sp
  print sp.__version__
You will need to completely remove the old versions if you choose to
upgrade. You should be able to do this from Add/Remove Programs.

Cheers,
Scott
___
NumPy-Discussion mailing list
numpy-discuss...@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion



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


Re: Updating Packages in 2.5 (win/numpy) and Related Matters (the latest)

2010-02-17 Thread W. eWatson

 On 17 February 2010 07:25,  josef.p...@gmail.com wrote:
  On Wed, Feb 17, 2010 at 12:10 AM, Wayne Watson
  sierra_mtnv...@sbcglobal.net wrote:
  Hi, I'm working on a 1800+ line program that uses tkinter. Here 
are the
  messages I started getting recently. (I finally figured out how 
to copy

  them.). The program goes merrily on its way despite them.
 
 
  s\sentusersentuser_20080716NoiseStudy7.py
  C:\Python25\lib\site-packages\scipy\misc\__init__.py:25:
  DeprecationWarning: Num
  pyTest will be removed in the next release; please update your 
code to

  use nose
  or unittest
test = NumpyTest().test
 
  DeprecationWarnings mean some some functionality in numpy (or scipy)
  has changed and the old way of doing things will be removed and be
  invalid in the next version.
 
  During depreciation the old code still works, but before you upgrade
  you might want to check whether and how much you use these functions
  and switch to the new behavior.
 
  In the case of numpy.test, it means that if you have tests written
  that use the numpy testing module, then you need to switch them to the
  new nose based numpy.testing. And you need to install nose for running
  numpy.test()
Wayne - The DeprecationWarnings are being raised by SciPy, not by your
code. You probably don't have a recent version of SciPy installed. The
most recent release of SciPy is 0.7.1 and works with NumPy 1.3.0. I
don't think you will see the warnings if you upgrade SciPy and NumPy
on your system.

Check your NumPy and SciPy versions at a python prompt as follows:

  import numpy as np
  print np.__version__
  import scipy as sp
  print sp.__version__
You will need to completely remove the old versions if you choose to
upgrade. You should be able to do this from Add/Remove Programs.

Cheers,
Scott
___
NumPy-Discussion mailing list
numpy-discuss...@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion



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


Re: Updating Packages in 2.5 (win/numpy) and Related Matters (the latest)

2010-02-17 Thread W. eWatson
Had trouble posting this to the same thread above. Request above to 
provide response from numpy mail list.


 On 17 February 2010 07:25,  josef.p...@gmail.com wrote:
  On Wed, Feb 17, 2010 at 12:10 AM, Wayne Watson
  sierra_mtnv...@sbcglobal.net wrote:
  Hi, I'm working on a 1800+ line program that uses tkinter. Here 
are the
  messages I started getting recently. (I finally figured out how 
to copy

  them.). The program goes merrily on its way despite them.
 
 
  s\sentusersentuser_20080716NoiseStudy7.py
  C:\Python25\lib\site-packages\scipy\misc\__init__.py:25:
  DeprecationWarning: Num
  pyTest will be removed in the next release; please update your 
code to

  use nose
  or unittest
test = NumpyTest().test
 
  DeprecationWarnings mean some some functionality in numpy (or scipy)
  has changed and the old way of doing things will be removed and be
  invalid in the next version.
 
  During depreciation the old code still works, but before you upgrade
  you might want to check whether and how much you use these functions
  and switch to the new behavior.
 
  In the case of numpy.test, it means that if you have tests written
  that use the numpy testing module, then you need to switch them to the
  new nose based numpy.testing. And you need to install nose for running
  numpy.test()
Wayne - The DeprecationWarnings are being raised by SciPy, not by your
code. You probably don't have a recent version of SciPy installed. The
most recent release of SciPy is 0.7.1 and works with NumPy 1.3.0. I
don't think you will see the warnings if you upgrade SciPy and NumPy
on your system.

Check your NumPy and SciPy versions at a python prompt as follows:

  import numpy as np
  print np.__version__
  import scipy as sp
  print sp.__version__
You will need to completely remove the old versions if you choose to
upgrade. You should be able to do this from Add/Remove Programs.

Cheers,
Scott
___
NumPy-Discussion mailing list
numpy-discuss...@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion



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


Re: Wrestling with the Py2exe Install, Win7, Py2.5

2010-02-17 Thread W. eWatson

On 2/17/2010 3:44 AM, mk wrote:

W. eWatson wrote:


P.S. I didn't really use PyInstaller on Windows, though -- just on
Linux, where it works beautifully.

Regards,
mk

Well,Ive made some progress with a py2exe tutorial. It starts with the 
short hello world! program. But something stumbled right away in 
setup.py. I'm on a mail list to sort this out.

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


Updating Packages in 2.5 (win/numpy) and Related Matters

2010-02-16 Thread W. eWatson
I normally use IDLE on Win, but recently needed to go to command prompt 
to see all error messages. When I did, I was greeted by a host of 
deprecation and Numpy messages before things got running. The program 
otherwise functioned OK, after I found the problem I was after. Are 
these messages a warning to get to the next update of numpy?


I would guess that updating to a higher update does not mean I need to 
remove the old one, correct?


In general for libraries like numpy or scipy, I use win32 updates, but I 
see win32-p3 updates too on download pages. Since I may be distributing 
this program to p3 machines, will I need to provide the win32-p3 updates 
to those users?


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


Re: Is there a simple way to find the list index to the max value?

2010-02-16 Thread W. eWatson

On 2/16/2010 4:41 AM, Arnaud Delobelle wrote:

Arnaud Delobellearno...@googlemail.com  writes:


W. eWatsonwolftra...@invalid.com  writes:


See Subject. a = [1,4,9,3]. Find max, 9, then index to it, 2.


Here are a few ways.


[...]

My copy past went wrond and I forgot the first one:


a = [1,4,9,3]
max_index = a.index(max(a))
max_index

2


Ah, the good one for last! Thanks.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Updating Packages in 2.5 (win/numpy) and Related Matters

2010-02-16 Thread W. eWatson

On 2/16/2010 7:30 AM, Robert Kern wrote:

On 2010-02-16 06:16 AM, W. eWatson wrote:

I normally use IDLE on Win, but recently needed to go to command prompt
to see all error messages. When I did, I was greeted by a host of
deprecation and Numpy messages before things got running. The program
otherwise functioned OK, after I found the problem I was after. Are
these messages a warning to get to the next update of numpy?

I would guess that updating to a higher update does not mean I need to
remove the old one, correct?

In general for libraries like numpy or scipy, I use win32 updates, but I
see win32-p3 updates too on download pages. Since I may be distributing
this program to p3 machines, will I need to provide the win32-p3 updates
to those users?


You will definitely want to ask these questions on the numpy-discussion
mailing list. They are numpy-specific. Please copy-and-paste the
messages that you get.

http://www.scipy.org/Mailing_Lists

Good idea, for the first part of this. I would think In genera for ... 
would be answerable here, but I'll give them both a shot.


I'll post what I find here, as a follow up.
--
http://mail.python.org/mailman/listinfo/python-list


Wrestling with the Py2exe Install, Win7, Py2.5

2010-02-16 Thread W. eWatson
I've finally decided to see if I could make an executable out of a py 
file. Win7. Py2.5. I brought down the install file and proceeded with 
the install. I got two warning messages. Forgot the first. The second 
said,Could not set the key value. I again used OK. I think that was 
the only choice. It then issued a message in a larger dialog. It was 
about setting a key, and pointed me to a log. It mentions a Removepy2exe -u


Although it finished, I have no idea where the program is. It does not 
show up on the Start menu All Programs List nore my desktop. What's up?


I've had these messages (key) occur on other Python installs as I 
transition to Win7. So far no problem.


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


Is there a simple way to find the list index to the max value?

2010-02-16 Thread W. eWatson

See Subject. a = [1,4,9,3]. Find max, 9, then index to it, 2.
--
http://mail.python.org/mailman/listinfo/python-list


Looking for a Compiled Demo of MPL (matplotlib) Graphics

2010-02-15 Thread W. eWatson
Does anyone know where I can find a compiled demo that uses MPL 
graphics? I'd like, if possible, a Win version whose size is less than 
10M, so that I can send it via e-mail, if necessary. It should use plot, 
so that someone can manipulate the plot with the navigation controls. At 
this point, I have no idea if that method is the fundamental graph tool 
or not. I suspect it is.


If a mailable demo isn't available, maybe there's a web site that one 
can download such examples from?

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


Re: Tangling with mathplotlib(MPL) on XP and Win7 -- show() stopper

2010-02-10 Thread W. eWatson
Solved. I need to get into the interactive mode. Never heard of it until 
this morning.


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


Re: Socket Error: Permission Denied (Firewall)

2010-02-09 Thread W. eWatson

(corrected typos)
I decided to go with outbound in McAfee. Now when I run the program, I 
get a long list of messages about deprecations and  NumpyTest will be 
removed in the next release. please update code to nose or unittest.


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


Re: Socket Error: Permission Denied

2010-02-09 Thread W. eWatson
I decided to go with outbound. Now when I run the program, I get a long 
of messabge about deprecations and  NumpyTest will be removed in the 
next release. please update code to nose or unittest.


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


Socket Error: Permission Denied

2010-02-08 Thread W. eWatson
I'm using IDLE with winxp. It seems every day I get into the Subject 
above. Usually, after 5-8 minutes I get past it. A msg appearing at the 
same time say, IDLE's subprocess didn't make connect. ... possible 
firewall problem.


A resource for this is http://bugs.python.org/issue6941. There a 
number of choices. Perhaps the most appealing is:


adgprogramming: first, bring up your task manager and make sure there
are no python processes running.  2.6.x subprocesses can get stuck.
Then make sure that your firewall isn't blocking socket access to
localhost.  Then restart IDLE.  IDLE 3.1.1 may work for you since it
has the recent enhancement that allows multiple copies of IDLE to run
simultaneously, but it still needs interprocess access via sockets.

How would I know the which Python processes or subprocesses are running? 
I can kill the main one, but that seems to do no good.

pythonw.exe.

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


Re: Socket Error: Permission Denied

2010-02-08 Thread W. eWatson

On 2/8/2010 7:24 PM, W. eWatson wrote:

I'm using IDLE with winxp. It seems every day I get into the Subject
above. Usually, after 5-8 minutes I get past it. A msg appearing at the
same time say, IDLE's subprocess didn't make connect. ... possible
firewall problem.

A resource for this is http://bugs.python.org/issue6941. There a
number of choices. Perhaps the most appealing is:

adgprogramming: first, bring up your task manager and make sure there
are no python processes running. 2.6.x subprocesses can get stuck.
Then make sure that your firewall isn't blocking socket access to
localhost. Then restart IDLE. IDLE 3.1.1 may work for you since it
has the recent enhancement that allows multiple copies of IDLE to run
simultaneously, but it still needs interprocess access via sockets.

How would I know the which Python processes or subprocesses are running?
I can kill the main one, but that seems to do no good.
pythonw.exe.

Comments?
I'm using McAffee. I see it was pythonw.exe blocked in red. There are 
several choices: Allow Access, Allow Outboubnd only

Block (current), Remove Prgrm permission, Learn More.

Outbound only seem reasonable, but why does the blocking keep returning 
every many hours, or maybe when I reboot, which I've done several times 
today?

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


Tangling with mathplotlib(MPL) on XP and Win7 -- show() stopper

2010-02-08 Thread W. eWatson
I'm doing most of this on a win7 machine. When I installed MPL, I had 
two small dialogs appear that said something was missing, but I pressed 
on. MPL seemed to generally work except for the show() problem. When it 
was to be executed to show the output of plot(x,y), it did just that; 
however, the shell window hung, and I had to upper right corner x my way 
out of it--2 to 3 steps. The plot window and program easily went the 
same way. IDLE is the tool of choice on both machines.


I'm in the process of bringing programs from my XP to the win7 machine, 
and on the XP machine I decided to start using MPL with a 900 line Py 
program that I'm revising. I had gotten stuck with the very same problem 
there. However, last night I realized someone had added a MPL plot to it 
years ago, and it does not fail on show().  I've put print stmts after 
show() in the big program, but nothing is printed in either case when I 
close the plot window. Tried in IDLE and executing from clicking on the 
py file in its folder.


I brought some of this up on the MPL mailing list, and one respondent 
said he had tried some of the examples with show(), and they had worked.


I noticed the dialog msgs mentioned above, and thought I made a mistake 
in not installing numpy first, so tried to figure out a way to do it. 
Three posts on different forums did not provide an answer. I 
accidentally found the author of MPL's hidden away in one of MPL files. 
He said it didn't make a difference and asked me not to use his address. 
I though the warning msgs might be of interest to him, so wrote to him. 
He had blocked me. Perhaps I need to file a bug report to get his 
attention on that.




Anyway, I'm now stalled on the development of the big program. It's 
possible this is an IDLE problem, but I ran the big program with a click 
on the file, and the black window showed the same problem. This is all 
on XP Pro.


I'm going to copy the two code segments here. Maybe someone can see a 
difference.


=OLD working code
 def light_curve( self ):
 result = []
 test = 1
 for tup in self.subimages:
 left,top,subimage = tup
 total = 0
 avg_total = 0
 if (test == 1):
 box = (left, top, left+128, top+128)
 region = self.reference_image.crop(box)
 self.reference_image.paste(subimage, box)
 test = 2
 else:
 for x in range(left+43,left+82):
 for y in range(top+43, top+82):
 avg_total = avg_total + 
self.reference_image.getpixel((x, y))
 for x in range(43,82): #take the center 40 X 40 pixel 
block

 for y in range(43,82):
 v = subimage.getpixel((x, y))
 total = total + v
 #for x in range(left, left+127):
 #for y in range(top, top+127):
 #avg_total = avg_total + 
self.reference_image.getpixel((x, y))

 #for x in range(0, 127):
 #for y in range(0, 127):
 #total = total + subimage.getpixel((x, y))
 result.append(total - avg_total) #(average - 
background average) gives pixel intensity above the background)

 plotting_x = range(2, len(result)+2)
 plot(plotting_x, result)
 xlabel('Frame #')
 ylabel('Pixel count above background count')
 title('Light curve for selected subplot')
 show()

===New Code with show problem
 def get_point_trail_stats(self): # Simple track statistics
 xy = array(self.xya)[:,0:2]  # creates a two column array for x,y
 pt2pt_dist = []
 pt_dist = []
 for k in arange(0,len(xy)-1):
 distance = sqrt((xy[k+1,0]-xy[k,0])**2 + 
(xy[k+1,1]-xy[k,1])**2)

 pt_dist.append(distance)
 # wtw print k ,k, (xy[k,0], xy[k,1]),  distance: , 
distance

 # wtwfor k in arange(0, len(xy)-50):
 # wtwprint k: %3i dist: %6.2f (x,y) (%4.1f,%4.1f) % (k, 
pt_dist[k], xy[k,0], xy[k,1])

 per_tile25 = stats.scoreatpercentile(pt_dist,25.0)
 per_tile50 = stats.scoreatpercentile(pt_dist,50.0)
 per_tile75 = stats.scoreatpercentile(pt_dist,75.0)
 mean   = stats.mean(pt_dist)
 std= stats.std(pt_dist)
 #sys.exit()
 amin   = min(pt_dist)
 amax   = max(pt_dist)
 printmean: %7.2f std: %7.2f min: %7.2f max: %7.2f % 
(mean, std, amin, amax)
 printquartiles (25-per: %7.2f, 50-per: %7.2f, 75-per: 
%7.2f):  % (per_tile25, per_tile50, per_tile75)

 #printExtended stats
 #printmin: %7.2f max: %7.2f mean: %7.2f std: %7.2f % \
 #(min, max, mean, std)
 #printp25: %7.2f p50: %7.2f p75: %7.2f % (per_tile25, 
per_tile50, 

How Uninstall MatPlotLib?

2010-02-06 Thread W. eWatson

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


Drawing a zig-zag Trail in Python?

2010-02-05 Thread W. eWatson
I'd like to draw something like an animal track. Between each point is a 
line. Perhaps the line would have an arrow showing the direction of 
motion. There should be x-y coordinates axises. PIL? MatPlotLib, ??

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


Re: How Uninstall MatPlotLib?

2010-02-05 Thread W. eWatson

On 2/5/2010 8:17 AM, W. eWatson wrote:

See Subject.
I'm working in IDLE in Win7. It seems to me it gets stuck in 
site-packages under C:\Python25. Maybe this is as simple as deleting the 
entry?


Well, yes there's a MPL folder under site-packages and an info MPL file 
of 540 bytes. There  are  also pylab.py, pyc,and py0 files under site.

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


Re: Drawing a zig-zag Trail in Python?

2010-02-05 Thread W. eWatson

On 2/5/2010 9:30 AM, Grant Edwards wrote:

On 2010-02-05, W. eWatsonwolftra...@invalid.com  wrote:


I'd like to draw something like an animal track. Between each
point is a line. Perhaps the line would have an arrow showing
the direction of motion. There should be x-y coordinates
axises. PIL? MatPlotLib, ??


I'd probably use gnuplot-py, but I'm probably biased since I've
been using gnuplot since way before I learned Python.

It appears this is easier than I thought. MLB's plot will do it. I can 
put arrows at the end of a line, and even use sleep to watch the path 
slowly evolving.

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


Exiting a Program Running in Idle, Various Choices

2010-02-04 Thread W. eWatson
I I have a  very simple program running in Python, with say the last 
line print bye. it finishes leaving the script showing  in the 
shell window. The program proceeds linearly to the bottom line.


Suppose now I have instead a few lines of MatPlotLib code (MPL) like 
this at the end:


...
Show()

Show displays some graph and again the code proceeds linearly from line 
1. However, if one closes the graphic by clicking the x in the upper 
right corner of that window, then no  appears in the shell, and one 
must kill the shell using the x in the shell's upper right corner. A 
little dialog with the choices of OK (kill) or cancel appears. Use OK 
and the shell window disappears. A ctrl-c does nothing in the shell.


I know about sys.exit(),and a finish def when using Tkinter. I'm not 
using Tkinter as far as I know via MPL.


So how does one exit smoothly in this case of Show(), so that the shell 
window remains ready to entry commands?

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


What's the Scoop on \\ for Paths? (Win)

2010-01-31 Thread W. eWatson
I'm sure that \\ is used in some way for paths in Win Python, but I have 
not found anything after quite a search. I even have a six page pdf on a 
file tutorial. Nothing. Two books. Nothing. When I try to open a file 
along do I need, for example, Events\\record\\year\\today? Are paths 
like, .\\Events allowed, or am I mixing up my Linux memory on this?

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


Re: What's the Scoop on \\ for Paths? (Win)

2010-01-31 Thread W. eWatson

Alf P. Steinbach wrote:

* W. eWatson:
I'm sure that \\ is used in some way for paths in Win Python, but I 
have not found anything after quite a search. I even have a six page 
pdf on a file tutorial. Nothing. Two books. Nothing. When I try to 
open a file along do I need, for example, 
Events\\record\\year\\today? Are paths like, .\\Events allowed, or 
am I mixing up my Linux memory on this?


The Python issue with \\ is that in a literal string \\ denotes a single 
\ character, like


   print( back\\slash )
  back\slash
   _

This is just like in other languages with syntax inherited from C. Look 
up escape sequences. It has nothing to do with files and paths per se, 
but means that you cannot write e.g. c:\windows\system32, but must 
write something like c:\\windows\\system32 (try to print that string), 
or, since Windows handles forward slashes as well, you can write 
c:/windows/system32 :-).


The Window issue with \\ is that \\ as a path prefix denotes an UNC 
(Universal Naming Convention) path. Usually that would be a LAN or WAN 
network path, but it can also denote a printer or a pipe or a mailslot 
or just about anything. Using UNC paths opens the door to creating files 
and directories that other programs won't be able to handle, so Just Say 
No(TM), if you can.



Cheers  hth.,

- Alf

Ah, yes. Thanks for the memory jog.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the Scoop on \\ for Paths? (Win)

2010-01-31 Thread W. eWatson

Steve Holden wrote:


You need to read up on string literals is all. \\ is simply the
literal representation of a string containing a single backslash. This
comes about because string literals are allowed to contain special
escape sequences which are introduced by a backslash; since this gives
the backslash a special meaning in string literals we also have to use
an escape sequence (\\) to represent a backslash.

In practice you will find that

a) Many Windows APIs (but not the command line) are just as happy with a
forward slash as a backslash to separate file path components; and

b) The best practice is to build filenames using the routines provided
in the os.path module, which guarantees to give results correct for the
current platform.

regards
 Steve

Basic sys functions brought out the \ separator for paths.

What am I missing here? Looks OK to me.


 abc=r'xyz\\'
 abc
'xyz'
 print abc
xyz\\
 abc.replace(r'\',r'z')

SyntaxError: invalid syntax
 abc
'xyz'
--
http://mail.python.org/mailman/listinfo/python-list


py2exe and pydocs. Downloads?

2010-01-17 Thread W. eWatson
I'm using Python 2.5 under windows, and IDLE. Do py2exe and pydocs come 
with the package, or do I have to download them?

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


Changing Lutz's mydir from Edition 2, Learning Python

2010-01-17 Thread W. eWatson
See Subject. The code is below with a few changes I made at the bottom 
by inserting

import string
import numpy

module = raw_input(Enter module name: )
listing(module)

I thought I'd see if I could convert this to a program instead, which 
asks the user for the module.


As prompt entry, it was meant to do this, for example:

import math
import pynum
mydir.listing(numpy)

As below, it fails with:


Is it possible to get this to work?
Enter module name: numpy
--
name:
Traceback (most recent call last):
  File 
C:/Sandia_Meteors/Sentinel_Development/Learn_Python/mydir_pgm.py, line 
31, in module

listing(module)
  File 
C:/Sandia_Meteors/Sentinel_Development/Learn_Python/mydir_pgm.py, line 
8, in listing

print name:, module.__name__, file:, module.__file__
AttributeError: 'str' object has no attribute '__name__
mydir start===
# a module that lists the namespaces of other modules

verbose = 1

def listing(module):
if verbose:
print -*30
print name:, module.__name__, file:, module.__file__
print -*30

count = 0
for attr in module.__dict__.keys():  # scan namespace
print %02d) %s % (count, attr),
if attr[0:2] == __:
print built-in name  # skip __file__, etc.
else:
print getattr(module, attr)  # same as .__dict__[attr]
count = count+1

if verbose:
print -*30
print module.__name__, has %d names % count
print -*30

if __name__ == __main__:
import mydir
import string
import numpy

module = raw_input(Enter module name: )
listing(module)
#listing(mydir)  # self-test code: list myself
===end==
--
http://mail.python.org/mailman/listinfo/python-list


Re: Changing Lutz's mydir from Edition 2, Learning Python

2010-01-17 Thread W. eWatson

Chris Rebert wrote:

On Sun, Jan 17, 2010 at 12:11 PM, W. eWatson wolftra...@invalid.com wrote:

See Subject. The code is below with a few changes I made at the bottom by
inserting
   import string
   import numpy

   module = raw_input(Enter module name: )
   listing(module)


As the error says, strings have no __name__ attribute; from this, one
can infer that listing() expects a module object, not a string which
is the name of a module.

Try instead:
module = __import__(raw_input(Enter module name: ))
listing(module)

Cheers,
Chris
--
http://blog.rebertia.com


I thought I'd see if I could convert this to a program instead, which asks
the user for the module.


...



 File C:/Sandia_Meteors/Sentinel_Development/Learn_Python/mydir_pgm.py,
line 31, in module
   listing(module)
 File C:/Sandia_Meteors/Sentinel_Development/Learn_Python/mydir_pgm.py,
line 8, in listing
   print name:, module.__name__, file:, module.__file__
AttributeError: 'str' object has no attribute '__name__

Very cool. Thanks to both of you.
--
http://mail.python.org/mailman/listinfo/python-list


IDLE Namespace Toolbox? Windows.

2010-01-17 Thread W. eWatson
This is a follow up to my post Changing Lutz's mydir.  It would seem 
there should be some sort of toolbox that allows one to do things like 
mydir, and perhaps a lot more. Maybe something like it exists in Linux. 
I'm a Windows user. I've found it a bit aggravating that using dir and 
help, for example, that the output just rolls on off the screen and I 
have to play around with the shell scroll bars to find what I'm looking 
for. A few simple changes to mydir should change that, but I would hope 
or think maybe there are even more tools to generally help.

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


Re: py2exe and pydocs. Downloads?

2010-01-17 Thread W. eWatson

Gabriel Genellina wrote:
En Sun, 17 Jan 2010 15:16:17 -0300, W. eWatson wolftra...@invalid.com 
escribió:


I'm using Python 2.5 under windows, and IDLE. Do py2exe and pydocs 
come with the package, or do I have to download them?


py2exe has to be downloaded from www.py2exe.org
I don't know pydocs, but pydoc comes with Python

Thanks. I'll look at the link. Actually, I was close 
http://www.py2exe.org/index.cgi/Tutorial, but no banana (cigar).  Yep, 
right on your link, download from source forge.


According to Lutz's 4th edition (reading from Amazon), Pydoc is shipped 
with Python. I found this earlier in the Python Help under Global Index 
for modules.

==
The pydoc module automatically generates documentation from Python 
modules. The documentation can be presented as pages of text on the 
console, served to a Web browser, or saved to HTML files.


The built-in function help() invokes the online help system in the 
interactive interpreter, which uses pydoc to generate its documentation 
as text on the console. The same text documentation can also be viewed 
from outside the Python interpreter by running pydoc as a script at the 
operating system's command prompt. For example, running



pydoc sys

at a shell prompt
=
I get:
 import pydoc
 pydoc sys
SyntaxError: invalid syntax

The book says Help uses it, and there's some sort of html version, but 
I'm missing something here. Command line, Linux shell?

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


Re: IDLE Namespace Toolbox? Windows.

2010-01-17 Thread W. eWatson

John Bokma wrote:

W. eWatson wolftra...@invalid.com writes:


This is a follow up to my post Changing Lutz's mydir.  It would seem
there should be some sort of toolbox that allows one to do things like
mydir, and perhaps a lot more. Maybe something like it exists in
Linux. I'm a Windows user. I've found it a bit aggravating that using
dir and help, for example, that the output just rolls on off the
screen and I have to play around with the shell scroll bars to find
what I'm looking for. A few simple changes to mydir should change
that, but I would hope or think maybe there are even more tools to
generally help.


on the command prompt:

cmd | more

works 


Apparently, not in IDLE under Win.
 dir() | more
Traceback (most recent call last):
  File pyshell#42, line 1, in module
dir() | more
NameError: name 'more' is not defined
--
http://mail.python.org/mailman/listinfo/python-list


Re: chr(12) Form Feed in Notepad (Windows)

2010-01-16 Thread W. eWatson

D'Arcy J.M. Cain wrote:

On Fri, 15 Jan 2010 20:17:35 -0800
W. eWatson wolftra...@invalid.com wrote:
Could be, but I have no way of easily knowing. In any case, I was trying 
to write a simple report that could be printed with titles at the top of 
each page. If there's another common format that I can write in to 
produce the file, that's fine. It may be this is so difficult to be 
impossible. Long, long ago this was no problem. :-)


Why not generate a PostScript or PDF file in the first place?  Check
out reportlab.



New Courier and NotePad produces a good looking result.

I'm trying to keep this effort to a minimum. I don't think tracking down 
how to write PP code PDF code is worth for this effort.


In another related effort that I might get involved in, it would be good 
to be able to produce graphical data as from MatPlotLib and be able to 
print that to a printer directly from a Python program.

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


chr(12) Form Feed in Notepad

2010-01-15 Thread W. eWatson
I thought I'd put a page break, chr(12), character in a txt file I wrote 
to skip to the top of the page. It doesn't work. Comments?

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


Re: chr(12) Form Feed in Notepad

2010-01-15 Thread W. eWatson

Grant Edwards wrote:

On 2010-01-15, W. eWatson wolftra...@invalid.com wrote:


I thought I'd put a page break, chr(12), character in a txt
file I wrote to skip to the top of the page. It doesn't work.
Comments?


Yes, it does work.

Apparently not with with my Brother 1440 laser printer. The character in 
NotePad.txt looks like a small rectangle, and on the printed page. Same 
result HP C6180 Photosmart.

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


Re: chr(12) Form Feed in Notepad (Windows)

2010-01-15 Thread W. eWatson

Tim Chase wrote:

W. eWatson wrote:

Grant Edwards wrote:

On 2010-01-15, W. eWatson wolftra...@invalid.com wrote:


I thought I'd put a page break, chr(12), character in a txt
file I wrote to skip to the top of the page. It doesn't work.
Comments?

Yes, it does work.

Apparently not with with my Brother 1440 laser printer. The character 
in NotePad.txt looks like a small rectangle, and on the printed page. 
Same result HP C6180 Photosmart.


But are you sending the raw control codes to the printer, or are you 
sending the image-of-my-text-document to a printer-GDI which then 
renders the as-you-see-it out of the printer?


The pseudo-pipeline comparison would be

  type file.txt  lpt1:

which would send the raw text file to the printer (assuming it's set up 
on LPT1, otherwise, use whatever port it's attached to in your printer 
control panel); or are you using something like


  notepad file.txt
  File - Print

which renders to an internal image representation and then sends that 
image out to the printer.  If it were a dot-matrix printer, you'd 
here/see the difference in a jiffy -- the raw dump is fast and uses the 
printer's built-in fonts while the render-as-image is slow and NOISY.


One alternative is possibly to set up the Generic Text printer as a 
device type and attach it to the same port; I've had fair fortune with 
this letting me control the printer more directly if I want fast dumps 
(particularly on dot-matrix printers) rather than pretty dumps.


-tkc



I should mention I'm using Windows. I just put chr(12) right in the txt. 
It's the first character in the next line of the txt file where I want 
to page forward. Not acquainted with GDI. Maybe I need some sequence of 
such characters?

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


Re: chr(12) Form Feed in Notepad (Windows)

2010-01-15 Thread W. eWatson

Tim Chase wrote:

W. eWatson wrote:

Tim Chase wrote:

The pseudo-pipeline comparison would be

  type file.txt  lpt1:

which would send the raw text file to the printer (assuming it's set 
up on LPT1, otherwise, use whatever port it's attached to in your 
printer control panel); or are you using something like


  notepad file.txt
  File - Print


I should mention I'm using Windows. I just put chr(12) right in the 
txt. It's the first character in the next line of the txt file where I 
want to page forward. Not acquainted with GDI. Maybe I need some 
sequence of such characters?


It's not a matter of you controlling the GDI stuff.  Unless you're 
writing directly to the printer device, printing on Windows is done 
(whether by Notepad, gvim, Word, Excel, whatever) into a graphical 
representation which is then shipped off to the printer.  So if you're 
printing from Notepad, it's going to print what you see (the little 
square), because Notepad renders to this graphical representation to 
print.  If you send the file *directly* to the printer device (bypassing 
the Win32 printing layer), it will send the ^L directly and should eject 
a new page on most printers.


-tkc


I am writing a txt file. It's up to the user to print it using Notepad 
or some other tool.  I have no idea how to send it directly to the 
printer, but I really don't want to furnish that capability in the 
program. From Google, The Graphics Device Interface (GDI).

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


Re: chr(12) Form Feed in Notepad (Windows)

2010-01-15 Thread W. eWatson

Mensanator wrote:

On Jan 15, 6:40 pm, W. eWatson wolftra...@invalid.com wrote:

Tim Chase wrote:

W. eWatson wrote:

Tim Chase wrote:

...

program. From Google, The Graphics Device Interface (GDI).


Have you considered the possibility that your printer can't print
raw text files? I had one that would ONLY print Postscript. Embedding
a chr(12) would accomplish nothing, you HAD to use a driver that
would translate chr(12) into the appropriate Postcript codes.

What you're doing MIGHT work for others with different printers.


Could be, but I have no way of easily knowing. In any case, I was trying 
to write a simple report that could be printed with titles at the top of 
each page. If there's another common format that I can write in to 
produce the file, that's fine. It may be this is so difficult to be 
impossible. Long, long ago this was no problem. :-)


I suppose I could copy the txt file into wordpad, and print it there.
--
http://mail.python.org/mailman/listinfo/python-list


Re: chr(12) Form Feed in Notepad (Windows)

2010-01-15 Thread W. eWatson

Neil Hodgson wrote:

W. eWatson wrote:


I am writing a txt file. It's up to the user to print it using Notepad
or some other tool.  


   WordPad will interpret chr(12) as you want.

   Neil


That may be the solution. Just tell the end user to copy the file into 
it, and print it there.


I just tried it in Wordpad, and it works, but my --- underlines are 
pushed together. Maybe tabs instead of spaces. The columns past Seq # in 
WordPad may suffer from the characters not being fixed width. Well, a 
little work with WordPad might be enough for users to get it right. 
Copy txt file into wordpad. Select all the text, and set format to 
fixed (if that's possible.).


Here's what a txt sample looks like. It has line wrap here, and the page 
feed


Date/Time Station UTC  Seq # Frames Time Span Pix 
Dst Pix/Sec
--- -- ---  - -- - 
--- ---
2008/11/12 17:38:58 WW 2008/11/13 01:38:58  1   Noise data.  Short 
track.
2008/11/12 17:39:24 WW 2008/11/13 01:39:24  2   Noise data.  Short 
track.



  -PAGE FEED
Date/Time Station UTC  Seq # Frames Time Span Pix 
Dst Pix/Sec
--- -- ---  - -- - 
--- ---
2008/11/17 22:29:54 WW 2008/11/18 06:29:54 21   Noise data.  Short 
track.
2008/11/18 01:51:36 WW 2008/11/18 09:51:36 22   Noise data.  Short 
track.
2008/11/18 04:05:03 WW 2008/11/18 12:05:03 23   Noise data.  Short 
track.
2008/11/18 17:40:42 WW 2008/11/19 01:40:42 2495  3.17 
48.17   15.21

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


Re: Fractional Hours from datetime?

2010-01-12 Thread W. eWatson

Ben Finney wrote:

Alf P. Steinbach al...@start.no writes:


And considering this, and the fact that Google's archive is now the
main Usenet archive, message id's are not that useful, really.


You've demonstrated only that Google is an unreliable Usenet archive.

One doesn't even need to use Usenet, in this case, since
comp.lang.python is a forum distributed both as a Usenet forum and a
mailing-list forum.


Good Clarke quote. (Not present here.)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread W. eWatson

Austyn wrote:

Here's an improvement in case you want your code to work outside of
Arizona:

from time import time, timezone
h = ((time() - timezone) / 3600) % 24

On Jan 10, 9:04 pm, Austyn aus...@gmail.com wrote:

How about:

import time
arizona_utc_offset = -7.00
h = (time.time() / 3600 + arizona_utc_offset) % 24

dt.timetuple()[6] is the day of the week; struct tm_time doesn't
include a sub-second field.

On Jan 10, 10:28 am, W. eWatson wolftra...@invalid.com wrote:




Maybe there's a more elegant way to do this. I want to express the
result of datetime.datetime.now() in fractional hours.
Here's one way.
dt=datetime.datetime.now()
xtup = dt.timetuple()
h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6
#  now is in fractions of an hour


There seems to be some controversy about this and other matters of 
datetime. 
http://blog.twinapex.fi/2008/06/30/relativity-of-time-shortcomings-in-python-datetime-and-workaround/

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


Re: Fractional Hours from datetime?

2010-01-11 Thread W. eWatson

Martin P. Hellwig wrote:

Martin P. Hellwig wrote:

W. eWatson wrote:
Maybe there's a more elegant way to do this. I want to express the 
result of datetime.datetime.now() in fractional hours.


Here's one way.

dt=datetime.datetime.now()
xtup = dt.timetuple()
h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6
#  now is in fractions of an hour


Here is another (though personally I don't find this more elegant than 
yours, perhaps a bit more readable):


  now = datetime.datetime.now()
  fractional_hour = int(now.strftime('%H')) + 
int(now.strftime('%M')) / 60.0



Actually my version is overcomplicated:
  now = datetime.datetime.now()
  fractional_hour = now.hour + now.minute / 60.0


See my post about the datetime controversy about 3-4 posts up from yours.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread W. eWatson

Martin P. Hellwig wrote:

Martin P. Hellwig wrote:

W. eWatson wrote:
Maybe there's a more elegant way to do this. I want to express the 
result of datetime.datetime.now() in fractional hours.


Here's one way.

dt=datetime.datetime.now()
xtup = dt.timetuple()
h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6
#  now is in fractions of an hour


Here is another (though personally I don't find this more elegant than 
yours, perhaps a bit more readable):


  now = datetime.datetime.now()
  fractional_hour = int(now.strftime('%H')) + 
int(now.strftime('%M')) / 60.0



Actually my version is overcomplicated:
  now = datetime.datetime.now()
  fractional_hour = now.hour + now.minute / 60.0


See my post about the datetime controversy about 3-4 posts up from yours.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread W. eWatson

Ben Finney wrote:

W. eWatson wolftra...@invalid.com writes:


See my post about the datetime controversy about 3-4 posts up from
yours.


This forum is distributed, and there's no “up” or “3-4 messages” that is
common for all readers.

Could you give the Message-ID for that message?

Sort of like outer space I guess. No real direction. How would I find 
the message ID?


It's easier to place the comment here:

There seems to be some controversy about this and other matters of 
datetime. 
http://blog.twinapex.fi/2008/06/30/relativity-of-time-shortcomings-in-python-datetime-and-workaround/

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


Fractional Hours from datetime?

2010-01-10 Thread W. eWatson
Maybe there's a more elegant way to do this. I want to express the 
result of datetime.datetime.now() in fractional hours.


Here's one way.

dt=datetime.datetime.now()
xtup = dt.timetuple()
h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6
#  now is in fractions of an hour
--
http://mail.python.org/mailman/listinfo/python-list


Astronomy--Programs to Compute Siderial Time?

2010-01-06 Thread W. eWatson
Is there a smallish Python library of basic astronomical functions? 
There are a number of large such libraries that are crammed with 
excessive functions not needed for common calculations.

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


Re: Astronomy--Programs to Compute Siderial Time?

2010-01-06 Thread W. eWatson

W. eWatson wrote:
Is there a smallish Python library of basic astronomical functions? 
There are a number of large such libraries that are crammed with 
excessive functions not needed for common calculations.
It looks like I've entered a new era in my knowledge of Python. I found 
a module somewhat like I want, siderial.py. You can see an intro to it 
at http://infohost.nmt.edu/tcc/help/lang/python/examples/sidereal/ims//.
It appears that I can get the code for it through section 1.2, near the 
bottom. I scooped it siderial.py up, and placed it in a corresponding 
file of the same name and type via NotePad. However, there is a xml file 
below it. I know little about it. I thought maybe I could do the same, 
but Notepad didn't like some characters in it. As I understand Python 
doc files are useful. So how do I get this done, and where do I put the 
files?

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


Re: Astronomy--Programs to Compute Siderial Time?

2010-01-06 Thread W. eWatson

Roy Smith wrote:

In article hi2o39$hm...@news.eternal-september.org,
 W. eWatson wolftra...@invalid.com wrote:

Is there a smallish Python library of basic astronomical functions? 
There are a number of large such libraries that are crammed with 
excessive functions not needed for common calculations.


FWIW, if you have any interest in this kind of stuff, you must read the 
classic book on the subject:


http://www.amazon.com/Astronomical-Formulae-Calculators-Jean-Meeus/dp/094339
6220

This is not some textbook which takes graduate level physics to understand.  
It's a straight-forward primer for people who want to use calculators to 
compute phase of the moon and stuff like that.
Thanks, but I'm quite familiar with it. My copy is some 10-15 years old. 
 I suspect he never wrote a newer edition for any computer language. I 
do have access to a C++ library, but I don't think that's going to do me 
much good with Python.


My problem at the moment is finding either someone who has implemented 
it or another similar module.


Note I posted just before you that I have found a siderial.py module, 
but am not familiar with how one installs them or the doc mechanism.

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


Re: Astronomy--Programs to Compute Siderial Time?

2010-01-06 Thread W. eWatson

John Machin wrote:

On Jan 7, 11:40 am, W. eWatson wolftra...@invalid.com wrote:

W. eWatson wrote:

Is there a smallish Python library of basic astronomical functions?
There are a number of large such libraries that are crammed with
excessive functions not needed for common calculations.

It looks like I've entered a new era in my knowledge of Python.


Mild curiosity: this would be a wonderful outcome, but what makes it
look so?
I actually need to learn how to make a module that can be imported, 
which in the short interlude I have done. Also looked into docstrings 
and docs, which I now have a decent grasp of. Never really used either 
doc info or writing my own module before. Easy.



I found
a module somewhat like I want, siderial.py. You can see an intro to it
at http://infohost.nmt.edu/tcc/help/lang/python/examples/sidereal/ims//.
It appears that I can get the code for it through section 1.2, near the
bottom. I scooped it siderial.py up, and placed it in a corresponding
file of the same name and type via NotePad. However, there is a xml file
below it. I know little about it. I thought maybe I could do the same,
but Notepad didn't like some characters in it. As I understand Python
doc files are useful. So how do I get this done, and where do I put the
files?


The file you need is sidereal.py, not your twice-mentioned siderial.py
(the existence of which on the referenced website is doubtful).
How right you are. I misspelled it twice, and quickly found that out 
when I tried to use the [side][real] (easy mnemonic, two words) module. 
sidereal.


What you have been reading is the Internal maintenance
specification (large font, near the top of the page) for the module.
The xml file is the source of the docs, not meant to be user-legible.

What is it used for? Do I need it?

A very tiny amount of googling sidereal.py (quotes included) leads
to the user documentation at 
http://infohost.nmt.edu/tcc/help/lang/python/examples/sidereal/

Found that too as I cruised around.


Where do you put the files? Well, we're now down to only one file,
sidereal.py, and you put it wherever you'd put any other module that
you'd like to call ... if there's only going to be one caller, put it
in the same directory as that caller's code. More generally, drop it
in YOUR_PYTHON_INSTALL_DIR/Lib/site-packages
Again in my learning about modules, discovered that too. I think I'm 
on my way. Thanks.

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


Potential Conflicts by Installing Two Versions of Python (Windows)?

2010-01-01 Thread W. eWatson
I suspect that if one installs v2.4 and 2.5, or any two versions, that 
one will dominate, or there will be a conflict.  I suppose it would not 
be possible to choose which one should be used. Comments?

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


mod, modulo and % under 2.4 and 2.5

2009-12-31 Thread W. eWatson
About a year ago, I wrote a program that used mod() for modulo under 
2.5. Apparently, % is also acceptable, but the program works quite well. 
I turned the program over to someone who is using 2.4, and apparently 
2.4 knows nothing about mod(). Out of curiosity, what library is 
mod(a,b)(two args) in? It doesn't seem to be in numpy. It seems to be 
built-in. If so, why isn't it both 2.4 and 2.5?

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


Re: mod, modulo and % under 2.4 and 2.5

2009-12-31 Thread W. eWatson

Steven D'Aprano wrote:

On Thu, 31 Dec 2009 17:30:20 -0800, W. eWatson wrote:


About a year ago, I wrote a program that used mod() for modulo under
2.5. Apparently, % is also acceptable, but the program works quite well.
I turned the program over to someone who is using 2.4, and apparently
2.4 knows nothing about mod(). Out of curiosity, what library is
mod(a,b)(two args) in? It doesn't seem to be in numpy. It seems to be
built-in.


No it doesn't.

[st...@sylar ~]$ python2.5
Python 2.5 (r25:51908, Nov  6 2007, 16:54:01)
[GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2
Type help, copyright, credits or license for more information.

mod

Traceback (most recent call last):
  File stdin, line 1, in module
NameError: name 'mod' is not defined



So where is it? Here are the choices.
import sys, os, glob
import string
from numpy import *
from datetime import datetime, timedelta
import time

In the 2.4 version, I change nmnpy to Numeric
--
http://mail.python.org/mailman/listinfo/python-list


Re: mod, modulo and % under 2.4 and 2.5

2009-12-31 Thread W. eWatson

Ben Finney wrote:

W. eWatson wolftra...@invalid.com writes:


Steven D'Aprano wrote:

NameError: name 'mod' is not defined



So where is it? Here are the choices.
import sys, os, glob
import string
from numpy import *


If you use ‘from foo import *’ you forfeit any way of saying where a
name in your code gets bound.

Hence, don't do that.


Good idea!
--
http://mail.python.org/mailman/listinfo/python-list


DST and datetime

2009-12-30 Thread W. eWatson

Try this. It works for me and my application.

=Program
from datetime import datetime, timedelta
import time

DST_dict = { # West coast, 8 hours from Greenwich for PST
 2007:(2007/03/11 02:00:00, 2007/11/04 02:00:00),
 2008:(2008/03/09 02:00:00, 2008/11/02 02:00:00),
 2009:(2009/03/08 02:00:00, 2009/11/01 02:00:00),
 2010:(2010/03/14 02:00:00, 2010/11/07 02:00:00)}

def adjust_DST(DT_stamp, spring, fall):
# /mm/dd hh:mm:ss in,
print Date: , DT_stamp
format = '%Y/%m/%d %H:%M:%S'
dt = datetime(*(time.strptime(DT_stamp, format)[0:6])) # get six tuple
dspring = datetime(*(time.strptime(spring, format)[0:6]))
dfall   = datetime(*(time.strptime(fall, format)[0:6]))
if ((dt = dspring) and (dt = dfall)):
printadjustment
adj = timedelta(seconds = 3600)
dt = dt + adj
else:
printno adjustment
format = '%Y/%m/%d %H:%M:%S'
return dt.strftime(format)

print DST Adjustment
print + adjust_DST(2007/03/28 12:45:10, \
2007/03/11 02:00:00, 2007/11/04 02:00:00 )
print + adjust_DST(2009/11/26 20:35:15, \
2007/03/11 02:00:00, 2007/11/04 02:00:00 )

===Results==
ST Adjustment
Date:  2007/03/28 12:45:10
   adjustment
   2007/03/28 13:45:10
Date:  2009/11/26 20:35:15
   no adjustment
   2009/11/26 20:35:15
--
http://mail.python.org/mailman/listinfo/python-list


Re: Difference Between Two datetimes

2009-12-29 Thread W. eWatson

This is quirky.

 t1=datetime.datetime.strptime(20091205_221100,%Y%m%d_%H%M%S)
 t1
datetime.datetime(2009, 12, 5, 22, 11)
 type(t1)
type 'datetime.datetime'

t1:  2009-12-05 22:11:00 type 'datetime.datetime'

but in the program:
   import datetime

   t1=datetime.datetime.strptime(20091205_221100,%Y%m%d_%H%M%S)
   print t1: ,t1, type(t1)

produces
t1:  2009-12-05 22:11:00 type 'datetime.datetime'

Where did the hyphens and colons come from?

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


Re: Difference Between Two datetimes

2009-12-29 Thread W. eWatson

Peter Otten wrote:

W. eWatson wrote:


This is quirky.

  t1=datetime.datetime.strptime(20091205_221100,%Y%m%d_%H%M%S)
  t1
datetime.datetime(2009, 12, 5, 22, 11)
  type(t1)
type 'datetime.datetime'
 
t1:  2009-12-05 22:11:00 type 'datetime.datetime'

but in the program:
import datetime

t1=datetime.datetime.strptime(20091205_221100,%Y%m%d_%H%M%S)
print t1: ,t1, type(t1)

produces
t1:  2009-12-05 22:11:00 type 'datetime.datetime'

Where did the hyphens and colons come from?


print some_object

first converts some_object to a string invoking str(some_object) which in 
turn calls the some_object.__str__() method. The resulting string is then 
written to stdout. Quoting the documentation:


datetime.__str__()
For a datetime instance d, str(d) is equivalent to d.isoformat(' ').

datetime.isoformat([sep])
Return a string representing the date and time in ISO 8601 format, 
-MM-DDTHH:MM:SS.mm or, if microsecond is 0, -MM-DDTHH:MM:SS


Peter
So as long as I don't print it, it's datetime.datetime and I can make 
calculations or perform operations on it as though it is not a string, 
but a datetime object?

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


Re: Windows, IDLE, __doc_, other

2009-12-29 Thread W. eWatson

Lie Ryan wrote:

On 12/29/2009 5:10 AM, W. eWatson wrote:

Lie Ryan wrote:

If you're on Windows, don't use the Edit with IDLE right-click
hotkey since that starts IDLE without subprocess. Use the shortcut
installed in your Start menu.

When I go to Start and select IDLE, Saves or Opens want to go into
C:/Python25. I have to motor over to my folder where I keep the source
code. The code is in a folder about 4 levels below the top. That's a bit
awkward.

Is there a way to go directly to the folder I normally work in?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Difference Between Two datetimes

2009-12-28 Thread W. eWatson

BTW, all times are local to my city. Same time zone.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Difference Between Two datetimes

2009-12-28 Thread W. eWatson

Lie Ryan wrote:

On 12/28/2009 5:42 PM, W. eWatson wrote:

You're right. Y. Works fine. The produces datetime.datetime(2009, 1, 2,
13, 1, 15).
If I now use
t2=datetime.datetime.strptime(2009/01/04 13:01:15,%Y/%m/%d %H:%M:%S)
I get tw as
datetime.datetime(2009, 1, 4, 13, 1, 15)
Then t2-t1 gives,
datetime.timedelta(2)
which is a 2 day difference--I guess. Strange.


what's strange about it? the difference between 2009/01/02 13:01:15 and 
2009/01/04 13:01:15 is indeed 2 days... Can you elaborate what do you 
mean by 'strange'?
Easily. In one case, it produces a one argument funcion, and the other 
2, possibly even a year if that differs. How does one unload this 
structure to get the seconds and days?



Changing
t2=datetime.datetime.strptime(2009/01/04 14:00:30,%Y/%m/%d %H:%M:%S)
and differencing gives me,
datetime.timedelta(2, 3555), which seems to indicate a 2 day and 3555
second difference. Interesting, but I think there must be another way to
do this. Maybe not.


to do... what?

To find the difference more clearly. Why not just return (0,2,3555)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Difference Between Two datetimes

2009-12-28 Thread W. eWatson

Roy Smith wrote:

In article hh9k6g$pk...@news.eternal-september.org,
 W. eWatson wolftra...@invalid.com wrote:


BTW, all times are local to my city. Same time zone.


Yes, but how much time has elapsed between 2009/0/04 13:01:15 and 
2009/06/04 13:01:15?  Even if I tell you that both timestamps were done 
in the same city, you don't have enough information.


Hint #1: The answer in Sydney, Bangalore, and New York are all different.

Hint #2: Two of those cities are in temperate zones, and one is in the 
tropics.


Hint #3: If you don't pay attention to this, you will be bitten twice a 
year.
Sort of the opposite of a stopped clock. It's right twice a day. How 
does one solve the DST problem?

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


Re: Windows, IDLE, __doc_, other

2009-12-28 Thread W. eWatson


It the IDLE shell, it's not possible to retrieve lines entered earlier 
without copying them. Is there an edit facility?


I suggest you download a programmers' editor (like Notepad++ or PsPad) 
for programming work and use the basic Python interpreter for 
interactive work. The basic interpreter lives in a standard Window 
console window where you can use up and down arrow keys, F8 completion, 
F7 for list of earlier commands, etc (as documented by the doskey 
command in the Windows command interpreter). Just forget IDLE in 
windows: while Windows console windows are something from the middle 
ages, IDLE seems to stem from a period before that! g



Cheers  hth.,

- Alf

PS: Shameless plug: take a look at url: 
http://tinyurl.com/programmingbookP3, it's for Windows.


I just downloaded the three files. It looks useful. I take it you are 
the author?

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


Re: Windows, IDLE, __doc_, other

2009-12-28 Thread W. eWatson

Lie Ryan wrote:

On 12/22/2009 12:06 PM, W. eWatson wrote:

...

You must be starting IDLE without subprocess. Did you see this message

IDLE 2.6.1   No Subprocess 

when starting IDLE.
Yes, I usually start in a folder where I have my py program files, and 
do a right-click for IDLE edit.


If you're on Windows, don't use the Edit with IDLE right-click hotkey 
since that starts IDLE without subprocess. Use the shortcut installed in 
your Start menu.
When I go to Start and select IDLE, Saves or Opens want to go into 
C:/Python25. I have to motor over to my folder where I keep the source 
code. The code is in a folder about 4 levels below the top. That's a bit 
awkward.

What do subprocesses mean in this context? Why do I need them?




line: a = 1. I choose Run Module, and it runs it. I verify in the
interactive interpreter that a is 1. I then change that file to a = a
+ 1, and run it. Now, it errors out-- of course-- because IDLE
cleared the namespace and re-ran the module.

Hmmm, that appears to contrary to my numpy experience. I've never seen
any re-starting msg.
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on win32
Type copyright, credits or license() for more information.


That is irrelevant with numpy. If you start IDLE with subprocess, then 
every time before you run a script this message appears:


  = RESTART =

PS: you can force IDLE to restart the subprocess with Ctrl+F6


It says in the interpreter its restarting, even.


When IDLE is not run with subprocess, running a script is equivalent to 
copy and pasteing the script to the shell.
I just tried Ctrl+F6 on both the shell and script window. Nothing 
happened. Does that occur only if I fired up Python from Start?

Does a restart clear out the namespace?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Difference Between Two datetimes

2009-12-28 Thread W. eWatson

D'Arcy J.M. Cain wrote:

On Mon, 28 Dec 2009 08:20:28 -0800
W. eWatson wolftra...@invalid.com wrote:
Sort of the opposite of a stopped clock. It's right twice a day. How 
does one solve the DST problem?


Depends on which DST problem you have.  There is more than one solution
depending on what the problem is.  Store and compare in UTC and display
in local time is one solution but it may not be yours.

Actually, UTC is quite relevant here. I would guess there is some way to 
use datetime for UTC?

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


Re: Difference Between Two datetimes

2009-12-28 Thread W. eWatson

Ben Finney wrote:

W. eWatson wolftra...@invalid.com writes:


Lie Ryan wrote:

what's strange about it? the difference between 2009/01/02 13:01:15
and 2009/01/04 13:01:15 is indeed 2 days... Can you elaborate what
do you mean by 'strange'?



Easily. In one case, it produces a one argument funcion, and the other
2, possibly even a year if that differs.


In both cases it produces not a function, but a ‘datetime.timedelta’
object::

 import datetime
 t1 = datetime.datetime(2009, 1, 2, 13, 1, 15)
 t2 = datetime.datetime(2009, 1, 4, 13, 1, 15)
 type(t1)
type 'datetime.datetime'
 type(t2)
type 'datetime.datetime'

 dt = (t2 - t1)
 type(dt)
type 'datetime.timedelta'

What you're seeing in the interactive interpreter is a string
representation of the object::

 dt
datetime.timedelta(2)

This is no different from what's going on with any other string
representation. The representation is not the value.


How does one unload this structure to get the seconds and days?


It's customary to consult the documentation for questions like that
URL:http://docs.python.org/library/datetime.html#datetime.timedelta.


To find the difference more clearly. Why not just return (0,2,3555)


Because the ‘datetime.timedelta’ type is more flexible than a tuple, and
has named attributes as documented at the above URL::

 dt.days
2
 dt.seconds
0
 dt.microseconds
0

Well, it just seems weird to me. g. I'm modestly familiar with 
objects, but this seems like doing the following.


Suppose we have a module called trigonometry, trig for short. It 
contains lots of trig functions, and sort of uses the same concepts as 
datetime. Bear with me on that. Here's my imagined interpretive session:


 import trig
 c=trig.sin(90.0) # arg is in degrees
 print c
trig.cos(1.0)
 type(c)
type 'trig'
 value = c.value
 print value
1.0
I'd call that weird. Maybe in this case it is ... g

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


Re: Difference Between Two datetimes

2009-12-28 Thread W. eWatson

Steven D'Aprano wrote:

On Mon, 28 Dec 2009 23:50:30 +1100, Ben Finney wrote:


How does one unload this structure to get the seconds and days?

It's customary to consult the documentation for questions like that
URL:http://docs.python.org/library/datetime.html#datetime.timedelta.


No no no, it's customary to annoy everyone on the list by asking the 
question *without* consulting the documentation, and then to be told to 
Read The Fine Manual.


To be serious for a moment, if you're in the interactive interpreter, you 
can get some useful information by calling help(datetime.timedelta).


Yes, thanks. I'm starting to catch on to the idea there are tools like 
dir, help, doc sources, and ___dcc__ that can help. It doesn't seem to 
be standard practice to more or less teach the environment that Python 
is in. If they do, it's jumbled around. Most books start with Python 
itself and skirt the issues of the environment and interaction. Oddly, 
today I found a source that gets right into these concepts. It may have 
something to do with MIT. Here's a link to one of the three section of 
the reference 
http://docs.google.com/leaf?id=0B2oiI2reHOh4ZTFkY2ZmYzktZTVkZS00M2E1LTgwNDUtYWRjZTE1Nzc2ZDYzsort=namelayout=listpid=0B2oiI2reHOh4ZGVmNjk3MjgtZmY5YS00ZWQxLThkNWMtZmJkMmU1MWM1OTcxcindex=2. 



BTW, I had looked at some Python doc that seems to be apart from the 
reference above. So I'm not entirely remiss on this. I do look first. 
However, on the other hand, regarding the reference, 29 pages is a bit 
steep for any document.

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


Difference Between Two datetimes

2009-12-27 Thread W. eWatson

According to one web source, this program:

import datetime
bree = datetime.datetime(1981, 6, 16, 4, 35, 25)
nat  = datetime.datetime(1973, 1, 18, 3, 45, 50)

difference = bree - nat
print There were, difference, minutes between Nat and Bree

yields:
There were 3071 days, 0:49:35 minutes between Nat and Bree

That's fine, but I'd like to start with two dates as strings, as
1961/06/16 04:35:25 and 1973/01/18 03:45:50

How do I get the strings into a shape that will accommodate a difference?

For example,
t1=datetime.datetime.strptime(2009/01/02 13:01:15,%y/%m/%d %H:%M:%S)
doesn't do it.
ValueError: time data did not match format:  data=2009/01/02 13:01:15 
fmt=%y/%m/%d %H:%M:%S

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


Re: Difference Between Two datetimes

2009-12-27 Thread W. eWatson
You're right. Y. Works fine. The produces datetime.datetime(2009, 1, 2, 
13, 1, 15).

If I now use
t2=datetime.datetime.strptime(2009/01/04 13:01:15,%Y/%m/%d %H:%M:%S)
I get tw as
datetime.datetime(2009, 1, 4, 13, 1, 15)
Then t2-t1 gives,
datetime.timedelta(2)
which is a 2 day difference--I guess. Strange.
Changing
t2=datetime.datetime.strptime(2009/01/04 14:00:30,%Y/%m/%d %H:%M:%S)
and differencing gives me,
datetime.timedelta(2, 3555), which seems to indicate a 2 day and 3555 
second difference. Interesting, but I think there must be another way to 
do this. Maybe not.


Roy Smith wrote:

In article hh9dmv$f9...@news.eternal-september.org,
 W. eWatson wolftra...@invalid.com wrote:


t1=datetime.datetime.strptime(2009/01/02 13:01:15,%y/%m/%d %H:%M:%S)
doesn't do it.
ValueError: time data did not match format:  data=2009/01/02 13:01:15 
fmt=%y/%m/%d %H:%M:%S


The first thing that jumps out at me is that %y is the two-digit year.  You 
want %Y for 4-digit year.


One thing to keep in mind is that 2009/01/02 13:01:15 is ambiguous 
without a time zone.  Even if you assume that both timestamps were from the 
same location, you need to know what daylight savings rules that location 
uses, to do this right.

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


Re: Difference Between Two datetimes

2009-12-27 Thread W. eWatson

Ben Finney wrote:

W. eWatson wolftra...@invalid.com writes:


How do I get the strings into a shape that will accommodate a difference?

For example,
t1=datetime.datetime.strptime(2009/01/02 13:01:15,%y/%m/%d %H:%M:%S)
doesn't do it.
ValueError: time data did not match format:  data=2009/01/02 13:01:15
fmt=%y/%m/%d %H:%M:%S


As the error message indicates, the data input (the string) doesn't
match the specified format.

See the time format specifications at the ‘time.strftime’ documentation
URL:http://docs.python.org/library/time.html#time.strftime. Note
especially that ‘%y’ and ‘%Y’ are distinct.


Yes, see my response to the post above yours.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Windows, IDLE, __doc_, other

2009-12-21 Thread W. eWatson

Lie Ryan wrote:

On 12/21/2009 1:19 PM, W. eWatson wrote:

When I use numpy.__doc__ in IDLE under Win XP, I get a heap of words 
without reasonable line breaks.


\nNumPy\n=\n\nProvides\n  1. An array object of arbitrary 
homogeneous items\n  2. Fast mathematical operations over arrays\n  3. 
Linear Algebra, Fourier Transforms, Random Number



Is there a way to get this formated properly.


help(object)



If I use dir(numpy), I get yet a very long list that starts as:
['ALLOW_THREADS', 'BUFSIZE', 'CLIP', 'DataSource', 'ERR_CALL', 
'ERR_DEFAULT', 'ERR_DEFAULT2', 'ERR_IGNORE', 'ERR_LOG', 'ERR_PRINT', 
'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT', 'FPE_DIVIDEBYZERO', 
'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'False_', 'Inf', 
'Infinity', 'MAXDIMS', 'MachAr', 'NAN', 'NINF', 'NZERO', 'NaN', 
'PINF', 'PZERO', 'PackageLoader', 'RAISE', 'RankWarning', 
'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID', 'SHIFT_OVERFLOW', 
'SHIFT_UNDERFLOW', 'ScalarType', 'Tester', 'True_', 
'UFUNC_BUFSIZE_DEFAULT'


I see this might be a dictionary. What can I do to make it more 
readable or useful, or is that it? Is there a more abc as in Linux?


You can use pprint module:

import pprint
pprint.pprint(dir(object))

though help() is usually better

It the IDLE shell, it's not possible to retrieve lines entered earlier 
without copying them. Is there an edit facility?


Press Alt+P (Previous) and Alt+N (Next). Or you can click/select on the 
line you want to copy and press Enter.



Add to this. Isn't there a way to see the arguments and descriptions of
functions?


Use help(). Or if you're doing this without human intervention, use 
`inspect` module.
Wow, did I get a bad result. I hit Ctrl-P, I think instead of Alt-P, and 
a little window came up showing it was about to print hundreds of pages. 
 I can canceled it, but too late. I turned off my printer quickly and 
eventually stopped the onslaught.


I couldn't get Alt-P or N to work.

Another question. In interactive mode, how does one know what modules 
are active? Is there a way to list them with a simple command?

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


Re: Live Video Capture using Python

2009-12-21 Thread W. eWatson

David Lyon wrote:

Also try..

http://www.unixuser.org/~euske/python/vnc2flv/index.html

On Mon, 21 Dec 2009 11:15:32 +0530, Banibrata Dutta
banibrata.du...@gmail.com wrote:

Have you searched the archives of this list ? I remember seeing a related
discussion 5-6 months back.

On Mon, Dec 21, 2009 at 2:35 AM, aditya shukla
adityashukla1...@gmail.comwrote:


Hello Guys,

I am trying to capture images from a live broadcast of a cricket match
or
say any video using python. I can see the video in the browser.My aim is
to
capture the video at any moment and create an images.Searching on google
turns up  http://videocapture.sourceforge.net/ .I am not sure if this
would be help here.I would appreciate if someone points me in the right
direction.


Thanks

Aditya

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


I somehow clipped the posts above this thread, so am not sure what 
prompted this thread. Is there an open source set of modules to do all this?

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


Re: Windows, IDLE, __doc_, other

2009-12-21 Thread W. eWatson

Lie Ryan wrote:

On 12/22/2009 6:39 AM, W. eWatson wrote:

Wow, did I get a bad result. I hit Ctrl-P, I think instead of Alt-P, and
a little window came up showing it was about to print hundreds of pages.
I can canceled it, but too late. I turned off my printer quickly and
eventually stopped the onslaught.

I couldn't get Alt-P or N to work.

Another question. In interactive mode, how does one know what modules
are active? Is there a way to list them with a simple command?


What do you mean by active? All loaded modules, whether it is in your 
namespace or not? Then sys.modules.
Else if you want all names in your namespace, dir() would do, though 
it'll show other things as well.
Let's forget active. Isn't it true that math is automatically available 
to every module? From help(math):


Help on built-in module math:

NAME
math

FILE
(built-in)

DESCRIPTION
This module is always available.  It provides access to the
mathematical functions defined by the C standard.
=
So why do I need math.cos(...)? This is got to be some namespace issue.

Maybe the help is incorrect. I have:
 dir(__builtins__)
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 
'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 
'Exception', 'False', 'FloatingPointError', 'FutureWarning', 
'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 
'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 
'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', 
'NotImplementedError', 'OSError', 'OverflowError', 
'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', 
'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 
'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True', 
'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 
'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 
'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 
'WindowsError', 'ZeroDivisionError', '_', '__debug__', '__doc__', 
'__import__', '__name__', 'abs', 'all', 'any', 'apply', 'basestring', 
'bool', 'buffer', 'callable', 'chr', 'classmethod', 'cmp', 'coerce', 
'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 
'divmod', 'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 
'float', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 
'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 
'iter', 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min', 
'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range', 
'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round', 'set', 
'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 
'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip']

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


Re: Windows, IDLE, __doc_, other

2009-12-21 Thread W. eWatson

Stephen Hansen wrote:

On Mon, Dec 21, 2009 at 1:51 PM, W. eWatson wolftra...@invalid.com wrote:

Lie Ryan wrote:

On 12/22/2009 6:39 AM, W. eWatson wrote:

Wow, did I get a bad result. I hit Ctrl-P, I think instead of Alt-P, and




No, its not true. A built-in module does not mean its available
everywhere. It means its built into Python itself-- e.g., its directly
linked into the python dll and not a separate file (like most of the
the standard library).

Lots of modules are built-in, but they don't pollute the __builtins__
/ universal namespace. You import them to access them. If you want you
can from math import * if you want the math module to fill out your
module namespace (I don't recommend *'s personally, its better to
import symbols explicitly by name)

--S
This has got to be some sort of IDLE issue then. When I run a simple 
program. If I open this program in the IDLE editor:

#import math
print hello, math world.
print cos(0.5)
print sin(0.8)

then I get
print cos(0.5)
NameError: name 'cos' is not defined

OK,  dir()
['__builtins__', '__doc__', '__file__', '__name__', 'idlelib']

Fine. I now change the code to include import mat get the same:
print cos(0.5)
NameError: name 'cos' is not defined

Now,  dir()
['__builtins__', '__doc__', '__file__', '__name__', 'idlelib', 'math']

math is now available. so I change cos(0.5) to math.cos(0.5) and get
print sin(0.8)
NameError: name 'sin' is not defined
Fine, it needs math.
dir() is the same.

Now, I go to the script and enter
from math import *
dir is now bulked up with the math functions. I change back math.cos to 
cos and the program runs well.


This sort of figures. Apparently, I've added to the namespace by 
importing with *.


My point is that I'm betting different results. OK, fine. It appears the 
same thing happens with I modify the program itself with from math import *


So IDLE is not clearing the namespace each time I *run* the program. 
This is not good. I've been fooled. So how do I either clear the 
namespace before each Run? Do I have to open the file in the editor 
again each time before trying to Run it? I hope there's a better way.


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


Re: Windows, IDLE, __doc_, other

2009-12-21 Thread W. eWatson

Stephen Hansen wrote:

On Mon, Dec 21, 2009 at 2:57 PM, W. eWatson wolftra...@invalid.com wrote:

This has got to be some sort of IDLE issue then.


Huh? How do you figure?


When I run a simple
program. If I open this program in the IDLE editor:
#import math
print hello, math world.
print cos(0.5)
print sin(0.8)

then I get
   print cos(0.5)
NameError: name 'cos' is not defined


Of course, because -- cos is not defined. As I stated in my previous
email, math has to be imported to be used.

Yes, I agree.



OK,  dir()
['__builtins__', '__doc__', '__file__', '__name__', 'idlelib']

Fine. I now change the code to include import mat get the same:
   print cos(0.5)
NameError: name 'cos' is not defined


Yes, because cos is inside math.

True enough. Hang in there.


[snip

Now, I go to the script and enter
from math import *
dir is now bulked up with the math functions. I change back math.cos to cos
and the program runs well.

This sort of figures. Apparently, I've added to the namespace by importing
with *.


Apparently? -- you precisely and explicitly added every object in
'math' to your current namespace. from math import * does precisely
that.
Well, it's a big surprise to me, because I thought each time I ran from 
the editor that it reloaded the modules in my imports, and cleared out 
any it didn't find.



My point is that I'm betting different results. OK, fine. It appears the
same thing happens with I modify the program itself with from math import *


Different results? What different results are you talking about?
It seems to me as I fool around with interpreter under the script 
window, Im creating a mess out of the namespace the program uses, and 
the program responds incorrectly.


If you want to access 'sin' without 'math.', you'll have to do 'from
math import *' in each file where you want to do that.


So IDLE is not clearing the namespace each time I *run* the program. This is
not good. I've been fooled. So how do I either clear the namespace before
each Run? Do I have to open the file in the editor again each time before
trying to Run it? I hope there's a better way.


How do you figure its 'not clearing the namespace'? In which
namespace? I fire up IDLE, and start a new file, and put in a single

Try this sequence.
I just started plugging away again with IDLE and am pretty convinced
that IDLE is something of an enemy. I started afresh loading this into
the editor:

import math
print hello, math world.
print math.cos(0.5)
print math.sin(0.8)


Run works fine. No errors. Now I do:
  dir()
['__builtins__', '__doc__', '__file__', '__name__', 'idlelib', 'math']
 
OK, swell. Now I import via the script window
  import numpy as np
  dir()
['__builtins__', '__doc__', '__file__', '__name__', 'idlelib', 'math', 'np']

I think I'm adding to the namespace, both the program the shell sees,
because adding this ref to np in the program works fine.

import math
print hello, math world.
print math.cos(0.5)
print math.sin(0.8)
print np.sin(2.2)  ---

There's no np in that code, but yet it works. It must be in the 
namespace it sees, and it was put there through the interactive shell.



line: a = 1. I choose Run Module, and it runs it. I verify in the
interactive interpreter that a is 1. I then change that file to a = a
+ 1, and run it. Now, it errors out-- of course-- because IDLE
cleared the namespace and re-ran the module.
Hmmm, that appears to contrary to my numpy experience. I've never seen 
any re-starting msg.
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit 
(Intel)] on win32

Type copyright, credits or license() for more information.


It says in the interpreter its restarting, even.

--S

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


Windows, IDLE, __doc_, other

2009-12-20 Thread W. eWatson
When I use numpy.__doc__ in IDLE under Win XP, I get a heap of words 
without reasonable line breaks.


\nNumPy\n=\n\nProvides\n  1. An array object of arbitrary 
homogeneous items\n  2. Fast mathematical operations over arrays\n  3. 
Linear Algebra, Fourier Transforms, Random Number

...

Is there a way to get this formated properly.

If I use dir(numpy), I get yet a very long list that starts as:
['ALLOW_THREADS', 'BUFSIZE', 'CLIP', 'DataSource', 'ERR_CALL', 
'ERR_DEFAULT', 'ERR_DEFAULT2', 'ERR_IGNORE', 'ERR_LOG', 'ERR_PRINT', 
'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT', 'FPE_DIVIDEBYZERO', 
'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'False_', 'Inf', 
'Infinity', 'MAXDIMS', 'MachAr', 'NAN', 'NINF', 'NZERO', 'NaN', 'PINF', 
'PZERO', 'PackageLoader', 'RAISE', 'RankWarning', 'SHIFT_DIVIDEBYZERO', 
'SHIFT_INVALID', 'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'ScalarType', 
'Tester', 'True_', 'UFUNC_BUFSIZE_DEFAULT'

...
I see this might be a dictionary. What can I do to make it more readable 
or useful, or is that it? Is there a more abc as in Linux?


It the IDLE shell, it's not possible to retrieve lines entered earlier 
without copying them. Is there an edit facility?

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


<    1   2   3   4   5   >