morrowind no cd crack

2008-04-28 Thread fennelllindy8241
morrowind no cd crack

















http://crack.cracksofts.com

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


risk2 no disk patch

2008-04-28 Thread fennelllindy8241
risk2 no disk patch

















http://crack.cracksofts.com

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


strawberry patch

2008-04-28 Thread fennelllindy8241
strawberry patch

















http://crack.cracksofts.com

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


recipe for crack cocaine

2008-04-28 Thread fennelllindy8241
recipe for crack cocaine

















http://crack.cracksofts.com

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


norton ghost crack

2008-04-28 Thread fennelllindy8241
norton ghost crack

















http://crack.cracksofts.com

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


crack addict

2008-04-28 Thread fennelllindy8241
crack addict

















http://crack.cracksofts.com

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


convertxtodvd keygen

2008-04-28 Thread fennelllindy8241
convertxtodvd keygen

















http://crack.cracksofts.com

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


crack library

2008-04-28 Thread fennelllindy8241
crack library

















http://crack.cracksofts.com

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


mapsource keygen

2008-04-28 Thread fennelllindy8241
mapsource keygen

















http://crack.cracksofts.com

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


call od duty 4 crack download

2008-04-28 Thread fennelllindy8241
call od duty 4 crack download

















http://crack.cracksofts.com

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


ravenhearst crack

2008-04-28 Thread fennelllindy8241
ravenhearst crack

















http://crack.cracksofts.com

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


crack acrylic sheet repair

2008-04-28 Thread fennelllindy8241
crack acrylic sheet repair

















http://crack.cracksofts.com

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


py2exe do not compile from mingw

2008-04-28 Thread Alexandr N Zamaraev

OS: WinXP Home Ru + sp2
Python: 2.5.2
py2exe: latest CSV source
gcc (GCC) 3.4.5 (mingw-vista special r2)
GNU ld (GNU Binutils) 2.18.50.20080109

OS: WinXP Home Ru + sp2
Python: 2.5.2
py2exe: latest CSV source
gcc (GCC) 3.4.5 (mingw-vista special r2)
GNU ld (GNU Binutils) 2.18.50.20080109

I have patchs for compile py2exe from latest release mingw.

Correct setup, compile, and run errors.

This patch union 1012785 patch and 1378533 bag patch for latest CSV source.

see alse
http://sourceforge.net/tracker/index.php?func=detail&aid=1953133&group_id=15583&atid=315583, 




http://sourceforge.net/tracker/?func=detail&aid=1378533&group_id=15583&atid=115583, 




http://sourceforge.net/tracker/?func=detail&aid=1012785&group_id=15583&atid=315583


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


Re: error: (10035, 'The socket operation...

2008-04-28 Thread Gabriel Genellina
En Sun, 27 Apr 2008 21:41:57 -0300, Benjamin Kaplan <[EMAIL PROTECTED]> 
escribió:

>> On Sun, Apr 27, 2008 at 7:01 PM, Don Hanlen <[EMAIL PROTECTED]> wrote:
>>  > IDLE internal error in runcode()
>>  >  Traceback (most recent call last):
>>  >   File "C:\PYTHON25\lib\idlelib\rpc.py", line 235, in asyncqueue
>>  > self.putmessage((seq, request))
>>  >   File "C:\PYTHON25\lib\idlelib\rpc.py", line 332, in putmessage
>>  > n = self.sock.send(s[:BUFSIZE])
>>  >  error: (10035, 'The socket operation could not complete without
>>  >  blocking')
>>  >
>>  >  Does this look familiar to anyone?  I can't figure out what to do
>>  >  about it.  Python 2.5, windoze.  I get it when I execute a Tkinter op
>>  >  that works elsewhere.

>>  It might have something to do with the fact that IDLE uses Tkinter,
>>  but, having never used it myself, I'm not sure.

I think IDLE doesn't work well with Tkinter apps, they compete for the main 
loop. But perhaps that's already been resolved in recent releases. Anyway this 
looks like a different problem, I'd file a bug at bugs.python.org
In the meantime, run your app from the command line instead of from inside IDLE.

-- 
Gabriel Genellina

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


4502 cams patch

2008-04-28 Thread fennelllindy8241
4502 cams patch

















http://crack.cracksofts.com

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


imtoo crack

2008-04-28 Thread fennelllindy8241
imtoo crack

















http://crack.cracksofts.com

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


crack van

2008-04-28 Thread fennelllindy8241
crack van

















http://crack.cracksofts.com

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


class or class-instance ?

2008-04-28 Thread Stef Mientki

hello,

I've a procedure (or in fact a class method) that should be callable with
either a class
 (in which case the procedure should create an instance)
or with an instance of that class
as the parameter.

   def  somefunction ( self, parameter ) :
   if parameter is a class, create an instance of that class
   else do nothing



now I should be able to call the above procedure in either of the 
following ways:
 
   somefunction (  someclass  )


or

   somefunction ( someclass () )


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


Re: class or class-instance ?

2008-04-28 Thread Diez B. Roggisch

Stef Mientki schrieb:

hello,

I've a procedure (or in fact a class method) that should be callable with
either a class
 (in which case the procedure should create an instance)
or with an instance of that class
as the parameter.

   def  somefunction ( self, parameter ) :
   if parameter is a class, create an instance of that class
   else do nothing



now I should be able to call the above procedure in either of the 
following ways:
 
   somefunction (  someclass  )


or

   somefunction ( someclass () )


There is a

isclass

in the module inspect.

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


Re: error: (10035, 'The socket operation...

2008-04-28 Thread bockman
On 28 Apr, 01:01, Don Hanlen <[EMAIL PROTECTED]> wrote:
> IDLE internal error in runcode()
> Traceback (most recent call last):
>   File "C:\PYTHON25\lib\idlelib\rpc.py", line 235, in asyncqueue
>     self.putmessage((seq, request))
>   File "C:\PYTHON25\lib\idlelib\rpc.py", line 332, in putmessage
>     n = self.sock.send(s[:BUFSIZE])
> error: (10035, 'The socket operation could not complete without
> blocking')
>
> Does this look familiar to anyone?  I can't figure out what to do
> about it.  Python 2.5, windoze.  I get it when I execute a Tkinter op
> that works elsewhere.
>
> changing this:
>
> t = self.b.create_text(
>     (point.baseX + 1)*self.checkerSize/2 + fudge,
>     y + fudge,
>     text = str(point.occupied),
>     width = self.checkerSize)
>
> to
>
> t = self.b.create_text(
>     (point.baseX + 1)*self.checkerSize/2 + fudge,
>     y + fudge,
>     text = str(point.occupied),
>     font=("Times", str(self.checkerSize/2), "bold"),
>     width = self.checkerSize)
>
> for example.  The same code works fine elsewhere.  I thought I'd ask
> here before I try (no clue) increasing BUFSIZE in rpc.py?  I'm not
> crazy about tinkering with code I have no clue about..
> --
> don

The error is EWOULDBLOCK, which you get when you configure a socket
for asynchronous
I/O and then try an operation which cannot be completed immediately.
It is not an actual failure,
it is part of the asynch socket handling issues: it means that you
have to wait and try later.

AFAIK (almost nothing) the Tkinter application has two processes
(maybe the front-end and the interpreter)
which communicate through a socket. From the traceback, I world say
that the two processes communicate
using RPC protocol and the rpclib module, and that this in turns uses
the asyncqueue module, and one of them fails handling the EWOULDBLOCK
code.

I don't think that increasing BUFSIZE would solve the problem, since
you will try to send more bytes in a single
operation, and this would probably still result in an EWOULDBLOCK
return code.
Anyway, it looks like an IDLE problem, so if you can use another IDE
( Pythonwin? ), you could just ignore it,
maybe submit a bug report ?

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


the pink patch

2008-04-28 Thread landerdebraznpc
the pink patch







http://crack.cracksofts.com

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


keygen nfs pro street

2008-04-28 Thread landerdebraznpc
keygen nfs pro street







http://crack.cracksofts.com

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


vista ultimate crack

2008-04-28 Thread landerdebraznpc
vista ultimate crack







http://crack.cracksofts.com

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


norton internet security 2007 keygen

2008-04-28 Thread landerdebraznpc
norton internet security 2007 keygen







http://crack.cracksofts.com

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


crack and digichat

2008-04-28 Thread landerdebraznpc
crack and digichat







http://crack.cracksofts.com

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


crack gmail

2008-04-28 Thread landerdebraznpc
crack gmail







http://crack.cracksofts.com

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


Re: Related to Shelve Module

2008-04-28 Thread Gabriel Genellina
En Mon, 28 Apr 2008 02:08:31 -0300, tarun <[EMAIL PROTECTED]> escribió:

> Hi All,
> I want to store the class instance object variables persistenlty in one file
> so that other file can also access for some filtering. I tired doing this
> using the shelve module.
>
> *Code:*
> class A:
> pass
>
> import shelve
> filename = 'test.db'
> d = shelve.open(filename)
>
> a = A()
> print a
> d['1'] = a
>
> print d['1']
> d.close()
>
> *Output:*
> <__main__.A instance at 0x018B56C0>
> <__main__.A instance at 0x018B5760>
>
> *Observation:*
> I expect both the print statements to return the same value, The second
> print statement just reads the dictonary, but still the adress (0x..) is
> different from the first print statement. Can anyone tell me why. Also let
> me know if you the way of getting same value both the times.

By default, each time you do d['1'] you get a *different* object. A shelve 
isn't very smart: it stores a string representation of your object (using 
pickle) and each time you ask for the object, it unpickles the stored string. 
When used as a persistence mechanism, it doesn't matter so much, the process 
that created the original instance may have died eons ago.
If object identity is important to you, you should remember to "fetch" the 
values only once in a single process, or use the writeback=True argument to the 
shelve constructor. But read the warning at 


py> d = shelve.open(filename, writeback=True)
py> a = A()
py> d['1'] = a
py> x1 = d['1']
py> x2 = d['1']
py> x3 = d['1']
py> print a, x1
<__main__.A instance at 0x00A3D5D0> <__main__.A instance at 0x00A3D5D0>
py> a is x1 is x2 is x3
True

-- 
Gabriel Genellina

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


crack zone

2008-04-28 Thread landerdebraznpc
crack zone







http://crack.cracksofts.com

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


system mechanic 7 keygen

2008-04-28 Thread landerdebraznpc
system mechanic 7 keygen







http://crack.cracksofts.com

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


paltalk crack

2008-04-28 Thread landerdebraznpc
paltalk crack







http://crack.cracksofts.com

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


dvd cloner crack

2008-04-28 Thread landerdebraznpc
dvd cloner crack







http://crack.cracksofts.com

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


Abuse in comp.lang.python

2008-04-28 Thread Torsten Bronger
Path: 
uni-berlin.de!fu-berlin.de!postnews.google.com!f63g2000hsf.googlegroups.com!not-for-mail
Message-ID: <[EMAIL PROTECTED]>
From: [EMAIL PROTECTED]
Newsgroups: comp.lang.python
Subject: the pink patch
Date: Mon, 28 Apr 2008 00:52:20 -0700 (PDT)
Lines: 10
Organization: http://groups.google.com
NNTP-Posting-Host: 212.241.180.239
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1209369140 19824 127.0.0.1 (28 Apr 2008 07:52:20 
GMT)
X-Complaints-To: [EMAIL PROTECTED]
NNTP-Posting-Date: Mon, 28 Apr 2008 07:52:20 + (UTC)
Complaints-To: [EMAIL PROTECTED]
Injection-Info: f63g2000hsf.googlegroups.com; posting-host=212.241.180.239; 
posting-account=fGAdLgoAAABaPJnllSky1fhOhiaRCPm2
User-Agent: G2/1.0
X-HTTP-Via: 1.1 ds4204.dedicated.turbodns.co.uk:81 (squid/2.5.STABLE12)
X-HTTP-UserAgent: gzip(gfe),gzip(gfe)
Xref: wilson.homeunix.com comp.lang.python:23005

the pink patch







http://crack.cracksofts.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Question regarding Queue object

2008-04-28 Thread Nick Craig-Wood
David <[EMAIL PROTECTED]> wrote:
>  Another idea would be to have multiple queues, one per thread or per
>  message type "group". The producer thread pushes into the appropriate
>  queues (through an intelligent PutMsg function), and the consumer
>  threads pull from the queues they're interested in and ignore the
>  others.

Unfortunately a thread can only wait on one Queue at once (without
polling).  So really the only efficient solution is one Queue per
thread.

Make an intelligent PutMsg function which knows which Queue (or
Queues) each message needs to be put in and all the threads will have
to do is Queue.get() and be sure they've got a message they can deal
with.

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


Re:apache module: python and web programming, easy way...?

2008-04-28 Thread bvidinli
is there any apache module, you know, that i can just install with apt-get,
then put my .py file, and run it ?


2008/4/27 David <[EMAIL PROTECTED]>:
> >
>  >  www.webpy.org is supereasy to get going with. dont know which is
>  >  better for advanced stuff.
>  >
>
>  I don't think that webpy supports sessions. Their addition to webpy is
>  a Google Summer of Code project:
>
>  http://webpy.org/sessions/gsoc
>
>  Also, I can't find any reference to cookies or sessions in the webpy
>  online docs. Maybe it's possible to bolt on support with Python's
>  Cookie module.
>
>  David.
>
>
> --
>  http://mail.python.org/mailman/listinfo/python-list
>



-- 
İ.Bahattin Vidinli
Elk-Elektronik Müh.
---
iletisim bilgileri (Tercih sirasina gore):
skype: bvidinli (sesli gorusme icin, www.skype.com)
msn: [EMAIL PROTECTED]
yahoo: bvidinli

+90.532.7990607
+90.505.5667711
--
http://mail.python.org/mailman/listinfo/python-list


Re: Receive data from socket stream

2008-04-28 Thread Nick Craig-Wood
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>  I wanted to ask for standard ways to receive data from a socket stream
>  (with socket.socket.recv()). It's simple when you know the amount of
>  data that you're going to receive, or when you'll receive data until
>  the remote peer closes the connection. But I'm not sure which is the
>  best way to receive a message with undetermined length from a stream
>  in a connection that you expect to remain open. Until now, I've been
>  doing this little trick:
> 
>  data = client.recv(256)
>  new = data
>  while len(new) == 256:
>  new = client.recv(256)
>  data += new
> 
>  That works well in most cases. But it's obviously error-prone. What if
>  the client sent *exactly* two hundred and fifty six bytes? It would
>  keep waiting for data inside the loop. Is there really a better and
>  standard way, or is this as best as it gets?

What you are missing is that if the recv ever returns no bytes at all
then the other end has closed the connection.  So something like this
is the correct thing to write :-

  data = ""
  while True:
  new = client.recv(256)
  if not new:
  break
  data += new

>From the man page for recv

  RETURN VALUE

   These calls return the number of bytes received, or -1 if an
   error occurred.  The return value will be 0 when the peer has
   performed an orderly shutdown.

In the -1 case python will raise a socket.error.

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


Retrieving int from hex in a file.

2008-04-28 Thread Filipe Teixeira
Hi.

I have to open a binary file from an old computer and recover the
information stored (or at least try to). I use:

f=open('file.bin','rb')
a=f.read()
f.close()

a in now a string full of hex representations in the form:

a[6]='\x14'
a[7]='\x20'

I would like to convert these hex representations to int, but this
(the most obvious way) doesn't seem to be working

>>> q=a[6]
>>> q
'\x14'
>>> int(q,16)
Traceback (most recent call last):
  File "", line 1, in ?
ValueError: invalid literal for int():
>>>

How can I do this?

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


Re: Receive data from socket stream

2008-04-28 Thread Hrvoje Niksic
Nick Craig-Wood <[EMAIL PROTECTED]> writes:

> What you are missing is that if the recv ever returns no bytes at all
> then the other end has closed the connection.  So something like this
> is the correct thing to write :-
>
>   data = ""
>   while True:
>   new = client.recv(256)
>   if not new:
>   break
>   data += new

This is a good case for the iter() function:

buf = cStringIO.StringIO()
for new in iter(partial(client.recv, 256), ''):
buf.write(new)
data = buf.getvalue()

Note that appending to a string is almost never a good idea, since it
can result in quadratic allocation.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Receive data from socket stream

2008-04-28 Thread Nick Craig-Wood
Mark Tolonen <[EMAIL PROTECTED]> wrote:
> > So every time I use I want to send some thing, I must use
> >
> > totalsent = 0
> > while sent < len(data):
> >sent = sock.send(data[totalsent:])
> >totalsent += sent
> >
> > instead of a simple sock.send(data)? That's kind of nasty. Also, is it
> > better then to use sockets as file objects? Maybe unbuffered?
> 
>  I think you meant:
> 
>  while totalsent < len(data):
> 
>  Python also has the sendall() function.

Just to elaborate, sendall does exactly the above for you.

 sendall(self, *args)
 sendall(data[, flags])
 
 Send a data string to the socket.  For the optional flags
 argument, see the Unix manual.  This calls send() repeatedly
 until all data is sent.  If an error occurs, it's impossible
 to tell how much data has been sent.

There should really be a recvall for symmetry, but I don't think it
would get much use!

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


Re: Retrieving int from hex in a file.

2008-04-28 Thread Gabriel Genellina
En Mon, 28 Apr 2008 07:14:51 -0300, Filipe Teixeira <[EMAIL PROTECTED]> 
escribió:

> a in now a string full of hex representations in the form:
>
> a[6]='\x14'
> a[7]='\x20'
>
> I would like to convert these hex representations to int, but this
> (the most obvious way) doesn't seem to be working
>
 q=a[6]
 q
> '\x14'
 int(q,16)
> Traceback (most recent call last):
>   File "", line 1, in ?
> ValueError: invalid literal for int():


Use ord(q)

py> help(ord)
Help on built-in function ord in module __builtin__:

ord(...)
 ord(c) -> integer

 Return the integer ordinal of a one-character string.

py>

-- 
Gabriel Genellina

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


Re: Regular Expression - Matching Multiples of 3 Characters exactly.

2008-04-28 Thread Nick Craig-Wood
blaine <[EMAIL PROTECTED]> wrote:
>  I'm trying to write a string matching algorithm for genomic
>  sequences.  I'm pulling out Genes from a large genomic pattern, with
>  certain start and stop codons on either side.  This is simple
>  enough... for example:
> 
>  start = AUG stop=AGG
>  BBAUGWWAGGBB
> 
>  So I obviously want to pull out AUGWWAGG (and all other matches).
>  This works great with my current regular expression.
> 
>  The problem, however, is that codons come in sets of 3 bases.  So
>  there are actually three different 'frames' I could be using.  For
>  example:
>  ABCDEFGHIJ
>  I could have ABC DEF GHI or BCD EFG HIJ or CDE FGH IJx etc.
> 
>  So finally, my question.  How can I represent this in a regular
>  expression? :)  This is what I'd like to do:
>  (Find all groups of any three characters) (Find a start codon) (find
>  any other codons) (Find an end codon)
> 
>  Is this possible? It seems that I'd want to do something like this: (\w
>  \w\w)+(AUG)(\s)(AGG)(\s)* - where \w\w\w matches EXACTLY all sets of
>  three non-whitespace characters, followed by AUG \s AGG, and then
>  anything else.

I'm not sure what the \s are doing in there - there doesn't appear to
be any whitespace in your examples.

>  I hope I am making sense.  Obviously, however, this will make sure
>  that ANY set of three characters exist before a start codon.  Is
>  there a way to match exactly, to say something like 'Find all sets
>  of three, then AUG and AGG, etc.'.

I think you want

^(\w\w\w)*(AUG)((\w\w\w)*?)(AGG)

which will match up 0 or more triples, match AUG match 0 or more triples
then AGG.  The ? makes it a minimum match otherwise you'll match more
than you expect if there are two AUG...AGG sequences in a given genome.

  >>> import re
  >>> m=re.compile(r"^(\w\w\w)*(AUG)((\w\w\w)*?)(AGG)")
  >>> m.search("BBAUGWWAGGBB").groups()
  ('BBB', 'AUG', 'WW', 'WWW', 'AGG')
  >>> m.search("BBBQBBBAUGWWAGGBB")
  >>> m.search("BBBQQBBBAUGWWAGGBB")
  >>> m.search("BBBQQBBQBAUGWWAGGBB")
  <_sre.SRE_Match object at 0xb7de33e0>
  >>> m.search("BBBQQBBQBAUGWWAGGBB").groups()
  ('BQB', 'AUG', 'WW', 'WWW', 'AGG')
  >>> m.search("BBBQQBBQBAUGWQWAGGBB")
  >>> m.search("BBBQQBBQBAUGQWWAGGBB")
  >>> m.search("BBBQQBBQBAUGWWQWWQWWAGGBB")
  >>> m.search("BBBQQBBQBAUGWWQWAWQWWAGGBB")
  <_sre.SRE_Match object at 0xb7de33e0>
  >>> m.search("BBBQQBBQBAUGWWQWAWQWWAGGBB").groups()
  ('BQB', 'AUG', 'WWQWAWQWW', 'QWW', 'AGG')
  >>> 

>  This way, I could scan for genes, remove the first letter, scan for
>  more genes, remove the first letter again, and scan for more genes.
>  This would hypothetically yield different genes, since the frame
>  would be shifted.

Of you could just unconstrain the first match and it will do them all
at once :-

(AUG)((\w\w\w)*?)(AGG)

You could run this with re.findall, but beware that this will only
return non-overlapping matches which may not be what you want.

I'm not sure re's are the best tool for the job, but they should give
you a quick idea of what the answers might be.

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


Re: multiple pattern regular expression

2008-04-28 Thread micron_make

each of the suggested methods fit in. I have started trying them.

-Rohit


-- 
View this message in context: 
http://www.nabble.com/multiple-pattern-regular-expression-tp16895148p16936657.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: Retrieving int from hex in a file.

2008-04-28 Thread Peter Otten
Filipe Teixeira wrote:

> I have to open a binary file from an old computer and recover the
> information stored (or at least try to). I use:

> I would like to convert these hex representations to int, but this

If you want to do it efficiently have a look at the array module:

>>> import os, array
>>> a = array.array("B")
>>> filename = "/usr/bin/python"
>>> a.fromfile(open(filename, "rb"), os.path.getsize(filename))
>>> a[10]
0
>>> a[:10]
array('B', [127, 69, 76, 70, 2, 1, 1, 0, 0, 0])

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


Need help on left padding

2008-04-28 Thread rajesh kataraki
Hello,

 My requirement is I am using one variable ex. var = 5 which is
integer.
And this variable, I m using in some string. But I want this var
to be used as 005 again integer in this string.

 The snippet of string is as follows:

 container_name = "%s-%d-dso-%s.so" % (platform_affix,var, rteset)


 Please let me know how can I implement this efficiently in python
language.

Need help urgent.

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


Re: Need help on left padding

2008-04-28 Thread Marc 'BlackJack' Rintsch
On Mon, 28 Apr 2008 04:37:02 -0700, rajesh kataraki wrote:

>  My requirement is I am using one variable ex. var = 5 which is
> integer.
> And this variable, I m using in some string. But I want this var
> to be used as 005 again integer in this string.

In [22]: '%03d' % 5
Out[22]: '005'

Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list


Re: apache module: python and web programming, easy way...?

2008-04-28 Thread Graham Dumpleton
On Apr 28, 7:42 pm, bvidinli <[EMAIL PROTECTED]> wrote:
> is there any apache module, you know, that i can just install with apt-get,
> then put my .py file, and run it ?

http://www.modwsgi.org
http://www.modpython.org

The mod_wsgi module supports WSGI (http://www.wsgi.org) specification
which is where Python web framework hosting is heading whereas
mod_python has its own specific API which results in your application
only being able to be hosted with it and nothing else.

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


Re: Retrieving int from hex in a file.

2008-04-28 Thread bgeddy

Filipe Teixeira wrote:

Hi.

I have to open a binary file from an old computer and recover the
information stored (or at least try to). I use:

f=open('file.bin','rb')
a=f.read()
f.close()

a in now a string full of hex representations in the form:

a[6]='\x14'
a[7]='\x20'

I would like to convert these hex representations to int, but this
(the most obvious way) doesn't seem to be working


q=a[6]
q

'\x14'

int(q,16)

Traceback (most recent call last):
  File "", line 1, in ?
ValueError: invalid literal for int():

How can I do this?

Thanks


As you say you are trying to recover information from the old computer 
are you sure you want to convert the data to it's integer representation   ?
What I mean is in this case the string will contain the actual data read 
from the file, not a hex representation. It's just the python displays 
this data as '\x14'. BTW - are you sure it's displaying '\x20' from your 
data as this should be a space character i.e. " ".


In the python interpreter try this:

mydata=""
for i in range(256):
mydata+=chr(i)
>> mydata

This will show you the hex representation of the values in mydata that 
it can't display however the string is not a string of "hex values" as 
such, it contains the binary values 0-255.

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


Re: Retrieving int from hex in a file.

2008-04-28 Thread Filipe Teixeira
>
> Use ord(q)
>
> py> help(ord)
> Help on built-in function ord in module __builtin__:
>
> ord(...)
>  ord(c) -> integer
>
>  Return the integer ordinal of a one-character string.
>
> py>
>
> --
> Gabriel Genellina

Thank you Gabriel. It fit's my purpose.

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


Re: Need help on left padding

2008-04-28 Thread Albert Leibbrandt

Marc 'BlackJack' Rintsch wrote:

On Mon, 28 Apr 2008 04:37:02 -0700, rajesh kataraki wrote:

  

 My requirement is I am using one variable ex. var = 5 which is
integer.
And this variable, I m using in some string. But I want this var
to be used as 005 again integer in this string.



In [22]: '%03d' % 5
Out[22]: '005'

Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list

  

   that or use *str(5).zfill(3)*
--
http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression - Matching Multiples of 3 Characters exactly.

2008-04-28 Thread Jeff
Regular expressions for that sort of thing can get *really* big.  The
most efficient way would be to programmatically compose the regular
expression to be as exact as possible.

import re

def permutation(lst):

From http://labix.org/snippets/permutations/. Computes permutations
of a
list iteratively.
"""
queue = [-1]
lenlst = len(lst)
while queue:
i = queue[-1]+1
if i == lenlst:
queue.pop()
elif i not in queue:
queue[-1] = i
if len(queue) == lenlst:
yield [lst[j] for j in queue]
queue.append(-1)
else:
queue[-1] = i

def segment_re(a, b):
"""
Creates grouped regular expression pattern to match text between all
possibilies of three-letter sets a and b.
"""
def pattern(n):
return "(%s)" % '|'.join( [''.join(grp) for grp in 
permutation(n)] )

return re.compile( r'%s(\w+?)%s' % (pattern(a), pattern(b)) )

print segment_re(["a", "b", "c"], ["d", "e", "f"])

You could extend segment_re to accept an integer to limit the (\w+?)
to a definite quantifier.  This will grow the compiled expression in
memory but make matching faster (such as \w{3,n} to match from 3 to n
characters).

See http://artfulcode.net/articles/optimizing-regular-expressions/ for
specifics on optimizing regexes.
--
http://mail.python.org/mailman/listinfo/python-list


Checking for existance of feature / tools / solutions -- Something like Java webstart

2008-04-28 Thread Banibrata Dutta
Hi,

I've tried searching this list & googling around a bit -- trying to
see if there is a Java-Webstart like alternative for Python, the
closest approximate I've found is something suggested in this post:

http://mail.python.org/pipermail/python-list/2004-September/282837.html

Is this still pretty much the state-of-art ? Or, is there some other,
better, simpler, snappier alternative.

My requirements fundamentally are to use the web-mechanism
("something" embedded in a webpage, that is able to detect whether
particular (minimal) version of Python is installed on the client
system, and whether my client-software (Python app) is installed or
not, will possibly, first install Python (latest) if not installed,
and then my client-software (Python app). If both are installed, it'd
allow me to upgrade the python app (and/or Python itself prior to it).

This seems to be a something that should be fairly common thing that
folks might have to do!

thanks & regards,
Banibrata
--
http://mail.python.org/mailman/listinfo/python-list


Re: function that accepts any amount of arguments?

2008-04-28 Thread Bruno Desthuilliers

Lie a écrit :

On Apr 25, 2:12 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:


(...)


FWIW, I'd personnaly write avg as taking a sequence - ie,
not using varargs - in which case calling it without arguments would a
TypeError (so BTW please s/Value/Type/ in my previous post).


The problem with passing it as a sequence is, if you want to call it,
you may have to wrestle with this odd looking code:
avg((3, 4, 6, 7))

rather than this, more natural code:
avg(3, 4, 6, 7)


Possibly. Yet my experience is that, most of the time, such a function 
will be called with an already existing sequence, so the most common 
call scheme is


  res = avg(some_sequence)

which is more natural than

  res = avg(*some_sequence)

!-)



And FWIW, the OP asked if it is possible to pass variable amount of
arguments,  avg is just a mere example of one where it could be used
not where it could be best used.


Indeed - but that's not what I was commenting on.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Receive data from socket stream

2008-04-28 Thread Nick Craig-Wood
Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
>  Nick Craig-Wood <[EMAIL PROTECTED]> writes:
> 
> > What you are missing is that if the recv ever returns no bytes at all
> > then the other end has closed the connection.  So something like this
> > is the correct thing to write :-
> >
> >   data = ""
> >   while True:
> >   new = client.recv(256)
> >   if not new:
> >   break
> >   data += new
> 
>  This is a good case for the iter() function:
> 
>  buf = cStringIO.StringIO()
>  for new in iter(partial(client.recv, 256), ''):
>  buf.write(new)
>  data = buf.getvalue()
> 
>  Note that appending to a string is almost never a good idea, since it
>  can result in quadratic allocation.

My aim was clear exposition rather than the ultimate performance!

Anyway str += was optimised in python 2.4 or 2.5 (forget which) wasn't
it?  I'm not convinced it will be any worse performing than
cStringIO.StringIO.write() which effectively appends to a string in
exactly the same way.

This test agrees with me!

$ python -m timeit -s 's = ""' 'for i in xrange(10): s+="x"'
10 loops, best of 3: 23.8 msec per loop

$ python -m timeit -s 'from cStringIO import StringIO; s=StringIO()' 'for i in 
xrange(10): s.write("x")'
10 loops, best of 3: 56 msec per loop

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


is there a threadsafe cookie library?

2008-04-28 Thread fritz
I'm working with a script written in python2.4 that has to handle multiple http connections but I'm having concurrency issues with cookielib. Does anyone know of a threadsafe library that handles cookies?
--
http://mail.python.org/mailman/listinfo/python-list

Cookie Confusion - How to Set a Cookie

2008-04-28 Thread cbhoem
Hi -

I am trying my hand at python cookies.  I'm confused about a few
things though.  Do the python cookies get written to a cookies text
file?  I have simple code below -- I see the cookie in my HTTP header
but do not get anything in the cookie text file.  I'm working on
linux.

print "Content-type: text/html"
cookie = Cookie.SimpleCookie()
cookie['Test'] = 'abc'
print cookie
print

Are there rules about where in the header the set cookie line should
be?

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


Re: Receive data from socket stream

2008-04-28 Thread Jean-Paul Calderone

On Mon, 28 Apr 2008 08:30:03 -0500, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:

Hrvoje Niksic <[EMAIL PROTECTED]> wrote:

 Nick Craig-Wood <[EMAIL PROTECTED]> writes:

> What you are missing is that if the recv ever returns no bytes at all
> then the other end has closed the connection.  So something like this
> is the correct thing to write :-
>
>   data = ""
>   while True:
>   new = client.recv(256)
>   if not new:
>   break
>   data += new

 This is a good case for the iter() function:

 buf = cStringIO.StringIO()
 for new in iter(partial(client.recv, 256), ''):
 buf.write(new)
 data = buf.getvalue()

 Note that appending to a string is almost never a good idea, since it
 can result in quadratic allocation.


My aim was clear exposition rather than the ultimate performance!

Anyway str += was optimised in python 2.4 or 2.5 (forget which) wasn't
it?  I'm not convinced it will be any worse performing than
cStringIO.StringIO.write() which effectively appends to a string in
exactly the same way.

This test agrees with me!

$ python -m timeit -s 's = ""' 'for i in xrange(10): s+="x"'
10 loops, best of 3: 23.8 msec per loop

$ python -m timeit -s 'from cStringIO import StringIO; s=StringIO()' 'for i in 
xrange(10): s.write("x")'
10 loops, best of 3: 56 msec per loop



It's a bit nice that using cStringIO doesn't rely on a very esoteric
optimization in the CPython eval loop, as well as on what references
happen to exist to what objects.  For example, one might want to use a
debugger without falling back to the quadratic behavior of repeated
string concatenation.  cStringIO wins out in this case.

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


Re: ANN: pyspread 0.0.4

2008-04-28 Thread Martin Manns
On Sun, 27 Apr 2008 05:21:56 +0200
Martin Manns <[EMAIL PROTECTED]> wrote:

> The newest version pyspread 0.0.4 now runs on 
> + GTK
> + Windows
> + Mac (not tested myself but got positive reports)
> 
> New features in 0.0.4:
> + Column, line and table insertion and deletion
> + Themeable toolbar

I forgot to post the short description and the link:

pyspread is a spreadsheet that accepts a pure python expression in
each cell.

Highlights:
+ No non-python syntax add-ons
+ Access to python modules from cells
+ 3D grid
+ Numpy object array for representation of string entry into grid cell
+ Numpy object array for representation of eval function array
+ Cell access via slicing of numpy function array
+ X, Y, and Z yield current cell location for relative reference

Requires: Python >=2.4, Numpy 1.0.4, and wxPython 2.8.7.1.
License: GPL

Project page: http://pyspread.sourceforge.net

Best Regards

Martin

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


Chapter on real-time signal processing using numerical Python

2008-04-28 Thread Johannes Nix
Hi,

this might be of interest for people who are look for practical
information on
doing real-time signal processing, possibly using multiple CPUs, and
wonder
whether it's possible to use Python for audio-type worst case
latencies (around 25 ms).
I've done that in my PhD work, both with real-time requirements on
dual-CPU
64 bit platforms, and with very complex algorithms running on
multicomputers.

What I found is that numerical Python is a great environment for such
tasks. I've used it as well for massively parallel algorithms
(particle filters) for simulations of auditory scene analysis. What is
a very
special advantage is that if you get faster hardware, you can simply
copy your algorithms to a new system and compile - even if
it has a different CPU!

I've documented the approach in my PhD thesis, in Appendix A,
starting with some thoughts on developments in signal processing
in the last years. This piece is available online. Title and abstract
of that
chapter read as follows:

--
A real-time, script-based, multiprocessing Solution for experimental
Development of Signal Processing Algorithms

Evaluation of audio signal processing algorithms on real-time
platforms has
unique advantages. However, such environments also used to have the
disadvantage
of requiring expensive hardware, and tedious work to set them up,
while providing only a short useful life. This report proposes to
exploit advances
in hardware and software development by integrating real-time
processing
with script-based explorative development and use of multiprocessing
hardware.
The concept was implemented based on standard hardware and open
source software, and its realization and characteristics are presented
here. Applications
of the system for algorithm development and evaluation are described
briefly.

--


Here is the download link for several paper formats:

http://medi.uni-oldenburg.de/members/jnix/index.html#thesisdownload

Alternatively, for ISO A4 paper, use one of these two URLs:

http://medi.uni-oldenburg.de/download/paper/Nix,Johannes-PhDthesis-2005-ISO-A4-format.pdf
http://docserver.bis.uni-oldenburg.de/publikationen/dissertation/2006/nixloc05/nixloc05.html
(for that paper size, this are the PDF pages 155 - 163)



If you want to cite the chapter, e.g. when doing advocacy for
scientific
computing using SciPy, please do this as follows:

Nix, Johannes (2005), "A real-time, script-based, multiprocessing
Solution for experimental
Development of Signal Processing Algorithms", in: Localization and
Separation of Concurrent Talkers Based on Principles of Auditory Scene
Analysis and Multi-Dimensional Statistical Methods, Appendix A, Ph.D.
thesis, Universität Oldenburg, Germany.


Also, I am currently looking for interesting further work
opportunities
or contracts in the domain of scientific computing and statistical
estimation.
If you know some interesting position, don't hesistate to contact me.

Kind regards,

Johannes


--
Dr. Johannes Nix

Energy & Meteo Systems GmbH
Research & Development of windpower forecasts
Bremen, Germany
Phone: + 49 421 8963914



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


Re: Receive data from socket stream

2008-04-28 Thread s0suk3
On Apr 28, 4:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >  I wanted to ask for standard ways to receive data from a socket stream
> >  (with socket.socket.recv()). It's simple when you know the amount of
> >  data that you're going to receive, or when you'll receive data until
> >  the remote peer closes the connection. But I'm not sure which is the
> >  best way to receive a message with undetermined length from a stream
> >  in a connection that you expect to remain open. Until now, I've been
> >  doing this little trick:
>
> >  data = client.recv(256)
> >  new = data
> >  while len(new) == 256:
> >  new = client.recv(256)
> >  data += new
>
> >  That works well in most cases. But it's obviously error-prone. What if
> >  the client sent *exactly* two hundred and fifty six bytes? It would
> >  keep waiting for data inside the loop. Is there really a better and
> >  standard way, or is this as best as it gets?
>
> What you are missing is that if the recv ever returns no bytes at all
> then the other end has closed the connection.  So something like this
> is the correct thing to write :-
>
>   data = ""
>   while True:
>   new = client.recv(256)
>   if not new:
>   break
>   data += new
>
> From the man page for recv
>
>   RETURN VALUE
>
>These calls return the number of bytes received, or -1 if an
>error occurred.  The return value will be 0 when the peer has
>performed an orderly shutdown.
>
> In the -1 case python will raise a socket.error.
>
> --
> Nick Craig-Wood <[EMAIL PROTECTED]> --http://www.craig-wood.com/nick

But as I said in my first post, it's simple when you know the amount
of data that you're going to receive, or when you'll receive data
until the remote peer closes the connection. But what about receiving
a message with undetermined length in a connection that you don't want
to close? I already figured it out: in the case of an HTTP server/
client (which is what I'm doing), you have to look for an empty line
in the message, which signals the end of the message headers. As for
the body, you have to look at the Content-Length header, or, if the
message body contains the "chunked" transfer-coding, you have to
dynamically decode the encoding. There are other cases but those are
the most influent.

BTW, has anybody used sockets as file-like objects
(client.makefile())? Is it more secure? More efficient?

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


Re: API's and hardware communication. Newbie

2008-04-28 Thread Grant Edwards
On 2008-04-26, Grayham <[EMAIL PROTECTED]> wrote:
> Hi all
>
> I am new to this group so 'Hello All'
>
> I have a PC which is running linux and in it have installed a digital
> satellite card. I would like to write some software to access the card,
> tune it and bring back video. Basically a home brew DVB-s application.
>
> Being a non/new programmer (apart from some basic too many years ago) I
> decided to teach my self Python as from what i have read it's an easy and
> powerfull language to learn. I have been at it a few weeks and am getting
> on OK and finding it reasonably OK to pick up.
>
> The problem is i can find little to no information on programming for DVB
> cards or on how to access the Linux tv API in Python but I can find lots of
> information in C. This is making me think should i bother with Python and
> just learn C even though this will probably take a lot longer.

There are a couple of ways you can handle the problem:

 * You can use the ctypes modules to make C library calls. At
   first it seems a bit complicated, but it's really quite easy
   to use.  http://docs.python.org/lib/module-ctypes.html

 * You can write a C wrapper for the library so that it can be
   accessed as a Python module.  That's going to require a bit
   more C knowlege than the ctypes approach , but it's not as
   difficult as it looks.  http://www.python.org/doc/ext/intro.html

> Can some one help me or point me at a resource somewhere or
> would it be best to just learn C instead.  
>
> I am aware this is a complicated little project for someone
> just starting out but it will be a multifaceted program with
> loads of interesting classes, functions and loops and i don't
> have to start with the really difficult stuff first. I just
> want to know if it's possible under python to access the DVB
> card and if so how?


Freevo is a DVR system written in Python, so that might be a
good place to look: http://doc.freevo.org/

-- 
Grant Edwards   grante Yow! I guess you guys got
  at   BIG MUSCLES from doing too
   visi.commuch STUDYING!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Receive data from socket stream

2008-04-28 Thread Hrvoje Niksic
Nick Craig-Wood <[EMAIL PROTECTED]> writes:

>>  Note that appending to a string is almost never a good idea, since it
>>  can result in quadratic allocation.
>
> My aim was clear exposition rather than the ultimate performance!

That would normally be fine.  My post wasn't supposed to pick
performance nits, but to point out potentially quadratic behavior.

> Anyway str += was optimised in python 2.4 or 2.5 (forget which) wasn't
> it?

That optimization works only in certain cases, when working with
uninterned strings with a reference count of 1, and then only when the
strings are in stored local variables, rather than in global vars or
in slots.  And then, it only works in CPython, not in other
implementations.  The optimization works by "cheating" -- breaking the
immutable string abstraction in the specific cases in which it is
provably safe to do so.
http://utcc.utoronto.ca/~cks/space/blog/python/ExaminingStringConcatOpt
examines it in some detail.

Guido was reluctant to accept the patch that implements the
optimization because he thought it would "change the way people write
code", a sentiment expressed in
http://mail.python.org/pipermail/python-dev/2004-August/046702.html
This discussion shows that he was quite right in retrospect.  (I'm not
saying that the optimization is a bad thing, just that it is changing
the "recommended" way of writing Python in a way that other
implementations cannot follow.)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Retrieving int from hex in a file.

2008-04-28 Thread Grant Edwards
On 2008-04-28, Filipe Teixeira <[EMAIL PROTECTED]> wrote:
> Hi.
>
> I have to open a binary file from an old computer and recover the
> information stored (or at least try to). I use:
>
> f=open('file.bin','rb')
> a=f.read()
> f.close()
>
> a in now a string full of hex representations in the form:
>
> a[6]='\x14'
> a[7]='\x20'

a is now a string of binary data.  It doesn't contain a "hex
representation" of anything.  Hex is a way of printing stuff on
paper or on a screen.  Python doesn't store anything in hex.

> I would like to convert these hex representations to int,

That's your mistake: you don't have hex data. Nothing is being
stored in hex in your example.

> but this (the most obvious way) doesn't seem to be working
>
 q=a[6]
 q
> '\x14'
 int(q,16)

That converts a hex string into an integer, you've not got a
hex string.  You have a string containing binary data.

"4A4B4C" is a hex string.  It's 6 bytes long and contains the
ASCII characters '4' 'A' '4' 'B' '4' 'C'.

"\x4a\x4b\4c" is just a three-byte long chunk of binary data.
It was _typed_ in hex, but it's stored in binary not in hex.
It's identical to "JKL".

> Traceback (most recent call last):
>   File "", line 1, in ?
> ValueError: invalid literal for int():

>
> How can I do this?

You can use the struct module, or you can do it explicitly like
this:

>>> a = 'abcdef\x12\x34qwer'
>>> n = (ord(a[6])<<8) | ord(a[7])
>>> n
4660
>>> hex(n)
'0x1234'
>>> 

-- 
Grant Edwards   grante Yow! When you get your
  at   PH.D. will you get able to
   visi.comwork at BURGER KING?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Question regarding Queue object

2008-04-28 Thread [EMAIL PROTECTED]
I've never used it myself but you may find candygram interesting;
http://candygram.sourceforge.net, which AFAIK implements Erlang-style
message queues in Python.
--
http://mail.python.org/mailman/listinfo/python-list


Wing IDE 3.0.5 released

2008-04-28 Thread Wingware

Hi,

We're happy to announce version 3.0.5 of Wing IDE, an integrated development
environment for the Python programming language. It is available from:

http://wingware.com/downloads

Version 3.0.5 is a bug fix release that adds many vi mode improvements,
improves stability, and fixes other usability bugs.

See the change log at http://wingware.com/pub/wingide/3.0.5/CHANGELOG.txt
for details.

It is a free upgrade for all Wing 3.0 users.

*About Wing IDE*

Wing IDE is an integrated development environment for the Python programming
language.  It provides powerful debugging, editing, code intelligence,
testing, and search capabilities that reduce development and debugging
time, cut down on coding errors, and make it easier to understand
and navigate Python code.

New features added in Wing 3.0 include:

* Multi-threaded debugger
* Debug value tooltips in editor, debug probe, and interactive shell
* Autocompletion and call tips in debug probe and interactive shell
* Automatically updating project directories
* Testing tool, currently supporting unittest derived tests (*)
* OS Commands tool for executing and interacting with external commands (*)
* Rewritten indentation analysis and conversion (*)
* Introduction of Wing IDE 101, a free edition for beginning programmers
* Available as a .deb package for Debian and Ubuntu
* Support for Stackless Python
* Support for 64 bit Python on Windows and Linux

(*)'d items are available in Wing IDE Professional only.

System requirements are Windows 2000 or later, OS X 10.3.9 or later for PPC or
Intel (requires X11 Server), or a recent Linux system (either 32 or 64 bit).

*Purchasing and Upgrading*

Wing IDE Professional & Wing IDE Personal are commercial software and require
a license  to run.  To upgrade a 2.x license or purchase a new 3.x license:

Upgradehttps://wingware.com/store/upgrade
Purchase   https://wingware.com/store/purchase

Any 2.x license sold after May 2nd 2006 is free to upgrade; others cost
1/2 the normal price to upgrade.

--

The Wingware Team
Wingware | Python IDE
Advancing Software Development

www.wingware.com

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


Wing IDE 3.1beta3 released

2008-04-28 Thread Wingware

Hi,

Wingware has released version 3.1 beta3 of Wing IDE, an integrated development
environment for the Python programming language. It is available from:

http://wingware.com/wingide/beta

This release includes the following changes:

* How-To and improvements for using Wing IDE with Google App Engine
* Scan for sys.path changes in main debug file (e.g. for Zope buildouts)
* Preference to auto-strip trailing white space on save
* Many vi mode improvements
* Testing tool enhancements, including better support for test names
  that are not method names
* Sped up stepping in the debugger
* Set encoding for stdin/out/err in debug processes for better handling
  of non-ascii input and output
* Fixed problems with debugging stackless tasklets
* Python Shell allows spawned threads to run, rather than stopping all threads
* Improved support for debugging code invoked by execfile()
* Better autocompletion support for an x defined by 'import x.y.z'
* More bug fixes, including also all those found in Wing 3.0.5

Please see the change log for a detailed list of changes:

http://wingware.com/pub/wingide/prerelease/3.1.0-b3/CHANGELOG.txt

Version 3.1 introduces a number of new features and includes bug fixes not
found in the 3.0 series, as follows:

* Files within .zip or .egg files can be displayed in the editor
* Support for pkg_resources based namespace packages
* Support for doctest and nose unit test frameworks (**)
* Updated code analysis support for Python 2.5 constructs
* Improved support for tasklets in Stackless Python
* In-line argument entry of code templates/snippets (tab and back tab to
  traverse fields; arrow keys to change template indent, Esc to exit data
  entry mode) (**)
* Include templates by name in autocompleter (**)
* Simple word list driven auto-completion when working in non-Python files (*)
* Open from Project for quick selection of files from the Project by
  typing a fragment (*)
* Find Symbol for quick Goto-Definition for symbols in the current Python
  file by typing a fragment (*)
* Show gi_running and gi_frame in Stack Data for generators
* Sort menus and lists using more natural sorting so x2.py comes before x10.py
* Preference to strip trailing white space on save
* Scan for straightforward sys.path changes in main debug file
* How-To and improvements for using Wing IDE with Google App Engine
* Many bug fixes not in Wing 3.0.x

(*)'d items are available in Wing IDE Personal or Professional only.
(**)'d items are available in Wing IDE Professional only.

*About Wing IDE*

Wing IDE is an integrated development environment for the Python programming
language.  It provides powerful debugging, editing, code intelligence,
testing, and search capabilities that reduce development and debugging
time, cut down on coding errors, and make it easier to understand
and navigate Python code.

Wing IDE is available in three product levels:  Wing IDE Professional is
the full-featured Python IDE, Wing IDE Personal offers a reduced feature
set at a low price, and Wing IDE 101 is a free scaled back version designed
for teaching entry level programming courses with Python.

System requirements are Windows 2000 or later, OS X 10.3.9 or later for PPC or
Intel (requires X11 Server), or a recent Linux system (either 32 or 64 bit).

*Purchasing & Upgrading*

Wing IDE Professional & Wing IDE Personal are commercial software and require
a license to run. Wing 3.1 is a free upgrade for all Wing IDE 3.0 users. Any
2.x license sold after May 2nd 2006 is free to upgrade; others cost 1/2 the
normal price to upgrade.

To upgrade a 2.x license or purchase a new 3.x license:

Upgradehttps://wingware.com/store/upgrade
Purchase   https://wingware.com/store/purchase

--

The Wingware Team
Wingware | Python IDE
Advancing Software Development

www.wingware.com

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


Re: Regular Expression - Matching Multiples of 3 Characters exactly.

2008-04-28 Thread Helmut Jarausch

blaine wrote:

Hey everyone,
  For the regular expression gurus...

I'm trying to write a string matching algorithm for genomic
sequences.  I'm pulling out Genes from a large genomic pattern, with
certain start and stop codons on either side.  This is simple
enough... for example:

start = AUG stop=AGG
BBAUGWWAGGBB

So I obviously want to pull out AUGWWAGG (and all other matches).
This works great with my current regular expression.

The problem, however, is that codons come in sets of 3 bases.  So
there are actually three different 'frames' I could be using.  For
example:
ABCDEFGHIJ
I could have ABC DEF GHI or BCD EFG HIJ or CDE FGH IJx etc.

So finally, my question.  How can I represent this in a regular
expression? :)  This is what I'd like to do:
(Find all groups of any three characters) (Find a start codon) (find
any other codons) (Find an end codon)

Is this possible? It seems that I'd want to do something like this: (\w
\w\w)+(AUG)(\s)(AGG)(\s)* - where \w\w\w matches EXACTLY all sets of
three non-whitespace characters, followed by AUG \s AGG, and then
anything else.  I hope I am making sense.  Obviously, however, this
will make sure that ANY set of three characters exist before a start
codon.  Is there a way to match exactly, to say something like 'Find
all sets of three, then AUG and AGG, etc.'.  This way, I could scan
for genes, remove the first letter, scan for more genes, remove the
first letter again, and scan for more genes.  This would
hypothetically yield different genes, since the frame would be
shifted.



As an alternative - if you do need speed - have a look at

http://www.egenix.com/products/python/mxBase/mxTextTools/


Helmut.
--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
--
http://mail.python.org/mailman/listinfo/python-list


Re: Receive data from socket stream

2008-04-28 Thread Jean-Paul Calderone

On Mon, 28 Apr 2008 07:26:13 -0700 (PDT), [EMAIL PROTECTED] wrote:

[snip]


BTW, has anybody used sockets as file-like objects
(client.makefile())? Is it more secure? More efficient?


It's not more (or less) secure.  In certain cases, it's significantly less
efficient.  It's for simplicity of programming, not much else.

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


Re: class or class-instance ?

2008-04-28 Thread Stef Mientki




There is a

isclass

in the module inspect.

Diez


thanks Diez,
that's exactly what I was looking for.

cheers,
Stef

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


Given a string - execute a function by the same name

2008-04-28 Thread python
I'm parsing a simple file and given a line's keyword, would like to call
the equivalently named function.

There are 3 ways I can think to do this (other than a long if/elif
construct):

1. eval() 

2. Convert my functions to methods and use getattr( myClass, "method" )

3. Place all my functions in dictionary and lookup the function to be
called

Any suggestions on the "best" way to do this?

Thank you,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list


Re: Given a string - execute a function by the same name

2008-04-28 Thread Robert Bossy

[EMAIL PROTECTED] wrote:

I'm parsing a simple file and given a line's keyword, would like to call
the equivalently named function.

There are 3 ways I can think to do this (other than a long if/elif
construct):

1. eval() 


2. Convert my functions to methods and use getattr( myClass, "method" )

3. Place all my functions in dictionary and lookup the function to be
called

Any suggestions on the "best" way to do this?
(3) is the securest way since the input file cannot induce unexpected 
behaviour.
With this respect (1) is a folly and (2) is a good compromise since you 
still can write a condition before passing "method" to getattr(). Btw, 
if you look into the guts, you'll realize that (2) is nearly the same as 
(3)...


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


Re: Tremendous slowdown due to garbage collection

2008-04-28 Thread Dieter Maurer
"Martin v. Löwis" wrote at 2008-4-27 19:33 +0200:
>> Martin said it but nevertheless it might not be true.
>> 
>> We observed similar very bad behaviour -- in a Web application server.
>> Apparently, the standard behaviour is far from optimal when the
>> system contains a large number of objects and occationally, large
>> numbers of objects are created in a short time.
>> We have seen such behaviour during parsing of larger XML documents, for
>> example (in our Web application).
>
>I don't want to claim that the *algorithm* works for all typically
>applications well. I just claim that the *parameters* of it are fine.
>The OP originally proposed to change the parameters, making garbage
>collection run less frequently. This would a) have bad consequences
>in terms of memory consumption on programs that do have allocation
>spikes, and b) have no effect on the asymptotic complexity of the
>algorithm in the case discussed.

In our case, it helped to change the parameters:

  As usual in Python, in our case cyclic garbage is very rare.
  On the other hand, we have large caches with lots of objects,
  i.e. a large number of long living objects.
  Each generation 2 garbage collection visits the complete
  object set. Thus, if it is called too often, matters can
  deteriorate drastically.

  In our case, the main problem has not been the runtime
  but that during GC the GIL is hold (understandably).
  This meant that we had every few minutes a scheduling
  distortion in the order of 10 to 20 s (the time of
  our generation 2 gc).

We changed the parameters to let generation 2 GC happen
at about 1/1000 of its former frequency.


I do not argue that Python's default GC parameters must change -- only
that applications with lots of objects may want to consider a
reconfiguration.



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


Re: Given a string - execute a function by the same name

2008-04-28 Thread marek . rocki
One solution may be to use globals():

>>> globals()['foo']()

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


Re: Given a string - execute a function by the same name

2008-04-28 Thread Matimus
On Apr 28, 9:33 am, [EMAIL PROTECTED] wrote:
> I'm parsing a simple file and given a line's keyword, would like to call
> the equivalently named function.
>
> There are 3 ways I can think to do this (other than a long if/elif
> construct):
>
> 1. eval()
>
> 2. Convert my functions to methods and use getattr( myClass, "method" )
>
> 3. Place all my functions in dictionary and lookup the function to be
> called
>
> Any suggestions on the "best" way to do this?
>
> Thank you,
> Malcolm

You can always import yourself and use getattr on that module.

in file "mytest.py":

def foo():
print "foo called"

def call_by_name(name, *args, **kwargs):
import mytest

f = getattr(mytest, "foo")
f(*args,  **kwargs)

if __name__ == "__main__":
call_by_name('foo')



Alternatively you can import __main__ if you are always going to be
running directly from that file.

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


bisect intersection

2008-04-28 Thread Robert Bossy

Hi,

I stumbled into a sorted list intersection algorithm by Baeza-Yates 
which I found quite elegant. For the lucky enough to have a springerlink 
access, here's the citation:

http://dblp.uni-trier.de/rec/bibtex/conf/cpm/Baeza-Yates04

I implemented this algorithm in python and I thought I could share it. 
I've done some tests and, of course, it can't compete against dict/set 
intersection, but it will perform pretty well. Computing union and 
differences are left as an exercise...


from bisect import bisect_left

def bisect_intersect(L1, L2):
   inter = []
   def rec(lo1, hi1, lo2, hi2):
   if hi1 <= lo1: return
   if hi2 <= lo2: return
   mid1 = (lo1 + hi1) // 2
   x1 = L1[mid1]
   mid2 = bisect_left(L2, x1, lo=lo2, hi=hi2)
   rec(lo1, mid1, lo2, mid2)
   if mid2 < hi2 and x1 == L2[mid2]:
   inter.append(x1)
   rec(mid1+1, hi1, mid2+1, hi2)
   else:
   rec(mid1+1, hi1, mid2, hi2)
   rec(0, len(L1), 0, len(L2))
   inter.sort()
   return inter


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


Re: Given a string - execute a function by the same name

2008-04-28 Thread Gary Herron

[EMAIL PROTECTED] wrote:

I'm parsing a simple file and given a line's keyword, would like to call
the equivalently named function.

There are 3 ways I can think to do this (other than a long if/elif
construct):

1. eval() 


2. Convert my functions to methods and use getattr( myClass, "method" )

3. Place all my functions in dictionary and lookup the function to be
called

Any suggestions on the "best" way to do this?

Thank you,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
  


You are on the right track with (2), but you need not do any conversion. 
 All objects that have attributes (and a function is an attribute) can 
be looked up with getattr.


For instance, from a module (function getcwd from modules os):

>>> import os
>>> getattr(os,'getcwd')

>>> getattr(os,'getcwd')()
'/home/gherron'


You can use getattr with objects, classes, modules, and probably more.

Gary Herron



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


Re: Given a string - execute a function by the same name

2008-04-28 Thread Arnaud Delobelle
[EMAIL PROTECTED] writes:

> I'm parsing a simple file and given a line's keyword, would like to call
> the equivalently named function.
>
> There are 3 ways I can think to do this (other than a long if/elif
> construct):
>
> 1. eval() 
>
> 2. Convert my functions to methods and use getattr( myClass, "method" )
>
> 3. Place all my functions in dictionary and lookup the function to be
> called

4. Put all my functions in a module and use getattr(module, 'function')

-- 
Arnaud



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


Re: Remove multiple inheritance in Python 3000

2008-04-28 Thread Dieter Maurer
Nick Stinemates <[EMAIL PROTECTED]> writes on Thu, 24 Apr 2008 08:26:57 -0700:
> On Tue, Apr 22, 2008 at 04:07:01AM -0700, GD wrote:
> > Please remove ability to multiple inheritance in Python 3000.

I hope your request will not be followed.

> > Multiple inheritance is bad for design, rarely used and contains many
> > problems for usual users.

Multiple inheritance is very productive by supporting mixin classes.
I use it extensively and get clean code quickly developped.

I hate Java because it does not support multiple inheritance
and forces me to write lots of tedious error prone delegations
to work around this limitation.

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


Re: Regular Expression - Matching Multiples of 3 Characters exactly.

2008-04-28 Thread blaine
On Apr 28, 6:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> blaine <[EMAIL PROTECTED]> wrote:
> >  I'm trying to write a string matching algorithm for genomic
> >  sequences.  I'm pulling out Genes from a large genomic pattern, with
> >  certain start and stop codons on either side.  This is simple
> >  enough... for example:
>
> >  start = AUG stop=AGG
> >  BBAUGWWAGGBB
>
> >  So I obviously want to pull out AUGWWAGG (and all other matches).
> >  This works great with my current regular expression.
>
> >  The problem, however, is that codons come in sets of 3 bases.  So
> >  there are actually three different 'frames' I could be using.  For
> >  example:
> >  ABCDEFGHIJ
> >  I could have ABC DEF GHI or BCD EFG HIJ or CDE FGH IJx etc.
>
> >  So finally, my question.  How can I represent this in a regular
> >  expression? :)  This is what I'd like to do:
> >  (Find all groups of any three characters) (Find a start codon) (find
> >  any other codons) (Find an end codon)
>
> >  Is this possible? It seems that I'd want to do something like this: (\w
> >  \w\w)+(AUG)(\s)(AGG)(\s)* - where \w\w\w matches EXACTLY all sets of
> >  three non-whitespace characters, followed by AUG \s AGG, and then
> >  anything else.
>
> I'm not sure what the \s are doing in there - there doesn't appear to
> be any whitespace in your examples.
>
> >  I hope I am making sense.  Obviously, however, this will make sure
> >  that ANY set of three characters exist before a start codon.  Is
> >  there a way to match exactly, to say something like 'Find all sets
> >  of three, then AUG and AGG, etc.'.
>
> I think you want
>
> ^(\w\w\w)*(AUG)((\w\w\w)*?)(AGG)
>
> which will match up 0 or more triples, match AUG match 0 or more triples
> then AGG.  The ? makes it a minimum match otherwise you'll match more
> than you expect if there are two AUG...AGG sequences in a given genome.
>
>   >>> import re
>   >>> m=re.compile(r"^(\w\w\w)*(AUG)((\w\w\w)*?)(AGG)")
>   >>> m.search("BBAUGWWAGGBB").groups()
>   ('BBB', 'AUG', 'WW', 'WWW', 'AGG')
>   >>> m.search("BBBQBBBAUGWWAGGBB")
>   >>> m.search("BBBQQBBBAUGWWAGGBB")
>   >>> m.search("BBBQQBBQBAUGWWAGGBB")
>   <_sre.SRE_Match object at 0xb7de33e0>
>   >>> m.search("BBBQQBBQBAUGWWAGGBB").groups()
>   ('BQB', 'AUG', 'WW', 'WWW', 'AGG')
>   >>> m.search("BBBQQBBQBAUGWQWAGGBB")
>   >>> m.search("BBBQQBBQBAUGQWWAGGBB")
>   >>> m.search("BBBQQBBQBAUGWWQWWQWWAGGBB")
>   >>> m.search("BBBQQBBQBAUGWWQWAWQWWAGGBB")
>   <_sre.SRE_Match object at 0xb7de33e0>
>   >>> m.search("BBBQQBBQBAUGWWQWAWQWWAGGBB").groups()
>   ('BQB', 'AUG', 'WWQWAWQWW', 'QWW', 'AGG')
>   >>>
>
> >  This way, I could scan for genes, remove the first letter, scan for
> >  more genes, remove the first letter again, and scan for more genes.
> >  This would hypothetically yield different genes, since the frame
> >  would be shifted.
>
> Of you could just unconstrain the first match and it will do them all
> at once :-
>
> (AUG)((\w\w\w)*?)(AGG)
>
> You could run this with re.findall, but beware that this will only
> return non-overlapping matches which may not be what you want.
>
> I'm not sure re's are the best tool for the job, but they should give
> you a quick idea of what the answers might be.
>
> --
> Nick Craig-Wood <[EMAIL PROTECTED]> --http://www.craig-wood.com/nick

Thank you! Your suggestion was overly helpful.

Also thank you for the package suggestions.  BioPython is on my plate
to check out, but I needed a kind of quick fix for this one.  The
documentation for biopython seems pretty thick - I'm not a biologist
so I'm not even sure what kind of packages I'm even looking for.

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


descriptor & docstring

2008-04-28 Thread cyril giraudon
Hello,

I try to use python descriptors to define attributes with default
value (the code is reported below).
But apparently, it breaks the docstring mechanism.

help(Basis) shows the right help but help(Rectangle) shows only two
lines :
"
Help on class Rectangle in module basis2:

Rectangle = 
"
If the Rectangle.length attribute is removed, the help is OK.

Secondly, the __doc__ attribute of a PhysicalValue instance doesn't
seem to be read.

I don't understand.

Any idea ?

Thanks a lot

Cyril.



# A descriptor class with default value handling
class PhysicalValue(object):
  """
  A physical value descriptor
  """
  def __init__(self, default_value):
self.default_value = default_value
self.__doc__ = "Hello from Physical Value"

  def __get__(self, obj, type=None):
if obj.__dict__.has_key(self.key):
  return getattr(obj, self.key)
else:
  return self.default_value

  def __set__(self, obj, value):
if value is DefaultValue:
  setattr(obj, self.key, self.default_value)
else:
  setattr(obj, self.key, value)

# A meta class which adds instance attributes
# If hasattr(cls, "attr") then add "_attr" attribute.
class MyMetaClass(type):
  def __init__(cls, name, bases, dct):
super(MyMetaClass, cls).__init__(name, bases, dct)
print "Add property to ", name
def init(self):
  pvl = [item for item in cls.__dict__.items()
 if isinstance(item[1], PhysicalValue)]
  for pv in pvl:
print "Add _%s property to %s" % (pv[0], name)
cls.__dict__[pv[0]].key = "_" + pv[0]
setattr(self, "_" + pv[0], getattr(self, pv[0]))
cls.__init__ = init

# A basis class
class Basis(object):
  """
  Tempest basis class
  """
  __metaclass__ = MyMetaClass

# A concrete class
class Rectangle(Basis):
  """
  A beautiful Rectangle
  """
  length = PhysicalValue(12.)
--
http://mail.python.org/mailman/listinfo/python-list


Automating IE 6.0

2008-04-28 Thread Michael Harris
I tried to use the sample code to print a webpage via ie and I get the
following error:

 

Traceback (most recent call last):

  File
"C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py"
, line 310, in RunScript

exec codeObject in __main__.__dict__

  File "C:\ie.py", line 14, in 

ie.ExecWB(win32com.client.constants.OLECMDID_PRINT,
win32com.client.constants.OLECMDEXECOPT_DONTPROMPTUSER)

NameError: name 'win32com' is not defined

 

I have the win32com module installed and I clicked on makepy.py and
selected Microsoft Internet Controls (1.1).  The code was:
 
from win32com.client import Dispatch
from time import sleep
ie = Dispatch("InternetExplorer.Application")
ie.Visible = 1
ie.Navigate("http://www.cnn.com";  )
if ie.Busy:
 sleep(2)
# print the current IE document without prompting the user for the
printerdialog
ie.ExecWB(win32com.client.constants.OLECMDID_PRINT,win32com.client.const
ants
.OLECMDEXECOPT_DONTPROMPTUSER)
 

Why am I getting this error?

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

xcode able to run script?

2008-04-28 Thread Alex Pavluck
Does anyone know if it is possible to test your scripts from within
the xcode editor?  I am currently using Uilipad on windows and there
is a sub window that lets you view your output when you launch the
script from within the ide.  hopefully this makes sense.

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


How to unget a line when reading from a file/stream iterator/generator?

2008-04-28 Thread python
Is there an elegant way to unget a line when reading from a file/stream
iterator/generator?

By "unget" I mean a way to push back a line into the source stream and
backtrack the iterator/generator one step?

The only alternative I can see is to put my line reading in a while-True
loop (vs. a for-loop) that manually calls my file/stream
iterator/generator's .next() method while manually handling the
StopIteration exception. Doesn't sound too elegant.

Is there a Pythonic design pattern/best practice that I can apply here?

Thank you,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list


list.reverse()

2008-04-28 Thread Mark Bryan Yu
This set of codes works:

>>> x = range(5)
>>> x.reverse()
>>> x
[4, 3, 2, 1, 0]

But this doesn't:

>>> x = range(5).reverse()
>>> print x
None

Please explain this behavior. range(5) returns a list from 0 to 4 and
reverse just reverses the items on the list that is returned by
range(5). Why is x None (null)?
--
http://mail.python.org/mailman/listinfo/python-list


cytpes **int

2008-04-28 Thread VernM
I am using ctypes to wrap a set of functions in a DLL. It has been
going very well, and I am very impressed with ctypes. I want to call a
c function with a signature of: void func(int **cube), where the array
if ints in cube is modified by func. I want to setup cube with int
values, and access them after the call to func. I unerstand how to
setup the ctypes array, but how do I pass **cube to the function, and
how do I access the results?
--
http://mail.python.org/mailman/listinfo/python-list


Python 2.6, building SDL for Pygame

2008-04-28 Thread L. Lindstrom
I build the Pygame releases for Windows. Pygame wraps the Simple 
Directmedia Layer (SDL) C library. I am doing preliminary research into 
porting Pygame to Python 2.6. For Pythons 2.4 and 2.5 the Pygame 
extension modules are built with MinGW. They link cleanly against 
msvcr71.dll. A custom SDL, also linked to msvcr71.dll, is used. It is 
built with Msys/MinGW using the configure/make tool chain.


For Python 2.6 I expect Visual Studio 2008 will be required to build the 
Pygame extension modules. However, I am at a loss as to how to build SDL 
so it also links against msvcr90.dll. Windows' side=by-side assemblies 
get in the way. The Msys build process fails. The first test program 
configure compiles and runs refuses to load msvcr90.dll. It raises an 
R6034 error. How important is it that a C library uses the same C 
run-time as the Python extension module that wraps it? If it is not 
critical then the SDL library will just use msvcrt.dll for Pygame and 
Python 2.6.



--
Lenard Lindstrom
"[EMAIL PROTECTED]" % ('len-l', 'telus', 'net')
--
http://mail.python.org/mailman/listinfo/python-list


Re: Tremendous slowdown due to garbage collection

2008-04-28 Thread John Nagle

Dieter Maurer wrote:

Christian Heimes <[EMAIL PROTECTED]> writes on Sat, 12 Apr 2008 18:47:32 +0200:

[EMAIL PROTECTED] schrieb:

which made me suggest to use these as defaults, but then



We observed similar very bad behaviour -- in a Web application server.
Apparently, the standard behaviour is far from optimal when the
system contains a large number of objects and occationally, large
numbers of objects are created in a short time.
We have seen such behaviour during parsing of larger XML documents, for
example (in our Web application).


   Our solution to that was to modify BeautifulSoup to use weak pointers.
All the pointers towards the root and towards previous parts of the
document are "weak".  As a result, reference counting alone is sufficient
to manage the tree.  We still keep GC enabled, but it doesn't find much
to collect.

John Nagle
SiteTruth
--
http://mail.python.org/mailman/listinfo/python-list


Re: list.reverse()

2008-04-28 Thread Gary Herron

Mark Bryan Yu wrote:

This set of codes works:

  

x = range(5)
x.reverse()
x


[4, 3, 2, 1, 0]

But this doesn't:

  

x = range(5).reverse()
print x


None

Please explain this behavior. range(5) returns a list from 0 to 4 and
reverse just reverses the items on the list that is returned by
range(5). Why is x None (null)?
--
http://mail.python.org/mailman/listinfo/python-list
  
Because you are misusing reverse.  It is an operation on a list that 
reverses the list in place.   It is meant to be used only in the 
situation where you already have the list and want to reorder it:


x =  list ...
x.reverse() # reorders, but returns nothing
... now use x ...


You might look at the builtin reversed(list): 
http://www.python.org/doc/faq/programming/#how-do-i-iterate-over-a-sequence-in-reverse-order


Gary Herron



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


Re: Cookie Confusion - How to Set a Cookie

2008-04-28 Thread Aaron Watters
On Apr 28, 9:42 am, [EMAIL PROTECTED] wrote:
> I see the cookie in my HTTP header
> but do not get anything in the cookie text file.  I'm working on
> linux.
>
> print "Content-type: text/html"
> cookie = Cookie.SimpleCookie()
> cookie['Test'] = 'abc'
> print cookie
> print
>
> Are there rules about where in the header the set cookie line should
> be?

Hi Christian.  I think the cookie can go anywhere in
the header, but I usually put it before the content-type.
If you want to store the cookie to a file,
or even better, to a database of some sort, you have to
do it yourself, the Cookie module doesn't do it for you,
I hope.

  # store cookie to /tmp/cookie.txt
  file("/tmp/cookie.txt","w").write(str(cookie))

For parsing cookies, I stole and modified this from
the Django source (for use in a cgi script):

===
from Cookie import SimpleCookie
import os

# stolen and modified from Django
def parse_cookie(cookie=None, environ=None):
if cookie is None:
if environ is None:
environ = os.environ
cookie = environ.get('HTTP_COOKIE', '')
if cookie == '':
return {}
c = SimpleCookie()
c.load(cookie)
cookiedict = {}
for key in c.keys():
cookiedict[key] = c.get(key).value
return cookiedict

===
All the best.  -- Aaron Watters

===
http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=monster
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to unget a line when reading from a file/stream iterator/generator?

2008-04-28 Thread Arnaud Delobelle
[EMAIL PROTECTED] writes:

> Is there an elegant way to unget a line when reading from a file/stream
> iterator/generator?
>
> By "unget" I mean a way to push back a line into the source stream and
> backtrack the iterator/generator one step?
>
> The only alternative I can see is to put my line reading in a while-True
> loop (vs. a for-loop) that manually calls my file/stream
> iterator/generator's .next() method while manually handling the
> StopIteration exception. Doesn't sound too elegant.
>
> Is there a Pythonic design pattern/best practice that I can apply here?

It seems to me that the answer depends on what you do with your
unget'ed line (i.e. there is no included general purpose 'unget'
replacement).  If you provided some (pseudo-)code, someone might be
able to find an elegant way to perform the task without the need to
push back an element into an iterator.

As a last resort, you could always wrap your iterator into a some
'Backtrackable' class.

class Backtrackable(object):
  def __init__(self, iterator):
  self.iterator = iter(iterator)
  self._back = False
  self._last = None
  def __iter__(self):
  return self
  def next(self):
  if self._back:
  next = self._last
  else:
  self._last = next = self.iterator.next()
  self._back = False
  return next
  def back(self):
  if self._back:
  raise('Cannot backtrack twice')
  self._back = True

>>> b = Backtrackable([1,2,3])
>>> b.next()
1
>>> b.next()
2
>>> b.back()
>>> b.next()
2
>>> b.next()
3
--
http://mail.python.org/mailman/listinfo/python-list


Re: list.reverse()

2008-04-28 Thread Arnaud Delobelle
Mark Bryan Yu <[EMAIL PROTECTED]> writes:

> This set of codes works:
>
 x = range(5)
 x.reverse()
 x
> [4, 3, 2, 1, 0]
>
> But this doesn't:
>
 x = range(5).reverse()
 print x
> None
>
> Please explain this behavior. range(5) returns a list from 0 to 4 and
> reverse just reverses the items on the list that is returned by
> range(5). Why is x None (null)?

have you tried typing help(list.reverse) at the interactive prompt?

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


Re: So you think PythonCard is old? Here's new wine in an old bottle.

2008-04-28 Thread Fred Pacquier
John Henry <[EMAIL PROTECTED]> said :

> The performance of Qooxdoo is quite amazing - for a Javascript based
> web application.  Don't know about cell-phones though.  You can try
> their showcase web site I cited earlier.

Just for the record, Nokia Internet tablets (770, N800, N810) are the only 
things made by Nokia that are not cell-phones... They're ARM machines with 
a 800x480 4" screen, Wifi, Bluetooth, and Linux. And Python, pyGTK and 
Pygame. Probably pyQt next as they just bought Trolltech. But no wxPython.

I was not speaking of running just the client part in the device's browser, 
either - but the full Monty (haha) with the web server and the application 
engine, python, middleware and all. I'm doing it right now using a full-
blown framework (web2py), so it's not unreasonable. There's no Ajax in 
there though, so I'm wondering what kind of impact those tools you mention 
would have, server side.
 
> Yes, who would have throught we don't have to give up on Pythoncard?
 
Proof of superior vision, architecture and design, all that time ago...
--
http://mail.python.org/mailman/listinfo/python-list


Newbie Help - Alarms

2008-04-28 Thread Paul Jefferson
Hi,
I'm new to this having previously done some programming in Game Maker.
In Game Maker there was a function (Alarm) that lets you run a block of code
run every x seconds without freezing up the whole program waiting for it.
Is there an equavalant for this built in Python beacuse I can't find it?
Thanks for any help,
Paul
--
http://mail.python.org/mailman/listinfo/python-list

Simple unicode-safe version of str(exception)?

2008-04-28 Thread Russell E. Owen
I have code like this:
except Exception, e:
   self.setState(self.Failed, str(e))
which fails if the exception contains a unicode argument.

I did, of course, try unicode(e) but that fails.

The following works, but seems rather messy:

except Exception, e:
errStr = ",".join([unicode(s) for s in f.args])
self.setState(self.Failed, errStr)

Is there a simpler solution that works in Python 2.3-2.5?

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


Re: So you think PythonCard is old? Here's new wine in an old bottle.

2008-04-28 Thread John Henry
On Apr 27, 12:23 pm, Fred Pacquier <[EMAIL PROTECTED]> wrote:
>
> Do keep us posted !
>
> TIA,
> fp

Check it out now.

Only one to be added is the Multicolumn List (table), and then menus.
The other widgets (Togglebutton, BitmapCanvas, Gauge, Notebook,
CodeEditor) will not be implemented initially.

http://test.powersystemadvisors.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Installed python 2.5 over 2.4 and lost installed packages

2008-04-28 Thread james
On Apr 27, 8:42 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote:
> On Apr 27, 8:15 am, [EMAIL PROTECTED] wrote:

> > I recently updated os x from python 2.4 to 2.5 (from python.org) and
> > in doing so I lost my old python path entries.

> > So what is the right thing to do in this situation?
> > Is cp'ing the files from one place to another safe or advisable?

> As long as the Python extensions or packages are pure ones, then
> copying them over shouldn't hurt anything. If you have some that have
> C/C++ links (such as PIL or pywin32), then you'll need to reinstall
> those manually.

I tried that and the C extensions burned me.  Syck (for YAML) and
mercurial (I think ... there were  at least 2 problems) posted
warnings or bailed out with errors.  Looks like I will delay until I
have the time and energy to chase all my dependencies.  Perhaps once
my server (Ubuntu) moves to 2.6 I'll update my Mac at the same time.

>From now on I am storing my install packages somewhere accessible
instead of deleting them once I'm done with them.  I wish I could
generate a manifest of installed packages to make upgrading easier.

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


Re: Simple unicode-safe version of str(exception)?

2008-04-28 Thread Bjoern Schliessmann
Russell E. Owen wrote:

> I have code like this:
> except Exception, e:
>self.setState(self.Failed, str(e))
> which fails if the exception contains a unicode argument.

Fails how?
 
> I did, of course, try unicode(e) but that fails.

Converting unicode to unicode doesn't help. Instead of just e, try
using e.encode("some-encoding") where some-encoding should be your
system's default encoding like utf-8 or iso8859-1.

Regards,


Björn

-- 
BOFH excuse #434:

Please state the nature of the technical emergency

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


Python-URL! - weekly Python news and links (Apr 28)

2008-04-28 Thread Gabriel Genellina
QOTW:  "Posting to comp.lang.python is pair programming with the entire
internet ;-)" - Nick Craig-Wood
http://groups.google.com/group/comp.lang.python/msg/6f13cfca8a92c1a2

"When it got to the point where managers were asking, 'Why didn't you use
the config check tool?', it was a done deal." - Roy Smith, on Python adoption
http://mail.python.org/pipermail/advocacy/2008-April/000575.html


Ideas to design a Python client/server application involving many
aynchronous queries and real-time display of data:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/5e46184e940886b9/

Explicit variable declaration for functions:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/6c4a508edd2fbe04/

An example showing the difference between inheritance and composition:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/44612866d4d2fedb/

Lists: item and slice assignment are confusing for a novice Python
programmer:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/d00b0c848a3003fc/

Converting xhtml to html isn't as trivial as one might expect:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/4bbbcecf89693a74/

Using the subprocess module with non-blocking pipes:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/a6dd7b98211bbd4c/

Calling Python from PHP

http://groups.google.com/group/comp.lang.python/browse_thread/thread/ffb9d476ee4cd523/

People worried about code breakage in Python 3.0 (continued from last week)

http://groups.google.com/group/comp.lang.python/browse_thread/thread/f07feff4f01be76f/

Python Advocacy: success stories

http://groups.google.com/group/comp.lang.python/browse_thread/thread/1bd91aca0c86c57c/



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.

Just beginning with Python?  This page is a great place to start:
http://wiki.python.org/moin/BeginnersGuide/Programmers

The Python Papers aims to publish "the efforts of Python enthusiats":
http://pythonpapers.org/
The Python Magazine is a technical monthly devoted to Python:
http://pythonmagazine.com

Readers have recommended the "Planet" sites:
http://planetpython.org
http://planet.python.org

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

http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce

Python411 indexes "podcasts ... to help people learn Python ..."
Updates appear more-than-weekly:
http://www.awaretek.com/python/index.html

Steve Bethard continues the marvelous tradition early borne by
Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim
Lesher 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/

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

Although unmaintained since 2002, the Cetus collection of Python
hyperlinks retains a few

Re: How to unget a line when reading from a file/stream iterator/generator?

2008-04-28 Thread George Sakkis
On Apr 28, 2:07 pm, [EMAIL PROTECTED] wrote:
> Is there an elegant way to unget a line when reading from a file/stream
> iterator/generator?
>
> By "unget" I mean a way to push back a line into the source stream and
> backtrack the iterator/generator one step?
>
> The only alternative I can see is to put my line reading in a while-True
> loop (vs. a for-loop) that manually calls my file/stream
> iterator/generator's .next() method while manually handling the
> StopIteration exception. Doesn't sound too elegant.
>
> Is there a Pythonic design pattern/best practice that I can apply here?
>
> Thank you,
> Malcolm

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502304

HTH,
George
--
http://mail.python.org/mailman/listinfo/python-list


Re: Little novice program written in Python

2008-04-28 Thread Rogério Brito

On 04/25/2008 01:09 AM, Dennis Lee Bieber wrote:

On Thu, 24 Apr 2008 21:31:15 -0300, Rogério Brito <[EMAIL PROTECTED]>
declaimed the following in comp.lang.python:

a = [i for i in range(0,n+1)]


Uhm... At least in 2.4 and earlier, range() returns a list... No
need for the list-comp in that era... range() also begins with 0


Thanks for the suggestion. As I stated in my original message, I'm only 
"side-learning" Python, and I naturally think in list-comprehensions (it is like 
a set in Mathematics and you've seen that my program is Mathematical in its nature).


This is exactly the kind of suggestion that I was looking for.


Thanks, Rogério.

--
Rogério Brito : [EMAIL PROTECTED],ime.usp}.br : GPG key 1024D/7C2CAEB8
http://www.ime.usp.br/~rbrito : http://meusite.mackenzie.com.br/rbrito
Projects: algorithms.berlios.de : lame.sf.net : vrms.alioth.debian.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: Little novice program written in Python

2008-04-28 Thread Rogério Brito

On 04/25/2008 01:30 AM, Steve Holden wrote:

Rogério Brito wrote:
I'm just getting my feet wet on Python and, just for starters, I'm 
coding some elementary number theory algorithms (yes, I know that most 
of them are already implemented as modules, but this is an exercise in 
learning the language idioms).
Your Python is actually pretty good - if Raymond Hettinger pronounces it 
OK then few would dare to disagree.


Thank you.

As for your English, though, the word you sought was "Pythonic" (not 
that you will ever find such a word in Webster's dictionary). To suggest 
that your code is Pythonesque would mean you found it farcical or 
ridiculous (like a Monty Python sketch), which it clearly is not.


I didn't know about the pejorative meaning of Pythonesque. :-) Thanks for the 
comment on my English (which should be obvious that I'm not a native speaker).



PS: I think either my mailer or yours has mangled the indentation.


I think that it was mine.


Thanks, Rogério Brito.

--
Rogério Brito : [EMAIL PROTECTED],ime.usp}.br : GPG key 1024D/7C2CAEB8
http://www.ime.usp.br/~rbrito : http://meusite.mackenzie.com.br/rbrito
Projects: algorithms.berlios.de : lame.sf.net : vrms.alioth.debian.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: descriptor & docstring

2008-04-28 Thread cyril giraudon
A precision, I use python 2.5.2 under linux mandiva 2007.0

Cyril.


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


  1   2   >