Problem using/installing numarray

2005-02-16 Thread maxwell
I'm trying to use the 'numarray' package (v1.1.1) under Python 2.4
running under CygWin.

I initially downloaded the Windows executable version of the numarray
package, and installed it under C:\program
files\python\lib\site-packages.  That works with the Windows version of
Python, but not the CygWin version, where it fails with the msg:
   ImportError: No module named _conv
The file _conf.pyd exists, but my guess is that the .pyd suffix is not
recognized under the CygWin version of Python.  (But that doesn't make
sense...)

So I decided to download the .tgv version of the numarray package into
/lib/site-packages (under my CygWin dir), and build it.  Unfortunately,
the build fails with the msg:

   building 'numarray._conv' extension
   gcc -shared -Wl,--enable-auto-image-base \
   build/temp.cygwin-1.5.12-i686-2.4/Src/_convmodule.o \
   -L. -lpython2.4 -o \
   build/lib.cygwin-1.5.12-i686-2.4/numarray/_conv.dll \
   -L/lib -lm -lc -lgcc -L/lib/mingw -lmingwex

/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-pc-cygwin/bin/ld:
\
   cannot find -lpython2.4
   collect2: ld returned 1 exit status
   error: command 'gcc' failed with exit status 1

(I've tried to indicate the wrapped lines above by continuing them with
"\", but no guarantees this won't wrap again...)

At first I thought this was a problem with a path, but even hard coding
the path at the command line doesn't seem to work:

   > gcc -l/lib/python2.4

/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-pc-cygwin/bin/ld:
\
   cannot find -l/lib/python2.4

I have a _directory_ /lib/python2.4, but it sounds like gcc is looking
for some kind of library file.

Suggestions?

   Mike Maxwell

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


Re: Problem using/installing numarray

2005-02-17 Thread maxwell
Thanks, that explains why the CygWin Python will not import the .pyd
files:

>>> imp.get_suffixes()
[('.dll', 'rb', 3), ('module.dll', 'rb', 3), ('.py', 'U', 1), ('.pyc',
'rb', 2)]

Doesn't look like there's a way to get the CygWin Python to load .pyd
files.  So I guess I have to figure out why the build isn't working...

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


Re: Unable to run IDLE Under Windows

2005-03-04 Thread maxwell
Peter Otten wrote:
> Perhaps your configuration files contain bad data:
>
> # IDLE reads several config files to determine user preferences.
This
> # file is the default config file for general idle settings.
...
> # On Windows2000 and Windows XP the .idlerc directory is at
> #   Documents and Settings\\.idlerc

I have a similar problem: I can't run the Python IDLE app (i.e. the
file pythonw.exe), on either of two different machines.  However, I'm
using WinXP (and Python 2.4), and there is no .idlerc directory as
listed above.  One of hte machines had a .idlerc file under the Python
dir, and renaming it didn't help.  I just ran a search on the entire
hard drive of the other machine, and the only .idlerc dir is in my
CygWin home directory.  Since I'm not trying to run idle from a CygWin
bash shell etc., I don't think it's looking there.  (Just to make sure,
I renamed that dir...no luck.)

I uninstalled and re-installed Python 2.4, no change.  When I try to
run pythonw.exe, there is no indication that anything happens.  CPU
usage jumps for a  fraction of a second, then nothing.

I tried running 'idle' under CygWin, and it gives the following error
(lengthy traceback omitted, let me know if I should include that too):

  C:\cygwin\bin\python2.4.exe (2904): *** unable to remap
  C:\cygwin\bin\cygssl-0.9.7.dll to same address as parent
  (0x74) != 0x75
  2 [main] python2.4 3080 fork_parent: child 2904 died waiting
  for dll loading

Any other ideas why IDLE won't run?

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


Re: Unable to run IDLE Under Windows

2005-03-07 Thread maxwell
Thanks, guess I misunderstood--I thought "pythonw" _was_ IDLE.  Now I
see what IDLE is, and I wasn't actually wanting to run that.

And as it turns out, my _real_ problem was that my path was making me
run the CygWin version of Python from the "DOS" command prompt--which
understandably dies with a "CPU" error.

Now I'm squared away--thanks for the tip!

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


None in string formatting

2005-03-08 Thread rodney . maxwell
Was doing some string formatting, noticed the following:

>>> x = None
>>> "%s" % x
'None'

Is there a reason it maps to 'None'? I had expected ''.

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


Re: How to turn a variable name into a string?

2005-03-11 Thread Rodney Maxwell
> c = None  (result of an assignment after the os.environ.get()
returned a KeyError). 

Why not trap the KeyError?

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


2.4 crashes when try to exit app and mulitple threads active

2005-03-19 Thread Maxwell Hammer
An application I am developing executes many threads and then has a
"monitor" part that waits for certain events. One of these events causes
the application to have to shutdown. On shutdown the monitor part
notifies the threads of a shutdown, and the threads must cleanup and exit.
When all threads have exited the monitor itself exits.

The traceback below occured on a shutdown. At the time there was only one
thread running, however the same traceback occurs with many threads active.

Some things I've observed:
1 - my application is able to complete successfully,

2 - it appears to be only in python 2.4. - does not occur with 2.3.1.

3 - it is not consistent, there are times when there is no traceback

4 - more likely to occur the longer a thread/application has run.

5 - does occur frequently enough (50% of the time) to be a problem

I do not know how to investigate further. Any help or suggestions on how
to investigate this and resolve would be much appreciated.

Thanks.
-
Error traceback:
-
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python2.4/atexit.py", line 22, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.4/threading.py", line 636, in __exitfunc
self._Thread__delete()
File "/usr/lib/python2.4/threading.py", line 522, in __delete
del _active[_get_ident()]
KeyError: 16384
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.4/atexit.py", line 22, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.4/threading.py", line 636, in __exitfunc
self._Thread__delete()
File "/usr/lib/python2.4/threading.py", line 522, in __delete
del _active[_get_ident()]
KeyError: 16384

Software environment:
---
*
*** SYSTEM INFORMATION***
*** (Sat Mar 19 19:15:03 EST 2005)***
*
   Host or node name  : poseidon
   Machine type   : i686
   Operating system   : Linux
   Kernel version : 2.4.29
   Linux Distribution : Slackware 10.1.0
*
Python 2.4 (#1, Jan 1 2005,21:33:55) [GCC 3.3.4] on linux2
Gnu make 3.80
util-linux 2.12p
modutils 2.4.27
e2fsprogs tune2fs
Linux C Library 2.3.4
Dynamic linker (ldd) 2.3.4
Linux C++ Library 5.0.6
Procps 3.2.3
Net-tools 1.60
Kbd 1.12
Sh-utils 5.2.1
*
Modules Loaded:
nfs
lockd
sunrpc
ppp_deflate
zlib_inflate
zlib_deflate
bsd_comp
ppp_async
ppp_generic
slhc
emu10k1
ac97_codec
soundcore
xfs
ne2k-pci
8390
crc32
*
gcc version 3.3.4
Reading specs from
/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/specs Configured with:
../gcc-3.3.4/configure --prefix=/usr --enable-shared
--enable-threads=posix --enable-__cxa_atexit --disable-checking
--with-gnu-ld --verbose --target=i486-slackware-linux
--host=i486-slackware-linux
Thread model: posix
*

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


Re: 2.4 crashes when try to exit app and mulitple threads active

2005-03-20 Thread Maxwell Hammer
On Sat, 19 Mar 2005 22:35:39 -0500, Peter Hansen wrote:

> When you say "only one thread running", did you mean only
> one monitor thread in addition to the main thread, or did
> you really mean only the main thread was active at this time?

I meant there was the main app and one thread. The problem
does not occur when there are no threads running and the app
has to exit.

> Also, are you doing something odd to terminate threads
> here, and could you have screwed things up yourself?
Very likely - it has happened before :-)

> The code in question is at the end of the MainThread's
> __exitfunc() method, and normally this would be executing
> only after all other threads had terminated, and should
> be safe.  It appears as though the _active dictionary that
> tracks threads has been modified by someone else.

That is what it looks like to me. It seems that the interpreter
is trying to delete a non-existant thread

> Can you post a small self-contained example that
> reproduces the problem?
This will be difficult to do...but perhaps if I give a summary:

def main():
...initialize/configure
...wait for certain events
...based on events launch appropriate thread as follows:

thread.start_new_thread(event_module.run, (StateValues, (job_parms)))
...

def event_module.run(StateValues, (job_parms)):
...initialize/configure
while (1):
Return = os.system(RunString)

if Shutdown flag exists:#thread detects here if needs 
to exit
save_job(parms)
cleanup_exit(message, exit_code)
if Return == 0: # SUCCESS
break
elif Return == 1:   # ERROR
... 
elif Return == 7:   # ERROR
...

def cleanup_exit(message, exit_code):
remove temp files
log message, etc
return

So at shutdown, any threads running save their state to a job file
then simply do a return.

Hope this helps...also I use command line apps to program like Nedit.

Know of any visual python debuggers? I know there is "idle"...
any others, better ones? 
Have you heard of "eric" python ide. Is it good? - it would have debug
capabilities but is dependent on many libraries I think.

thanks a lot.

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


python.exe on Mac OS X!?

2005-04-17 Thread Rodney Maxwell
I did a source code build of Python 2.4.1 on OS X (10.3.8) and the
executable produced was 'python.exe'. Can someone tell me whether this
is a bug, feature, or UserError?

% ./configure

% make

% ./python.exe
Python 2.4.1 (#1, Apr 17 2005, 12:14:12)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
>>>

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


Re: python.exe on Mac OS X!?

2005-04-17 Thread Rodney Maxwell
>> executable produced was 'python.exe'. Can someone tell me whether
this
>> is a bug, feature, or UserError?

> I'm not sure. Why don't you grab the binary?

> http://www.python.org/ftp/python/2.4.1/MacPython-OSX-2.4.1-1 .dmg

Because I need to keep multiple versions of Python on this machine, and
as far as I can tell the binary installer overwrites the default
installed version.
I could be wrong.

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


Re: python.exe on Mac OS X!?

2005-04-17 Thread Rodney Maxwell
> The default file system on MacOSX is case insensitive.  As a result
the .exe
> extension is required to disambiguate the generated executable from
the 
> Python directory in the source distro. 

OK. I got it.

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


Re: some suggestions about GUI toolkits?

2005-12-28 Thread Bill Maxwell
On 28 Dec 2005 05:51:50 -0800, "Luis M. González" <[EMAIL PROTECTED]>
wrote:

>This question comes up in this mailing list every two or three days...
>I suggest taking some time to read previous threads (use Google Groups
>for en easier experience) and you'll find thousands of opinions and
>suggestions.
...SNIP...

Yes, and in my opinion, that's exactly the problem.  There are too many
opinions and suggestions and too few organized evaluations.  And, most
of the attempts to organize the information seem to be out of date for
the partial list of GUIs that they do try to evaluate.

I've been chewing through my own evaluation for the past 2 or 3 weeks,
and have been downloading and trying things on my own.  I think reading
the suggestions from past threads, then digging around and reading
descriptions of the ones that seem interesting, and then actually trying
to go through the tutorials (if they exist) is the only way to decide.

I'm finding that you can tell quite a lot by just looking for
documentation and tutorials, and seeing how up-to-date the websites are.

I've been keeping some notes as I plow through all this, and I've toyed
with the idea of writing up something that might be useful to others,
but that would be a BIG task, and I'm wimping out and just being selfish
and mostly only looking toward my own self interest.   So, I guess I'm
just spouting another opinion and not much organized information, and
contributing to the problem rather than the solution!  :^)

Anyway, having said all that, I find myself settling on using wxGlade,
which builds wxPython apps and GUIs.  

wxGlade:   http://wxglade.sourceforge.net/
wxPython:  http://wxpython.org/

There are two huge things that have influenced me to use this:

1)  Just by messing around with the wxGlade tutorials and experimenting,
I have managed to throw together a fairly sophisticated GUI interface
that uses a wxPython "NoteBook" in its main window (the notebook gives
you a tabbed interface), a working menu, a multi-segment status bar, and
separate modal and non-modal dialogs.  I really like the notebook
interface, and this became my "standard" when looking at other GUI
generator programs.  This thing just went together easily, which is more
than I can say about trying to use some of the other GUI generators.

2)  The availability of the new wxPython reference docs on the wxPython
site.  These really, really help when messing around trying to learn how
to do new things.  


Some comments on wxGlade:

I've found that the wxGlade user interface crashes fairly easily in some
spots, but if you save often, you can work around that.  It's worth it
just to get access to its sophisticated capabilities.  The tutorials are
not fully up to date, but at least they exist, and I believe they will
soon be updated.  

The latest wxGlade version has added automatic event handling setup and
"stub" function generation, which makes it much easier, in my mind, to
connect the GUI to your own code -- unfortunately one of the tutorials
(ironically, the one marked "new") still shows the old manual way of
making event handlers, and the web site sort of implies that wxGlade
won't ever do that, but it does.  Figuring out how to use it is easy,
once you notice where to type in the name of your handler in the wxGlade
user interface (I stumbled across this myself, and only later discovered
the little comment on the website that says "The current version is 0.4:
it adds wxWidgets 2.6 suppport and code generation of event handler
stubs for Python and C++ output").

Up until I discovered wxGlade, I had pretty much resigned myself to keep
using TkInter and writing the code myself.  This wxGlade thing is much
easier.

Oh, one more thing -- the wxGlade website is a good place to look for
finding other GUI builders for wxPython/wxWidgets.  They provide a nice
list at the bottom of the box on the right-hand side of the front
webpage.

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


Why is 'None' not assignable but 'True'/'False' are?

2006-01-02 Thread Rodney Maxwell
In Python 2.4.1:

>>> None = 99
SyntaxError: assignment to None
>>> True = 99
>>> False = 99
>>> True == False
True
---
So why is 'None' special?

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


Re: How to choose the right GUI toolkit ?

2006-11-09 Thread Bill Maxwell
On 8 Nov 2006 11:49:07 -0800, "John Henry" <[EMAIL PROTECTED]>
wrote:

>
>John Salerno wrote:
>> Dan Lenski wrote:
>>
>> > So, is there another toolkit I should be looking at?
>>
>> I highly recommend wxPython. It's very mature, full-featured, and
>> portable, and fairly easy to learn as well. I can't really compare it to
>> other toolkits (not having used any of them, except Tkinter), but it's
>> definitely one of the most popular and well-supported ones out there.
>>
>> http://www.wxpython.org/
>
>I highly recommend that you try PythonCard (which sits on top of
>wxPython).  You can get productive very very quickly.  Take a look at:
>
>http://pythoncard.sourceforge.net/walkthrough1.html


I took a brief look at PythonCard almost a year ago and got discouraged
by what I found, so I stopped looking at it.  I've inserted my notes
from back then, below.  Does anybody know if these things have been
fixed in the latest release?

Bill


=
My notes from Fri Dec-23-2005:

This is a list of gripes I have while trying to learn about PythonCard.
I'm trying to investigate various GUI builders for Python, and
PythonCard looks promising, but a lot of things are getting in the way.

I installed yesterday, using this installer:
PythonCard-0.8.1.FIXED.win32.exe

A)  The very first example in the tutorial is wrong!  

On this page:  http://pythoncard.sourceforge.net/documentation.html
When you follow this link to try something for the very first time:

Getting Started in PythonCard by Dan Shafer: 
http://pythoncard.sourceforge.net/walkthrough1.html

You quickly see that the minimal.py example doesn't even contain
this line, even though the tutorial refers to it:

def on_menuFileAbout_select(self, event):

And, of course, if you replace the word "pass" with this, as
instructed:

result = dialog.alertDialog(self, 'It works!', 'Showing Off')

it won't run, because the existing "pass" line isn't inside a def
inside of a class.


B)  Is the Notebook widget really supported?

In the installed file "changelog.txt" (gets installed as part of
PythonCard installation), it says:

"added Notebook component, PageBackground, and testNotebook
sample"

But, the testNotebook sample is nowhere to be found.

I looked lots of places, including the main SourceForge web site,
and on the wiki, here:

http://wiki.wxpython.org/index.cgi/PythonCard

Both the main website and the wiki seem way out of date, and the
latest dates I could find on both of them are sometime in 2004.

Finally, by following the mailing list archive link on the main
website, I managed to find a reference to the notebook component on the
ASPN site, where some guy named Brian wonders about the same thing as
me, concerning the availability of the notebook component:

http://aspn.activestate.com/ASPN/Mail/Message/pythoncard/2536825

and, that message led me here:

http://article.gmane.org/gmane.comp.python.pythoncard/1060

where Kevin Altis admits that he forgot to include it in the 0.8.1
release!  At least he provides a way to download it separately.  But,
gheesh, this is pretty poor for a new user.  I was interested in using
the notebook component right away, because I looked at the wxGlade
tutorial before looking at PythonPage, and they use the notebook
component in their example (and I decided I really want to use the
component).

To add insult to injury, after you download the zip file with the
testNotebook stuff, the readme file says this:

"Until we have a Notebook integrated into some of the other
samples or tools this will serve as a basic test app, but I don't expect
to include it in releases."

C)  Are the websites being maintained?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to choose the right GUI toolkit ?

2006-11-10 Thread Bill Maxwell
On 9 Nov 2006 22:48:10 -0800, "John Henry" <[EMAIL PROTECTED]>
wrote:

>Upon closer look, the walkthrough did say:
>
>***
>from PythonCard import model
>
>Change that so it says:
>
>from PythonCard import dialog, model
>
>Save the code.
>***
>
>So, it works.


Thanks for looking into it.  It sounds like either it has been fixed in
the newer version -- or I didn't do something correctly.  It's been a
long time, and I was just going by the notes I made back then.









>
>
>
>John Henry wrote:
>> Bill Maxwell wrote:
>> > On 8 Nov 2006 11:49:07 -0800, "John Henry" <[EMAIL PROTECTED]>
>> > wrote:
>> >
>> > >
>> > >John Salerno wrote:
>> > >> Dan Lenski wrote:
>> > >>
>> > >> > So, is there another toolkit I should be looking at?
>> > >>
>> > >> I highly recommend wxPython. It's very mature, full-featured, and
>> > >> portable, and fairly easy to learn as well. I can't really compare it to
>> > >> other toolkits (not having used any of them, except Tkinter), but it's
>> > >> definitely one of the most popular and well-supported ones out there.
>> > >>
>> > >> http://www.wxpython.org/
>> > >
>> > >I highly recommend that you try PythonCard (which sits on top of
>> > >wxPython).  You can get productive very very quickly.  Take a look at:
>> > >
>> > >http://pythoncard.sourceforge.net/walkthrough1.html
>> >
>> >
>> > I took a brief look at PythonCard almost a year ago and got discouraged
>> > by what I found, so I stopped looking at it.  I've inserted my notes
>> > from back then, below.  Does anybody know if these things have been
>> > fixed in the latest release?
>> >
>> > Bill
>> >
>> >
>> > =
>> > My notes from Fri Dec-23-2005:
>> >
>> > This is a list of gripes I have while trying to learn about PythonCard.
>> > I'm trying to investigate various GUI builders for Python, and
>> > PythonCard looks promising, but a lot of things are getting in the way.
>> >
>> > I installed yesterday, using this installer:
>> > PythonCard-0.8.1.FIXED.win32.exe
>> >
>> > A)  The very first example in the tutorial is wrong!
>> >
>> >On this page:  http://pythoncard.sourceforge.net/documentation.html
>> >When you follow this link to try something for the very first time:
>> >
>> >Getting Started in PythonCard by Dan Shafer:
>> >http://pythoncard.sourceforge.net/walkthrough1.html
>> >
>> >You quickly see that the minimal.py example doesn't even contain
>> > this line, even though the tutorial refers to it:
>> >
>>
>> I am not sure which one you are referring to but in the
>> PythonCard\samples\minimal, you will find a minimal.py that says:
>>
>> #!/usr/bin/python
>>
>> """
>> __version__ = "$Revision: 1.8 $"
>> __date__ = "$Date: 2005/12/17 15:20:02 $"
>> """
>>
>> from PythonCard import model
>>
>>
>> class Minimal(model.Background):
>> def on_menuFileAbout_select(self, event):
>> pass
>>
>> if __name__ == '__main__':
>> app = model.Application(Minimal)
>> app.MainLoop()
>>
>>
>>
>> >def on_menuFileAbout_select(self, event):
>> >
>> >And, of course, if you replace the word "pass" with this, as
>> > instructed:
>> >
>> >result = dialog.alertDialog(self, 'It works!', 'Showing Off')
>> >
>> >it won't run, because the existing "pass" line isn't inside a def
>> > inside of a class.
>> >
>>
>> No, it didn't work because the author forgot to mention that you have
>> to do a:
>>
>> from PythonCard import model, dialog
>>
>> instead of just:
>>
>> from PythonCard import model
>>
>> I just tried it and it works.
>>
>> >
>> > B)  Is the Notebook widget really supported?
>> >
>> >In the installed file "changelog.txt" (gets installed as part of
>> > PythonCard installation), it says:
>> >
>

Re: Python deployment options.

2006-11-15 Thread Bill Maxwell
On 8 Nov 2006 03:42:09 -0800, "king kikapu" <[EMAIL PROTECTED]>
wrote:

>
>I see...So, if these are the only options, the only "safe" bet is to
>install the language on the machine (beeing Win, Linux or Mac)
>and execute the .py files, right ??


No, those are not the only options.  

Check out PyInstaller:  http://pyinstaller.python-hosting.com/


I haven't used the latest versions.  But, I've used the old Gordon
McMillan package that PyInstaller is based on, and had good success.


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


Re: Network Programming in Python

2006-06-22 Thread Bill Maxwell
On 22 Jun 2006 12:02:14 -0700, [EMAIL PROTECTED] wrote:

>I am a newbie in python. I want to learn and implement a small
>networking concept. Please help me. Every help is appreciated.
>
>I have one Linux Box and one Windows PC. I want to have a daemon
>running on Windows PC which listens on some specicif port number. I
>want to send a TCP/IP or UDP/IP packet from Linux box to Windows PC to
>start some application. As Windows PC recieves such a packet from Linux
>Box it executes a certain .exe file. I want to implement this concept.
>
>In short I want to remotely send command from Linux to Windows PC to
>start a particular application.


Have you checked out Pyro (Python Remote Objects)?

http://pyro.sourceforge.net/

Bill



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


Re: About alternatives to Matlab

2006-11-29 Thread Bill Maxwell
On 16 Nov 2006 13:09:03 -0800, "sturlamolden" <[EMAIL PROTECTED]>
wrote:

...SNIP...

>To compare Matlab with NumPy we can e.g. use the D4 discrete wavelet
>transform. I have here coded it in Matlab and Python/NumPy using Tim
>Swelden's lifting scheme.
>
>First the Matlab version (D4_Transform.m):
>
>function x = D4_Transform(x)
>   % D4 Wavelet transform in Matlab
>   % (C) Sturla Molden
>   C1 =  1.7320508075688772;
>   C2 =  0.4330127018922193;
>   C3 = -0.066987298107780702;
>   C4 =  0.51763809020504137;
>   C5 =  1.9318516525781364;
>   s1 = zeros(ceil(size(x)/2));
>   d1 = zeros(ceil(size(x)/2));
>   d2 = zeros(ceil(size(x)/2));
>   odd = x(2:2:end);
>   even = x(1:2:end-1);
>   d1(:) = odd - C2*even;
>   s1(1) = even(1) + C2*d1(1) + C3*d1(end);
>   s1(2:end) = even(2:end) + C2*d1(2:end) + C3*d1(1:end-1);
>   d2(1) = d1(1) + s1(end);
>   d2(2:end) = d1(2:end) + s1(1:end-1);
>   x(1:2:end-1) = C4*s1;
>   x(2:2:end) = C5*d2;
>   if (length(x) >2)
>  x(1:2:end-1) = D4_Transform(x(1:2:end-1));
>   end
>
>
>Then the Python version (D4.py):
>
>import numpy
>import time
>
>def D4_Transform(x, s1=None, d1=None, d2=None):
>   """
>   D4 Wavelet transform in NumPy
>   (C) Sturla Molden
>   """
>   C1 = 1.7320508075688772
>   C2 = 0.4330127018922193
>   C3 = -0.066987298107780702
>   C4 = 0.51763809020504137
>   C5 = 1.9318516525781364
>   if d1 == None:
>  d1 = numpy.zeros(x.size/2)
>  s1 = numpy.zeros(x.size/2)
>  d2 = numpy.zeros(x.size/2)
>   odd = x[1::2]
>   even = x[:-1:2]
>   d1[:] = odd[:] - C1*even[:]
>   s1[0] = even[0] + C2*d1[0] + C3*d1[-1]
>   s1[1:] = even[1:] + C2*d1[1:] + C3*d1[:-1]
>   d2[0] = d1[0] + s1[-1]
>   d2[1:] = d1[1:] + s1[:-1]
>   even[:] = C4 * s1[:]
>   odd[:] = C5 * d2[:]
>   if x.size > 2:
>
>D4_Transform(even,s1[0:even.size/2],d1[0:even.size/2],d2[0:even.size/2])
>
>if __name__ == "__main__":
>   x = numpy.random.rand(2**23)
>   t0 = time.clock()
>   D4_Transform(x)
>   t = time.clock()
>   print "Elapsed time is %.6f seconds" % (t-t0)
>
...SNIP...


I couldn't help but notice that the following two lines from the above
code are doing different things, but I think they are supposed to do the
same things (the first is the Matlab version, the 2nd is the Python
version):


>   d1(:) = odd - C2*even;

>   d1[:] = odd[:] - C1*even[:]


I don't understand what this code is doing, so I don't know which is
wrong.  I don't even know if this is the actual code you are using. Just
thought I'd mention it.


Bill


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


Re: Why not just show the out-of-range index?

2006-12-03 Thread Bill Maxwell
On Sun, 3 Dec 2006 23:31:56 -0500, Jean-Paul Calderone
<[EMAIL PROTECTED]> wrote:

>On 3 Dec 2006 17:23:49 -0800, Russ <[EMAIL PROTECTED]> wrote:
>>
>>> Rather, they (like I) will encourage to OP to submit a patch that fixes the 
>>> problem.
>>
>>Now, that would be rather silly. I would have to familiarize myself
>>with the code for the Python interpreter, then send a patch to the
>>maintainers (and hope they notice it in their inboxes), while the
>>maintainers themselves could probably "fix" the problem in two minutes
>>flat. No thanks!
>
>And I have some laundry that I would like you to do for me.  Let me know
>when a convenient time for you to pick it up would be.
>
>Jean-Paul


Are you saying that you place such low value on feedback from Python
users that you don't even want them to try and ask questions that might
help to improve the language?

In other words, if I'm not skilled or knowledgeable enough to improve
something myself, I shouldn't even mention it?


Bill


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


Re: Write a GUI for a python script?

2006-03-04 Thread Bill Maxwell
On Fri, 3 Mar 2006 07:19:34 -0500, "Peter Decker" <[EMAIL PROTECTED]>
wrote:

>I started with wxPython and struggled with it for a long time. I was
>able to get the job done, but using it never seemed natural. Then I
>found the Dabo project, whose ui module wraps wxPython into a much
>more Pythonic, consistent interface. Since then I've been able to
>create GUIs without much effort at all. I highly recommend Dabo if you
>are thinking about wxPython.

Dabo does look really nice, but seems like it has a ways to go yet.

I downloaded it a couple of weeks ago, and the very first thing I wanted
to do doesn't seem to be supported.  I tried to create a simple
application with a Notebook control inside a frame.  The Notebook
control doesn't appear to be supported yet.

Is that right, or am I just not looking in the right places?


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


Re: Write a GUI for a python script?

2006-03-05 Thread Bill Maxwell
On Sat, 4 Mar 2006 13:08:35 -0500, "Peter Decker" <[EMAIL PROTECTED]>
wrote:

>On 3/4/06, Bill Maxwell <[EMAIL PROTECTED]> wrote:
>
>> Dabo does look really nice, but seems like it has a ways to go yet.
>>
>> I downloaded it a couple of weeks ago, and the very first thing I wanted
>> to do doesn't seem to be supported.  I tried to create a simple
>> application with a Notebook control inside a frame.  The Notebook
>> control doesn't appear to be supported yet.
>>
>> Is that right, or am I just not looking in the right places?
>
>It's fully supported. Their generic term for these paged controls is a
>'pageframe', so a wx.Notebook is their dPageFrame class; wx.Listbook
>is their dPageList class; wx.Choicebook is their dPageSelect, and they
>also have a page control with no tabs called (gasp!) dPageFrameNoTabs.
>One thing that they've done is pick names for classes and properties
>that are the most common for all toolkits instead of blindly following
>the wx names.
>
>All of these classes have the same interface, and respond to the same
>events. IOW, they've unified these different classes so that they have
>a single API, making working with them much easier.


Thanks for the info.  Knowing that, I was able to create a simple app in
the Dabo Designer that contains a Notebook.

But, I'm having a heck of a time finding any documentation at all on
Dabo.  I looked all thru the website(s), and have combed the Dabo
software package itself.

Either I'm doing something wrong, or documentation is pretty sparse for
Dabo.

What little info I could find on the Dabo Wiki seems pretty old.  I also
watched the two Sizer videos, but there's not enough info there to learn
much.  

I read somewhere that they are concentrating on the User Interface
designer instead of the database aspects.  The GUI maker is what I'm
interested in using, not the rest.  I don't want to code the GUI
manually.  Do you know where I can find more information on the
Designer?

Thanks,

Bill

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


Re: Python Developers Handbook - Mistake done and corrected.

2005-06-11 Thread Maxwell Hammer
On Fri, 10 Jun 2005 04:52:12 -0700, wooks wrote:

> 
> Your understanding of Usenet is that a post has to "appeal" (for the
> want of a better word) to the majority of the NG readership.
> 
> Look over a hundred people took a look (and the hits are steadily
> going up whether despite or because of this thread). I am not going to
> posit either way as to whether that amounts to vindication  but it does
> suggsest that I have not comitted the heinous crime against netiquette
> that some people are making out.

Actually you're making a mistake there:
Maybe 100 people took a look at Wook's book, but a lot more than 100 people
were pissed off at yet another Commercial post.
Next time use the "announce" NG.

Always ask youself...so if 2 billion people did what I'm about to do,
will it make a big stink? Most times the answer is: a huge stink.

Cheers.

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


Help with thread related tracebacks

2005-06-15 Thread Maxwell Hammer
Hope someone can help with a problem I'm having.
A python program I wrote terminates with the following traceback.

*** start traceback ***
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python2.4/atexit.py", line 22, in _run_exitfuncs
func(*targs, **kargs)
  File "/usr/lib/python2.4/threading.py", line 636, in __exitfunc
self._Thread__delete()
  File "/usr/lib/python2.4/threading.py", line 522, in __delete
del _active[_get_ident()]
KeyError: 16384
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.4/atexit.py", line 22, in _run_exitfuncs
func(*targs, **kargs)
  File "/usr/lib/python2.4/threading.py", line 636, in __exitfunc
self._Thread__delete()
  File "/usr/lib/python2.4/threading.py", line 522, in __delete
del _active[_get_ident()]
KeyError: 16384
*** end traceback ***

The program works correctly, and the traceback occurs ONLY after my
program has exited normally.

I really don't know what causes this, and since the
program is quite large I wouldn't know what code snippet to post (if any).

The following pseudocode describes what my program does:

Main thread starts
  does some processing...
  while...
does some processing...
loads a function from a module known only at runtime by doing:
exec 'import %s as Plugin' % PluginImportPath
exec 'PluginStartFunction=getattr(Plugin, \'%s\')' % FunctionName
PluginStartFunction(job commands...)
monitor_events()
if we have to quit:
  signal threads to complete and exit.
  wait for threads to indicate complete
  exit
  # end while


Plugin Module:
  PluginStartFunction(job commands...):
does some processing...
run the module's "run" function by doing:
thread.start_new_thread(PluginRunFunction, (job commands...))
return

  PluginRunFunction(job commands...):
does some processing...
spawns an external unix (console) program by doing:
RETURN=os.system(program string...)
does some processing...
return
  ##end Plugin Module

I have to load the plugin functions using "exec" because the plugin modules are
only known at runtime, so cannot be hard-coded.

In any case, I have made sure that the main thread does wait for all other
threads to have terminated before it calls sys.exit and exits.
It is only after main thread has exited that the above traceback occurs.

Any gurus out there that can aid with this?

Any and all help would be appreciated, even guidance as to what to investigate
or to try.

By the way what graphical debuggers do people use for debugging python apps.?

Thanks very much

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


How should threads be terminated? (related to 'Help with thread related tracebacks')

2005-06-16 Thread Maxwell Hammer
Hi all,

This is related to an earlier post 'Help with thread related
tracebacks'...for which I have had no feedback yet :-(

How should a thread complete i.e. how should it exit?
Reading the python online docs one gets the idea that simply returning is
OK - but I'm not sure.
Is it ok to do a sys.ext()? Use 'return' or just let them run out with no
'return' ???

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


Re: How should threads be terminated? (related to 'Help with thread related tracebacks')

2005-06-17 Thread Maxwell Hammer
On Thu, 16 Jun 2005 16:20:23 -0400, Peter Hansen wrote:

> Maxwell Hammer wrote:
>> This is related to an earlier post 'Help with thread related
>> tracebacks'...for which I have had no feedback yet :-(
> 
> If the question was well formulated, and it's been more than a couple of 
> days, you should consider reposting.  It's very unusual for a post with 
> such a subject (if it was a clear question) to get _no_ feedback around 
> here.

Fair enough. The question is not expressed clearly for others. Do you have
any suggestions as to how to describe the problem clearer?

I can think of no other way but to say I have an app that when I terminate
it, completes ok, However the last thing that happens before the shell
prompt returns is that there is a traceback *within* python.
(The actual post goes into more details of course.)

I just took a guess that it is *thread* related from the output of the
traceback. I'm still learning python, so how could one pose the problem
*clearer*? 

And thanks for the feedback regarding threads, by the way.
Max

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


Re: How should threads be terminated? (related to 'Help with thread related tracebacks')

2005-06-17 Thread Maxwell Hammer
Thanks Brian & Martin for the links.
I actually found another good one:
http://linuxgazette.net/107/pai.html

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


Re: PythonCard or Dabo?

2007-06-01 Thread Bill Maxwell
On 19 Mar 2007 10:40:03 -0700, [EMAIL PROTECTED] wrote:

...
>You might want to submit this to the wxpython news-group. 
...

What is the name of this newsgroup?  I can't seem to locate it on my
news server.

Thanks,

Bill



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


Extended slicing and Ellipsis - where are they used?

2007-09-13 Thread Rodney Maxwell
The following are apparently legal Python syntactically:
   L[1:3, 8:10]
   L[1, ..., 5:-2]

But they don't seem to work on lists:
>>> l = [0,1,2,3]
>>> l[0:2,3]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: list indices must be integers
>>> l[...]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: list indices must be integers

So where is this extended slicing used?

--
Rodney

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


Re: Extended slicing and Ellipsis - where are they used?

2007-09-15 Thread Rodney Maxwell
On Sep 13, 5:50 pm, James Stroud <[EMAIL PROTECTED]> wrote:
> Rodney Maxwell wrote:
> > The following are apparently legal Python syntactically:
> >L[1:3, 8:10]
> >L[1, ..., 5:-2]
>
> > But they don't seem to work on lists:
> >>>> l = [0,1,2,3]
> >>>> l[0:2,3]
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > TypeError: list indices must be integers
> >>>> l[...]
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > TypeError: list indices must be integers
>
> > So where is this extended slicing used?
>
> AFAICT this syntax is not used in the standard library. However, the
> mega-beauty of it is that you can make use of it in your own classes:
>
> py> class Bob(list):
> ...   def __getitem__(self, i):
> ... try:
> ...   return [list.__getitem__(self, j) for j in i]
> ... except TypeError:
> ...   return list.__getitem__(self, i)
> ...
> py> b = Bob(xrange(15, 30))
> py> b[3, 5, 7, 13]
> [18, 20, 22, 28]
>
> James

Or
>>> b[0:3, 5, 9]
[[15, 16, 17], 20, 24]

which is what I was looking for in the first place.

Thanks,
Rodney

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


Re: Extended slicing and Ellipsis - where are they used?

2007-09-15 Thread Rodney Maxwell
On Sep 13, 5:50 pm, James Stroud <[EMAIL PROTECTED]> wrote:
> Rodney Maxwell wrote:
> > The following are apparently legal Python syntactically:
> >L[1:3, 8:10]
> >L[1, ..., 5:-2]
>
> > But they don't seem to work on lists:
> >>>> l = [0,1,2,3]
> >>>> l[0:2,3]
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > TypeError: list indices must be integers
> >>>> l[...]
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > TypeError: list indices must be integers
>
> > So where is this extended slicing used?
>
> AFAICT this syntax is not used in the standard library. However, the
> mega-beauty of it is that you can make use of it in your own classes:
>
> py> class Bob(list):
> ...   def __getitem__(self, i):
> ... try:
> ...   return [list.__getitem__(self, j) for j in i]
> ... except TypeError:
> ...   return list.__getitem__(self, i)
> ...
> py> b = Bob(xrange(15, 30))
> py> b[3, 5, 7, 13]
> [18, 20, 22, 28]
>
> James

Or
>>> b[0:3, 5, 9]
[[15, 16, 17], 20, 24]

which is what I was looking for in the first place.

Thanks,
Rodney

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


Re: wxPython problem

2006-05-06 Thread Bill Maxwell
On 28 Apr 2006 10:16:57 -0700, [EMAIL PROTECTED] wrote:

>What I'm wondering is, perhaps it has something to do with the wx.pth
>file? I can't seem to find anything in the documentation about what the
>path should be, which file it should be pointing to.

Mine has this in it:

wx-2.6-msw-unicode

this points to a subdirectory of the site-packages directory.  Mine
looks like this:

D:\Programs\Python\Lib\site-packages\wx-2.6-msw-unicode\wx
D:\Programs\Python\Lib\site-packages\wx-2.6-msw-unicode\wxPython

My understanding is that the wx.pth adds to the Python path.  So, this
directory in your system:

site-packages/wx-2.6-gtk2-unicode

is searched automatically.  From there, you need to import wx or
wxPython, then access using "wx." or "wxPython." 

Regards,
Bill
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Functions continuing to ru after returning something?

2010-08-31 Thread Maxwell Hansen

On 08/30/2010 05:05 PM, Bradley Hintze wrote:

I may be having a brain fart, but is it at all possible to have a
function first return a value then continue its calculation. Like this
simple example:

my_var = 5
def my_function():
 return my_var
 my_var +=1

This obviously won't work as written but is there a cleaver way around this.



return stops execution of any code remaining in the function, but just 
out of curiosity, why do you need to do this?

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