IMAP UTF-7, any codec for that anywhere?

2004-12-01 Thread Max M
Is there any codec available for handling The special UTF-7 codec for IMAP?
I have searched the web for info, but there only seem to be discussions 
about it. Not actual implementations.

This is what I am talking about:
http://www.faqs.org/rfcs/rfc2060.html
5.1.3.  Mailbox International Naming Convention
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
--
http://mail.python.org/mailman/listinfo/python-list


Re: pre-PEP generic objects

2004-12-01 Thread Peter Otten
Steven Bethard wrote:

 Peter Otten wrote:
 Steven Bethard wrote:
 
def __eq__(self, other):
x.__eq__(y) == x == y
return (isinstance(other, self.__class__)
and self.__dict__ == other.__dict__)
 
 This results in an asymmetry:
 
 [snip]
 
 Whether this is intended, I don't know. If someone can enlighten me...

 Unintended.  

Oops, I meant CPython's rich comparison, not your __eq__() implementation.

 I'll switch to 
  self.__class__ == other.__class__
 or
  type(self) == type(other)
 Any preference?

Normally none of them. The former if hard pressed because all old-style
classes have the same type(). But it doesn't really matter here.

Peter

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


Re: Python 2.4 Uninstall Entry in WinXP Registry

2004-12-01 Thread Martin v. Löwis
Brad Tilley wrote:
Python 2.3 placed a registry key under:
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Python2.3' 
[...]
Python 2.4 does not use this registry entry on the two machines I have 
installed it on... any tips on how to locate this?
It's under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{82D9302E-F209-4805-B548-52087047483A}
which is the product code of Python 2.4. Notice that Python 2.4.1
will use a different product code.
However, if you merely want to avoid that users remove the package,
you can set the ARPNOREMOVE property during installation, e.g.
msiexec /i python24.msi ARPNOREMOVE=1
You might want to set ARPNOMODIFY and ARPNOREPAIR as well.
If you cannot readily pass that property on the command line during
installation, you can use orca.exe (or a python script) to add this
property to the Property table of python24.msi.
If you have W2k or later, you can also set the NoRemove registry
value under the key above, to hide the remove feature after
installation.
HTH,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: IMAP UTF-7, any codec for that anywhere?

2004-12-01 Thread Brian Quinlan
Max M wrote:
Is there any codec available for handling The special UTF-7 codec for IMAP?
I have searched the web for info, but there only seem to be discussions 
about it. Not actual implementations.
Is there something special do you need or is recipe OK?
 u\u00ff.encode('utf-7')
'+AP8-'
Cheers,
Brian
--
http://mail.python.org/mailman/listinfo/python-list


2.4 or 2.3.4 for 2.3 software?

2004-12-01 Thread Jens Bloch Helmers
Can we expect the current release of 2.4 to be just as reliable as
2.3.4 for 2.3 compliant software?

Thanks for any help!
Jens
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: RELEASED Python 2.4 (final)

2004-12-01 Thread BJörn Lindqvist
Christmas came early this year. Thank you all nice Python developers. 

-- 
mvh Björn
--
http://mail.python.org/mailman/listinfo/python-list


Re: 2.4 or 2.3.4 for 2.3 software?

2004-12-01 Thread Gerhard Haering
On Wed, Dec 01, 2004 at 10:23:55AM +0100, Jens Bloch Helmers wrote:
 Can we expect the current release of 2.4 to be just as reliable as
 2.3.4 for 2.3 compliant software?

Only time will tell.

I myself had never had any problems with 2.x.0 versions of Python. Only early
2.0.x had a few problems in the C API for me.

-- Gerhard


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: decorators ?

2004-12-01 Thread BJörn Lindqvist
Some more decorator examples.

How to create abstract methods using an @absractmethod decorator:
http://www.brpreiss.com/books/opus7/html/page117.html

Generics, property getters and setters. I don't know what these
decorators are supposed to do:
http://www.cis.upenn.edu/~edloper/pydecorators.html -

And according to this,
http://www.prothon.org/pipermail/prothon-user/2004-August/003173.html,
one use of decorators is to put a functions docstring before the def
f(): line like this:

@doc(blabla does something.)
def blabla():

Here is one decorator for optimizing:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/277940

I think the essence of decorators is that it makes it possible to do
in Python what you in other languages do with method qualifiers. This
declaration in Java

public synchronized static void doStuff()

would you write in Python as

@public
@synchronized
@staticmethod
def doStuff():

I haven't seen an example of a @synchronized decorator, but I assume
it is possible. Hopefully, it is possible to create a @private
decorator which throws some kind of exception when a private method is
accessed from outside the class. If that is possible, then it would
also be nice to have a @public decorator which doesn't do anything. As
far as I know, only two decorators are included in the standard
library in Python 2.4, @staticmethod and @classmethod. That is a
little unfortunate, because many more obvious ones could have been
included. The devs are probably planning to correct that in the coming
versions.
That is all I know about decorators. Or rather THINK I know from
reading stuff on the internet. Please don't flame me if I'm wrong. :)

-- 
mvh Björn
--
http://mail.python.org/mailman/listinfo/python-list


Re: Question on sorting

2004-12-01 Thread Peter Otten
Lad wrote:

 wes weston [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]...
 Lad wrote:
  Hi,
  I have a file of records of 4 fields each.
  Each field is separated by a semicolon. That is
  
  Filed1;Ffield2;Field3;Field4
  
  But there may be also empty records such as
  
  (only semicolons).
  
  For sorting I used
  #
  lines = file('Config.txt').readlines()# a file I want to sort
  lines.sort()
  ff=open('ConfigSorted.txt','w')# sorted file
  ff.writelines(lines)
  ff.close()
  ###
  It was sorted but empty records were first. I need them to be last(at
  the end of the file). How can I do that?
  
  Thanks for help
  Lad
 
 Lad,
 The sort call can have a function name as an arg. You
 could do:
 
 def mycompare(s1,s2):
 #return -1 to put s1's at front; 1 to put s1's at back; 0 for a tie
 #if s1== and s2: return 1
 
 lines.sort(mycompare)
 
 Wes,
 Thank you for reply. But I do not understand mycompare function. Can
 you please explain to me how it should work? Thanks

compare(a, b) is just a function for comparing two items/lines. I must
return -1 if ab, +1 if ab, and 0 if a==b. For example the following
compare moves the  records to the end and keeps the order of others
unaffected:

 items = [, ;a;b;;, ;b;a;;, a;b;c;d;e, a;;;d;e]
 def compare(a, b):
... return cmp(a == , b == ) or cmp(a, b)
...
 items.sort(compare)
 items
[';a;b;;', ';b;a;;', 'a;;;d;e', 'a;b;c;d;e', '']

As Eddie Corns pointed out, you left some doubt whether that is really what
you want. Here is a more complex compare() that handles the lines as
columns split by ; and puts empty columns last in the sorting order:

 def key(row):
... return [(not col, col) for col in row.split(;)]
...
 def compare(a, b):
... return cmp(key(a), key(b))
...
 items.sort(compare)
 items
['a;b;c;d;e', 'a;;;d;e', ';a;b;;', ';b;a;;', '']

If you are on Python 2.4, you don't need the compare() detour and can use
key() directly:

 items.sort(key=key)
 items
['a;b;c;d;e', 'a;;;d;e', ';a;b;;', ';b;a;;', '']

Finally, the  lines don't seem to carry any information - why not
filter them out completely?

 items = [line[:-1] for line in file(cfg.txt, U) if line != \n]


Peter

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


Regular Expression Problem...

2004-12-01 Thread andrea . gavana
Hello NG,

 I am quite new with Python... I'm writing an application that does
also some regexp things on strings, but I'm having problem about
identifying/extracting a substring from another string. What I have to do
is to extract all the strings that begins with a $ character, but
excluding characters like . (point) and ' (single quote) and \ /
(slashes). For example I have:

1) This Is An $EXAMPLE String
2) This Is An $EXAMPLE.String
3) 'This Is An $EXAMPLE'
4) This Is An \$EXAMPLE\String;

I would like to extract only the keyword $EXAMPLE and what I'm using at
the moment is:

#CODE BEGIN
import re

mystring = This Is An \$EXAMPLE\String;
regex = re.compile([\$]+\S*,re.IGNORECASE)
keys = regex.findall(mystring)

#CODE END

Obviously this code returns things like $EXAMPLE', $EXAMPLE/, $EXAMPLE. and
so on...
Does anyone have a suggestion?

Thank you a lot.

Andrea.

--

Message for the recipient only, if received in error, please notify the
sender and read http://www.eni.it/disclaimer/

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


Re: Regular Expression Problem...

2004-12-01 Thread Jorge Godoy
[EMAIL PROTECTED] writes:

 #CODE BEGIN
 import re

 mystring = This Is An \$EXAMPLE\String;
 regex = re.compile([\$]+\S*,re.IGNORECASE)
 keys = regex.findall(mystring)

 #CODE END

regex = re.compile([\$]+\w*,re.IGNORECASE)

 import re

 mystring = This Is An \$EXAMPLE\String;
 regex = re.compile([\$]+\w*,re.IGNORECASE)
 keys = regex.findall(mystring)
 keys
['$EXAMPLE']
 


Be seeing you,
-- 
Godoy. [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Regular Expression Problem...

2004-12-01 Thread Doran_Dermot
You could try the following:
regex = re.compile([\$]\w+, re.IGNORECASE)

I've only done a bit of testing.  Maybe somebody has a better solution.

Cheers!!

Dermot. 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: 01 December 2004 12:23
To: [EMAIL PROTECTED]
Subject: Regular Expression Problem...

Hello NG,

 I am quite new with Python... I'm writing an application that does
also some regexp things on strings, but I'm having problem about
identifying/extracting a substring from another string. What I have to do
is to extract all the strings that begins with a $ character, but
excluding characters like . (point) and ' (single quote) and \ /
(slashes). For example I have:

1) This Is An $EXAMPLE String
2) This Is An $EXAMPLE.String
3) 'This Is An $EXAMPLE'
4) This Is An \$EXAMPLE\String;

I would like to extract only the keyword $EXAMPLE and what I'm using at
the moment is:

#CODE BEGIN
import re

mystring = This Is An \$EXAMPLE\String;
regex = re.compile([\$]+\S*,re.IGNORECASE)
keys = regex.findall(mystring)

#CODE END

Obviously this code returns things like $EXAMPLE', $EXAMPLE/, $EXAMPLE. and
so on...
Does anyone have a suggestion?

Thank you a lot.

Andrea.


--

Message for the recipient only, if received in error, please notify the
sender and read http://www.eni.it/disclaimer/

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


Re: Help With Hiring Python Developers

2004-12-01 Thread Bill McClain
On 2004-12-01, fuego [EMAIL PROTECTED] wrote:
 My company (http://primedia.com/divisions/businessinformation/) has
 two job openings that we're having a heckuva time filling. 

Allow offsite workers and you'll have all the candidates you want.

-Bill
-- 
Sattre PressThe King in Yellow
http://sattre-press.com/ by Robert W. Chambers
[EMAIL PROTECTED] http://sattre-press.com/kiy.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Regular Expression Problem...

2004-12-01 Thread Peter Otten
[EMAIL PROTECTED] wrote:

 identifying/extracting a substring from another string. What I have to do
 is to extract all the strings that begins with a $ character, but
 excluding characters like . (point) and ' (single quote) and \ /
 (slashes). For example I have:
 
 1) This Is An $EXAMPLE String
 2) This Is An $EXAMPLE.String
 3) 'This Is An $EXAMPLE'
 4) This Is An \$EXAMPLE\String;
 
 I would like to extract only the keyword $EXAMPLE and what I'm using at

Is that what you want?

 import re
 r = re.compile([$]\w+)
 r.findall(
... 1) This Is An $EXAMPLE String
... 2) This Is An $EXAMPLE.String
... 3) 'This Is An $EXAMPLE'
... 4) This Is An \$EXAMPLE\String;
... )
['$EXAMPLE', '$EXAMPLE', '$EXAMPLE', '$EXAMPLE']

Peter

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


RE: 2.4 or 2.3.4 for 2.3 software?

2004-12-01 Thread Batista, Facundo
Title: RE: 2.4 or 2.3.4 for 2.3 software?





[Jens Bloch Helmers]


#- Can we expect the current release of 2.4 to be just as reliable as
#- 2.3.4 for 2.3 compliant software?


Actually, you can expect to be more reliable, a lot of bugs were fixed.


. Facundo



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

Regexp question

2004-12-01 Thread Philippe C. Martin
I realize this is more a regexp question than a python question, but maybe one 
of the re object could help me:

I have wish to know how to _no_ match:

This is but an example of the data I handle:

xx xx xx xx xx xx xx [yy yy yy yy yy yy yy] (zz zz zz zz)

I currently can retrieve the three group of logical data blocks with:

l_str = 'xx xx xx xx xx xx xx [yy yy yy yy yy yy yy] (zz zz zz zz)'
p = re.compile(r'([a-f-0-9\s]*) (\[[a-f-0-9\s]*\]) 
(\([a-f-0-9\s]*\))',re.IGNORECASE) #OK
g = p.search(l_str)


What I would rather do is.

get the data block that is _not_ between brackets or parenthesis  i.e; 'xx xx 
xx xx xx xx xx' knowing that the intial string could be:

[yy yy yy yy yy yy yy]  xx xx xx xx xx xx xx  (zz zz zz zz)


Any clue  ?

Regards,

Philippe






-- 
*
Philippe C. Martin
SnakeCard LLC
www.snakecard.com
*
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IMAP UTF-7, any codec for that anywhere?

2004-12-01 Thread Jp Calderone
On Wed, 01 Dec 2004 10:35:59 +0100, Max M [EMAIL PROTECTED] wrote:
Brian Quinlan wrote:
   Max M wrote:
  
   Is there any codec available for handling The special UTF-7 codec for
   IMAP?
 
   Is there something special do you need or is recipe OK?
  
 u\u00ff.encode('utf-7')
   '+AP8-'
 
 
 A recipe would be excellent. Unfortunately yours is no right. It should 
 have looke like:
 
   imapUTF7Encode(u\u00ff)
 'AP8-'
 
 I believe you missed the 'special' in The special UTF-7 codec for IMAP?
 
 Imap folders use a non-standard version of utf-7, where some characters 
 are different.
 
 I found som messages from 2001 on the net between a few Python unicode 
 developers, where they discuss implementing it. But I cannot find an 
 implementation anywhere.
 
 I found a perl module that converts to/from the codec, but as usual that 
 is regex hell. Well ok its not that difficult, but I still need to think 
 to hard to parse Perl regex'

  Twisted's IMAP4 support includes an implementation of this codec.  Most of 
the API also happily accepts unicode objects and encodes them as necessary, too.

http://www.twistedmatrix.com/

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


Re: decorators ?

2004-12-01 Thread Skip Montanaro

Jacek Anything you can do with decorators, you could do before (with
Jacek the exception of rebinding the __name__ of functions).

And while that feature was added because we realized it would be nice if the
decorated function could have the same name as the original function, it
seems like that change could stand on its own merits.

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


Re: Semaphore or what should I use?

2004-12-01 Thread Jeremy Jones
Bastian Hammer wrote:
Hi
I´m wondering why there are so few examples with Semaphore.
Is it obsolete?
I´ve got a Class Data.
It offers 2 Threads methods for updating, editing, .. a private
dictionary.
Now I have to make sure, that both threads are synchronal, 
1 thread edits something and the other is blocked until the first
thread is ready.

Isn´t it a good idea to do this with a semaphore?
And if I should use a Semaphore here, could anybody give me an example
how it should look like?
Everything that I test throws errors :(
Thank you :)
Bye, Bastian
 

Sure, you can use a Semaphore.  But it sounds like you are really 
wanting an exclusive lock.  Semaphore can do that for you - actually 
it's the default behavior.  You could try using a regular old Lock.  
Semaphores are locking counters.  You set the counter at initialization 
to some number (the default is 1).  When you enter into a  semaphored 
area of code (using the .acquire() method), the counter attempts to 
decrement and will do so if it doesn't push it beneath 0.  Upon exiting 
the area of semaphored code (by calling the .release() method on the 
semaphore), the counter is incremented.  An example would look like this:

import threading
class locking_writer:
   def __init__(self, some_file):
   self.sema = threading.Semaphore()
   self.f = open(some_file, 'w')
   def write(self, content):
   self.sema.acquire()
   self.f.write(content)
   self.sema.release()
and used like this:
In [16]: l = locking_writer('/tmp/foo')
In [17]: l.write('test')
I haven't tested this with multiple threads, so I'll leave that up to 
you if you want to use it.

Now, with all that said, the preferred way of synchronizing between 
threads is to use a Queue (import Queue\nq = Queue.Queue()).  If you 
have a file that more than one thread needs to update, you probably want 
to create a thread just to update that file and have the threads 
responsible for getting information to update it with pass that 
information into a queue.  You may have reasons for not wanting to do 
that, but it's worth looking into and considering.

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

Re: Regexp question

2004-12-01 Thread Miki Tebeka
Hello Philippe,

 What I would rather do is.
 
 get the data block that is _not_ between brackets or parenthesis  i.e; 'xx 
 xx 
 xx xx xx xx xx' knowing that the intial string could be:
See http://docs.python.org/lib/re-syntax.html and search for negative
lookahead

HTH.
--

Miki Tebeka [EMAIL PROTECTED]
http://tebeka.spymac.net
The only difference between children and adults is the price of the toys
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Struggling with struct.unpack() and p format specifier

2004-12-01 Thread Geoffrey
Thanks for your response.

I guess the documentation on the p format wasn't clear to me ... or
perhaps I was just hoping to much for an easy solution !

The data is part of a record structure that is written to a file with
a few int's and longs mixed in.  The pattern repeats through the
file with sometime up to 2500 repititions.

Clearly I can create a subroutine to read the records and extract out
the fields.  I was just hoping I could use the struct module and
create a pattern like 'LLHpHLpppH' which would unpack the date and
automatically give me the strings without needing to first determine
their lengths as the length is already embedded in the data.

Any suggestion on how to go about proposing the ability to read
variable length strings based on the preceeding byte value to the
struct module ?  It seems it would be a valuable addition, helping
with code clarity, readability and saving quite a few lines of code -
well atleast me anyways !

Thanks again.

Peter Hansen [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]...
 Geoffrey wrote:
  As I mentioned, I can parse the string and read it with multiple
  statements, I am just looking for a more efficient solution.
 
 This looks like about the best you can do, using the information
 from Tim's reply:
 
   buf = '\0\0\xb9\x02\x13EXCLUDE_CREDIT_CARD'
   import struct
   x = struct.unpack('xxBB%sp' % (ord(buf[4])+1), buf)
   x
 (185, 2, 'EXCLUDE_CREDIT_CARD')
 
 If you wanted to avoid hard-coding the 4, you would
 be most correct to do this:
 
 header = 'xxBB'
 lenIndex = struct.calcsize(header)
 x = struct.unpack('%s%dp' % (header, ord(buf[lenIndex])+1), buf)
 
 ... though that doesn't exactly make it all that readable.
 
 -Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Semaphore or what should I use?

2004-12-01 Thread Ville Vainio
 Bastian == Bastian Hammer [EMAIL PROTECTED] writes:

Bastian Now I have to make sure, that both threads are
Bastian synchronal, 1 thread edits something and the other is
Bastian blocked until the first thread is ready.

Bastian Isn´t it a good idea to do this with a semaphore?

Semaphore will do, but this is a classical use case for
threading.Lock.

There should be lots of stuff regarding locks (or more googleably,
mutexes) on the net.

-- 
Ville Vainio   http://tinyurl.com/2prnb
-- 
http://mail.python.org/mailman/listinfo/python-list


A little threading problem

2004-12-01 Thread Alban Hertroys
Hello all,
I need your wisdom again. I'm working on a multi-threaded application 
that handles multiple data sources in small batches each time. The idea 
is that there are 3 threads that run simultaneously, each read a fixed 
number of records, and then they wait for eachother. After that the main 
thread does some processing, and the threads are allowed to continue 
reading data.

I summarized this part of the application in the attached python script, 
which locks up rather early, for reasons that I don't understand (I 
don't have a computer science education), and I'm pretty sure the 
problem is related to what I'm trying to fix in my application. Can 
anybody explain what's happening (Or maybe even show me a better way of 
doing this)?

Regards,
Alban Hertroys,
MAG Productions.
import sys
import threading

class AThread(threading.Thread):
	def __init__(self, name, mainCond, allowedCond):
		self.counter	= 0
		self.name		= name
		self.mainCond	= mainCond
		self.condAllowed = allowedCond
		self.waitUntilRunning = threading.Condition()

		threading.Thread.__init__(self, None, None, name, [])

	def start(self):
		threading.Thread.start(self)

		# Let the main thread wait until this thread is ready to accept Notify
		# events.
		self.waitUntilRunning.acquire()
		self.waitUntilRunning.wait()
		self.waitUntilRunning.release()

	def run(self):
		threading.Thread.run(self)

		# Print numbers 1 - 25
		while self.counter  25:
			self.condAllowed.acquire()

			# Tell the main thread that we're ready to receive Notifies
			self.waitUntilRunning.acquire()
			self.waitUntilRunning.notify()
			print Running
			self.waitUntilRunning.release()

			# Wait for a Notify from the main thread
			print Wait
			self.condAllowed.wait()
			self.condAllowed.release()

			self.counter += 1

			print Thread %s: counter = %d % (self.name, self.counter)


			# Tell the main thread that a thread has reached the end of the loop
			self.mainCond.acquire()
			self.mainCond.notify()
			self.mainCond.release()

class Main(object):
	def __init__(self):
		self.condWait = threading.Condition()
		self.condAllowed = threading.Condition()

		self.threads = [
			AThread('A', self.condWait, self.condAllowed),
			AThread('B', self.condWait, self.condAllowed),
			AThread('C', self.condWait, self.condAllowed),
		]

		# Start the threads
		for thread in self.threads:
			thread.start()

		while True:
			# Allow the threads to run another iteration
			self.condAllowed.acquire()
			print Notify
			self.condAllowed.notifyAll()
			self.condAllowed.release()

			# Wait until all threads reached the end of their loop
			for thread in self.threads:
self.condWait.acquire()
self.condWait.wait()
self.condWait.release()


main = Main()

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

Re: pdb with emacs

2004-12-01 Thread Benjamin Rutt
Yuri Shtil [EMAIL PROTECTED] writes:

 I am trying to learn python and use the gud/pdb from emacs. The
 functionality that I am used to under gud/gdb and gud/perldb is missing, or
 I don't know how to make it work.
 Specifically: when I start pdb on a script file, the source does not show in
 an another window as it does with perldb and gdb. 

The source appears for me if I do C-c C-s immediately after startup.

 If I bring it up in an another window, the ^X SPC set a break, but
 the subsequent gud-next commands do not move the execution cursor in
 the source file window.

I can in general set breakpoints using C-x SPC in the source buffer
after the source appears, which will be hit after I resume
execution.  So I guess I don't observe your problems.  I am using a
custom pdb executable script though, maybe this helps:

#!/bin/sh
exec python $HOME/opt/python-2.3/lib/python2.3/pdb.py $@
-- 
Benjamin Rutt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.4 Uninstall Entry in WinXP Registry

2004-12-01 Thread Brad Tilley
Martin v. Löwis wrote:
Brad Tilley wrote:
Python 2.3 placed a registry key under:
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Python2.3' 

[...]
Python 2.4 does not use this registry entry on the two machines I have 
installed it on... any tips on how to locate this?

It's under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{82D9302E-F209-4805-B548-52087047483A} 

which is the product code of Python 2.4. Notice that Python 2.4.1
will use a different product code.
However, if you merely want to avoid that users remove the package,
you can set the ARPNOREMOVE property during installation, e.g.
msiexec /i python24.msi ARPNOREMOVE=1
You might want to set ARPNOMODIFY and ARPNOREPAIR as well.
If you cannot readily pass that property on the command line during
installation, you can use orca.exe (or a python script) to add this
property to the Property table of python24.msi.
If you have W2k or later, you can also set the NoRemove registry
value under the key above, to hide the remove feature after
installation.
HTH,
Martin
That's very helpful, thanks Martin! How do I set the install path to 
c:\Program Files?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Syntax for extracting multiple items from a dictionary

2004-12-01 Thread Simon Brunning
On Wed, 1 Dec 2004 10:23:28 -0500, Dave Merrill [EMAIL PROTECTED] wrote:
 anton muhin wrote:
  Or dict((key, row[key]) for key in cols).
 
 I'm on Py 2.3.3, and neither of these appear to work. Can someone confirm? I
 can't see anything in the 2.4 release notes that point to where this would
 have changed.

They use generator expressions, which were introduced by Python 2.4.
See http://www.python.org/dev/doc/devel/whatsnew/node4.html.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Syntax for extracting multiple items from a dictionary

2004-12-01 Thread Jean Brouwers

The correct syntax is:

dict([(key, row[key]) for key in cols])

i.e. the list must be enclosed in [...].

/Jean Brouwers



In article [EMAIL PROTECTED], Dave Merrill
[EMAIL PROTECTED] wrote:

 anton muhin wrote:
  Stefan Behnel wrote:
  
  
   shark schrieb:
  
   row = {fname : Frank, lname : Jones, city : Hoboken,
   state :
   Alaska}
   cols = (city, state)
  
   Is there a best-practices way to ask for an object containing only the
   keys
   named in cols out of row? In other words, to get this:
   {city : Hoboken, state : Alaska}
  
  
   Untested:
  
   dict( (key,value) for (key,value) in row.iteritems() if key in cols )
  
   Works in Py2.4
  
   Stefan
 
  Or dict((key, row[key]) for key in cols).
 
  regards,
  anton.
 
 I'm on Py 2.3.3, and neither of these appear to work. Can someone confirm? I
 can't see anything in the 2.4 release notes that point to where this would
 have changed.
 
 Thanks,
 
 shark
 

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


Re: SOAPpy/ZSI/Twisted SOAP over stdin/stdout?

2004-12-01 Thread Harry George
Harry George [EMAIL PROTECTED] writes:

 Normally the SOAP Servers are designed to take control of a port and
 run their own sockets via inheritance from SocktServer.
 
 But under inetd and xinetd, the port is controlled elsewhere and the
 service just gets the stdin/stdout. I need to configure (or tweak) one
 of the SOAP servers to use that connection.
 
 Has anyone done this with any of the above named SOAP servers?
 Recommmendations or hints if I try it myself?

First, thanks for the hints - I definitely want to investigate Twisted
basic.  Second, I've solved it by doing an xinetd redirect.  Do
external control on one port, then pass the data to an internal-only
port which is watched by the SOAP server.

-- 
[EMAIL PROTECTED]
6-6M21 BCA CompArch Design Engineering
Phone: (425) 294-4718
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: RELEASED Python 2.4 (final)

2004-12-01 Thread Klaus Meyer
Anthony Baxter schrieb:
happy to announce the release of Python 2.4.
Thanks!
minor remarks:
First line from C:\Python24\README.txt
This is Python version 2.4 alpha 3
In C:\Python24\Tools
in various subdirs the README.TXT files disappeared.
--
regards kgm
--
http://mail.python.org/mailman/listinfo/python-list


Re: Question on sorting

2004-12-01 Thread Lad
Peter Otten [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]...
 Lad wrote:
 
  wes weston [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]...
  Lad wrote:
   Hi,
   I have a file of records of 4 fields each.
   Each field is separated by a semicolon. That is
   
   Filed1;Ffield2;Field3;Field4
   
   But there may be also empty records such as
   
   (only semicolons).
   
   For sorting I used
   #
   lines = file('Config.txt').readlines()# a file I want to sort
   lines.sort()
   ff=open('ConfigSorted.txt','w')# sorted file
   ff.writelines(lines)
   ff.close()
   ###
   It was sorted but empty records were first. I need them to be last(at
   the end of the file). How can I do that?
   
   Thanks for help
   Lad
  
  Lad,
  The sort call can have a function name as an arg. You
  could do:
  
  def mycompare(s1,s2):
  #return -1 to put s1's at front; 1 to put s1's at back; 0 for a tie
  #if s1== and s2: return 1
  
  lines.sort(mycompare)
  
  Wes,
  Thank you for reply. But I do not understand mycompare function. Can
  you please explain to me how it should work? Thanks
 
 compare(a, b) is just a function for comparing two items/lines. I must
 return -1 if ab, +1 if ab, and 0 if a==b. For example the following
 compare moves the  records to the end and keeps the order of others
 unaffected:
 
  items = [, ;a;b;;, ;b;a;;, a;b;c;d;e, a;;;d;e]
  def compare(a, b):
 ... return cmp(a == , b == ) or cmp(a, b)
 ...
  items.sort(compare)
  items
 [';a;b;;', ';b;a;;', 'a;;;d;e', 'a;b;c;d;e', '']
 
Petr,
thank you for help and explanation.
It works
Lad
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.4 Uninstall Entry in WinXP Registry

2004-12-01 Thread Brad Tilley
Brad Tilley wrote:
Martin v. Löwis wrote:
Brad Tilley wrote:
Python 2.3 placed a registry key under:
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Python2.3' 


[...]
Python 2.4 does not use this registry entry on the two machines I 
have installed it on... any tips on how to locate this?

It's under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{82D9302E-F209-4805-B548-52087047483A} 

which is the product code of Python 2.4. Notice that Python 2.4.1
will use a different product code.
However, if you merely want to avoid that users remove the package,
you can set the ARPNOREMOVE property during installation, e.g.
msiexec /i python24.msi ARPNOREMOVE=1
You might want to set ARPNOMODIFY and ARPNOREPAIR as well.
If you cannot readily pass that property on the command line during
installation, you can use orca.exe (or a python script) to add this
property to the Property table of python24.msi.
If you have W2k or later, you can also set the NoRemove registry
value under the key above, to hide the remove feature after
installation.
HTH,
Martin

That's very helpful, thanks Martin! How do I set the install path to 
c:\Program Files?
I found the documentation here:
http://python.fyxm.net/2.4/msi.html
--
http://mail.python.org/mailman/listinfo/python-list


assymetry between a == b and a.__eq__(b) (WAS: pre-PEP generic objects)

2004-12-01 Thread Steven Bethard
Peter Otten wrote:
Steven Bethard wrote:
def __eq__(self, other):
   x.__eq__(y) == x == y
   return (isinstance(other, self.__class__)
   and self.__dict__ == other.__dict__)

This results in an asymmetry:
from bunch import Bunch
class B(Bunch): pass
...
B().__eq__(Bunch())
False
Bunch().__eq__(B())
True
With indirect use of __eq__() this puzzling behaviour disappears:
B() == Bunch()
False
Bunch() == B()
False
Whether this is intended, I don't know. If someone can enlighten me...
It does look like it's at least documented:
http://docs.python.org/ref/comparisons.html
The operators , , ==, =, =, and != compare the values of two 
objects. The objects need not have the same type. If both are numbers, 
they are converted to a common type. Otherwise, objects of different 
types always compare unequal, and are ordered consistently but arbitrarily.

This sounds like using == makes a guarantee that objects of different 
types will compare unequal, while my __eq__ method (using isinstance) 
did not make this guarantee.

I tried to check the C code to verify this (that different classes are 
guaranteed to be unequal) but rich comparisons make that code pretty 
complicated.

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


Drawing Cogwheels and Combinatoric diagrams

2004-12-01 Thread Andrew James
Gentlemen,
I'm looking for a graphing or drawing python package that will allow me 
to draw complex geometric shapes. I need to be able to create shapes 
like cogwheels and Venn diagrams:

http://encyclopedia.thefreedictionary.com/Venn
The library must support alpha blending and the ability to return x,y 
co-ordinates for a shape, as I want to draw an imagemap on top of parts 
of the shape.

Can PIL do this, or do I need to go the way of GnuPlot or Gri? Can 
anyone give me an example of a complex shape drawn like this?

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


Re: Regexp question

2004-12-01 Thread Mitja
On Wed, 1 Dec 2004 07:48:24 -0600, Philippe C. Martin  
[EMAIL PROTECTED] wrote:

I realize this is more a regexp question than a python question, but  
maybe one
of the re object could help me:

I have wish to know how to _no_ match:
This is but an example of the data I handle:
xx xx xx xx xx xx xx [yy yy yy yy yy yy yy] (zz zz zz zz)
I currently can retrieve the three group of logical data blocks with:
l_str = 'xx xx xx xx xx xx xx [yy yy yy yy yy yy yy] (zz zz zz zz)'
p = re.compile(r'([a-f-0-9\s]*) (\[[a-f-0-9\s]*\])
(\([a-f-0-9\s]*\))',re.IGNORECASE) #OK
g = p.search(l_str)
What I would rather do is.
get the data block that is _not_ between brackets or parenthesis  i.e;  
'xx xx
xx xx xx xx xx' knowing that the intial string could be:

[yy yy yy yy yy yy yy]  xx xx xx xx xx xx xx  (zz zz zz zz)
Any clue  ?
regexps seem an overkill for the task at hand.
If data is really as simple as you suggest, you can try the following:
s = 'xx [y y] (z z)'
s = s[:s.index('(')] + s[s.index(')')+1:]
s
'xx [y y] '
s = s[:s.index('[')] + s[s.index(']')+1:]
s
'xx  '
s.strip()
'xx'
Relevant lines:
s = s[:s.index('(')] + s[s.index(')'):]
s = s[:s.index('[')] + s[s.index(']')+1:]
s = s.strip()
--
Mitja
--
http://mail.python.org/mailman/listinfo/python-list


Converting String to Class

2004-12-01 Thread michael
Hello,

I have a script that is called by the shell this way :

mqtrigger.py TMC2TEST.QUEUE LV1871.MQPROCESS

So argv[1] is the string TMC2TEST.QUEUE LV1871.MQPROCESS

I would like to construct a class with that string that contains the
attributes

-StrucId
-VersionId
-QName
-ProcessName

I am thinking about using the following info

opts = [['StrucId', CMQC.MQTMC_STRUC_ID, '4s'],   
['Version', CMQC.MQTMC_VERSION_2, '4s'],
['QName', '', '48s'],   ## or less :-)
['ProcessName', '', '48s']] ## or less :-)

1. is the attributename
2. is the default
3. is the format in the string

So the string could be parsed with the opts Info and the attributes
could be inserted into the class. I dont even have a starting point
how to do that. Could somebody point my into the right direction

Regards

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


Re: A little threading problem

2004-12-01 Thread Jeremy Jones




Alban Hertroys wrote:
Hello
all,
  
  
I need your wisdom again. I'm working on a multi-threaded application
that handles multiple data sources in small batches each time. The idea
is that there are 3 threads that run simultaneously, each read a fixed
number of records, and then they wait for eachother. After that the
main thread does some processing, and the threads are allowed to
continue reading data.
  
  
I summarized this part of the application in the attached python
script, which locks up rather early, for reasons that I don't
understand (I don't have a computer science education), and I'm pretty
sure the problem is related to what I'm trying to fix in my
application. Can anybody explain what's happening (Or maybe even show
me a better way of doing this)?
  
  
Regards,
  
  
Alban Hertroys,
  
MAG Productions.
  
  

import sys
import threading

class AThread(threading.Thread):
	def __init__(self, name, mainCond, allowedCond):
		self.counter	= 0
		self.name		= name
		self.mainCond	= mainCond
		self.condAllowed = allowedCond
		self.waitUntilRunning = threading.Condition()

		threading.Thread.__init__(self, None, None, name, [])

	def start(self):
		threading.Thread.start(self)

		# Let the main thread wait until this thread is ready to accept Notify
		# events.
		self.waitUntilRunning.acquire()
		self.waitUntilRunning.wait()
		self.waitUntilRunning.release()

	def run(self):
		threading.Thread.run(self)

		# Print numbers 1 - 25
		while self.counter  25:
			self.condAllowed.acquire()

			# Tell the main thread that we're ready to receive Notifies
			self.waitUntilRunning.acquire()
			self.waitUntilRunning.notify()
			print "Running"
			self.waitUntilRunning.release()

			# Wait for a Notify from the main thread
			print "Wait"
			self.condAllowed.wait()
			self.condAllowed.release()

			self.counter += 1

			print "Thread %s: counter = %d" % (self.name, self.counter)


			# Tell the main thread that a thread has reached the end of the loop
			self.mainCond.acquire()
			self.mainCond.notify()
			self.mainCond.release()

class Main(object):
	def __init__(self):
		self.condWait = threading.Condition()
		self.condAllowed = threading.Condition()

		self.threads = [
			AThread('A', self.condWait, self.condAllowed),
			AThread('B', self.condWait, self.condAllowed),
			AThread('C', self.condWait, self.condAllowed),
		]

		# Start the threads
		for thread in self.threads:
			thread.start()

		while True:
			# Allow the threads to run another iteration
			self.condAllowed.acquire()
			print "Notify"
			self.condAllowed.notifyAll()
			self.condAllowed.release()

			# Wait until all threads reached the end of their loop
			for thread in self.threads:
self.condWait.acquire()
self.condWait.wait()
self.condWait.release()


main = Main()

  

You've got a deadlock. I modified your script to add a print "T-%s" %
self.name before an acquire and after a release in the threads you spun
off (not in the main thread). Here is the output:

[EMAIL PROTECTED] threading]$ python tt.py
T-A: acquiring condAllowed
T-A: acquiring waitUntilRunning
T-A: Running
T-A: released waitUntilRunning
T-A: Wait
T-B: acquiring condAllowed
T-B: acquiring waitUntilRunning
T-B: Running
T-B: released waitUntilRunning
T-B: Wait
T-C: acquiring condAllowed
T-C: acquiring waitUntilRunning
T-C: Running
T-C: released waitUntilRunning
T-C: Wait
Notify
T-A: released condAllowed
T-A: counter = 1
T-A: acquiring mainCond
T-A: released mainCond
T-A: acquiring condAllowed
T-A: acquiring waitUntilRunning
T-A: Running
T-A: released waitUntilRunning
T-A: Wait
T-C: released condAllowed
T-C: counter = 1
T-C: acquiring mainCond
T-C: released mainCond
T-C: acquiring condAllowed
T-C: acquiring waitUntilRunning
T-C: Running
T-C: released waitUntilRunning
T-C: Wait
T-B: released condAllowed
T-B: counter = 1
T-B: acquiring mainCond
T-B: released mainCond
T-B: acquiring condAllowed
Notify -Here is
your problem
T-A: released condAllowed
T-A: counter = 2
T-A: acquiring mainCond
T-A: released mainCond
T-A: acquiring condAllowed
T-A: acquiring waitUntilRunning
T-A: Running
T-A: released waitUntilRunning
T-A: Wait
T-B: acquiring waitUntilRunning
T-B: Running
T-B: released waitUntilRunning
T-B: Wait
T-C: released condAllowed
T-C: counter = 2
T-C: acquiring mainCond
T-C: released mainCond
T-C: acquiring condAllowed
T-C: acquiring waitUntilRunning
T-C: Running
T-C: released waitUntilRunning
T-C: Wait

Notify is called before thread B (in this case) hits the
condAllowed.wait() piece of code. So, it sits at that wait() for
forever (because it doesn't get notified, because the notification
already happened), waiting to be notified from the main thread, and the
main thread is waiting on thread B (again, in this case) to call
mainCond.notify(). This approach is a deadlock just wanting to happen
(not waiting, because it already did happen). What is it exactly that
you are trying to accomplish? I'm sure there is a better approach.

Jeremy Jones



-- 

Re: Syntax for extracting multiple items from a dictionary

2004-12-01 Thread Peter Hansen
Dave Merrill wrote:
anton muhin wrote:
Or dict((key, row[key]) for key in cols).
I'm on Py 2.3.3, and neither of these appear to work. 
You're probably getting the error shown.  Try the change in
the line following it instead.
Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]
 row = {'fname': 'Frank', 'lname': 'Jones', 'city': 'Hoboken', 
'state': 'Alaska'}
 cols = ['city', 'state']
 dict((key, row[key]) for key in cols)
  File stdin, line 1
dict((key, row[key]) for key in cols)
   ^
SyntaxError: invalid syntax
 dict([(key, row[key]) for key in cols])
{'city': 'Hoboken', 'state': 'Alaska'}


I can't see anything in the 2.4 release notes that point to where this would
have changed.
See http://www.python.org/2.4/highlights.html and search for
generator expressions.
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Python xmlrpc servers?

2004-12-01 Thread ted holden

I have a project for which being able to write xmlrpc server code in python
would be vastly preferable to the second choice solution for a number of
reasons.  Unfortunately, pretty much everything I see on the net in the way
of documentation appears either insufficient or outdated.

The example given in the Python documentation for  SimpleXMLRPCServer is
more or less incomprehensible.  That example is as follows:

class MyFuncs:
   def div(self, x, y) : return div(x,y)

handler = CGIXMLRPCRequestHandler()
handler.register_function(pow)
handler.register_function(lambda x,y: x+y, 'add')
handler.register_introspection_functions()
handler.register_instance(MyFuncs())
handler.handle_request()

I don't see where the div(x,y) which is returned in the class function
definition comes from.  I don't see any relationship between the class
MyFuncs and the rest of the program.  I don't see where the returned
function pow comes from or what its relevance is.  I don't see what
lambda is or how a lambda function is supposed to be construed as adding
two numbers together.  I don't see how this server is supposed to be used.

I also find an example written by Dave Warner:

http://www.onlamp.com/pub/a/python/2001/01/17/xmlrpcserver.html

which is about four years old and dated.  In particular, the include file 
xmlrpcserver which he imports no longer exists.

And then, I find one example in an IBM reference which actually does work as
stated on a single computer:

http://www-106.ibm.com/developerworks/webservices/library/ws-pyth10.html

The test client provided looks like:

mport xmlrpclib

server = xmlrpclib.ServerProxy(http://localhost:;)
month = server.getMonth(2002, 8)
print month


which actually works.  Nonetheless I need this thing to work across
machines.  I have a primitive network here usingVerizon DMS and a Linksys
router which sees the three computers on it as 192.168.1.100,
192.168.1.101, and 192.168.1.102 as usual. 

Question is, what does it take to run the server on 102 and a client on 100?

Changing the obvious line in the client program to:

server = xmlrpclib.ServerProxy(http://192.168.1.102:;)

doesn't work.  Aside from that, I'd like to get the CGI version of the thing
which uses .py files in the CGI bin to work as well and again the only
example I see of that (in the Python documentation) is undecipherable. 

I'd appreciate any suggestions or info anybody might have.








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


Re: Help With Hiring Python Developers

2004-12-01 Thread Miklós P
fuego [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 My company (http://primedia.com/divisions/businessinformation/) has
 two job openings that we're having a heckuva time filling.  We've
 posted at Monster, Dice, jobs.perl.org and python.jobmart.com.  Can
 anyone advise other job boards that might be helpful?  Also, feel free
..
 Thanks in advance!

Hm, you're looking for *Manhattan locals* who are required to have Perl
skills (i.e. magically working, hardly readable line noise :D ) but
optionally they may have Python skills, too (i.e. magically working, easily
readable pseudo code :D )

How about adding the additional requirement of COBOL and that the applicant
must live in a particular street? :-)

Miklós



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


Re: Python 3000 and Python Regrets

2004-12-01 Thread Ian Bicking
[EMAIL PROTECTED] wrote:
I just came across the slides for Guido van Rossum's Python Regrets
talk, given in 2002. It worries me that much of my Python code would
be broken if all of his ideas were implemented. He doesn't even like
'print'. Of course, I am not qualified to argue with Van Rossum about
the direction of Python.
When is Python 3000 expected to appear? Is there a list of expected
incompatibilities with Python 2.3? Are serious Python programmers
already taking care to avoid using Python features that may disappear
in Python 3000?
Python 3000 is kind of imaginary.  It's a what-if: what if Guido could 
do whatever he wanted without worrying about backward compatibility?

At one point Python 3000 and Python 3.0 were kind of the same thing (or 
the same plan -- neither are implemented or even thoroughly planned). 
Now they are separate ideas -- if you see references to Python 3.0, it 
also includes some backward incompatible changes and cleanup, like maybe 
input() will disappear, and integer division will go away, and things 
like range() will return iterators (and xrange goes away).  But it's 
much more conservative, and presented as a more realistic plan.  print 
will still be around.

--
Ian Bicking  /  [EMAIL PROTECTED]  /  http://blog.ianbicking.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python xmlrpc servers?

2004-12-01 Thread Skip Montanaro

ted The example given in the Python documentation for
ted SimpleXMLRPCServer is more or less incomprehensible.  

Agreed, there is a doc fix needed.  Try mentally adding

from math import *

to the start of the example.  That will get you the pow function.  It's
still incorrect though.  There's no div function, either builtin or in the
math module.  The MyFuncs class should be defined as in the 2.4 docs:

class MyFuncs:
def div(self, x, y) : return x // y

ted I don't see any relationship between the class MyFuncs and the rest
ted of the program.

In this simpleminded example, there is none.  The goal of the example is to
show how the register_* methods are used.  In a real-life application any
instances registered would probably store considerable parts of the
application state or be able to communicate with those objects that do.

ted I don't see what lambda is or how a lambda function is supposed
ted to be construed as adding two numbers together.

Lambda is a keyword in Python used to create and return very simple
(single-expression) functions.  Lambda expressions can be used anywhere
you'd normally use a function object.  See:

http://www.python.org/doc/current/ref/lambdas.html

The line containing the lambda expression:

server.register_function(lambda x,y: x+y, 'add')

could be recast as:

def add(x, y):
return x+y

server.register_function(add, 'add')

though the second arg isn't required since it matches the function's
__name__ attribute.  It's required when a lambda expression is used though
because lambda expressions don't have terribly useful __name__ attributes:

 f = lambda x,y: x+y
 f
function lambda at 0x65c970
 f.__name__
'lambda'
 def add(x,y):
...   return x+y
... 
 add.__name__
'add'

ted And then, I find one example in an IBM reference which actually
ted does work as stated on a single computer:
...
ted which actually works.  Nonetheless I need this thing to work across
ted machines.

The server listens to localhost on port .  To allow it to listen for
external connections change localhost to the name or IP address of the
server.  Before you do that make sure you understand the ramifications of
exposing your XML-RPC server to a broader class of potential clients, some
of which are bound to be malicious.

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


Re: Python 3000 and Python Regrets

2004-12-01 Thread Tim Peters
[EMAIL PROTECTED]
 I just came across the slides for Guido van Rossum's Python
 Regrets talk, given in 2002. It worries me that much of my Python
 code would be broken if all of his ideas were implemented.

Actually, none of it would break, provided you don't change the Python
implementation you use.

 He doesn't even like 'print'. Of course, I am not qualified to argue
 with Van Rossum about the direction of Python.

 When is Python 3000 expected to appear?

This is usually expressed an as a positive offset from the time hell
freezes over, but people vary in their estimation of both parts.  At a
minimum, it requires that Guido first get a job where he can
concentrate on Python development.  That will happen when hell freezes
over, but may happen before then.  Hard to say.

 Is there a list of expected incompatibilities with Python 2.3?

No.

 Are serious Python programmers already taking care to avoid
 using Python features that may disappear in Python 3000?

No, although some naturally avoid dubious features without being
threatened wink.
-- 
http://mail.python.org/mailman/listinfo/python-list


non blocking read()

2004-12-01 Thread Uwe Mayer
Hi,

I use select() to wait for a file object (stdin) to become readable. In that
situation I wanted to read everything available from stdin and return to
the select statement to wait for more.

However, the file object's read method blocks if the number of bytes is 0 or
negative. 

Is there no way to read everything a channel's got currently got without
blocking?

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


Re: module imports and memory usage

2004-12-01 Thread Carlos Ribeiro
On Tue, 30 Nov 2004 16:46:43 -0500, Brad Tilley [EMAIL PROTECTED] wrote:
 I discovered that when I wrap my code up in a function def and call it
 that it uses around 4.6 MB of RAM all the time... even while sleeping.
 However, when I don't put it in a function def it uses around 2.6MB of
 data when it executes and only 100KB while sleeping. Why is this?

Totally unchecked, popped up from somewhere between my ears.

Is it possible that (in some situations) the function object keeps a
reference to its locals() somewhere, in such a way that it never gets
collected? Just wondering...


-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: [EMAIL PROTECTED]
mail: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python xmlrpc servers?

2004-12-01 Thread ted holden
Skip Montanaro wrote:


 ted I don't see what lambda is or how a lambda function is supposed
 ted to be construed as adding two numbers together.
 
 Lambda is a keyword in Python used to create and return very simple
 (single-expression) functions.  Lambda expressions can be used anywhere
 you'd normally use a function object.  See:
 
 http://www.python.org/doc/current/ref/lambdas.html
 
 The line containing the lambda expression:
 
 server.register_function(lambda x,y: x+y, 'add')
 
 could be recast as:
 
 def add(x, y):
 return x+y
 
 server.register_function(add, 'add')

That's a whole lot easier to digest.  I'd have assumed lambda was some sort
of stat function...


 The server listens to localhost on port .  To allow it to listen for
 external connections change localhost to the name or IP address of the
 server.  Before you do that make sure you understand the ramifications of
 exposing your XML-RPC server to a broader class of potential clients, some
 of which are bound to be malicious.
 
 Skip


Many thanks, that's the part I was missing in the case of standalone
servers.  The only other real question is what about the cgi servers?  I'd
assume I'd take the example given:

class MyFuncs:
def div(self, x, y) : return div(x,y)

handler = CGIXMLRPCRequestHandler()
handler.register_function(pow)
handler.register_function(lambda x,y: x+y, 'add')
handler.register_introspection_functions()
handler.register_instance(MyFuncs())
handler.handle_request()

Stuff that into a file in the cgi-bin dir on the server, and then try to use
something like: 


server = xmlrpclib.Server(http://192.168.1.102/testserver.py;)
or
server = xmlrpclib.Server(http://192.168.1.102/cgi-bin/testserver.py;)


That still hasn't worked, so far at least.










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


Re: Python xmlrpc servers?

2004-12-01 Thread Skip Montanaro

ted Would several web services on the same server listen on different
ted ports (, 8889, 8890...) or on the same port?

Port numbers are never implicit.  You need to provide a listen port each
time you start the server.

Skip


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


Re: Python xmlrpc servers?

2004-12-01 Thread Skip Montanaro
ted The only other real question is what about the cgi servers?  I'd
ted assume I'd take the example given:

ted class MyFuncs:
ted def div(self, x, y) : return div(x,y)

ted handler = CGIXMLRPCRequestHandler()
ted handler.register_function(pow)
ted handler.register_function(lambda x,y: x+y, 'add')
ted handler.register_introspection_functions()
ted handler.register_instance(MyFuncs())
ted handler.handle_request()

ted Stuff that into a file in the cgi-bin dir on the server, and then
ted try to use something like:

ted server = xmlrpclib.Server(http://192.168.1.102/testserver.py;)
ted or
ted server = xmlrpclib.Server(http://192.168.1.102/cgi-bin/testserver.py;)

ted That still hasn't worked, so far at least.

I've never used XML-RPC in a CGI context before.  Have you looked in your
web server's error log file?

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


Re: pickle and py2exe

2004-12-01 Thread Johan Lindberg
 Im trying to compile a script with py2exe. The pickle module is causing the
 program to give an error.
 
 Traceback (most recent call last):
   File SETIstat.pyw, line 330, in ?
   File SETIstat.pyw, line 84, in start_up
   File SETIstat.pyw, line 79, in config_load
   File pickle.pyc, line 1390, in load
   File pickle.pyc, line 872, in load
   File pickle.pyc, line 985, in load_string
 LookupError: unknown encoding: string-escape
 
 the data in the pickled file is a dictionary containing a couple strings. The
 strings do contain \n and \t charaters but no other special characters or
 anything. 
 
 Does anyone have any suggestions to what I can try to get around this? The
 pickle module works fine when the .pyw file is run. Its only when I compile
 this is there an issue. 
 
 Thanks for any help,
 
 Justin

Have you included string-escape encoding in your setup.py?
My guess is that you can fix the problem with something similar to:

 from distutils.core import setup
 import py2exe
 opts = { py2exe: { packages: [encodings], } }
 setup(windows= [spam.py], options= opts)

in your setup.py.

Hope it helps
/Johan Lindberg
-- 
http://mail.python.org/mailman/listinfo/python-list


Python Win32 Silent Install

2004-12-01 Thread Matt Gerrans
Looks like the installer for the Win32 extensions has changed from Wise to 
distutils, so now my automated silent installations don't work anymore. 
Anyone know if the distutils binary installer can be run silently?I 
haven't been able find a command line reference for distutils binaries (I'm 
still sifting through http://www.python.org/doc/current/dist/, though...).

Maybe there is a better way to do an unattended install of the Win32 
extensions (that is, perhaps without using the binary)?

Anyway, I'm looking into this on the python.org and starship pages, but I 
just thought I'd see if anyone can point me in the right direction...

- Matt 


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


Re: Python xmlrpc servers?

2004-12-01 Thread Jaime Wyant
Mark Pilgrim wrote a really neat piece of python code that did XML-RPC
over CGI.  It seems to have disappeared from his website, though
(http://diveintomark.org/public/webservices.txt).

If you can't dig it up, I have a working copy that I use.  I'll post
it / email it if you want.

jw


On Wed, 1 Dec 2004 13:26:21 -0600, Skip Montanaro [EMAIL PROTECTED] wrote:
 ted The only other real question is what about the cgi servers?  I'd
 ted assume I'd take the example given:
 
 ted class MyFuncs:
 ted def div(self, x, y) : return div(x,y)
 
 ted handler = CGIXMLRPCRequestHandler()
 ted handler.register_function(pow)
 ted handler.register_function(lambda x,y: x+y, 'add')
 ted handler.register_introspection_functions()
 ted handler.register_instance(MyFuncs())
 ted handler.handle_request()
 
 ted Stuff that into a file in the cgi-bin dir on the server, and then
 ted try to use something like:
 
 ted server = xmlrpclib.Server(http://192.168.1.102/testserver.py;)
 ted or
 ted server = 
 xmlrpclib.Server(http://192.168.1.102/cgi-bin/testserver.py;)
 
 ted That still hasn't worked, so far at least.
 
 I've never used XML-RPC in a CGI context before.  Have you looked in your
 web server's error log file?
 
 Skip
 
 
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: Python 3000 and Python Regrets

2004-12-01 Thread Matt Gerrans
Anyway, what's to worry about?When the time comes just whip out a little 
script that converts Python 1.6 (or whatever you like) to Python3K; it will 
only take seven lines of P3K code. 


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


Re: Python Win32 Silent Install

2004-12-01 Thread Thomas Heller
Matt Gerrans [EMAIL PROTECTED] writes:

 Looks like the installer for the Win32 extensions has changed from Wise to 
 distutils, so now my automated silent installations don't work anymore. 
 Anyone know if the distutils binary installer can be run silently?I 
 haven't been able find a command line reference for distutils binaries (I'm 
 still sifting through http://www.python.org/doc/current/dist/, though...).

There are no command line options for the distutils created installer,
and silent installation is not possible.

 Maybe there is a better way to do an unattended install of the Win32 
 extensions (that is, perhaps without using the binary)?

I should be quite easy to write a Python script that opens the binary as
a zipfile, and then does what the gui does without showing a gui.

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


Re: Python xmlrpc servers?

2004-12-01 Thread Jaime Wyant
Check these out -

http://server3.sleekcom.com/~jaime/webservice.html (syntax highlighted version)
http://server3.sleekcom.com/~jaime/webservice.txt (savable text version)

HTH,
jw

On Wed, 01 Dec 2004 20:04:46 GMT, ted holden [EMAIL PROTECTED] wrote:
 Jaime Wyant wrote:
 
  Mark Pilgrim wrote a really neat piece of python code that did XML-RPC
  over CGI.  It seems to have disappeared from his website, though
  (http://diveintomark.org/public/webservices.txt).
 
  If you can't dig it up, I have a working copy that I use.  I'll post
  it / email it if you want.
 
 
 Thanks, couldn't hurt anything to post it.  Again the real problem seems to
 be the cnostant state of flux of open software and the attempts to have
 machines and software write documentation don't really seem to help much.
 
 
 Ted
 
 
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: Python 3000 and Python Regrets

2004-12-01 Thread Brad Tilley
Matt Gerrans wrote:
Anyway, what's to worry about?When the time comes just whip out a little 
script that converts Python 1.6 (or whatever you like) to Python3K; it will 
only take seven lines of P3K code. 


How about 'import classic'
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python xmlrpc servers?

2004-12-01 Thread ted holden
Skip Montanaro wrote:


 If so, you need to qualify the reference to the handler class like
 
 SimpleXMLRPCServer.CGIXMLRPCRequestHandler

Again thanks, that works.  If I weren't worried about jinxing myself I'd say
I seem to be in pretty good shape at this point...

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


Re: non blocking read()

2004-12-01 Thread Donn Cave
In article [EMAIL PROTECTED],
 Uwe Mayer [EMAIL PROTECTED] wrote:

 Hi,
 
 I use select() to wait for a file object (stdin) to become readable. In that
 situation I wanted to read everything available from stdin and return to
 the select statement to wait for more.
 
 However, the file object's read method blocks if the number of bytes is 0 or
 negative. 
 
 Is there no way to read everything a channel's got currently got without
 blocking?


Yes, there is a way - os.read() (also known as posix.read())

It's better not to mix buffered I/O (like file object
I/O functions) with select() at all, because select()
actually applies to system level file descriptors and
doesn't know anything about the buffer.

Get the file descriptor with fileno(), and never refer
to the file object again after that.

   Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: recombination variations

2004-12-01 Thread Peter Otten
David Siedband wrote:

 The problem I'm solving is to take a sequence like 'ATSGS' and make all
 the DNA sequences it represents.  The A, T, and G are fine but the S
 represents C or G.  I want to take this input:
 
 [ [ 'A' ] , [ 'T' ] , [ 'C' , 'G' ], [ 'G' ] , [ 'C' , 'G' ] ]
 
 and make the list:
 
 [ 'ATCGC' , 'ATCGG' , 'ATGGC' , 'ATGGG' ]

[...]

The code you provide only addresses the first part of your problem, and so
does mine:

 def disambiguate(seq, alphabet):
... return [list(alphabet.get(c, c)) for c in seq]
...
 alphabet = {
... W: AT,
... S: CG
... }
 disambiguate(ATSGS, alphabet)
[['A'], ['T'], ['C', 'G'], ['G'], ['C', 'G']]

Note that identity entries (e. g. mapping A to A) in the alphabet
dictionary are no longer necessary. The list() call in disambiguate() is
most likely superfluous, but I put it in to meet your spec accurately.

Now on to the next step :-)

Peter

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


Re: Python Win32 Silent Install

2004-12-01 Thread Trent Mick
Matt Gerrans wrote:
Maybe there is a better way to do an unattended install of the Win32 
extensions (that is, perhaps without using the binary)?
You could use the ActivePython MSI package, which includes the PyWin32 
extensions and offers a silent install option:

http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/installnotes.html#install_silent
Cheers,
Trent
--
Trent Mick
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: assymetry between a == b and a.__eq__(b) (WAS: pre-PEP genericobjects)

2004-12-01 Thread Terry Reedy

Steven Bethard [EMAIL PROTECTED] wrote in message
 def __eq__(self, other):
x.__eq__(y) == x == y
return (isinstance(other, self.__class__)

Since an instance of a subclass is an instance of a parent class, but not 
vice versa, I believe you introduce here the assymetry you verify below.

and self.__dict__ == other.__dict__)
 This results in an asymmetry:

from bunch import Bunch
class B(Bunch): pass
 ...
B().__eq__(Bunch())
 False
Bunch().__eq__(B())
 True

Terry J. Reedy



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


PIL for Python 2.4 ?

2004-12-01 Thread Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle.
Hi !

I can't install PIL on Python 2.4 ; the soft search Python 2.3 ; gh
!
Do you know if the great F.L. want to make, soon, a P24 version ?

Thanks !
-- 
Michel Claveau



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


Re: Python 2.4 Uninstall Entry in WinXP Registry

2004-12-01 Thread Martin v. Löwis
Brad Tilley wrote:
I found the documentation here:
http://python.fyxm.net/2.4/msi.html
The original, of course, is at
http://python.org/2.4/msi.html
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.4 Uninstall Entry in WinXP Registry

2004-12-01 Thread Brad Tilley
Martin v. Löwis wrote:
Brad Tilley wrote:
I found the documentation here:
http://python.fyxm.net/2.4/msi.html

The original, of course, is at
http://python.org/2.4/msi.html
Regards,
Martin
Thanks Martin... going to a .msi was a great move... we can do fully 
automated, unattended installs now. I appreaciate your work.

P.S. Here's what my batch install file currently looks like:
msiexec /i python-2.4.msi /qb! ALLUSERS=1 ARPNOREMOVE=1 ARPNOMODIFY=1 
ARPNOREPAIR=1 ADDLOCAL=ALL TARGETDIR=C:\Program Files\Python24

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


Time zones

2004-12-01 Thread Timothy Hume
Hi,

I want to ensure that all my time calculations are done in UTC. This is 
easy with Python on UNIX machines. I simply set the TZ environment 
variable to UTC, and it ensures that the time functions use UTC. 

My question is, how do I get similar functionality using Python on 
Windows?

Thanks,

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


Re: non blocking read()

2004-12-01 Thread Jp Calderone
On 01 Dec 2004 15:55:18 -0500, David Bolen [EMAIL PROTECTED] wrote:
Jp Calderone [EMAIL PROTECTED] writes:
 
  def nonBlockingReadAll(fileObj):
  bytes = []
  while True:
  b = fileObj.read(1024)
  bytes.append(b)
  if len(b)  1024:
  break
  return ''.join(bytes)
 
 Wouldn't this still block if the input just happened to end at a
 multiple of the read size (1024)?

  Only if the file has not been put into non-blocking mode.  But the function 
as given is wrong, I left out the exception handling in the case you mention.  
Rather than blocking forever, fileObj.read(1024) will raise IOError (EAGAIN) if 
the input happened to be a multiple of 1024 bytes long.  Here is the corrected 
version:

def nonBlockingReadAll(fileObj):
bytes = []
while True:
try:
b = fileObj.read(1024)
except IOError, e:
if e.args[0] == errno.EAGAIN:
break
raise
bytes.append(b)
if len(b)  1024:
break
return ''.join(bytes)

  Arguably, there is no longer any point to checking the length of b in this 
version, since at worst you will break on the next iteration of the loop.  It 
doesn't hurt, though.

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


Re: Python 3000 and Python Regrets

2004-12-01 Thread Gustavo Córdova Avila
Brad Tilley wrote:
Matt Gerrans wrote:
Anyway, what's to worry about?When the time comes just whip out a 
little script that converts Python 1.6 (or whatever you like) to 
Python3K; it will only take seven lines of P3K code.
How about 'import classic'
from past import python23
:-)
--
Gustavo Córdova Avila [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]
*Tel:* +52 (81) 8130-1919 ext. 127
Integraciones del Norte, S.A. de C.V.
Padua #6047, Colonia Satélite Acueducto
Monterrey, Nuevo León, México.
--
http://mail.python.org/mailman/listinfo/python-list


Re: String operations

2004-12-01 Thread Steve Holden
Anoop Rajendra wrote:
Hi. I'm trying to resolve an issue with strings.
The command(inclusive of the back-slashes)
condor_q -l -constraint ProjectId==\anoopr_samadams.fnal.gov_161903_30209\
is the only way the command returns the right result. 
I'm trying to run this command from inside a python program.
The way I can get it work is by: 

os.system('condor_q -l -constraint 
ProjectId==\\\anoopr_samadams.fnal.gov_161903_30209\\\')
But, I'd rather use the os.exec functions to get the output. But 

os.execvp(condor_q,[condor_q,-l,-constraint,'ProjectId==\\\anoopr_samadams.fnal.gov_161903_30209\\\'])
doesnt work. Its definately a problem with one of the million
backslashes and quotes present, but I'm not able to figure it out.
What am I doing wrong?
I believe that you don't need to escape the quotes inside the argument 
strings when you call os.execvp(), because there's no shell interpreting 
the arguments. So, in theory, what you appear to need would be

os.execvp(condor_q,[condor_q,-l,-constraint,'ProjectId==anoopr_samadams.fnal.gov_161903_30209'])
or even, since I don't see the need for the quotes in the first place,
os.execvp(condor_q,[condor_q,-l,-constraint,'ProjectId==anoopr_samadams.fnal.gov_161903_30209'])
or
os.execvp(condor_q,[condor_q,-l,-constraint,ProjectId==anoopr_samadams.fnal.gov_161903_30209])
regards
 Steve
--
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Win32 Silent Install

2004-12-01 Thread Luke Skywalker
On Wed, 01 Dec 2004 17:15:38 -0500, Steve Holden [EMAIL PROTECTED]
wrote:

You are right about ActiveState, the copy you download from their web 
site is licensed to prohibit redistribution. They might be prepared to 
cut you a special license, but you'd have to ask them about that.

Does it mean it's not allowed to build an application with ActiveState
Python, and generate an installer that installs the whole thing,
forcing users to go to ActiveState's web site and download the
interpreter? Gee, that changes everything...

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


Re: Time zones

2004-12-01 Thread David Bolen
Timothy Hume [EMAIL PROTECTED] writes:

 I want to ensure that all my time calculations are done in UTC. This is 
 easy with Python on UNIX machines. I simply set the TZ environment 
 variable to UTC, and it ensures that the time functions use UTC. 
 
 My question is, how do I get similar functionality using Python on 
 Windows?

If you're just talking about time module functions, I think you should
be able to do the same thing.  The time functions are overlays for the
C library versions which do use tzset() and look at the TZ environment
variable as under Unix.

 py24
Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32
Type help, copyright, credits or license for more information.
 import time
 print time.tzname
('Eastern Standard Time', 'Eastern Daylight Time')
 print time.ctime()
Wed Dec 01 17:42:08 2004

 TZ=UTC py24
Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32
Type help, copyright, credits or license for more information.
 import time
 print time.tzname
('UTC', '')
 print time.ctime()
Wed Dec 01 22:42:21 2004


(I've used 2.4 here, but the same results work back until 1.5.2)

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


Re: Python Win32 Silent Install

2004-12-01 Thread Steve Holden
Luke Skywalker wrote:
On Wed, 01 Dec 2004 17:15:38 -0500, Steve Holden [EMAIL PROTECTED]
wrote:

You are right about ActiveState, the copy you download from their web 
site is licensed to prohibit redistribution. They might be prepared to 
cut you a special license, but you'd have to ask them about that.

Does it mean it's not allowed to build an application with ActiveState
Python, and generate an installer that installs the whole thing,
forcing users to go to ActiveState's web site and download the
interpreter? Gee, that changes everything...
Luke.
Obviously the license agreement at 
http://www.activestate.com/Products/ActivePython/license_agreement.plex 
would be the authoritative statement. ActiveState do, however, license 
their distribution for OEM purposes, as the links to the right of the 
above-quoted page suggest.

However, the current Community License (v4) says:  ...
   2. You may make and give away verbatim copies of this Package for 
personal use, or for use within your organization, provided that you 
duplicate all of the original copyright notices and associated 
disclaimers. You may not distribute copies of this Package, or copies of 
packages derived from this Package, to others outside your organization 
without specific prior written permission from ActiveState (although you 
are encouraged to direct them to sources from which they may obtain it 
for themselves). ...

This makes is pretty clear that if you plan to distribute outside your 
own organization they expect you to get an OEM license if you want to 
use their distribution.

regards
 Steve
--
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Win32 Silent Install

2004-12-01 Thread Matt Gerrans
You guessed correctly.   Python is on HP (and Compaq now) PCs because I put 
it there.

And yes, I did get the I've found Python on my computer, what does it do 
and can I remove it from the support group.   How to answer that?You 
have a computer with Windows Script Host (JScript  VBScript) built in and 
you want to remove Python?I think the best answer is it does all kinds 
of wonderful things!   You can remove it, of course (easy enough, it is in 
the Add / Remove Programs list, after all), but why don't you learn how to 
use it instead?(I even unhooked the file association to prevent Python 
file attachments in emails from giving a black eye to Python, so out of the 
box, it was relatively safe).

I've use Python and the Win32 extensions for much of the automation of the 
process that pre-installs all the software on the PCs.   Of course, Python 
is very versatile and is ideal for the wide range of tasks, large and small 
that are involved.Being that it is both powerful and easy to learn (and 
also because of no lack of evangelism (I hate that term, but don't have a 
better synonym) on my part), it has been adopted as the main language used 
by the whole division for build-automation related tasks.   Before Python, I 
wrote the tools in C++ and did scripting with JScript.   I don't think I 
have to tell anyone on this list how dramatic an increase in productivity 
Python can give over these in many areas (there are a still a few areas 
where the C++ tools reign, but Python also works well with those).

I was contacted by Kevin Altis and later Stephan Deibel about doing a Python 
success story about this and I was game.I did start it, but didn't get 
it finished in time for the Python Success Story book before OSCON 2004 in 
July and have since put it on the back burner.I need to take a little 
vacation from work, so I can finish that.

- Matt 


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


database questions ala newbie pythonist

2004-12-01 Thread chris
Hello,
  Just started with python and databases.
I am making a small script to update a local database.
Looked around and couldn't find to many links with info about python with
databases.
Any links or other resources anyone can recommend is appreciated.

My question is in the following small script:

##
import dbi
import odbc
myconn = odbc.odbc('testpy')
mycursor = myconn.cursor()
mycursor.execute('Update Categories Set DelStatus = 0 Where ProductID =
1190' )
mycursor.close()
myconn.close()
...
###

This works fine using the literals 0 (For Delstatus) and 1190 (for
ProductID)
But when I try to use a variable such as:

###
...
varA = '0'
varB = '1190'
mycursor.execute('Update Categories Set DelStatus = ' varA 'Where ProductID
= ' varB)
...
###

I get errors.  Please excuse my ignorance in what is probably obvious to
most others within this newsgroup.
What I am trying to do is to update my database from a 2 field .CSV file
I figured I could load the CSV file into a dictionary and parse each row
running a query using the values from varA and VarB from the key value
pairs.
Right now I am just trying to get the database part to work that is why
there is no CSV code.
So I guess what I am asking is how do I pass values through the sql
statement:
###
...
mycursor.execute('Update Categories Set DelStatus = X1 Where ProductID =
X2' )# Values replacing X1 and X2.
...
###
Any help is greatly appreciated.

Chris


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


Re: Python Win32 Silent Install

2004-12-01 Thread Peter Hansen
Matt Gerrans wrote:
You guessed correctly.   Python is on HP (and Compaq now) PCs because I put 
it there.
Do you think you could expand on the brief description about this
that is to be found in the following page?
http://www.python.org/doc/faq/installed.html
The python.org webmaster email address gets *lots* of requests
from innocent and ignorant users who are concerned about finding
this thing called Python on their new machines, and most of
them seem curiously more interested in removing it than in discovering
what it actually is there for.
The auto-response points them to the above page, I believe, and it
would perhaps save the webmaster types some time if there was a more
official HP version of the situation than the Apparently some of
HP/Compaq's administrative tools are written in Python. comment that is
there now.
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.4 and Tkinter

2004-12-01 Thread Jean Brouwers

FWIW, we just installed Python 2.4 (on RH Linx 8), rebuilt it from
scratch and everything is fine.  Tkinter is there, _tkinter as well and
idle comes up as expected.

/Jean Brouwers



In article [EMAIL PROTECTED],
Jeffrey Barish [EMAIL PROTECTED] wrote:

 http://www.python.org/moin/TkInter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3000 and Python Regrets

2004-12-01 Thread Peter Hansen
Dave Benjamin wrote:
Steve Holden wrote:
from __past__ import __mistakes__
LOL! Better yet:
import __past__
del __past__.__mistakes__

You can't change the past, as everyone knows, so
the names in that module are constants, like None
is in Python 2.4.
It's better simply not to spend time looking at it,
following the Pythonic DCOSM** idiom clearly suggests:
from __past__ import __mistakes__
del __mistakes__
Of course, those who forget history are doomed to repeat
it, so it might be better to do this, even though it's
in violation of common Python stylistic advice:
from __past__ import *
del __mistakes__
Unfortunately, I'm not sure whether you'll get a NameError
here, because the from xx import * pattern generally
doesn't retrieve names that begin with an underscore...
-sucking-up-bandwidth-for-all-its-worth-ly y'rs,
 Peter
** Don't cry over spilt milk, of course...
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Win32 Silent Install

2004-12-01 Thread Brad Tilley
Peter Hansen wrote:
... innocent and ignorant users who are concerned about finding
this thing called Python on their new machines, and most of
them seem curiously more interested in removing it than in discovering
what it actually is there for.
This has been my experience as well. I don't have millions or even 
thousands of users... only hundreds. However, this is the exact same 
reason that I try to hide Python installs and make them unremovable. I 
guess all of the Windows based Spyware and Adware have made people 
overly cautious... if it looks suspicious, then remove it. To the 
average user, the name 'Python' doesn't sound harmless either.
--
http://mail.python.org/mailman/listinfo/python-list


Dr. Dobb's Python-URL! - weekly Python news and links (Dec 2)

2004-12-01 Thread Cameron Laird
QOTW:  ... why does Microsoft try so hard to protect its sources?
To avoid embarrassment. -- Peter Maas and Grant Edwards
http://groups.google.com/groups?frame=leftth=9a599152d8b23b54

Sufficiently advanced cluelessness is indistinguishable from
malice. -- Alex Martelli


2.4 is final, buildable under Windows in at least a couple 
of ways, improved, ...
http://www.brunningonline.net/simon/blog/archives/001657.html

asyncore, Twisted, the Python core...--do you understand how
they relate to TLS, serial-port usage, GUI-oriented event
processing, and so on?
http://groups.google.com/groups?th=752ebdb8b57fa3f3

Ian Bicking and others describe the meaning of Python 3000.
http://groups.google.com/groups?frame=leftth=8f9b6a3959888f2b

Reading without blocking is possible--with care.
http://groups.google.com/groups?frame=leftth=78654cfc06d2fbbe

Josiah Carlson and Paul McGuire explain decorators.
http://groups.google.com/groups?th=5bfb80b43887bc1f

Nick Coghlan knows sick ways to spell file.
http://groups.google.com/groups?frame=rightth=e562a771d1c827c9

Python works in Frontier.
http://radio.weblogs.com/0100039/2004/11/30.html#a626



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily  
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html 
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce

Brett Cannon continues the marvelous tradition established by 
Andrew Kuchling and Michael Hudson of intelligently summarizing
action on the python-dev mailing list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
http://www.vex.net/~x/parnassus/   

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

The Python Business Forum further[s] the interests of companies
that base their business on ... Python.
http://www.python-in-business.org

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance. 
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.
http://www.python.org/psf/donate.html

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch
   
Cetus collects Python hyperlinks.
http://www.cetus-links.org/oo_python.html

Python FAQTS
http://python.faqts.com/

The Cookbook is a collaborative effort to capture useful and
interesting recipes.
http://aspn.activestate.com/ASPN/Cookbook/Python

Among several Python-oriented RSS/RDF feeds available are
http://www.python.org/channews.rdf
http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi
http://python.de/backend.php
For more, see
http://www.syndic8.com/feedlist.php?ShowMatch=pythonShowStatus=all
The old Python To-Do List now lives principally in a
SourceForge reincarnation.
http://sourceforge.net/tracker/?atid=355470group_id=5470func=browse
http://python.sourceforge.net/peps/pep-0042.html
 
The online Python Journal is posted at pythonjournal.cognizor.com.
[EMAIL PROTECTED] and [EMAIL PROTECTED]
welcome submission of material that helps people's understanding
of Python use, and offer Web presentation of your work.

*Py: the Journal of the Python Language*
http://www.pyzine.com

Archive probing tricks of the trade:

http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.pythonnum=100


Re: wxPython to build an HTML analyser/displayer?

2004-12-01 Thread Roger Binns

Luke Skywalker [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 Does wxWidgets offer an HTML displayer widget,

Yes.  In general it is highly recommended to download wxPython
and the associated demo app.  The demo app shows every single
widget so you get an idea of what is available, what they look
like and you can examine the demo code to see how they are used.

 and is it good enough?

Unlikely.  It is a simple HTML viewer and doesn't support stylesheets
amongst other things.  (It does support adding your own tags,
widgets and virtual filesystems though).  More details are at
http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin_wxhtml.html
(The Tags supported by wxHTML 75% of the way down will be useful
 information for you)

However the good news is you have two alternatives.  One is that
on Windows you can use the IE HTML display widget directly.  See
the demo.

If you need to be cross platform then wxMozilla is worth looking at
(which is apparently active despite appearing dormant).  Start at
http://wxmozilla.sourceforge.net/pmwiki/pmwiki.php/Main/Documentation

Roger 


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


Re: non blocking read()

2004-12-01 Thread Greg Ewing
Donn Cave wrote:
If we are indeed talking about a pipe or something that
really can block, and you call fileobject.read(1024),
it will block until it gets 1024 bytes.
No, it won't, it will block until *some* data is
available, and then return that (up to a maximum of
1024).
If the fd has just been reported by select() as ready
for reading, then something is there, so the first
read() call won't block. But if there was exactly
1024 bytes there, the second read() call *will* block,
because there are now 0 bytes available (which I think
is what an earlier poster was hinting at).
For this reason, if you have no way of knowing how
much data to expect in advance, it's better to avoid
making more than one read() call on a fd per select().
If you don't get a whole line (or whatever chunk you're
looking for), put what you've got into a buffer, and
go back to select(). When you've built up a complete
chunk in the buffer, process it. Keep in mind that
part of the next chunk may be in the tail of the
buffer, so be prepared to chop a chunk off the
beginning of the buffer and leave the rest for later.
Another possibility that's been suggested is putting
the fd into non-blocking mode. I wouldn't recommend
that; the last time I tried it (which was quite a long
time ago) select() and non-blocking I/O didn't mix
well. While it may be possible to get it to work, I
don't think you'd gain much. You need to understand
that there's no guaranteed relationship between the
chunks of data written to one end of a pipe or socket
and those returned by reading the other end. So you'd
still need to be prepared to buffer and re-chunk the
data. You'd end up doing all of what I outlined above,
with the extra complication of non-blocking I/O thrown
in. I don't see any advantage in it.
--
Greg Ewing, Computer Science Dept,
University of Canterbury,   
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
--
http://mail.python.org/mailman/listinfo/python-list


Re: non blocking read()

2004-12-01 Thread Greg Ewing
Steve Holden wrote:
When access is made to a file object in 
non-blocking mode it will return whatever data there are immediately 
available in the buffers, up to the number of bytes requested. If the 
buffers are currently empty the process will generate an error
Are you sure that's right? If so, it would seem that
reading a non-blocking disk file would *never* return
any data...
--
Greg Ewing, Computer Science Dept,
University of Canterbury,   
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
--
http://mail.python.org/mailman/listinfo/python-list


Re: Video Catalogue

2004-12-01 Thread Tom B.

Rodney Dangerfield [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Greetz!

 Recently I started creating a CGI application for my gf that
 she would use for indexing and keeping track of her video
 collection.

 I am relatively new to python so I started with the basics.
 I figured out how to extract the form field values in a
 script and how to save to a file.

 My question is which data type should I use to store the information
 about the videos? I was thinking of using a dictionary variable,
 I saw something about the pickle module too, could I use it to
 save the state of my dictionary to a file and than later read it
 and feed values from it to the form fields via CGI?

 All help is greatly appreciated.

I think a dictionary might work well, I might use a dictionary within a 
dictionary.

vidiodict = 
{'Title':{'description':'','date':'','cast':'','length':'130.99','comments':''}}

that way you could look at vidiodict['Title']['length'] it returns '130.99'.

Tom 


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


[PIL] import error

2004-12-01 Thread Egor Bolonev
import image
gives
Traceback (most recent call last):
  File image1.py, line 7, in ?
import image
ImportError: No module named image
i've installed python 2.3.4 and PIL for python 2.3
--
http://mail.python.org/mailman/listinfo/python-list


Re: [PIL] import error

2004-12-01 Thread Egor Bolonev
On Thu, 02 Dec 2004 13:10:25 +1000, Egor Bolonev [EMAIL PROTECTED] wrote:
ho error is bad case. there must be import Image
import image
gives
Traceback (most recent call last):
   File image1.py, line 7, in ?
 import image
ImportError: No module named image
i've installed python 2.3.4 and PIL for python 2.3
--
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython to build an HTML analyser/displayer?

2004-12-01 Thread Luke Skywalker
On Wed, 1 Dec 2004 16:57:45 -0800, Roger Binns
[EMAIL PROTECTED] wrote:
(snip)

Thx the links.

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


Re: recombination variations

2004-12-01 Thread Hung Jung Lu
alphabet = {
'A': 'A',
'T': 'T',
'C': 'C',
'G': 'G',
'W': 'AT',
'M': 'AC',
'R': 'AG',
'Y': 'TC',
'K': 'TG',
'S': 'CG',
'H': 'ATC',
'D': 'ATG',
'V': 'AGC',
'B': 'CTG',
'N': 'ATCG'
}

expand = lambda t: reduce(lambda r, s: [x+y for x in r for y in
alphabet[s]], t, [''])

print expand('ATSGS')

--

['ATCGC', 'ATCGG', 'ATGGC', 'ATGGG']
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: IPython 0.6.5 is out

2004-12-01 Thread CarlosRivera
Looks cool.  I will have to check it out.
--
http://mail.python.org/mailman/listinfo/python-list


Re: pre-PEP generic objects

2004-12-01 Thread Nick Craig-Wood
Steven Bethard [EMAIL PROTECTED] wrote:
  Nick Craig-Wood wrote:
  Steven Bethard [EMAIL PROTECTED] wrote:
  
  I promised I'd put together a PEP for a 'generic object' data type for 
  Python 2.5 that allows one to replace __getitem__ style access with 
  dotted-attribute style access (without declaring another class).  Any 
  comments would be appreciated!
  
  My experience from using this is that whenever I used Hash(), I found
  that later on in the refinement of the conversion it became its own
  class.
 
  This has also generally been my experience, though I'm not sure it's as 
  true for the XML DOM to Bunch translation.  Did you use Hash() in the 
  same way for hierarchical data?

Hash() got nested yes, but not in a general purpose structure like
your XML example.
 
  So my take on the matter is that this encourages perl style
  programming (just ram it in a hash, and write lots of functions acting
  on it) rather than creating a specific class for the job which is dead
  easy in python anyway and to which you can attach methods etc.
 
  You'll note that the (pre-)PEP explicitly notes that this object is 
  intended only for use when no methods are associated with the attributes:
 
  When no methods are to be associated with the attribute-value mappings,
  declaring a new class can be overkill.
 
  I do understand your point though -- people might not use Bunch in the 
  way it's intended.  Of course, those same people can already do the same 
  thing with a dict instead (e.g. write a bunch of functions to handle a 
  certain type of dict).  If someone wants to write Perl in Python, 
  there's not much we can really do to stop them...

No there isn't ;-)

The above does make it a lot more convenient though blob['foo'] is
rather difficult to type compared to blob.foo!

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: database questions ala newbie pythonist

2004-12-01 Thread Weinhandl Herbert
chris wrote:
...

This works fine using the literals 0 (For Delstatus) and 1190 (for
ProductID)
But when I try to use a variable such as:
###
...
varA = '0'
varB = '1190'
mycursor.execute('Update Categories Set DelStatus = ' varA 'Where ProductID
= ' varB)
use string formatting expressions
(which are easier to handle than string concatenation) :
'UPDATE Categories SET DelStatus=%d WHERE ProductID=%s;' % (varA,'1190')
or maybe
UPDATE Categories SET DelStatus='%d' WHERE ProductID='%d'; % (0,varB)
if your DB wants your int's as string

###
I get errors.  Please excuse my ignorance in what is probably obvious to
most others within this newsgroup.
What I am trying to do is to update my database from a 2 field .CSV file
I figured I could load the CSV file into a dictionary and parse each row
running a query using the values from varA and VarB from the key value
pairs.
happy pythoning
Herbert
--
http://mail.python.org/mailman/listinfo/python-list