Re: reading timestamp from vid file (avi)

2005-03-09 Thread flupke
Lucas Raab wrote:
flupke wrote:
Hi,
i capture a movie from mividv to an avi containing the dv video. I 
found a program that reads the timestamp from the avi so you know the 
exact date and time the video was shot. However, the source of that 
program is not available and it doesn't allow to batch process a 
directory of video files which is a pain if you import the video using 
"split scenes".

Is there a script/program in python that reads the header or where do 
i start to write something like that?

Any info is appreciated.
Regards,
Benedict
Take a look at pymedia at http://pymedia.org.
Thanks, i'll see if i can do something with it. It looks promising but 
not as simple so i might ask  this question on their list.

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


thread end and make main program end also?

2005-03-09 Thread martinnitram
Dear all,

   Following are some codes:

   from myClass import * # some user define classes, which will catch
the exception within its function

   thread_function():
  myClass myclass
  while (1):
 returnValue = myclass.myfunction();
 print "Return Value %s" % returnValue
  #... cont' to do something

# main
thrd =  threading.Thread(None,thread_function,"thread_function")
thrd.setDaemon(True)
thrd.start()
#... cont' to do other thing

'myClass.myfunction()' will return some value (used 'return') when
caught exceptions and let the 'thread_function()' handle the following.
But now found that after 'myClass.myfunction()' return, both thread
program and main program will exit, when i prefer it will cont' to run.


 is it the default behavior of thread return? Thank a lot

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


Re: capturing text from a GUI window

2005-03-09 Thread Myles Strous
Earl Eiland wrote:
> This sounds like just what I need.  What is COM, and where do I get
it?

Also worth checking out:

Simon Brunning's WinGuiAuto - control/query of windows and controls,
including the function getEditText to read the text in an edit control.
See http://www.brunningonline.net/simon/blog/archives/001129.html
You'll probably also need something like Winspector to get class names
etc - see http://www.windows-spy.com/

AutoIt3 - freeware, has a DLL version that is COM-controllable (after
registration using "regsvr32 AutoItX3.dll" from a console window). I
must admit that so far I've only ever used version 2 through COM.
Includes functions such as ControlGetText and WinGetText, and throws in
a separate spy/info program as well. See
http://www.autoitscript.com/autoit3/

COM (component object model) - inter-component communication
technology. See http://www.microsoft.com/com/default.mspx

Makes it easy for programs with COM client functonality to use/control
functions exposed in a COM server program (well, that's the Dispatch
part of it that's applicable to your situation, it's apparently a fair
bit more than that).

Mark Hammond's Python for Windows extensions (thank you Mark Hammond!),
also known as Win32All or PyWin32, adds COM client funcionality to
Python.
(Note: Python+PyWin32 also does COM server stuff, but you don't need to
know about that.)

Use the COM Makepy utility (under the Tools menu) in PythonWin (the IDE
that comes with the Python for Windows extensions) to get a nice
interface module for your chosen COM server component, then just call
the functions in the interface module (or whatever the correct
technical name is for the generated .py file).

Worth reading:
http://www.python.org/windows/win32com/QuickStartClientCom.html

Example Python uses of COM server components:
http://www.boddie.org.uk/python/COM.html
http://www.pyzine.com/Issue007/Section_Articles/article_PythonCOM.html
http://schram.net/articles/python/eudora.html
http://www.daniweb.com/code/snippet208.html
http://tinyurl.com/42rxa

(Using a COM component is very similar in a variety of programming
languages)

In case you don't already have the Python for Windows extensions, or
the ActiveState Python distribution which includes them: see
http://sourceforge.net/projects/pywin32/

Regards, Myles.

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


Re: BaseHTTPServer.BaseHTTPRequestHandler and HTTP chunking

2005-03-09 Thread Steve Holden
Andy Leszczynski wrote:
Does BaseHTTPServer.BaseHTTPRequestHandler support HTTP protocol chunking?
No. Hardly any HTTP 1.1 features are supported.
regards
 Steve
--
http://mail.python.org/mailman/listinfo/python-list


Re: looking for case insesitive dictionary

2005-03-09 Thread Michael Spencer
Andy Leszczynski wrote:
so e.g.
x={}
x['a']=1
x['A']=2
print x['a'] #prints 2
Thx, A.
http://www.google.com/search?&q=python+case+insensitive+dictionary
Michael
--
http://mail.python.org/mailman/listinfo/python-list


looking for case insesitive dictionary

2005-03-09 Thread Andy Leszczynski
so e.g.
x={}
x['a']=1
x['A']=2
print x['a'] #prints 2
Thx, A.
--
http://mail.python.org/mailman/listinfo/python-list


BaseHTTPServer.BaseHTTPRequestHandler and HTTP chunking

2005-03-09 Thread Andy Leszczynski
Does BaseHTTPServer.BaseHTTPRequestHandler support HTTP protocol chunking?
Thanks, Andy
--
http://mail.python.org/mailman/listinfo/python-list


SimpleHTTPRequestHandler handling long lasting requests problem

2005-03-09 Thread Andy Leszczynski
I need a HTTP server handling long lasting requests e.g. 10-30 seconds. 
Below is a pice of the code. In order to make the server reponsive while 
handling othere requests I use SocketServer.ThreadingMixIn.

However the problem is the it does not work out. I checked thet a new 
thread is created for each new connection new, but the main loop seems 
to be frozen until the prevoius handling ends.

What could go wrong?
Thanks, Andy

* * *
import os
import time
import BaseHTTPServer
import SocketServer
import threading
import sys
class
SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
response=""+str(time.time())
self.send_response(200)
self.send_header("Content-type",'text/plain')
self.send_header("Content-Length",len(response))
self.end_headers()
time.sleep(10) #simulation of the processing
self.wfile.write(response)
def do_POST(self):
self.do_GET()
class
myWebServer(SocketServer.ThreadingMixIn,BaseHTTPServer.HTTPServer):
  pass
if __name__ == '__main__':
server_address = ('',80)
httpd=myWebServer(server_address,SimpleHTTPRequestHandler)
sa=httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1],"..."
httpd.serve_forever()
--
http://mail.python.org/mailman/listinfo/python-list


Re: read() / readline() / readlines()

2005-03-09 Thread Dave Lajoie



Fyi, I found the 
answer ( at least one that still works )
 
def PrintThread(myThread):    
while myThread.isAlive() == True:    
line = p.stdout.readline()[:-1]    if 
line == 
"":    
continue    if line == 
'\0':    
break    print line
 
Dave.

  - Original Message - 
  From: 
  Dave 
  Lajoie 
  To: Python-list@python.org 
  Sent: Wednesday, March 09, 2005 12:24 
  AM
  Subject: read() / readline() / 
  readlines()
  
  Hello!
      would someone know a method 
  that allows
      to read line delimited by "\n" 
  instead of trapping "\0" like
      readlines does?
   
  I have to write my own while loop to do 
  this.
   
      while myThread.isAlive() == 
  True:    myChar = 
  p.stdout.read(1)    if myChar == 
  '\0':    
  print "Found EOF, 
  exiting!"    
  break    myStr = myStr + 
  myChar    if myChar == 
  '\n':    
  print 
  myStr    
  myStr = 
  ""    
  continue
   
  is there a more elegant way to do 
  this?
  tx
  Dave.
-- 
http://mail.python.org/mailman/listinfo/python-list

hotshot load error

2005-03-09 Thread Charles Hartman
I've used profile before, but wanted to get more information so I  
thought I'd try hotshot instead. It works fine when used like profile.  
But when I run it using this line,
	prof = hotshot.Profile('ScanHot.prof', lineevents=1)
though it runs all right, when I try to load the resulting file I get  
this:

>>> hs = hotshot.stats.load("ScanHot.prof")
Traceback (most recent call last):
  File "", line 1, in ?
  File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/hotshot/stats.py", line 12, in load
return StatsLoader(filename).load()
  File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/hotshot/stats.py", line 51, in load
assert not self._stack
AssertionError

--which I don't understand. (The program is a GUI one using wxPython  
2.5, running from within the WingIDE on a Mac under OS 10.3.8, if any  
of that makes a difference. Nothing there prevents hotshot from loading  
a file that's been made without the lineevents=1 argument.)

Charles Hartman
Professor of English, Poet in Residence
http://cherry.conncoll.edu/cohar
http://villex.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: os.walk(entire filesystem)

2005-03-09 Thread Grumman
Tobiah wrote:

When I do os.walk('/') on a Linux computer, the entire file system is 
walked. On windows, however, I can only walk one drive at a time (C:\, 
D:\, etc.). 

If this is a personal utility for one computer, and if you run XP on
that computer, then you have the ability to mount secondary drives
on to the file system of your main drive.  This would give you the
effect that you are enjoying on the Linux side.
I am guessing that the utility that does this is the same one
that allows you to partition drives, but I'm not sure.
Ditto for win2k. right click 'My computer'->'Manage'->'Disk Management'
The only restriction is that both the root filesystem, and the one you 
want to mount within it have to be NTFS. (I may be wrong, but that 
appears to be true on my system.)

Still a moot point if this is to be widely deployed to existing PCs though.
--
http://mail.python.org/mailman/listinfo/python-list


Usage example for ANSI.py from the pexpect package

2005-03-09 Thread Eric Myers
Hello folks:

(This message is also posted on the help forum at the pexpect
sourceforge page, but all indentation in the code got stripped away
when I submitted the post.)

For some time I've wanted to make use of the ANSI.py module in the
pexpect package to handle screen-based telnet sessions in Python, but I
could never break the ice with the thing.  After reading an article by
Greg Jorgenson where he recounts using the package to help him solve a
problem for a customer, I wrote him asking if he could give me any tips
to help me get started.  Greg very graciously sent me some code to use
as an example, and I've finally been able to make some headway, thanks
to him.  I'm at least sputtering along now, so I wanted to take the
time to pass along a little code in case anyone else out there would
like to tinker with this tool but has a little trouble getting off the
dime...

The code I'm posting below is a script that establishes a telnet
connection with my Linux machine, starts the vim text editor, reads
some text from the splash screen over a range of coordinates, and moves
the cursor around.  On my machine, the raw data sent over the telnet
stream after issuing the "vim" command is this:

.[1;24r.[27m.[24m.[0m.(B.[H.[J.[2;1H.[1m~
(...and then a series of "~" symbols with line breaks-- takes up a lot
of screen space... :-))
~.[0m.(B.[24;63H0,0-1.[9CAll.[6;32HVIM - Vi IMproved.[8;34Hversion
6.3.54.[9;29Hby Bram Moolenaar et al..[10;24HModified by
.[1m<[EMAIL PROTECTED]>.[0m.(B.[11;19HVim is open source and freely
distributable.[13;26HHelp poor children in Uganda!.[14;18Htype  :help
iccf.[1m.[0m.(B.[7Cfor information.[16;18Htype
:q.[1m.[0m.(B.[15Cto exit.[17;18Htype  :help.[1m.[0m.(B
or  .[1m.[0m.(B  for on-line help.[18;18Htype  :help
version6.[1m.[0m.(B   for version info.[1;1H

The script is used to process the raw stream and read characters 25
through 37 on row 18, and it correctly reports "help version6" as the
result.

A great deal of the code that follows is either blatantly
cut-and-pasted from the sample Greg sent me, or has been modified only
slightly.  I have included some code of my own which makes use of the
set_option_negotiation_callback method of the Telnet class, which can
be used to establish an agreement between the client and server on how
the session will proceed.  Learning how to use that method was a hurdle
for me when I did it, maybe someone down the line will find an example
useful.  Beware, though-like I said, it's my own code, and I'm a
rookie.  There's probably a lot of room for improvement in what I came
up with.

One thing that I think is worth noting-none of the code below depends
on the pexpect module itself. It just uses the standard telnetlib to
establish the connection, and then uses the ANSI, screen, and FSM
modules from the pexpect package to interpret the output of a
screen-based application. The upshot of this is that the pty module is
not required, so you can use this with the native Windows version of
Python. Cygwin is not required.

Finally, I'd like to express my thanks to Mr. Jorgensen one more time.
Greg, you really helped out when I was ready to become frustrated. It's
people like you that make the 'net a nicer place to work and play!

OK, without further ado, here's the script-

#! /usr/bin/env python
""" ansi_py_usage: example for usage of the ANSI.py module """

from telnetlib import Telnet
from telnetlib import DO, DONT, WILL, WONT, theNULL, TTYPE, IAC, SB, \
SE, ECHO
import ANSI

global host_address,username,password

host_address='address_of_the_machine_you_want_to_connect_to'
username='your_username'  # P.S.-- it's very bad practice to hard-code
password='your_password'  # in a hostname, username, and password!
terminal_type='vt100'


class AnsiPyTestImplementation:
def __init__(self):
self.conn = None
self.crt = ANSI.ANSI(25,80)

def login(self, host, username, password):
try:
# empty the read buffer and check the connection
self.conn.read_eager()
except:
self.conn = None
tries = 45
while tries > 0:
print "logging in..."
try:
if self.conn is None:
#
# The following is an example of how to use the
# set_option_negotiation_callback method of the
# Telnet function.  When any sub-negotiation
# requests are received from the server during the
# client/server hand-shaking, a user-defined
# function can be called to handle the situation.
#
self.conn = Telnet()
self.conn.set_option_negotiation_callback(self.neg)
self.conn.open(host)
self.waitfor("login: ", 5)
self.sendln(username)
self.waitfor("Password: ", 2)
self.sendln(password)
 

Re: How to allow events during long processing routine?

2005-03-09 Thread Brent W. Hughes
Thanks, M.E.Farmer.

I continue to be impressed with how quickly and nicely one can get help 
here.

Brent


"M.E.Farmer" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Survey says.
> ...wxYield()
>
> ;)
> M.E.Farmer
> 


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


Re: python cvs interface?

2005-03-09 Thread corey
Ah, unfortunately it looks like this program uses something called
gcvs, a gtk cvs interface written in C++, for interfacing to low level
cvs routines.  So it probably won't work for me.  Oh well.  Anyone else
have any suggestions?

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


email.Message.set_charset and Content-Transfer-Encoding

2005-03-09 Thread David Bolen
I've noticed that using set_charset() on an email.Message instance will not
replace any existing Content-Transfer-Encoding header but will install one
if it isn't yet present.

Thus, if you initially create a message without a charset, it defaults to
us-ascii, and creates both Content-Type and Content-Transfer-Encoding
headers (the latter of which defaults to "7bit").

If you then later attempt to change the charset (say, to "iso-8859-1")
with set_charset(), it adjusts the Content-Type header, but leaves the
Content-Transfer-Encoding header alone, which I would think is no
longer accurate, since it is the new charset's body encoding that will
eventually be used when flattening the message, which would then no longer
match the encoding header.

It's also different than if you had passed in an iso-8859-1 charset
originally when constructing the message instance, in which case the
encoding would have been selected as quoted-printable.

The documentation for set_charset seemed to imply (at least to me)
that eventual headers generated by a generator would be affected by
the change in charset, so having it stay at 7bit was confusing.

Is anyone aware of a reason why the encoding shouldn't adjust in
response to a set_charset call similar to how a supplied charset
initially establishes it at message creation time?

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


Re: capturing text from a GUI window

2005-03-09 Thread Earl Eiland
On Tue, 2005-03-08 at 14:27, [EMAIL PROTECTED] wrote:
> Earl Eiland wrote:
> > Anyone know how to capture text from GUI output?  I need to process
> > information returned via a GUI window.
> >
> > Earl
> 
> Assuming Windows, then these guys have an interesting tool:
> http://www.skesoft.com/textcatch.htm
> It's not free, but you can try it before you buy it.
> You will need COM to control it from Python.

This sounds like just what I need.  What is COM, and where do I get it? 
(I'm really a Linux guy. I don't ken the mysteries of Window very well.)

earl

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


Re: os.walk(entire filesystem)

2005-03-09 Thread Larry Bates
I don't think what you want would even work.  You can't walk A:
unless a floppy is present, O/S will bark at you.  You can't
walk D: (cdrom drive) unless a CDROM is present.  What about
network drives???  Unlike Linux where these directories appear
to be empty if nothing is mounted Windows tries to read a
directory and errors.  Just follow what Peter Hansen has
suggested and write a wrapper function that calls os.walk
repeatedly for all the actual drives in your system
that are readable at all times.  It isn't all that hard.

Larry Bates


rbt wrote:
> More of an OS question than a Python question, but it is Python related
> so here goes:
> 
> When I do os.walk('/') on a Linux computer, the entire file system is
> walked. On windows, however, I can only walk one drive at a time (C:\,
> D:\, etc.). Is there a way to make os.walk() behave on Windows as it
> behaves on Linux? I'd like to walk the entire file system at once... not
> one drive at a time.
> 
> Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.walk(entire filesystem)

2005-03-09 Thread Tobiah

When I do os.walk('/') on a Linux computer, the entire file system is 
walked. On windows, however, I can only walk one drive at a time (C:\, 
D:\, etc.). 
If this is a personal utility for one computer, and if you run XP on
that computer, then you have the ability to mount secondary drives
on to the file system of your main drive.  This would give you the
effect that you are enjoying on the Linux side.
I am guessing that the utility that does this is the same one
that allows you to partition drives, but I'm not sure.
--
http://mail.python.org/mailman/listinfo/python-list


Re: PythonWin line spacing

2005-03-09 Thread Neil Hodgson
Thomas Philips:

> I've just downloaded and installed ActivePython and am trying to
> customize the PythonWin editor. Its line spacing seems to default to 2,
> and consequently, I cannot see many lines of code on a screen. How do I
> set the line spacing to 1?

   I presume you are talking about the Interactive Window which is 
spread out a bit. The line height is determined by the tallest font 
possible in the window. You could go looking through the code to find 
all the styles set up for that window. Selecting View | Fixed Font 
*twice* does tighten up the text.

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


Re: An Odd Little Script

2005-03-09 Thread Michael Hoffman
Michael Hoffman wrote:
Greg Lindstrom wrote:
I have a file with varying length records.  All but the first record, 
that is; it's always 107 bytes long.  What I would like to do is strip 
out all linefeeds from the file, read the character in position 107 
(the end of segment delimiter) and then replace all of the end of 
segment characters with linefeeds, making a file where each segment is 
on its own line.

H... here's one way of doing it:
import mmap
import sys
DELIMITER_OFFSET = 107
N.B. this is a zero-based 107. If you are using one-based coordinates,
then this is actually position 108.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list


Re: os.walk(entire filesystem)

2005-03-09 Thread Peter Hansen
rbt wrote:
More of an OS question than a Python question, but it is Python related 
so here goes:

When I do os.walk('/') on a Linux computer, the entire file system is 
walked. On windows, however, I can only walk one drive at a time (C:\, 
D:\, etc.). Is there a way to make os.walk() behave on Windows as it 
behaves on Linux? I'd like to walk the entire file system at once... not 
one drive at a time.
Basically, no, I don't think so.  The two operating systems
have different concepts of what a file system is, and Linux
sees the world from one root, while Windows has many.
But that aside, is there anything stopping you from just
writing your own wrapper routine that does the right
thing** on Windows?
-Peter
** "Right thing" might be tricky: walking all drive letters
would *really* annoy me in most programs, since some of them
are network shares, some of them are removable storage like
CompactFlash modules, and some might just be "subst" drives
that map to a subfolder on another drive.  Make sure you
at least check with the appropriate Windows API which
drives are really local storage and stick to them.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Unicode BOM marks

2005-03-09 Thread "Martin v. LÃwis"
Steve Horsley wrote:
It is my understanding that the BOM (U+feff) is actually the  Unicode 
character "Non-breaking zero-width space". 
My understanding is that this used to be the case. According to
http://www.unicode.org/faq/utf_bom.html#38
the application should now specify specific processing, and both
simply dropping it, or reporting an error are both acceptable behaviour.
Applications that need the ZWNBSP behaviour (i.e. want to indicate that
there should be no break at this point) should use U+2060 (WORD JOINER).
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: distutils: binary distribution?

2005-03-09 Thread "Martin v. Löwis"
Stefan Waizmann wrote:
I would like the distutils are creating a binary distribution only - means
create the distribution file with *.pyc files WITHOUT the *.py files. Any
ideas?
You will need to create your own command. You can either specialize the 
build command, to not copy the source code (more specifically, the 
build_py command), or you modify the relevant bdist_* command to not 
include the "built" .py files into the binary distribution.

Once you have implemented the derived commands, you pass them to the
setup function in the cmdclass keyword argument.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to allow events during long processing routine?

2005-03-09 Thread M.E.Farmer
Survey says.
...wxYield()

;)
M.E.Farmer

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


Re: Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread Jeff Epler
untested

def my_getter(m, i, f):
try:
return m[i]
except (KeyError, IndexError):
return f()

my_getter(d, 'x', bigscaryfunction)
my_getter(d, 'y', lambda: scaryinlineexpresion)


pgp04VRKFqQL1.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: An Odd Little Script

2005-03-09 Thread Benji York
Greg Lindstrom wrote:
I have a task which -- dare I say -- would be easy in  
Perl  but would rather do in Python (our primary 
language at Novasys).  I have a file with varying length records.  All 
but the first record, that is; it's always 107 bytes long.  
I intuit that you are dealing with EDI documents.  If so, there have 
been some recent discussions (and code) here.  This Google Groups search 
will probably help: 
http://groups-beta.google.com/groups?q=group:comp.lang.python+edi&start=0&scoring=d&;
(http://tinyurl.com/6urby).
--
Benji York
Sr. Software Engineer
Zope Corporation
--
http://mail.python.org/mailman/listinfo/python-list


Re: An Odd Little Script

2005-03-09 Thread M.E.Farmer
Greg Lindstrom wrote:
> Hello-
>
> I have a task which -- dare I say -- would be easy in

> Perl  but would rather do in Python (our primary
> language at Novasys).  I have a file with varying length records.
All
> but the first record, that is; it's always 107 bytes long.  What I
would
> like to do is strip out all linefeeds from the file, read the
character
> in position 107 (the end of segment delimiter) and then replace all
of
> the end of segment characters with linefeeds, making a file where
each
> segment is on its own line.  Currently, some vendors supply files
with
> linefeeds, others don't, and some split the file every 80 bytes.  In
> Perl I would operate on the file in place and be on my way.  The
files
> can be quite large, so I'd rather not be making extra copies unless
it's
> absolutely essential/required.
>
> I turn to the collective wisdom/trickery of the list to point me in
the
> right direction.  How can I perform the above task while keeping my
sanity?
>
> Thanks!
> --greg
> --
> Greg Lindstrom   501 975.4859
> Computer Programmer  [EMAIL PROTECTED]
> NovaSys Health
> Little Rock, Arkansas
>
> "We are the music makers, and we are the dreamers of dreams."  W.W.

This should be fairly simple, but maybe not ;)
# get the end of segment character
# this is not optimal but should be a start
f = open('yourrecord', 'r')
eos  = f.seek(107).read(1)
r = f.read()
f.close()
r = r.replace('\r', '')
r = r.replace('\n', '')
r = r.replace(eos, '\n')
f = open('yourrecord', 'w')
f.write(r)
f.close()

hth,
M.E.Farmer

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


Re: An Odd Little Script

2005-03-09 Thread James Stroud
This might be hack-ish, more elegant solutions are likely to exist, but this 
is the general idea:

LINEFEED = "\n"  # or whatever
EOR = "?"# or whatever

def fixEOR(filename):
  f = open(filename,"r+")
  byte = True
  # loops through whole file
  while True:
# loops through record
while byte and (byte != EOR):
  byte=f.read(1)
if not byte:
  break
f.seek(-1,1)# backup 1
byte = LINEFEED
f.write(byte)   # incidentally, will put LINEFEED at EOF
f.flush()
  f.close()



On Wednesday 09 March 2005 02:06 pm, Greg Lindstrom wrote:
> Hello-
>
> I have a task which -- dare I say -- would be easy in 
> Perl  but would rather do in Python (our primary
> language at Novasys).  I have a file with varying length records.  All
> but the first record, that is; it's always 107 bytes long.  What I would
> like to do is strip out all linefeeds from the file, read the character
> in position 107 (the end of segment delimiter) and then replace all of
> the end of segment characters with linefeeds, making a file where each
> segment is on its own line.  Currently, some vendors supply files with
> linefeeds, others don't, and some split the file every 80 bytes.  In
> Perl I would operate on the file in place and be on my way.  The files
> can be quite large, so I'd rather not be making extra copies unless it's
> absolutely essential/required.
>
> I turn to the collective wisdom/trickery of the list to point me in the
> right direction.  How can I perform the above task while keeping my sanity?
>
> Thanks!
> --greg
> --
> Greg Lindstrom   501 975.4859
> Computer Programmer  [EMAIL PROTECTED]
> NovaSys Health
> Little Rock, Arkansas
>
> "We are the music makers, and we are the dreamers of dreams."  W.W.

-- 
James Stroud, Ph.D.
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Recognizing the Arrival of a New File

2005-03-09 Thread Chris Green
Greg Lindstrom <[EMAIL PROTECTED]> writes:

> Hello-
> I am writing an application where I need to recognize when a file 
> arrives in a given directory.  Files may arrive at any time during the 
> course of the day.  Do I set up a cron job to poll the directory every 
> few minutes?  Write a daemon to monitor the directory?  Or is there some 
> other more common/accepted way to perform this task?  I'm using Python 
> 2.3 on Linux.

At my last job, we had a similar problem and I wanted to be able to
check that the file was closed by the application that was putting it
there (in that case the application was w32 writing to a share via
samba).

http://cmg.dok.org/cgi-bin/pyblosxom.cgi/python/linuxlease/

Every other way I could find that relied on simple FS semantics had
the possibility of reading a file partially.
-- 
Chris Green <[EMAIL PROTECTED]>
Eschew obfuscation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Share a accomodation at PyCon from march 22-27?

2005-03-09 Thread Gregoire Weber
Hi Guys,
is someone interested in sharing accomodation during the upcoming PyCon?
I'll be there from the 22 to 27th of march (five nights).
Gregoire
--
http://mail.python.org/mailman/listinfo/python-list


Re: Web framework

2005-03-09 Thread Phil Jackson
"Gianluca Sartori" <[EMAIL PROTECTED]> writes:

> What web framework do you suggest to develop with?

I tend to use mod_python.

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


Re: An Odd Little Script

2005-03-09 Thread Terry Hancock
On Wednesday 09 March 2005 04:06 pm, Greg Lindstrom wrote:
> Hello-
> 
> I have a task which -- dare I say -- would be easy in  
> Perl  but would rather do in Python (our primary 
> language at Novasys).  I have a file with varying length records.  All 
> but the first record, that is; it's always 107 bytes long.  What I would 
> like to do is strip out all linefeeds from the file, read the character 
> in position 107 (the end of segment delimiter) and then replace all of 
> the end of segment characters with linefeeds, making a file where each 
> segment is on its own line.  Currently, some vendors supply files with 
> linefeeds, others don't, and some split the file every 80 bytes.  In 
> Perl I would operate on the file in place and be on my way.  The files 
> can be quite large, so I'd rather not be making extra copies unless it's 
> absolutely essential/required.

The only problem I see is the "in place" requirement, which seems silly
unless by "quite large" you mean multiple gigabytes.  Surely Perl
actually makes a copy in the process even though you never see
it? That much shouldn't be hard, but *actually* doing it in-place
runs into problems with the file data being accidently overwritten,
doesn't it?

I'd make a copy and delete the original afterwards.

delimiter = open('original', 'r').read(108)[107]
# this is actually the 108th character, right?
# if you mean the actual 107th character, that'll be element [106] of course

BLOCKSIZE = 1
inf = open('original', 'r')
ouf = open('result', 'w')

for block in inf.read(BLOCKSIZE):
 block = block.replace('\n', '')
 block = block.replace(delimiter, '\n')
 ouf.write(block)

Now, if we can GUARANTEE that the block never gets longer, it seems
likely that you could actually open the file 'rw' and use the same file handle
for output and input, with explicit seek() and tell() methods being used:

# REALLY, COMPLETELY UNTESTED AND DANGEROUS

delimiter = open('original', 'r').read(108)[107]  # this is actually the 108th 
character, right?
BLOCKSIZE = 1
f = open('didnt_really_want_that_file_anyway.dat', 'rw')

def indata(fp, sz):
data = fp.read(sz)
pos   = fp.tell()
return data, pos

def outdata(fp, pos, data):
fp.seek(pos)
fp.write(data)
pos  = fp.tell()
return pos

outpos = 0
for block, inpos in indata(f,BLOCKSIZE):
 block = block.replace('\n', '')
 block = block.replace(delimiter, '\n')
 outpos = outdata(f, outpos, block)

# TOTALLY UNTESTED!

I can imagine evil operating system behavior that could make this trash the 
file,
BTW, such as reading or writing data in blocks.  I'd want to test to make sure
such things don't happen (or that Python magically compensates somehow).

But is it really worth that?

Cheers,
Terry

-- 
--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: An Odd Little Script

2005-03-09 Thread Michael Hoffman
Greg Lindstrom wrote:
I have a file with varying length records.  All 
but the first record, that is; it's always 107 bytes long.  What I would 
like to do is strip out all linefeeds from the file, read the character 
in position 107 (the end of segment delimiter) and then replace all of 
the end of segment characters with linefeeds, making a file where each 
segment is on its own line.
H... here's one way of doing it:
import mmap
import sys
DELIMITER_OFFSET = 107
data_file = file(sys.argv[1], "r+w")
data_file.seek(0, 2)
data_length = data_file.tell()
data = mmap.mmap(data_file.fileno(), data_length, access=mmap.ACCESS_WRITE)
delimiter = data[DELIMITER_OFFSET]
for index, char in enumerate(data):
if char == delimiter:
data[index] = "\n"
data.flush()
There are doubtless more efficient ways, like using mmap.mmap.find()
instead of iterating over every character but that's an exercise for
the reader. And personally I would make extra copies ANYWAY--not doing
so is asking for trouble.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list


Re: python cvs interface?

2005-03-09 Thread corey
Thanks, that looks promising, I'll take a look!

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


Re: Web framework

2005-03-09 Thread Fred Pacquier
"Gianluca Sartori" <[EMAIL PROTECTED]> said :

> Hi guys,
> What web framework do you suggest to develop with? I had a look both at
> Nevow and Quixote. These seemes to be the most appreciated by the
> community. Anyway, I had no luck looking for a complete and coherent
> documentation.

Snakelets is nice, clean, simple to get started, and well documented. 
Karrigell is about in the same league. CherryPy is a step above (all IMO of 
course).

-- 
YAFAP : http://www.multimania.com/fredp/
-- 
http://mail.python.org/mailman/listinfo/python-list


[wxPython] How to allow events during long processing routine?

2005-03-09 Thread Brent W. Hughes
I'm running some code that takes a long time to finish.  I would like the 
user to be able to do other things while it is running.  It seems to me 
there is a function I can call to tell wxPython to process any pending 
messages or events.  I would call this perhaps every 1000 times through my 
loop.  Anybody remember the name of that function?

Brent


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


An Odd Little Script

2005-03-09 Thread Greg Lindstrom
Hello-
I have a task which -- dare I say -- would be easy in  
Perl  but would rather do in Python (our primary 
language at Novasys).  I have a file with varying length records.  All 
but the first record, that is; it's always 107 bytes long.  What I would 
like to do is strip out all linefeeds from the file, read the character 
in position 107 (the end of segment delimiter) and then replace all of 
the end of segment characters with linefeeds, making a file where each 
segment is on its own line.  Currently, some vendors supply files with 
linefeeds, others don't, and some split the file every 80 bytes.  In 
Perl I would operate on the file in place and be on my way.  The files 
can be quite large, so I'd rather not be making extra copies unless it's 
absolutely essential/required.

I turn to the collective wisdom/trickery of the list to point me in the 
right direction.  How can I perform the above task while keeping my sanity?

Thanks!
--greg
--
Greg Lindstrom   501 975.4859
Computer Programmer  [EMAIL PROTECTED]
NovaSys Health
Little Rock, Arkansas
"We are the music makers, and we are the dreamers of dreams."  W.W.
--
http://mail.python.org/mailman/listinfo/python-list


Re: [perl-python] a program to delete duplicate files

2005-03-09 Thread Terry Hancock
On Wednesday 09 March 2005 06:56 am, Xah Lee wrote:
> here's a large exercise that uses what we built before.
> 
> suppose you have tens of thousands of files in various directories.
> Some of these files are identical, but you don't know which ones are
> identical with which. Write a program that prints out which file are
> redundant copies.

For anyone interested in responding to the above, a starting
place might be this maintenance script I wrote for my own use.  I don't
think it exactly matches the spec, but it addresses the problem.  I wrote
this to clean up a large tree of image files once.  The exact behavior
described requires the '--exec="ls %s"' option as mentioned in the help.

#!/usr/bin/env python
# (C) 2003 Anansi Spaceworks
#---
# find_duplicates
"""
Utility to find duplicate files in a directory tree by 
comparing their checksums.
"""
#---
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#---

import os, sys, md5, getopt


def file_walker(tbl, srcpath, files):
"""
Visit a path and collect data (including checksum) for files in it.
"""
for file in files:
filepath = os.path.join(srcpath, file)
if os.path.isfile(filepath):
chksum = md5.new(open(os.path.join(srcpath, file)).read()).digest()
if not tbl.has_key(chksum): tbl[chksum]=[]
tbl[chksum].append(filepath)

def find_duplicates(treeroot, tbl=None):
"""
Find duplicate files in directory.
"""
dup = {}
if tbl is None: tbl = {}
os.path.walk(treeroot, file_walker, tbl)
for k,v in tbl.items():
if len(v) > 1:
dup[k] = v
return dup

usage = """
 USAGE: find_duplicates  [
Python-formatted command string to act on the indexed
duplicate in each duplicate group found.  E.g. try
--exec="ls %s"

   -n, --index=
Which in a series of duplicates to use. Begins with '1'.
Default is '1' (i.e. the first file listed).

  Example:
You've copied many files from path ./A into path ./B. You want
to delete all the ones you've processed already, but not
delete anything else:

% find_duplicates -q --exec="rm %s" --index=1 ./A ./B
"""

def main():
action = None
quiet  = 0
index  = 1
dup= {}

opts, args = getopt.getopt(sys.argv[1:], 'qhHn:x:', 
['quiet', 'help', 'exec=', 'index='])

for opt, val in opts:
if   opt in ('-h', '-H', '--help'):
print usage
sys.exit()
elif opt in ('-x', '--exec'):
action = str(val)
elif opt in ('-n', '--index'):
index  = int(val)
elif opt in ('-q', '--quiet'):
quiet = 1

if len(args)==0:
dup = find_duplicates('.')
else:
tbl = {}
for arg in args:
dup = find_duplicates(arg, tbl=tbl)

for k, v in dup.items():
if not quiet:
print "Duplicates:"
for f in v: print "\t%s" % f
if action:
os.system(action % v[index-1])

if __name__=='__main__':
main()



-- 
--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: enum question

2005-03-09 Thread Terry Hancock
On Friday 04 March 2005 02:54 pm, M.N.A.Smadi wrote:
> does python support a C-like enum statement where one can define a 
> variable with prespesified range of values?

No, but in most situations where I would've used an enum, I use a 
trivial class like this:

class states:
ON, OFF, UNKNOWN, UNDEFINED, INCOMPREHENSIBLE, SILLY = range(6)

The values are actually integers of course.  Then I can pass named values to a 
function:

from silly import walk, states

walk(kind=states.SILLY)

If you want to make them more like a bitfield, you could always do this instead:

class properties:
AUDIBLE, VISIBLE, SPEAKABLE = [2**i for i in range(3)]

then you can have, e.g.:

evil(allowed=False, AUDIBLE|VISIBLE|SPEAKABLE)

if mode & AUDIBLE: hear()
if mode & VISIBLE: see()

etc.

Obviously if you want more rigid assurance of the behavior of the variable
in question you'd need more work. But most of the time, enums are just to
make the code more readable, so I do this, which is extremely compact,
and yet pretty clear.  You *can* drop the enum values into the module
namespace, but then importing them is a pain, so I like to qualify them
with the class as shown.

Cheers,
Terry


-- 
--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


[German] Deutsche Python Newsgroup ist eingerichtet

2005-03-09 Thread Christian Helmbold
(This posting will be interesting for german speaking folks only.)
Hallo,
die deutsche Pyhton-Newsgroup de.comp.lang.python wurde endlich 
eingerichtet. Vielen Dank an alle, die fuer die Einrichtung gestimmt haben!

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


Re: python cvs interface?

2005-03-09 Thread Jeff Reavis
Corey,
WinCvs can use python for macros, you might want to look at their code:

http://cvs.sourceforge.net/viewcvs.py/cvsgui/cvsgui/PythonLib/cvsgui/

You may also want to look at viewcvs, which is written in Python.

-jjr

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


Re: Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread Michael Spencer
Dave Opstad wrote:
In this snippet:
d = {'x': 1}
value = d.get('x', bigscaryfunction())
the bigscaryfunction is always called, even though 'x' is a valid key. 
Is there a "short-circuit" version of get that doesn't evaluate the 
second argument if the first is a valid key? For now I'll code around 
it, but this behavior surprised me a bit...

Dave
If (and this is a big if) you know that the dictionary contains no values that 
evaluate to boolean false, then you can use the short-circuiting 'or' operator:

 >>> def bigscaryfunction():
 ... print "scary"
 ...
 >>> d= globals()
 >>> d.get("key") or bigscaryfunction()
 scary
 >>> d.get("__name__") or bigscaryfunction()
 'LazyDictget'
 >>>
Alternatively, you can just write your own getter function:
 >>> def lazyget(dict_, key, default):
 ... if key in dict_:
 ... return dict_[key]
 ... else:
 ... return default()
 ...
 >>> lazyget(d,"key",bigscaryfunction)
 scary
 >>> lazyget(d,"__name__",bigscaryfunction)
 'LazyDictget'
 >>>
The optimal choice of whether to "look before you leap" i.e., "if key in dict_" 
or simply catch KeyError, depends on the ratio of hits to misses.  Google will 
turn up some experimental data on this, but, I seem to recall that if more than 
10% attempts are misses, then LBYL is faster, because raising the exception is slow

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


Re: Web framework

2005-03-09 Thread Jeff Reavis
You may also want to look at Spyce. It is similar to JSP,PHP, or ASP.
There are some good docs and examples at the site.

http://spyce.sourceforge.net/

-jjr

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


Re: Unicode BOM marks

2005-03-09 Thread Steve Horsley
Francis Girard wrote:
Le lundi 7 Mars 2005 21:54, "Martin v. LÃwis" a Ãcrit :
Hi,
Thank you for your very informative answer. Some interspersed remarks  follow.

I personally would write my applications so that they put the signature
into files that cannot be concatenated meaningfully (since the
signature simplifies encoding auto-detection) and leave out the
signature from files which can be concatenated (as concatenating the
files will put the signature in the middle of a file).

Well, no text files can't be concatenated ! Sooner or later, someone will use 
"cat" on the text files your application did generate. That will be a lot of 
fun for the new unicode aware "super-cat".

It is my understanding that the BOM (U+feff) is actually the 
 Unicode character "Non-breaking zero-width space". I take 
this to mean that the character can appear invisibly 
anywhere in text, and its appearance as the first character 
of a text is pretty harmless. Concateniating files will 
leave invisible space characters in the middle of the text, 
but presumably not in the middle of words, so no harm is 
done there either.

I suspect that the fact that an explicitly invisible 
character feff has an invalid character code fffe for its 
byte-reversed counterpart is no accident, and that the 
charecter was intended from inception to also server as a 
byte order indication.

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


Re: popen2.Popen3 doesn't work well for me

2005-03-09 Thread Steven Bethard
alexrait1 wrote:
It does but that's not what I want.  I need a class which I can query
for process termination for instance...
Is there a way to overcome this problem with Popen3?
If you're using Python 2.4 you should look into the subprocess module. 
I think these docs might be what you're looking for:

http://docs.python.org/lib/node235.html
STeVe
--
http://mail.python.org/mailman/listinfo/python-list


Re: Running doctests with unittest

2005-03-09 Thread Jim Sizelove
Thomas Heller wrote:
I'm trying to integrate some doctest tests with unittest.  The tests
must be exposed as one or more subclasses of unittest.TestCase, so I'm
collecting them with a call to doctest.DocTestSuite(), and then add them
to a TestCase class I have created.
The tests seem to run, but they always seem to succeed - I have no idea
why.  Any ideas?
Thomas
---snip---
"""
print "Hi"
print 1213
"""
def func():
"""
>>> print "spam"
>>> print blah
"""
import doctest, unittest
suite = doctest.DocTestSuite()
class TestCase(unittest.TestCase):
pass
for index, test in enumerate(suite._tests):
setattr(TestCase, "test_%d" % index, test)
if __name__ == "__main__":
if 1:
import unittest
unittest.main()
else:
import doctest
doctest.testmod()
---snip---
I can't explain why all the tests seemed to pass, but I tried a 
different approach that works.

Once you have a suite object, you just need to run it.  The 
TextTestRunner works well for that.  I got output errors and failures by 
 doing the following:

if __name__ == '__main__':
import doctest, unittest
suite = doctest.DocTestSuite()
testRunner = unittest.TextTestRunner()
testRunner.run(suite)
HTH,
Jim Sizelove
--
http://mail.python.org/mailman/listinfo/python-list


Re: popen2.Popen3 doesn't work well for me

2005-03-09 Thread alexrait1
It does but that's not what I want.  I need a class which I can query
for process termination for instance...
Is there a way to overcome this problem with Popen3?

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


Re: Python 2.4 removes None data type?

2005-03-09 Thread Jarek Zgoda
Jacek Generowicz napisał(a):
Implication: A long standing wart in Python now gone.  Its time to
gloat. Are there any really evil glitches LEFT in Python?
Python 2.4 (#1, Dec  1 2004, 14:23:15) 
[GCC 3.2.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

True, False = False, True
True
False
Ugh, today I've found this in some legacy code (yes, there *is* legacy 
code in Python). And I will not touch this module until such syntax 
become illegal.

--
Jarek Zgoda
http://jpa.berlios.de/ | http://www.zgodowie.org/
--
http://mail.python.org/mailman/listinfo/python-list


os.walk(entire filesystem)

2005-03-09 Thread rbt
More of an OS question than a Python question, but it is Python related 
so here goes:

When I do os.walk('/') on a Linux computer, the entire file system is 
walked. On windows, however, I can only walk one drive at a time (C:\, 
D:\, etc.). Is there a way to make os.walk() behave on Windows as it 
behaves on Linux? I'd like to walk the entire file system at once... not 
one drive at a time.

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


Re: Best way to make a list unique?

2005-03-09 Thread Michael Spencer
Marc Christiansen wrote:
Michael Spencer <[EMAIL PROTECTED]> wrote:
Nice. When you replace None by an object(), you have no restriction on
the elements any more:

Thanks for the suggestion, Marc.
Note that if there is no need to access the middle of the collection, then the 
implementation is simpler, and less resource-intensive, since the items can be 
singly-linked

class UniqueQueue(object):
def __init__(self, iterable):
self._data = _data = {}
self._last = self._root = object() # An object the user is unlikely to
   # reference - thanks Marc
self.update(iterable)
def push(self, obj):
if not obj in self._data:
self._data[self._last] = obj
self._last = obj
def pop(self):
data = self._data
first = data.pop(self._root)
self._root = first
return first
def update(self, iterable):
last = self._last
data = self._data
for item in iterable:
if item not in data:
data[last] = item
last = item
self._last = last
def __iter__(self):
data = self._data
next = self._root
try:
while 1:
next = data[next]
yield next
except KeyError:
raise StopIteration
def __repr__(self):
return "%s(%s)" % (self.__class__.__name__,list(self))
 >>> q = UniqueQueue(range(5))
 >>> q.update(range(3,8))
 >>> q
 UniqueQueue([0, 1, 2, 3, 4, 5, 6, 7])
 >>> q.pop()
 0
 >>> q
 UniqueQueue([1, 2, 3, 4, 5, 6, 7])
 >>>
 >>> q.push(None)
 >>> q
 UniqueQueue([1, 2, 3, 4, 5, 6, 7, None])
 >>>
Michael

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


Re: Second argument to super().

2005-03-09 Thread Steven Bethard
Tobiah wrote:
What is the purpose of the second argument to super()?
You probably want to check the docs[1] again.  They give an example:
class C(B):
def meth(self, arg):
super(C, self).meth(arg)
What is meant by the returning of an 'unbound' object
when the argument is omitted.
If you supply a second argument (an instance of the type) to super, the 
returned object will be bound to that instance.  For example:

py> class C(object):
... def g(self):
... print 'g'
...
py> class D(C):
... def h(self):
... print 'h'
...
py> d = D()
py> s = super(D, d)
py> d2 = D()
py> s2 = super(D, d2)
py> s == s2
False
Note that the object returned depends on the instance passed in.  An 
'unbound' object would not be bound in this way to the instance.

Note also that the super object returned has access only to the methods 
of the superclass:

py> s.g
>
py> d.g
>
py> s.h
Traceback (most recent call last):
  File "", line 1, in ?
AttributeError: 'super' object has no attribute 'h'
py> d.h
>

Also, when would I pass an object as the second argument,
and when would I pass a type?
For most use cases, you'll probably only want an object (an instance). 
You might run into the type case if you define the staticmethod __new__ 
in a class:

py> class S(str):
... def __new__(cls, s):
... return super(S, cls).__new__(cls, 'S(%s)' %s)
...
py> S('abc')
'S(abc)'
In this case __new__ takes as a first argument the class (type) of the 
object, so if you want to invoke the superclass __new__, you need to 
pass the type to super.  (You don't have an instance to pass.)

STeVe
[1] http://docs.python.org/lib/built-in-funcs.html#l2h-70
--
http://mail.python.org/mailman/listinfo/python-list


python cvs interface?

2005-03-09 Thread corey
Hi everyone, this should be a quick question.  I'm writing some scripts
to take some file and move them into a CVS repository, but it's pretty
slow, because it uses system calls to execute the CVS commands.  Has
anyone ever made a python to CVS interface library that I could use?
I've been trying to google around for something, but predictably I get
a zillion sourceforge repository hits, and it isn't really helping.  So
anyway, if anyone knows of a useful module, I'd love to hear about it.
Thanks!

- Corey

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


Re: Error on xpath-ing a DOM with namespaces

2005-03-09 Thread Piet
> NSS = {u'wsdl': u'http://schemas.xmlsoap.org/wsdl/'}
> #""processorNss" = "namespace bindings to be used by the processor"
> ctx = Context(wsdl_doc, processorNss=NSS)
> Evaluate(u'wsdl:description/wsdl:documentation', context=ctx)
> """
> 
> Should give you a start.
Thanks a lot. I found a solution for my problem and lots of food for
thought for improving my XML handling in general.
Best regards
Piet
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread Steven Bethard
Bill Mill wrote:
On 9 Mar 2005 10:05:21 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
Maybe this can help:
value = d.get('x', lambda: bigscaryfunction())

def test(): print 'gbye'
...
d = {}
z = d.get('x', lambda: test())
z
 at 0x008D6870>
So this seems to be merely an obfuscation of:
z = d.get('x', test)
z

I just wanted to ask, am I missing something?
Nope that looks right.  See "Overuse of lambda" in 
http://www.python.org/moin/DubiousPython for discussion of exactly this 
mistake.

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


Re: Problematic behavior of the import statement when several module files have the same name.

2005-03-09 Thread Steven Bethard
Xif wrote:
Hello Everyone!
Here's a problem with relative imports:
Suppose I have a package called some_package (in a separate directory
included in the PYTHONPATH, with an __init__.py file etc.)
This package has a module inside the directory, called "database", and
therefore  residing in the file some_package/database.py.
Now, what if there's another module, for example inside the
site-packages directory, with the same file name (i.e. database.py)?
We have a problem. Since although these modules have different absolute
names ("some_package.database" for the first module, and just
"database" for the second), when I try to do
import database
from inside some_package, it first of all tries to find the matching
file in the some_package directory (i.e. do a relative import). Since
it first checks the some_package directory, and finds database.py
there,
import database
in fact imports the module with the absolute name
some_package.database.
You've just re-discovered the reason you should always use absolute 
imports.  Check out:

http://www.python.org/doc/faq/programming.html#what-are-the-best-practices-for-using-import-in-a-module
STeVe
--
http://mail.python.org/mailman/listinfo/python-list


Re: running programs from within python

2005-03-09 Thread Steven Bethard
M.N.A.Smadi wrote:
> am getting an error in the script as follows:
>
> NameError: global name 'os' is not defined
>
> however i dont get the same error when running from the python CLI.
> (and yes i am importing the os module)
> Steven Bethard wrote:
> Can you give the full exception message (i.e. copy-paste it from the
> output)?
M.N.A.Smadi top-posted:
this is the full error
Traceback (most recent call last):
 File "./plugin.py", line 60, in ?
   main()
 File "./plugin.py", line 40, in main
   os.system("/root/tmp/bibutils_3.14/isi2xml " + isi_file + " > 
tmp_isi_xml.xml")
NameError: global name 'os' is not defined
Hmmm...  I don't see how you'd get this if you're really importing the 
os module (as you say above).  Are you sure that you have 'import os' at 
the top of plugin.py?  You don't have any conditional wrapped around it 
do you?

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


PythonWin line spacing

2005-03-09 Thread tkpmep
I've just downloaded and installed ActivePython and am trying to
customize the PythonWin editor. Its line spacing seems to default to 2,
and consequently, I cannot see many lines of code on a screen. How do I
set the line spacing to 1?

Thomas Philips

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


Re: Web framework

2005-03-09 Thread dowskimania
Gianluca Sartori wrote:
> Hi guys,
>
> What web framework do you suggest to develop with?

I really like CherryPy.  It has a very intuitive design.  A "directory"
is an object and the "files" in it are methods.  URL variables are
passed as arguments to the methods.  The CherryPy site has a good
tutorial and some examples that should get you up and running fairly
quickly.

http://www.cherrypy.org

> Thanks for any suggestion,
> Gianluca

Hope this helps.

Christian

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


RE: running programs from within python

2005-03-09 Thread Batista, Facundo
Title: RE: running programs from within python





[James Stroud]


#- import os


He says he did it:


#- > > M.N.A.Smadi wrote:
#- > >> (and yes i am importing the os module)


But he still didn't paste the code here



.    Facundo


Bitácora De Vuelo: http://www.taniquetil.com.ar/plog
PyAr - Python Argentina: http://pyar.decode.com.ar/



  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ADVERTENCIA.


La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley.

Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo.

Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada.

Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje.

Muchas Gracias.



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

Re: Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread Reinhold Birkenfeld
Dave Opstad wrote:
> In this snippet:
> 
> d = {'x': 1}
> value = d.get('x', bigscaryfunction())
> 
> the bigscaryfunction is always called, even though 'x' is a valid key. 
> Is there a "short-circuit" version of get that doesn't evaluate the 
> second argument if the first is a valid key? For now I'll code around 
> it, but this behavior surprised me a bit...

Well, if the dict only contains ints, here is a dirty hack (but don't
use it instead of the try/except approach):

class Littletinyproxy:
def __int__(self):
return bigscaryfunction()

d = dict(x=1)
value = int(d.get('x', Littletinyproxy()))


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


Re: running programs from within python

2005-03-09 Thread James Stroud
You should

import os

On Wednesday 09 March 2005 10:06 am, M.N.A.Smadi wrote:
> this is the full error
>
>
> Traceback (most recent call last):
>   File "./plugin.py", line 60, in ?
> main()
>   File "./plugin.py", line 40, in main
> os.system("/root/tmp/bibutils_3.14/isi2xml " + isi_file + " >
> tmp_isi_xml.xml")
> NameError: global name 'os' is not defined
>
> smadi
>
> Steven Bethard wrote:
> > M.N.A.Smadi wrote:
> >> am getting an error in the script as follows:
> >>
> >> NameError: global name 'os' is not defined
> >>
> >> however i dont get the same error when running from the python CLI.
> >> (and yes i am importing the os module)
> >
> > Can you give the full exception message (i.e. copy-paste it from the
> > output)?
> >
> > STeVe

-- 
James Stroud, Ph.D.
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095
-- 
http://mail.python.org/mailman/listinfo/python-list


Second argument to super().

2005-03-09 Thread Tobiah
What is the purpose of the second argument to super()?
What is meant by the returning of an 'unbound' object
when the argument is omitted.
Also, when would I pass an object as the second argument,
and when would I pass a type?
Thanks,
Tobiah
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread Kent Johnson
F. Petitjean wrote:
Le Wed, 09 Mar 2005 09:45:41 -0800, Dave Opstad a écrit :
Is there a "short-circuit" version of get that doesn't evaluate the 
second argument if the first is a valid key? For now I'll code around 
it, but this behavior surprised me a bit...
def scary():
print "scary called"
return 22
d = dict(x=1)
d.get('x', lambda *a : scary())
# print 1
d.get('z', (lambda *a : scary())())
scary called
22
So you have to change the code at the point of call depending on whether the requested value is in 
the dict? ;)

If you can get this to work I'm sure we can find other applications for such 
'smart code' :-)
Kent
--
http://mail.python.org/mailman/listinfo/python-list


RE: Forums based on python

2005-03-09 Thread Batista, Facundo
Title: RE: Forums based on python





[EMAIL PROTECTED]


#- HI
#- I AM NEW TO PROGRAMING PRESENTLY I AM USING WINDOWS ME AND WHAT I SAW IN PYTHON INTEREST ME ANN AWFUL LOT. I DOWNLOADED VERSION 2.4 AND I #- TRIED TO GET MY PROGRAM "HELLO WORLD" ETC I SAVED ALL PROGRAMS BUT WHEN I WANT TO RUN IT I CAN'T FIND UNDER  EDIT=RUN SCRIPT = WHERE CAN I #- GO TO RUN MY BEGINNING PROGRAMS. DID I DOWNLOAD THE WRONG VERSION

#- THANK YOU FOR ANY HELP 
#- EDWARD


A message like...


"""
Hi,
 
I'm new to programming. Presently I'm using Windows ME and what I saw in Python interest me a lot.


I downloaded the version 2.4, and I tried to get my program "Hello world", etc...


I saved all programs but when I want to run it I can't find under "Edit"/"Run script". Where can I go to run my beginning programs?

Did I download the wrong version?


Thank you for any help


 Edward
"""


will bring you more help. Note that I'm not considering the actual sense of your words, just the format.


Regards,


.    Facundo


Bitácora De Vuelo: http://www.taniquetil.com.ar/plog
PyAr - Python Argentina: http://pyar.decode.com.ar/



  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ADVERTENCIA.


La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley.

Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo.

Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada.

Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje.

Muchas Gracias.



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

RE: Problematic behavior of the import statement when several modulefiles have the same name.

2005-03-09 Thread Robert Brewer
Xif wrote:
> Here's a problem with relative imports:
> 
> Suppose I have a package called some_package (in a separate directory
> included in the PYTHONPATH, with an __init__.py file etc.)
> 
> This package has a module inside the directory, called "database", and
> therefore  residing in the file some_package/database.py.
> 
> Now, what if there's another module, for example inside the
> site-packages directory, with the same file name (i.e. database.py)?
> 
> We have a problem. Since although these modules have 
> different absolute
> names ("some_package.database" for the first module, and just
> "database" for the second), when I try to do
> 
> import database
> 
> from inside some_package, it first of all tries to find the matching
> file in the some_package directory (i.e. do a relative import). Since
> it first checks the some_package directory, and finds database.py
> there,
> 
> import database
> 
> in fact imports the module with the absolute name
> some_package.database.
> 
> This is problemat on two levels:
> 
> 1) It is surprising and undesirable that "import database" in effect
> may do two completely different things ("import some_package.database"
> or "import database") depending on an external, unpredictable factor:
> the existence of a database.py file inside the some_package directory.
> 
> 2) It effectively prevents you from naming a module inside a package
> with the same name of any module in the "root" PYTHONPATH directories.
> In my example, there's no sane way I can see of having
> some_package.database if there's already a database module 
> (database.py
> file) in any PYTHONPATH directory.
> 
> Are my observations correct?  Is there something I ignored?  Should
> this be posted somewhere else?

Short answer: don't use relative imports:

from some_package import database

http://docs.python.org/ref/import.html


Robert Brewer
MIS
Amor Ministries
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread Bill Mill
On 09 Mar 2005 18:13:01 GMT, F. Petitjean <[EMAIL PROTECTED]> wrote:
> Le Wed, 09 Mar 2005 09:45:41 -0800, Dave Opstad a écrit :
> > In this snippet:
> >
> > d = {'x': 1}
> > value = d.get('x', bigscaryfunction())
> >
> > the bigscaryfunction is always called, even though 'x' is a valid key.
> > Is there a "short-circuit" version of get that doesn't evaluate the
> > second argument if the first is a valid key? For now I'll code around
> > it, but this behavior surprised me a bit...
> def scary():
> print "scary called"
> return 22
> 
> d = dict(x=1)
> d.get('x', lambda *a : scary())
>
> # print 1
> d.get('z', (lambda *a : scary())())
> scary called
> 22

but:

>>> d.get('x', (lambda *a: test())())
test called
1

So how is this different than d.get('x', test()) ?

Peace
Bill Mill
bill.mill at gmail.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread Bill Mill
On 9 Mar 2005 10:05:21 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Maybe this can help:
> 
> value = d.get('x', lambda: bigscaryfunction())

>>> def test(): print 'gbye'
...
>>> d = {}
>>> z = d.get('x', lambda: test())
>>> z
 at 0x008D6870>

So this seems to be merely an obfuscation of:

>>> z = d.get('x', test)
>>> z


I just wanted to ask, am I missing something?

Peace
Bill Mill
bill.mill at gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread F. Petitjean
Le Wed, 09 Mar 2005 09:45:41 -0800, Dave Opstad a écrit :
> In this snippet:
> 
> d = {'x': 1}
> value = d.get('x', bigscaryfunction())
> 
> the bigscaryfunction is always called, even though 'x' is a valid key. 
> Is there a "short-circuit" version of get that doesn't evaluate the 
> second argument if the first is a valid key? For now I'll code around 
> it, but this behavior surprised me a bit...
def scary():
print "scary called"
return 22

d = dict(x=1)
d.get('x', lambda *a : scary())
# print 1
d.get('z', (lambda *a : scary())())
scary called
22

First (wrong) version :
d.get('z', lambda *a : scary())
 at 0x40598e9c>
> 
> Dave
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread bearophileHUGS
Maybe this can help:

value = d.get('x', lambda: bigscaryfunction())

Bearophile

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


Re: Popen3 and capturestderr

2005-03-09 Thread Kenneth Pronovici
On Wed, Mar 09, 2005 at 06:17:50AM -, Donn Cave wrote:
> Quoth Kenneth Pronovici <[EMAIL PROTECTED]>:
> ...
> | If ignoreStderr=False, I use popen2.Popen4 so that stderr and stdout are
> | intermingled.  If ignoreStderr=True, I use popen2.Popen3 with
> | capturestderr=True so stderr doesn't appear in the output.  This
> | functionality exists so I have an equivalent of command-line redirection
> | of stderr, i.e. command 2>/dev/null.  
> ...
> | After some digging, I've decided that this behavior probably occurs
> | because I am ignoring the pipe.childerr file object.  Indeed, if I call
> | pipe.childerr.close() right after opening the pipe, my "ls" command that
> | had been hanging completes normally.  However, other commands which
> | actually attempt to write to stderr don't seem to like this very much.
> |
> | What is the right way to discard stderr when working with a pipe?  I
> | want to consistently throw it away, and I don't see a good way to do
> | this with the popen2 implementation.
> 
> Right, popen2 gives you about 3 options, out of probably dozens that
> you could get with shell redirections.  On the other hand, the source
> is available, and Python is an OOP language, so I assume there is no
> reason you can't make a derived class that does just what you want.
> In the present case I guess that would mean something like
>null = os.open('/dev/null', os.O_RDWR)
>os.dup2(null, 0)
>os.dup2(null, 2) (depending)
>os.close(null)
> along with other stuff you can just copy from Popen4.

Ah... ok, subclassing is an option I hadn't considered.  I'll give that
a whirl and see whether I can make it work.

KEN

-- 
Kenneth J. Pronovici <[EMAIL PROTECTED]>
Personal Homepage: http://www.skyjammer.com/~pronovic/
"They that can give up essential liberty to obtain a little 
 temporary safety deserve neither liberty nor safety." 
  - Benjamin Franklin, Historical Review of Pennsylvania, 1759 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: running programs from within python

2005-03-09 Thread M.N.A.Smadi
this is the full error
Traceback (most recent call last):
 File "./plugin.py", line 60, in ?
   main()
 File "./plugin.py", line 40, in main
   os.system("/root/tmp/bibutils_3.14/isi2xml " + isi_file + " > 
tmp_isi_xml.xml")
NameError: global name 'os' is not defined

smadi
Steven Bethard wrote:
M.N.A.Smadi wrote:
am getting an error in the script as follows:
NameError: global name 'os' is not defined
however i dont get the same error when running from the python CLI. 
(and yes i am importing the os module)

Can you give the full exception message (i.e. copy-paste it from the 
output)?

STeVe

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


Forums based on python

2005-03-09 Thread Naouka



HI
I AM NEW TO PROGRAMING PRESENTLY I AM USING WINDOWS ME AND WHAT I SAW IN 
PYTHON INTEREST ME ANN AWFUL LOT. I DOWNLOADED VERSION 2.4 AND I TRIED TO 
GET MY PROGRAM "HELLO WORLD" ETC I SAVED ALL PROGRAMS BUT WHEN I WANT TO RUN IT 
I CAN'T FIND UNDER  EDIT=RUN SCRIPT = WHERE CAN I GO TO RUN MY BEGINNING 
PROGRAMS. DID I DOWNLOAD THE WRONG VERSION
THANK YOU FOR ANY HELP 
EDWARD
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread Bill Mill
Dave,

On Wed, 09 Mar 2005 09:45:41 -0800, Dave Opstad <[EMAIL PROTECTED]> wrote:
> In this snippet:
> 
> d = {'x': 1}
> value = d.get('x', bigscaryfunction())
> 
> the bigscaryfunction is always called, even though 'x' is a valid key.
> Is there a "short-circuit" version of get that doesn't evaluate the
> second argument if the first is a valid key? For now I'll code around
> it, but this behavior surprised me a bit...

There is no short-circuit function like you're asking for, because
it's impossible in python. To pass an argument to the 'get' function,
python evaluates the bigscaryfunction before calling 'get'.

(I believe this means that python doesn't have "lazy evaluation", but
the language lawyers may shoot me down on that. Wikipedia seems to say
that it means python doesn't have "delayed evaluation").

Here are two ways to do what you want:

if 'x' in d: value = d['x']
else: value = bigscaryfunction()

or:

def sget(dict, key, func, *args):
if key in dict: return key
else: return func(*args)

sget(d, 'x', bigscaryfunction)

Both methods are untested, but should work with minor modifications.

Peace
Bill Mill
bill.mill at gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread Peter Hansen
Dave Opstad wrote:
In this snippet:
d = {'x': 1}
value = d.get('x', bigscaryfunction())
the bigscaryfunction is always called, even though 'x' is a valid key. 
Is there a "short-circuit" version of get that doesn't evaluate the 
second argument if the first is a valid key? For now I'll code around 
it, but this behavior surprised me a bit...
try:
value = d['x']
except KeyError:
value = bigscaryfunction()
get() is just a method, and arguments to methods are always
evaluated before being passed to the method, so the short
answer is "no, there is no 'version' of get() that will do
what you want".
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread Dave Opstad
In this snippet:

d = {'x': 1}
value = d.get('x', bigscaryfunction())

the bigscaryfunction is always called, even though 'x' is a valid key. 
Is there a "short-circuit" version of get that doesn't evaluate the 
second argument if the first is a valid key? For now I'll code around 
it, but this behavior surprised me a bit...

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


Problematic behavior of the import statement when several module files have the same name.

2005-03-09 Thread Xif
Hello Everyone!

Here's a problem with relative imports:

Suppose I have a package called some_package (in a separate directory
included in the PYTHONPATH, with an __init__.py file etc.)

This package has a module inside the directory, called "database", and
therefore  residing in the file some_package/database.py.

Now, what if there's another module, for example inside the
site-packages directory, with the same file name (i.e. database.py)?

We have a problem. Since although these modules have different absolute
names ("some_package.database" for the first module, and just
"database" for the second), when I try to do

import database

from inside some_package, it first of all tries to find the matching
file in the some_package directory (i.e. do a relative import). Since
it first checks the some_package directory, and finds database.py
there,

import database

in fact imports the module with the absolute name
some_package.database.

This is problemat on two levels:

1) It is surprising and undesirable that "import database" in effect
may do two completely different things ("import some_package.database"
or "import database") depending on an external, unpredictable factor:
the existence of a database.py file inside the some_package directory.

2) It effectively prevents you from naming a module inside a package
with the same name of any module in the "root" PYTHONPATH directories.
In my example, there's no sane way I can see of having
some_package.database if there's already a database module (database.py
file) in any PYTHONPATH directory.

Are my observations correct?  Is there something I ignored?  Should
this be posted somewhere else?

Your comments would be appreciated.

Xif

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


Help with socket staus

2005-03-09 Thread Miley, Shain
Hello,
First let me say hello since I am new to this list.  

Recently I downloaded and installed the c3 suite of python2 scripts so that I 
can execute commands on multiple unix nodes.  What I am looking to do is 
determine when an ssh connection fails (either sshd has been stopped, the node 
is not in service, etc).  I have been unable to find good documentation to help 
me resolve this issue.  The message that I receive when ssh fails is this:

ssh: connect to host test.node.com port 22: Connection refused

So I guess my question is this...are there any methods to determine the state 
of a socket connection (i.e connected, no connected, connection failed, etc).

Thanks in advance,

Shain


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


Re: logging addLevelName

2005-03-09 Thread Jeremy Jones
[EMAIL PROTECTED] wrote:
I am trying to add a new logging level.
logging.config.fileConfig("bengineLog.cfg")
logging.CLIENT = logging.INFO + 1
logging.addLevelName( logging.CLIENT, 'CLIENT' )
logging.root.setLevel( [logging.INFO, logging.CLIENT, logging.WARNING,
logging.ERROR, logging.CRITICAL] )
logger = logging.getLogger(None)
logging.Logger.client('test')
I get error:
AttributeError: class Logger has no attribute 'client'
Any help?
 

Looks like what you want is logger.log().  Here is an example that takes 
your addLevelName code and logs at levels info to critical:

#!/usr/bin/env python
import logging
#create new log level
logging.CLIENT = logging.INFO + 1
logging.addLevelName(logging.CLIENT, "CLIENT")
logging.root.setLevel([logging.INFO, logging.CLIENT, logging.WARNING, 
logging.ERROR, logging.CRITICAL])

#create logger with "mylogger"
logger = logging.getLogger("mylogger")
logger.setLevel(logging.INFO)
#create file handler and set level to debug
fh = logging.FileHandler("test.log")
fh.setLevel(logging.DEBUG)
#create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
#create formatter
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - 
%(message)s")
#add formatter to handlers
fh.setFormatter(formatter)
ch.setFormatter(formatter)
#add handlers to logger
logger.addHandler(fh)
logger.addHandler(ch)

logger.debug("this is debug")
logger.info("this is info")
logger.log(logging.CLIENT, "this is client")
logger.warning("this is warning")
logger.error("this is error")
logger.critical("this is critical")
It produces this output:
2005-03-09 12:28:33,399 - mylogger - INFO - this is info
2005-03-09 12:28:33,401 - mylogger - CLIENT - this is client
2005-03-09 12:28:33,458 - mylogger - WARNING - this is warning
2005-03-09 12:28:33,460 - mylogger - ERROR - this is error
2005-03-09 12:28:33,518 - mylogger - CRITICAL - this is critical
HTH,
Jeremy Jones
--
http://mail.python.org/mailman/listinfo/python-list


Re: running programs from within python

2005-03-09 Thread Steven Bethard
M.N.A.Smadi wrote:
am getting an error in the script as follows:
NameError: global name 'os' is not defined
however i dont get the same error when running from the python CLI. (and 
yes i am importing the os module)
Can you give the full exception message (i.e. copy-paste it from the 
output)?

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


RE: running programs from within python

2005-03-09 Thread Batista, Facundo
Title: RE: running programs from within python





[M.N.A.Smadi]


#- am getting an error in the script as follows:
#- 
#- NameError: global name 'os' is not defined


What script? 


Please paste it here. If it's more than 20 lines, trim it until you find the smaller script that has the error.


.    Facundo


Bitácora De Vuelo: http://www.taniquetil.com.ar/plog
PyAr - Python Argentina: http://pyar.decode.com.ar/



  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ADVERTENCIA.


La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley.

Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo.

Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada.

Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje.

Muchas Gracias.



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

Re: running programs from within python

2005-03-09 Thread M.N.A.Smadi
am getting an error in the script as follows:
NameError: global name 'os' is not defined
however i dont get the same error when running from the python CLI. (and 
yes i am importing the os module)

is this a bug in python 2.3 (the one am currently using)
thanks
m.smadi
Steven Bethard wrote:
M.N.A.Smadi wrote:
M.N.A.Smadi wrote:
hi;
in general: how can i pass a string containing a concatenated 
sequcne of command line arguments to a unix system CLI?

i guess i will answer myself:
import os
os.system(string)

Also worth noting is that if you're using Python 2.4, you might want 
to look at the subprocess module, which replaces many of the older 
os.* calls with a more flexible interface.  For the os.system 
replacement, see:

http://docs.python.org/lib/node235.html
STeVe

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


Re: [CherryPy]Serve dynamic binary file in cherrypy?

2005-03-09 Thread Remi Delon
"mep" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> Hi,
> After lookup in cherrypy site and google for a while, I haven't
> found any information about cherrypy how to serve dynamic binary
> file(some generated charts).Is there any easy way to do this?
>  In cherrypy 2.0 & python 2.4

Yes, there is an easy way: have your handler method return the binary
data, and set the Content-Type before returning the data, like this:

# class Root:
# def index(self):
# ... Generate binary data in "data" ...
# cpg.response.headerMap['Content-Type'] = 'image/gif'
# return data

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


Re: running programs from within python

2005-03-09 Thread Steven Bethard
M.N.A.Smadi wrote:
M.N.A.Smadi wrote:
hi;
in general: how can i pass a string containing a concatenated sequcne 
of command line arguments to a unix system CLI?

i guess i will answer myself:
import os
os.system(string)
Also worth noting is that if you're using Python 2.4, you might want to 
look at the subprocess module, which replaces many of the older os.* 
calls with a more flexible interface.  For the os.system replacement, see:

http://docs.python.org/lib/node235.html
STeVe
--
http://mail.python.org/mailman/listinfo/python-list


RE: running programs from within python

2005-03-09 Thread Batista, Facundo
Title: RE: running programs from within python





[M.N.A.Smadi]


#- i guess i will answer myself:
#- import os
#- os.system(string)


If you have Py2.4, it's better to use subprocess().


.    Facundo


Bitácora De Vuelo: http://www.taniquetil.com.ar/plog
PyAr - Python Argentina: http://pyar.decode.com.ar/



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

SOAPpy Interoperability w/AXIS C++

2005-03-09 Thread jkohans
Hello,

I am having some trouble getting a Python client written using SOAPpy
0.11.6 to work with a Web Service that is published using AXIS C++
version 1.4.  I have a C++ client working, and I am able to compare the
SOAP messages that are being sent by it and the Python client.

It appears as though the only difference is the definition of the XML
Schema and XML Schema-instance namespace.  The C++ client refers to the
2001 versions, but the Python client refers to the 1999 versions.  Has
anyone run into a similar problem and been able to find a work around?
Thanks in advance for any help.

Regards,
Jeremy Kohansimeh

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


Re: running programs from within python

2005-03-09 Thread M.N.A.Smadi
M.N.A.Smadi wrote:
hi;
in general: how can i pass a string containing a concatenated sequcne 
of command line arguments to a unix system CLI?

my specific problem:
i have an executable that is called xyz (written in C if that matters) 
that i cannot modify, which prints it is text output to the screen and 
takes an input as t.txt.
on a unix terminal, i do the ./xyz t.txt > tmp.txt
so that the tmp.txt will contain the output of the xyz executable

i tried the following but it did not work
import os
os.execl("./xyz","t.txt > tmp.txt") #the thing just hangs there
i aslo tried
os.execl("./xyz","t.txt") # but it does not output anything to the 
screen either, hangs there too

any suggestions?
thanks
m.smadi
i guess i will answer myself:
import os
os.system(string)
!!
--
http://mail.python.org/mailman/listinfo/python-list


running programs from within python

2005-03-09 Thread M.N.A.Smadi
hi;
in general: how can i pass a string containing a concatenated sequcne of 
command line arguments to a unix system CLI?

my specific problem:
i have an executable that is called xyz (written in C if that matters) 
that i cannot modify, which prints it is text output to the screen and 
takes an input as t.txt.
on a unix terminal, i do the ./xyz t.txt > tmp.txt
so that the tmp.txt will contain the output of the xyz executable

i tried the following but it did not work
import os
os.execl("./xyz","t.txt > tmp.txt") #the thing just hangs there
i aslo tried
os.execl("./xyz","t.txt") # but it does not output anything to the 
screen either, hangs there too

any suggestions?
thanks
m.smadi
--
http://mail.python.org/mailman/listinfo/python-list


MDaemon Warning - virus found: RETURNED MAIL: SEE TRANSCRIPT FOR DETAILS

2005-03-09 Thread Automatic Email Delivery Software

*** WARNING **
Este mensaje ha sido analizado por MDaemon AntiVirus y ha encontrado 
un fichero anexo(s) infectado(s).  Por favor revise el reporte de abajo.

AttachmentVirus name   Action taken
--
mail.zip  Email-Worm.Win32.Mydoom.m Removed


**


The message was not delivered due to the following reason:

Your message could not be delivered because the destination computer was
not reachable within the allowed queue period. The amount of time
a message is queued before it is returned depends on local configura-
tion parameters.

Most likely there is a network problem that prevented delivery, but
it is also possible that the computer is turned off, or does not
have a mail system running right now.

Your message was not delivered within 5 days:
Host 197.51.128.93 is not responding.

The following recipients did not receive this message:


Please reply to [EMAIL PROTECTED]
if you feel this message to be in error.

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

Web framework

2005-03-09 Thread Gianluca Sartori
Hi guys,

What web framework do you suggest to develop with? I had a look both at
Nevow and Quixote. These seemes to be the most appreciated by the
community. Anyway, I had no luck looking for a complete and coherent
documentation.

Thanks for any suggestion,
Gianluca

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


Re: [perl-python] a program to delete duplicate files

2005-03-09 Thread TZOTZIOY
On 9 Mar 2005 04:56:13 -0800, rumours say that "Xah Lee" <[EMAIL PROTECTED]> 
might
have written:

>Write a Perl or Python version of the program.
>
>a absolute requirement in this problem is to minimize the number of
>comparison made between files. This is a part of the spec.

http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/de90435f3e56ab0c/048e292ec9adb82d

The whole thread is about finding duplicate files.
-- 
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Your suggestions re virus, round 6: Virus KO

2005-03-09 Thread Anthra Norell
Josef,
  I'll definitely take a close look at all the suggestions I have been
offered, in the interest of future damage prevention. This time, though, the
fight is over and I emerge victorious!
  Poking around here and I came across huge startup or execution log
files listing rather unabashed file names. Since I'm not into that, how did
it get there? Turned out the files were all identical and also identical to
the attachment of each one of the many obviously automated decoy messages I
have been getting of late (like: 'Offer expires today',  or 'I'm shocked! Is
that really you', etc.). (Not that I ever opened any one oif them.) Anyway,
I scanned the whole disk for files of identical lenght and ended up with 869
copies of the obnoxity. One of them was C:\WINDOWS\fvprotect.exe--a windows
process of all things. I eradicated the whole lot and now all is well. I
don't believe any damage was caused, except that the Norton virus scanner
still won't start. Perhaps another install will fix that too.
 Linux is next. Do you know of a good disk-partitioning program?
Frederic

- Original Message -
From: "Josef Albert Meile" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, March 09, 2005 12:23 PM
Subject: Re: Your suggestions re virus, round 5


> Hi Frederic,
>
> >Protected mode doesn't make any difference with respect to stuff not
> >running. Plus it doesn't connect to the internet. So I went back to
> >unprotected mode to download WinTask. I played around with it for a while
> >without being able to figure out how it works. All the while my resolve
> >strengthened to start everyting from scratch and take the opportunity to
> >install Linux. I startet uninstalling stuff I never use and started
hunting
> >for the original media of the stuff I do use and already face the
> >predicament of not finding some. I imagine an uninstaller that saves an
> >application and restores it from the save. Do you know of any such thing?
> Sorry, I don't know if such thing exists. But anyway, at last alternative,
I
> will
> do a backup of the important files and reinstall everything.
>
> There is another alternative, but you have to know what you are doing:
> http://www.hijackthis.de
>
> You can also get a log of the running processes with this tool and do an
> online analysis on the hijackthis.de website. There are also forums there
> where you can ask.
>
> Good luck,
> Josef
>
> _
> Don't just search. Find. Check out the new MSN Search!
> http://search.msn.click-url.com/go/onm00200636ave/direct/01/
>

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


Re: i18n: looking for expertise

2005-03-09 Thread [EMAIL PROTECTED]
Michael:

on my box, (winXP SP2), sys.getfilesystemencoding() returns 'mbcs'.

If you post your revised solution to this unicode problem, I'd be
delighted to test it on Windows.  I'm working on a Tkinter front-end
for Vivian deSmedt's rsync.py and would like to address the issue of
accented characters in folder names.

thanks
Stewart 
stewart dot midwinter at gmail dot com

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


Re: Split text file into words

2005-03-09 Thread Duncan Booth
qwweeeit wrote:

>ll=re.split(r"[\s,{}[]()+=-/*]",i)

The stack overflow comes because the ()+ tried to match an empty string as 
many times as possible.

This regular expression contains a character set '\s,{}[' followed by the 
expression '()+=-/*]'. You can see that the parentheses aren't part of a 
character set if you reverse their order which gives you an error when the 
expression is compiled instead of failing when trying to match:

>>> ll=re.split(r"[\s,{}[])(+=-/*]",i)

Traceback (most recent call last):
  File "", line 1, in -toplevel-
ll=re.split(r"[\s,{}[])(+=-/*]",i)
  File "C:\Python24\Lib\sre.py", line 157, in split
return _compile(pattern, 0).split(string, maxsplit)
  File "C:\Python24\Lib\sre.py", line 227, in _compile
raise error, v # invalid expression
error: unbalanced parenthesis
>>> 

I suspect you actually meant the character set to include the other 
punctuation characters in which case you need to escape the closing square 
bracket or make it the first character:

Try:

ll=re.split(r"[\s,{}[\]()+=-/*]",i)

or:

ll=re.split(r"[]\s,{}[()+=-/*]",i)

instead.


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


Re: Python COM Class Question

2005-03-09 Thread Steve Holden
pemo wrote:
I'm trying to use difflib.py from a COM aware language - and, for ease of 
use, I'm initially trying to get this going from VB6.

I've wrappered difflib.py correctly I think, and I can now call into it and 
call a global method (called 'test' of course).  Here's the consuming code:

Dim PythonUtils As Object
Set PythonUtils = CreateObject("DiffLib.Utils")
Debug.Print PythonUtils.test()
However, difflib contains classes - like SequenceMatcher, and I've no idea 
how to get an instance of these from PythonUtils.

Can someone help me here please?
I hope so.
You need to wrap the Python objects for use in the COM framework - once 
wrapped their methods can be called by the client code.

You'll find wrap in win32com.server.util.
regards
 Steve
--
http://mail.python.org/mailman/listinfo/python-list


Re: Working on a log in script to my webpage

2005-03-09 Thread Steve Holden
Pete. wrote:
I better mention, that I rather make it all in python and html (found out 
that python somehow works with asp)

I know that what I have to do is the following:
1) When the user logs in, I have to store a session ID in a cookie
In actual fact it's best not to wait until the user logs in: every 
request that comes in for the service should be examined for the cookie 
(which the browser will always return once it's received it). If there's 
no cookie then the server should include one in its response.

That way, each session is identified by a unique cookie value, which can 
be used (among other things) to locate any state that's associated with 
the sessions (such as a "who is this user" variable).

2) When page1 is loaded(upon correctly entered username/password) the cookie 
has to be sent to page 1 and on page one there should be a tjeck to see if 
the cookies has the right values.
Not quite: the cookie (retained on the client and sent to the server 
with each request) just identifies the session, and the session state 
storage (maintained on the server, one per active session) holds the 
information about the session like whether the user has logged in, 
what's in their shopping cart, and so on.

Each page (or, if you are using an application framework like Webware, 
the framework) can examine state memory to determine whether the 
conditions for access have been met, and redirect to an error page if 
not. For this purpose ASP maintained a "Session" object for each 
session's state memory.

3) everytime a page is loaded, there has to be a tjeck, to see if the 
cookies has the right value, if not the page shouldt be loaded, and the user 
should be redirected back to login page.

Almost, see above.
It does sound very easy to make: Create a store-holder(cookies), create a 
session ID upon log in, tjeck if it is the right sessionID in the cookies 
everytime a page is loaded, if not redirect back to log in page.

But eventhough it sounds easy, I cant quite get the hold of if..
I tried googling, but didnt really find anything, that helpfull...
It's true that there isn't actually much on the web that explains 
sessions with specific reference to Python. I can, however, after quite 
a lot of searching, thoroughly recommend

  http://webapparch.sourceforge.net/
for an overview of what happens in a session-oriented web service. I 
would suggest you start with Section 8, and then read the whole thing, 
or at least all parts that interest you.

Any more advice...
Of course usually some mechanism supported by the specific server in use 
is involved.

  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65110
does show how to generate session IDs, but then you have to deliver them 
as cookies (of course, for security reasons you don't want session IDs 
to be easily guessed, as this would allow someone to "hijack" an 
existing session by impersonating a browser holding the right cookie value).

If you are prepared to read a bit of PHP (sorry ...) then
  http://www.phpbuilder.com/columns/paul20020729.php3
explains the details of session maintenance sufficiently clearly that 
you would get a good idea of how to implement the same ideas in Python.


Once again thanks for your time
Sincerly
Pete
[...]
You're welcome.
regards
 Steve
--
http://mail.python.org/mailman/listinfo/python-list


Re: Split text file into words

2005-03-09 Thread qwweeeit
I thank you for your help.
I already used re.split successfully but in this case...
I didn't explain more deeply because I don't want someone else do my
homework.

I want to implement a variable & commands cross reference tool.
For this goal I must clean the python source from any comment and
manifest string.
On the cleaned source file I must isolate all the words (keeping the
words connected by '.')

My wrong code (don't consider the line ref. in traceback ... it's an
extract!):

import re

# input text file w/o strings & comments

f=open('file.txt')
lInput=f.readlines() 
f.close()

fOut=open('words.txt','w')

for i in lInput:
.   ll=re.split(r"[\s,{}[]()+=-/*]",i)
.   fOut.write(' '.join(ll)+'\n')

fOut.close()

Traceback (most recent call last):
  File "./GetWords.py", line 70, in ?
ll=re.split(r"[\s,{}[]()+=-/*]",i)
  File "/usr/lib/python2.3/sre.py", line 156, in split
return _compile(pattern, 0).split(string, maxsplit)
RuntimeError: maximum recursion limit exceeded


... and if I use:
ll=re.split(r"\s,{}[]()+=-/*",i)

Traceback (most recent call last):
  File "./GetWords.py", line 70, in ?
ll=re.split(r"\s,{}[]()+=-/*",i)
  File "/usr/lib/python2.3/sre.py", line 156, in split
return _compile(pattern, 0).split(string, maxsplit)
  File "/usr/lib/python2.3/sre.py", line 230, in _compile
raise error, v # invalid expression
sre_constants.error: bad character range

I taught it was my mistake in the use of re.split...

I am using:   
Python 2.3.4 (#2, Aug 19 2004, 15:49:40)
[GCC 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)] on linux2
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Working on a log in script to my webpage

2005-03-09 Thread Pete.....
Thanks.

But I would really like to do this from scratch, so that I can learn it, I 
dont think I need that much more, before it works.

I found an example with asp, where the save the session if the password is 
correct. It isnt that long a code, so was wondering if it isnt possible to 
make something like that in python. Cause when this code is applied to the 
loginform, CODE2 will only have to be applied to every following page and 
everything is good.

code is from: 
http://tutorialized.com/tutorial/Creating-a-Members-Area-in-ASP/2234
CODE1
Set objRS = objConn.Execute (strSQL)
  '// see if there are any records returned
  If objRS.EOF Then
  'no username found
  strError = "- Invalid username or password" & vbNewLine
  Else
  'check password
  If objRS("password")=Request.Form("password") Then
   'username/password valid
   'save session data
   Session("loggedin") = True
   Session("userid") = objRS("id")
   'redirect to members area
   Response.Redirect ("default.asp")
   Response.End
  Else
   'invalid password
   strError = "- Invalid username or password" & vbNewLine

CODE2<%
If Session("loggedin") <> True Then Response.Redirect "login.asp"
%>


Members Area


Members Area
Welcome to our members area!
 In my code I have allready tested if the username and password is 
correct, so I just need to do the cookie thing :D

Thanks all, hope all my questions dosnt make you tired, I just really wanna 
figure this out, and I am doing this as a little hobby of mine, so I dont 
have anyone else to ask, hope that is okay...



"Kent Johnson" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Pete. wrote:
>> Hi all I am working on a log in script for my webpage.
>>
>> I have the username and the password stored in a PostgreSQL database.
>
> You might want to look at Snakelets and CherryPy.
>
> Snakelets is "a very simple-to-use Python web application server." One of 
> the features is "Easy user authentication and user login handling."
> http://snakelets.sourceforge.net/
>
> CherryPy is "a pythonic, object-oriented web development framework" that 
> seems to be popular. A recipe for password-protected pages in CherryPy is 
> here:
> http://www.cherrypy.org/wiki/PasswordProtectedPages
>
> Kent 


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


BayPIGgies: March 10, 7:30pm (FINAL MEETING AT STANFORD)

2005-03-09 Thread Aahz
WARNING: the last meeting of BayPIGgies at Stanford is currently
scheduled for March.  Our host, Danny Yoo, is leaving Stanford, and we
need to find a new location.  If you wish to assist with the search,
please join the BayPIGgies mailing list.

Meanwhile, let's all give hearty thanks to Danny for helping us find a
stable meeting location for so long!


The next meeting of BayPIGgies will be Thurs, March 10 at 7:30pm.

Donovan Preston will lead a discussion about using Python with OS X,
including integrating with PyObjC and GNUStep.

BayPIGgies meetings are in Stanford, California.  For more information
and directions, see http://www.baypiggies.net/


Before the meeting, we may meet at 6pm for dinner in downtown Palo Alto.
Discussion of dinner plans is handled on the BayPIGgies mailing list.


Advance notice: The April 14 meeting agenda has not been set.  Please
send e-mail to [EMAIL PROTECTED] if you want to suggest an
agenda -- and a meeting place!
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code -- 
not in reams of trivial code that bores the reader to death."  --GvR
-- 
http://mail.python.org/mailman/listinfo/python-list


Announcement: PyMatrix-0.0.1a Released

2005-03-09 Thread Colin J. Williams
PyMatrix is a package to provide access to the functionality of matrix 
algebra.

This package is currently based on numarray.  It includes a statistics 
module which includes a basic analysis of variance.

In the future it is hoped to enhance the generality of the divide 
operation, to add the transcendental functions as methods of the matrix 
class and to improve the documentation.  The expectation is that 
Numeric3 will eventually replace numarray and that this will necessitate 
some changes to PyMatrix

Downloads in the form of a Windows Installer (Inno) and a zip file are 
available at:

   http://www3.sympatico.ca/cjw/PyMatrix
An /Introduction to PyMatrix/ is available:
   http://www3.sympatico.ca/cjw/PyMatrix/IntroToPyMatrix.pdf
Information on the functions and methods of the matrix module is given at:
   http://www3.sympatico.ca/cjw/PyMatrix/Doc/matrix-summary.html
Colin W.
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to upgrade python on Redhat?

2005-03-09 Thread Paul Boddie
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL 
PROTECTED]>...
> 
> 2) Give up and install python 2.4 in /usr/local. This leaves me in the
> awkward situation of having to ensure that all our in-house scripts,
> all the time use /usr/local/bin/python.

Or, as recommended, use...

#!/usr/bin/env python

...and make sure the scripts are run in an appropriately configured environment.

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


  1   2   >