Re: Awkward format string

2007-08-02 Thread Gerard Flanagan
On Aug 1, 11:52 pm, Ian Clark <[EMAIL PROTECTED]> wrote:
> Gerard Flanagan wrote:
> > (snip)
>
> > def tostring(data):
> > return tuple(strftime(x) for x in data[:2]) + data[2:]
>
> Hrmm, not sure that having a function named tostring() that returns a
> tuple is the best idea. ;)
>

oops! SAD (Solipsistic API Design)... ;-)

Gerard


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


Re: a dict trick

2007-08-02 Thread Stargaming
On Thu, 02 Aug 2007 06:32:11 +, james_027 wrote:

> hi
> 
> for example I have this dictionary
> 
> dict = {'name':'james', 'language':'english'}

First of all, this is a bad name because it shadows (overwrites) the 
reference to the builtin constructor, `dict`.

> value = 'sex' in dict and dict['sex'] or 'unknown'
> 
> is a right pythonic of doing this one? I am trying to get a value from
> the dict, but if the key doesn't exist I will provide one.

If you're using using Python 2.5, you could do this without `and`/`or` 
trickery::

>>> d['name'] if 'name' in d else 'unknown'
'james'
>>> d['sex'] if 'sex' in d else 'unknown'
'unknown'

But there are more elegant ways. For example, the `get` method::

>>> d.get('name', 'unknown')
'james'
>>> d.get('sex', 'unknown')
'unknown'

See the `Python Library Reference, 3.8: Mapping types ` for more information on 
`dict` methods.

Or you could use the `collections.defaultdict ` type (new in 2.5, too), which I consider most 
elegant::

>>> from collections import defaultdict
>>> d2 = defaultdict(lambda:'unknown', d)
>>> d2['name']
'james'
>>> d2['sex']
'unknown'

HTH,
Stargaming

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


backup/restore postgresql database

2007-08-02 Thread Acm
I am working with Python 2.5 and Postgresql 8.2.4.

I would like to know how to perform the backup and restore operations
on postgresql through a python API (e.g. psycopg2).

Thank you.

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


Re: Time object?

2007-08-02 Thread Nikola Stjelja
On 8/1/07, Robert Dailey <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I'm well aware of the datetime module, however it is really inconsistent
> and useless to me. In order to do any arithmetic on time objects, I have to
> use the 'timedelta' class, which doesn't even allow me to do all the math I
> want to do.
>
> For example, I want to do "1 / timeobj", where timeobj might represent a
> time in the format of "00:00:00.00". Do I have to code my own class
> for this, or is there some other third party library out there that will
> allow me to do this?
>
> Thanks.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Convert each date you use to a timestamp, make all your calculations using
those timestamps, and then when you need a date back just convert the
desired timestamp to date time format of your choosing.

-- 
Please visit this site and play my RPG!

http://www.1km1kt.net/rpg/Marinci.php
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Equivalent to gzinflate() function in PHP.

2007-08-02 Thread Laurent Pointal
Adam Kubica a écrit :
> After some king of brain fucked tries, I found:
> 
> zlib.decompress( data ) #equivalent gzdecompress()
> zlib.decompress( data, -zlib.MAX_WBITS ) #equivalent gzdeflate()

Note: you can also use encode() and decode() methods on the string 
containing your data, specifying 'zip' as encoding.

Example:

 >>> s="Hello"*100
 >>> s1 = s.encode('zip')
 >>> len(s1)
18
 >>> s1
'x\x9c\xf3H\xcd\xc9\xc9\xf7\x18%F\x12\x01\x00\t\xb9\xc3Q'
 >>> s2 = s1.decode('zip')
 >>> len(s2)
500
 >>> s2
'HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHell
oHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHell
oHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHell
oHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHell
oHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHell
oHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHell
oHelloHelloHelloHello'
 >>>


IMHO this is mode understandable than zlib.decompress( data, 
-zlib.MAX_WBITS ).

A+

Laurent.

PS. There may be other compression encodings... look at 
encodings.aliases.aliases, where I can see 'zip' and 'zlib' (same), but 
also 'bz2'. - you can also found encoders for hexadecimal, quoted 
printable, and other formats.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a dict trick

2007-08-02 Thread Gary Herron
james_027 wrote:
> hi
>
> for example I have this dictionary
>
> dict = {'name':'james', 'language':'english'}
>
> value = 'sex' in dict and dict['sex'] or 'unknown'
>
> is a right pythonic of doing this one? I am trying to get a value from
> the dict, but if the key doesn't exist I will provide one.
>
> THanks
> james
>
>   
This fails if 'sex' is in the dictionary and it's value happens to be 
any of the values that evaluate to a boolean False.  In that case you'll 
get 'unknow' even though the key is in the dictionary.

However, python dictionaries provide a way to do this:

  dict.get('sex', 'unknown')

looks up the value associated with the key if it exists, otherwise it 
returns the provided default value.

You may also want to checkout the dictionary method setdefault which has 
the functionality of get PLUS if the key is not found, it adds the 
key,value pair to the dictionary.

Gary Herron

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


Re: Python IMAP web-access

2007-08-02 Thread Laurent Pointal
Damjan a écrit :
> Is there some project that implements web access to an IMAP store?
> 
> Maybe something AJAXy like http://roundcube.net/??

I dont know if this fill your need, but in my Python bookmarks, for 
webmail I have a reference to NiMail (http://www.nimail.org/).

A+

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


Re: a dict trick

2007-08-02 Thread [EMAIL PROTECTED]
james_027 wrote:
> hi
> 
> for example I have this dictionary
> 
> dict = {'name':'james', 'language':'english'}
> 
> value = 'sex' in dict and dict['sex'] or 'unknown'
> 
> is a right pythonic of doing this one? I am trying to get a value from
> the dict, but if the key doesn't exist I will provide one.
> 
> THanks
> james
> 

value = your_dict.get(key, default_value)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a dict trick

2007-08-02 Thread Alex Popescu
james_027 <[EMAIL PROTECTED]> wrote in news:1186036331.304916.304020
@e9g2000prf.googlegroups.com:

> hi
> 
> for example I have this dictionary
> 
> dict = {'name':'james', 'language':'english'}
> 
> value = 'sex' in dict and dict['sex'] or 'unknown'
> 
> is a right pythonic of doing this one? I am trying to get a value from
> the dict, but if the key doesn't exist I will provide one.
> 
> THanks
> james
> 

Same question discussed at large not far ago:
subject: "Pythonic way of missing dict keys" [1]

bests,
./alex
--
.w( the_mindstorm )p.

[1] 
http://groups.google.com/group/comp.lang.python/browse_thread/thread/175eb4
5909a05a18

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


Re: Where do they tech Python officialy ?

2007-08-02 Thread Alex Popescu
[EMAIL PROTECTED] (Alex Martelli) wrote in news:1i26u6o.pthuan2j7nufN%
[EMAIL PROTECTED]:

> Alex Popescu <[EMAIL PROTECTED]> wrote:
>...
>> Have you seen/heard of Jim lately? Cause I haven't. By the time he 
was
>> the lead of the AspectJ team his charismatic presence was everywhere 
(at
>> least around that project).
> 
> He wasn't at OSCON this year, but I hope to see him at Pycon next 
year.
> I don't see this as a deep dark M$ plot to kidnap and hide the best 
and
> brightest Open Sourcers, because I know what it means to get a 
wonderful
> challenging new job and pour all you have into it (I've had to skip a
> couple Pycons, myself, though I hope to be back next year).
> 

I wasn't trying to imply that (maybe just as a joke ;-)). It was more a 
personal curiosity.

> 
>> However I do agree with you. The only remark is that US trends are 
not
>> hitting my part of Eu so quickly ;-) (things are indeed changing).
> 
> About 3 years ago I was also getting sick and tired about my own part 
of
> the EU, which is part of why I emigrated:-).  I do see things getting
> better in Southern Europe, albeit from a distance.
>

Guess we both know the feeling then.
 
> 
>> > These are the ones you don't wan't to work for anyway !-)
>> 
>> Well... this is sometimes debatable :-).
> 
> A totally clueless employer may still be a way to make some quick and
> dirty money right now, but it will barely be enough to pay for the 
extra
> Maalox and Zantac you'll need.  Looking back on your life when you're
> closer to retirement than to when you started working, you'll see what 
a
> mistake it was to accept clueless-employers' offers, and how much
> happier your life would have been if you'd known that up front:-).
>

He he... been there done that :-). Escaped only with couple of Maalox, 
though :-).

bests,
./alex
--
.w( the_mindstorm )p.
 
> 
> Alex


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


Re: Emacs + python

2007-08-02 Thread Bruno Desthuilliers
Edward O'Connor a écrit :
>> Could anyone put me on the right track to developing Python with emacs
>> please : modes to consider, debugging etc hopefully all within emacs.
> 
> Personally, I prefer the python.el that ships with Emacs 22 to the
> python-mode.el from python.org. It seems more like other Emacs major
> modes.

Would you mind giving us a quick summary of the differences between 
these 2 modes ? As far as I'm concerned, I've been mostly happy with 
python-mode so far...

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


Re: beginner in python

2007-08-02 Thread km
Hi
Welcome to python !
there a a few suggestions in ur code which is a good practice to follow.
In the snippet:

> > for x in range(len(x_value)):
> >  x_co = float(x_value[x])-float(x_value[x+1])
> >  y_co = float(y_value[x])-float(y_value[x+1])
> >  z_co = float(z_value[x])-float(z_value[x+1])
> >  data = math.sqrt(x_co)*(x_co)+(y_co)*(y_co)+(z_co)*(z_co)
> >  print data

U suddenly change the indent from four spaces which u followed in previous
for loop. pls maintain consistency in indent. Standard  convention is to use
four spaces for indent.

Another problem is that u have not closed the filehandle  in the program!

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

Re: Emacs + python

2007-08-02 Thread Bruno Desthuilliers
hg a écrit :
(snip)
> Are there any cscope & ECB equivalent for Python ?

ECB (assuming we're talking about the same thing, ie Emacs Code Browser) 
works just fine with Python.

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


Re: Floats as keys in dict

2007-08-02 Thread Brian Elmegaard
greg <[EMAIL PROTECTED]> writes:

> Be careful with this. If you have two values that are
> very close together, but on different sides of a rounding
> boundary, they will end up as distinct keys even though
> they "should" be regarded as equal.

I don't think this is a big problem. It will only give me one more
node. 

Wouldn't the same be possible if I use bisect?

-- 
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.rugbyklubben-speed.dk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a dict trick

2007-08-02 Thread Bruno Desthuilliers
james_027 a écrit :
> hi
> 
> for example I have this dictionary
> 
> dict = {'name':'james', 'language':'english'}
> 
> value = 'sex' in dict and dict['sex'] or 'unknown'
> 
> is a right pythonic of doing this one?

No. The first problem is that using 'dict' as an identifier, you're 
shadowing the builtin dict type. The second problem is that you're 
reinventing the square wheel.

> I am trying to get a value from
> the dict, but if the key doesn't exist I will provide one.

d = {'name':'james', 'language':'english'}
d.get('sex', 'unknown')

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


Re: Pythonic way for missing dict keys

2007-08-02 Thread Alex Popescu
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

> Steven D'Aprano a écrit :
> (snip)
> 
>> Instead of doing:
> 
>> if callable(function): function()
>> 
>> you should do:
>> 
>> try:
>> function()
>> except TypeError:
>> pass
> 
> There are time where you may want to know if you have a callable
> without calling it...
> 
>> That should work for most uses of callable(), but isn't quite the
>> same. (What if function() has side-effects, or is expensive, and you
>> want to determine if it is callable, but not actually call it _now_?)
> 
> Indeed.
> 
> The 'correct' replacement would be:
> 
> if hasattr(obj, '__call__'):
># it's a callable
> 
> but I don't find it so Pythonic to have to check for a __magic__
> method. 
> 
> 

It looks like Python devs have decided it is Pythonic, because it is 
already in the PEP. Same for execfile and the others. And I am not 
arguing pro or con. I was just wondering about the reasons, as I haven't 
been able to find anything (neither here nor on the dev group).

bests,
./alex
--
.w( the_mindstorm )p.

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

Re: a dict trick

2007-08-02 Thread james_027
Hi,

what if we're not dealing with dict? is there a pythonic way of doing
ternary? the bool ? x:y

Thanks
james

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


Re: Awkward format string

2007-08-02 Thread Bruno Desthuilliers
beginner a écrit :
> Hi,
> 
> In order to print out the contents of a list, sometimes I have to use
> very awkward constructions. For example, I have to convert the
> datetime.datetime type to string first, construct a new list,

s/list/tuple/

> and then
> send it to print. The following is an example.
> 
>   x=(e[0].strftime("%Y-%m-%d"), e[1].strftime("%Y-%m-%d"))+e[2:]
>   print  >>f, "%s\t%s\t%d\t%f\t%f\t%f\t%d" % x
> 
> e is a tuple. x is my new tuple.
> 
> Does anyone know better ways of handling this?



 >>> from datetime import datetime
 >>> dt = datetime(2007,8,2)
 >>> dt
datetime.datetime(2007, 8, 2, 0, 0)
 >>> str(dt)
'2007-08-02 00:00:00'
 >>> "%s" % dt
'2007-08-02 00:00:00'
 >>> dt.date()
datetime.date(2007, 8, 2)
 >>> str(dt.date())
'2007-08-02'


Do you really need datetime objects ? If not, using date objects instead 
would JustWork(tm) - at least until someone ask you to use another date 
format !-)


Else, and since you seem to have a taste for functional programming:

from datetime import datetime
from functools import partial

def iformat(e):
 fake = lambda obj, dummy: obj
 for item in e:
 yield getattr(item, 'strftime', partial(fake, item))('%Y-%m-%d')


e = (datetime(2007,8,1),datetime(2007,8,2) ,42, 0.1, 0.2, 0.3, 1138)
print tuple(iformat(e))
print "%s\t%s\t%d\t%f\t%f\t%f\t%d" % tuple(iformat(e))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error with Tkinter and tkMessageBox

2007-08-02 Thread Fabio Z Tessitore
Il Thu, 02 Aug 2007 13:54:46 +1000, John McMonagle ha scritto:

 
> What window manager are you using ?

Hi John,

I'm using gnome, with gdm. Do you think the problem is this? I'm going to 
try with another one ... 

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


Re: Wing IDE for Python v. 3.0 beta1 released

2007-08-02 Thread John K Masters
On 18:23 Wed 01 Aug , Steve Holden wrote:
> Joshua J. Kugler wrote:
> > On Wednesday 01 August 2007 13:53, Robert Dailey wrote:
> >> He's secretly an employee of Wing IDE in disguise!!!
> > 
> > Sorry to destroy your conspiracy theories, but no, I've never been employed
> > by Wing IDE in any fashion, nor have I ever received any monetary
> > compensation from them in any form.  Just a satisfied user.  That's all.
> > 
> > j
> > 
> Me too, and I have to say the response I have had to all my technical 
> support requests has been first-class. Maybe they are busy because 
> they're in beta? I know they aren't the largest company, but they can 
> stand comparison with most when it comes to support.
> 
> I can't think of any other products I use where you can contact the 
> support team from right inside the software. And get answers without 
> paying per-incident support fees!
> 
> regards
>   Steve
> -- 

I am happy to hear that you have had a good experience with wingide and
I wish I could say the same as I have found the product to be excellent
as far as the concept goes but lacking in the implementation. 

To suggest that, because the autocompletion worked on one method of a
module and not on another was because I had not configured the
PYTHONPATH properly is at least insulting.

Regards, John
-- 
War is God's way of teaching Americans geography
uggest that mbrose Bierce (1842 - 1914)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error with Tkinter and tkMessageBox

2007-08-02 Thread Fabio Z Tessitore
I've tried to use Twm and SURPRISE! it works!!!

Can you say why? How can I fix the prob with Gnome?

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


Re: a dict trick

2007-08-02 Thread Bruno Desthuilliers
james_027 a écrit :
> Hi,
> 
> what if we're not dealing with dict? is there a pythonic way of doing
> ternary? the bool ? x:y

Python 2.5 introduced the following syntax:

expr1 if condition else expr2

In older Python versions, one has to use and/or (like you wrongly did) 
or tuple/dict dispatch or other ad-hoc tricks. Or use a plain old 
if/else branch.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: No module named DBUtils.PooledDB

2007-08-02 Thread cpmishra



-- Forwarded message --
From: cpmishra <[EMAIL PROTECTED]>
Date: Aug 2, 11:37 am
Subject: No module named DBUtils.PooledDB
To: comp.lang.python


Hi all
   I have used DBUtil with python2.4. when we run to program in
dos command ,successfully run but when we run in apache server
(locally)with modepython then given error.Pls  help me

program:
#import pgdb # import used DB-API 2 module
from DBUtils.PooledDB import PooledDB
import MySQLdb
#from mod_python import util
class Connection:

def getConnection(self):
pool = PooledDB(MySQLdb, 20,
db='ratingtool',host="localhost",port=3306, user="xwiki",
passwd="xwiki")
conn = pool.connection()
return conn



error:
No module named DBUtils.PooledDB

cp mishra

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


i am new to python-Please somebody help

2007-08-02 Thread cool . vimalsmail
i dont know how to convert a txt file into a zip file

(i.e.,)i have a file named packages and i want the packages file with
a ".gz" extension by implementing a python program

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


Re: Python end of file marker similar to perl's __END__

2007-08-02 Thread Magnus Lycka
Neil Cerutti wrote:
> On 2007-08-01, Cameron Laird <[EMAIL PROTECTED]> wrote:   .
>> I want to re-emphasize the "triple-quote it" tip mentioned
>> earlier in this thread.  I think the original questioner
>> will find this quite satisfying, if I understand his situ-
>> ation at all.
>>
>> *I* certainly have source code with embedded "junk" 
>> commented out as multi-line strings.
> 
> I used to do that, but now that I use doctests so much it's
> infeasible to comment out arbitrary code that way, since they
> can't necessarily nest.

If you consistently use e.g. ''' for doc strings, you can use
""" to comment out code blocks.

I still think it's better to do test-driven programming though.
Then you will very rarely have large blocks on non-working code.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic way for missing dict keys

2007-08-02 Thread Bruno Desthuilliers
Alex Popescu a écrit :
> Bruno Desthuilliers <[EMAIL PROTECTED]> wrote in
> news:[EMAIL PROTECTED]: 
(snip)
>> if hasattr(obj, '__call__'):
>># it's a callable
>>
>> but I don't find it so Pythonic to have to check for a __magic__
>> method. 
> 
> It looks like Python devs have decided it is Pythonic, because it is 
> already in the PEP. 

I do know, and I disagree with this decision.

FWIW, repr(obj) is mostly syntactic sugar for obj.__repr__(), 
getattr(obj, name) for obj.__getattr__(name), type(obj) for 
obj.__class__  etc... IOW, we do have a lot of builtin functions that 
mostly encapsulate calls to __magic__ methods, and I definitively don't 
understand why this specific one (=> callable(obj)) should disappear. I 
usually have lot of respect for Guido's talent as a language designer 
(obviously since Python is still MFL), but I have to say I find this 
particular decision just plain stupid. Sorry.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wing IDE for Python v. 3.0 beta1 released

2007-08-02 Thread Steve Holden
John K Masters wrote:
> On 18:23 Wed 01 Aug , Steve Holden wrote:
>> Joshua J. Kugler wrote:
>>> On Wednesday 01 August 2007 13:53, Robert Dailey wrote:
 He's secretly an employee of Wing IDE in disguise!!!
>>> Sorry to destroy your conspiracy theories, but no, I've never been employed
>>> by Wing IDE in any fashion, nor have I ever received any monetary
>>> compensation from them in any form.  Just a satisfied user.  That's all.
>>>
>>> j
>>>
>> Me too, and I have to say the response I have had to all my technical 
>> support requests has been first-class. Maybe they are busy because 
>> they're in beta? I know they aren't the largest company, but they can 
>> stand comparison with most when it comes to support.
>>
>> I can't think of any other products I use where you can contact the 
>> support team from right inside the software. And get answers without 
>> paying per-incident support fees!
>>
>> regards
>>   Steve
>> -- 
> 
> I am happy to hear that you have had a good experience with wingide and
> I wish I could say the same as I have found the product to be excellent
> as far as the concept goes but lacking in the implementation. 
> 
> To suggest that, because the autocompletion worked on one method of a
> module and not on another was because I had not configured the
> PYTHONPATH properly is at least insulting.
> 
> Regards, John

We must all be guided by personal experience, I suppose. Personally I 
wouldn't get insulted if someone suggested I might have made a mistake, 
since I have made enough in my life to recognize it as a pattern. 
Problem identification has to start with the most likely causes.

I am sure that had you written back to say you had checked the 
PYTHONPATH and were still looking for the problem cause they would have 
answered you civilly and with other possible causes.

regards
  steve

-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: Emacs + python

2007-08-02 Thread Hadron
Edward O'Connor <[EMAIL PROTECTED]> writes:

>> Could anyone put me on the right track to developing Python with emacs
>> please : modes to consider, debugging etc hopefully all within emacs.
>
> Personally, I prefer the python.el that ships with Emacs 22 to the
> python-mode.el from python.org. It seems more like other Emacs major
> modes.
>
>
> Ted

Could you extrapolate a little more on what you see as the differences?

I addition, I run pdb under emacs and the GUD menu appears but I cant
set break points by clicking in the left column of the source
display. Is there a way to get this working?
-- 
http://mail.python.org/mailman/listinfo/python-list


Use variable in regular expression

2007-08-02 Thread CarpeSkium
I know I can use a variable in regular expressions. I want to use a
regex to find something based on the beginning of the string. I am
using yesterday's date to find all of my data from yesterday.
Yesterday's date is 20070731, and assigned to the variable
"yesterday_date". I want to loop thru a directory and find all of the
yesterday's data ONLY IF the feature class has the date at the
BEGINNING of the filename.

Sample strings:
20070731_test1
Copy20070731_test1
20070731_test2
Copy20070731_test2
20070731_test3
Copy20070731_test3

I don't want the one's that start with "Copy". I can't figure out the
syntax of inserting the "^" into the regex. I've tried all of the
following, with no luck:

re.compile(^yesterday_date)
re.compile(r'^yesterday_date')
re.compile(r'^[yesterday_date]')
re.compile(r'[^yesterday_date]')

I don't know what I'm doing and I'm just guessing at this point. Can
anyone help? Thanks.

Mark

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


Re: DBUtil with modepython

2007-08-02 Thread Steve Holden
cpmishra wrote:
> Hi all
>I have used DBUtil in mysql databse. when we run to program in
> dos command ,successfully run but when we run in apache server
> (locally)with modepython then given error.Pls give me suggation
> 
> error:
> No module named DBUtils.PooledDB
> 
It seems likely that the web environment doesn't include the directory 
containing the DBUtils (DBUtil?) in the PYTHONPATH variable.

Try running this script as a CGI:

print "Content-Type: text/plain\n"
import os
for val in os.environ.items():
   print "%s=%s" % val

and see what PYTHONPATH looks like.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: Use variable in regular expression

2007-08-02 Thread Antti Rasinen

On 2007-08-02, at 13:43, [EMAIL PROTECTED] wrote:

> I know I can use a variable in regular expressions. I want to use a
> regex to find something based on the beginning of the string. I am
> using yesterday's date to find all of my data from yesterday.
> Yesterday's date is 20070731, and assigned to the variable
> "yesterday_date". I want to loop thru a directory and find all of the
> yesterday's data ONLY IF the feature class has the date at the
> BEGINNING of the filename.
>

> ...

> I don't want the one's that start with "Copy". I can't figure out the
> syntax of inserting the "^" into the regex. I've tried all of the
> following, with no luck:
>
> re.compile(^yesterday_date)
> re.compile(r'^yesterday_date')
> re.compile(r'^[yesterday_date]')
> re.compile(r'[^yesterday_date]')

The first one is a syntax error (^ outside a string means the xor- 
operation). The rest are just strings containing the _string_  
'yesterday_date' and not the value of the variable. So you need to do  
some string formatting(*

search_str = '^%s' % yesterday_date # I'm assuming yesterday_date is  
a string.
re.compile(search_str)

*) http://docs.python.org/lib/typesseq-strings.html

-- 
[ [EMAIL PROTECTED] <*> Antti Rasinen ]

This drone-vessel speaks with the voice and authority of the Ur-Quan.

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


beginner in python

2007-08-02 Thread Beema shafreen
Hi everybody ,
  I am a beginner in python,
 I have to fetch the redundant entries from a file,

code:

import re
L = []
fh = open('ARCHITECTURE_MAIN.txt','r')
for line in fh.readlines():
data =line.strip()
#   splitted = data.split('#')
L.append(data)
fh.close()


M=L
for x in L:
x = x.split('#')
for y in M:
y = y.split('#')
x_data = x[0],x[1],x[2],x[3]
#print x_data
y_data = y[0],y[1],y[2],y[3]
#print y_dat
if x_data[0] == y_data[0]:
  print x_data


i get the result as a tupule,
the text file which has datas separated by hash
entry#isoform#start#stop#  i have to check upto this

00250_1#ARCH_104#61#89#Literature#9224948#00250
00250_1#ARCH_104#97#126#Literature#9224948#00250
00250_1#ARCH_104#139#186#Literature#9224948#00250
00251_1#ARCH_463#7#59#SMART##00251
00251_1#ARCH_463#91#121#SMART##00251
00251_1#ARCH_463#251#414#SMART##00251
00251_1#ARCH_463#540#624#SMART##00251
00252_1#ARCH_474#1#21#Literature#8136357#00252
00252_1#ARCH_393#481#501#Literature#8136357#00252
00252_1#ARCH_463#523#553#SMART##00252
00253_1#ARCH_82#37#362#SMART##00253
00253_1#ARCH_54#365#522#SMART##00253
00253_1#ARCH_104#589#617#SMART##00253
00253_1#ARCH_104#619#647#SMART##00253
00253_1#ARCH_104#684#712#SMART##00253
00254_1#ARCH_82#27#352#SMART##00254
00254_1#ARCH_54#355#510#SMART##00254
00254_1#ARCH_104#576#604#SMART##00254
00254_1#ARCH_104#606#634#SMART##00254
00254_1#ARCH_104#671#699#SMART##00254
00255_1#ARCH_82#56#425#SMART##00255
00255_1#ARCH_54#428#582#SMART##00255
00255_1#ARCH_104#696#724#SMART##00255




can you suggest me ,what are the improvement i have to make in the above
code
regards
shafreen
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: i am new to python-Please somebody help

2007-08-02 Thread BartlebyScrivener
On Aug 2, 4:31 am, [EMAIL PROTECTED] wrote:
>
> i want the packages file with
> a ".gz" extension by implementing a python program

http://docs.python.org/lib/module-gzip.html

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


Re: Use variable in regular expression

2007-08-02 Thread vbr
...
> Yesterday's date is 20070731, and assigned to the variable
> "yesterday_date". I want to loop thru a directory and find all of the
> yesterday's data ONLY IF the feature class has the date at the
> BEGINNING of the filename.
...
> I can't figure out the
> syntax of inserting the "^" into the regex. 
> 
...
e.g.

yesterdayRE = re.compile("^"+yesterday_date)
...
should work (assuming yesterday_date is a string), but for that simple tests 
you may also try e.g.

filename.startswith(yesterday_date)

(with both filename and yesterday_date being strings).

Greetings,
   Vlasta

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


Re: Representation of new-style instance

2007-08-02 Thread Gabriel Genellina
En Wed, 01 Aug 2007 20:14:06 -0300, Raj B <[EMAIL PROTECTED]> escribió:

> Consider a new-style class
>
> class rabbit(object):
>def __init__(self,c):
> self.color = c
>
> r1=rabbit("blue")
> r2=rabbit("purple")
>
> Which C struct in the Python implementation is used to represent the
> instances c1 and c2 of the
> new-style class? I understand that when the class 'rabbit' is
> created, the type_new function
> in typeobject.c creates a copy of a 'struct typeobject' with
> dictionary tp_dict appropriately modified.

Yes. Then, rabbit("blue") means "call rabbit with a single argument,  
blue". The slot tp_call is searched, giving usually type_call, which  
itself calls tp_new (type_new if not overriden). (see type_call in  
typeobject.c).

> However, I can't figure out which structure is used for new-style
> instances and where the instance dictionary is stored. Could anyone
> please clarify?

All objects in Python are based on a PyObject structure; see object.h
Different object types have additional fields at the end, but all share  
the same basic layout.

-- 
Gabriel Genellina

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


Re: beginner in python

2007-08-02 Thread km
Hi

pls redefine ur problem.
I donot understand what u wanted to accomplish .
is it that u wanted to check and represent the redundant entry numbers as
one entry or is it
 with the isoform id as a single entry and without considering other data
like start  and stop ?

also observe that when u consider the whole line in the data file, they are
all unique - there is no redundancy.

KM
---
On 8/2/07, Beema shafreen <[EMAIL PROTECTED]> wrote:
>
> Hi everybody ,
>   I am a beginner in python,
>  I have to fetch the redundant entries from a file,
>
> code:
>
> import re
> L = []
> fh = open('ARCHITECTURE_MAIN.txt', 'r')
> for line in fh.readlines():
> data =line.strip()
> #   splitted = data.split('#')
> L.append(data)
> fh.close()
>
>
> M=L
> for x in L:
> x = x.split('#')
> for y in M:
> y = y.split('#')
> x_data = x[0],x[1],x[2],x[3]
> #print x_data
> y_data = y[0],y[1],y[2],y[3]
> #print y_dat
> if x_data[0] == y_data[0]:
>   print x_data
>
>
> i get the result as a tupule,
> the text file which has datas separated by hash
> entry#isoform#start#stop#  i have to check upto this
>
> 00250_1#ARCH_104#61#89#Literature#9224948#00250
> 00250_1#ARCH_104#97#126#Literature#9224948#00250
> 00250_1#ARCH_104#139#186#Literature#9224948#00250
> 00251_1#ARCH_463#7#59#SMART##00251
> 00251_1#ARCH_463#91#121#SMART##00251
> 00251_1#ARCH_463#251#414#SMART##00251
> 00251_1#ARCH_463#540#624#SMART##00251
> 00252_1#ARCH_474#1#21#Literature#8136357#00252
> 00252_1#ARCH_393#481#501#Literature#8136357#00252
> 00252_1#ARCH_463#523#553#SMART##00252
> 00253_1#ARCH_82#37#362#SMART##00253
> 00253_1#ARCH_54#365#522#SMART##00253
> 00253_1#ARCH_104#589#617#SMART##00253
> 00253_1#ARCH_104#619#647#SMART##00253
> 00253_1#ARCH_104#684#712#SMART##00253
> 00254_1#ARCH_82#27#352#SMART##00254
> 00254_1#ARCH_54#355#510#SMART##00254
> 00254_1#ARCH_104#576#604#SMART##00254
> 00254_1#ARCH_104#606#634#SMART##00254
> 00254_1#ARCH_104#671#699#SMART##00254
> 00255_1#ARCH_82#56#425#SMART##00255
> 00255_1#ARCH_54#428#582#SMART##00255
> 00255_1#ARCH_104#696#724#SMART##00255
>
>
>
>
> can you suggest me ,what are the improvement i have to make in the above
> code
> regards
> shafreen
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Catching SystemExit in C API code when embedding Python?

2007-08-02 Thread Stefan Bellon
Hi all!

I am embedding Python into a GUI application in a way that the GUI is
scriptable using Python.

Now I have come to a problem that when the user puts a "sys.exit(0)"
into his script to end the script, not only the script is terminated,
but also the GUI application itself. This is not the intended behaviour.

As in Python itself you can catch SystemExit, I think this should be
the way to go. But how do I catch this exception from within the C API?

Thanks in advance for any hints.

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


Re: Use variable in regular expression

2007-08-02 Thread Sion Arrowsmith
 <[EMAIL PROTECTED]> wrote:
>I know I can use a variable in regular expressions. I want to use a
>regex to find something based on the beginning of the string.

You're coming from a Perl background, right? No-one else would
think of using a regexp for such a simple thing. There are two
things you need to learn:

(a) Python doesn't do automatic variable interpolation in strings.
(b) For simple find and replace operations, there are string
methods which are easier and faster than regexps.

>Yesterday's date is 20070731, and assigned to the variable
>"yesterday_date". I want to loop thru a directory and find all of the
>yesterday's data ONLY IF the feature class has the date at the
>BEGINNING of the filename.
>
>Sample strings:
>20070731_test1
>Copy20070731_test1
>20070731_test2
>Copy20070731_test2
>20070731_test3
>Copy20070731_test3
>
>I don't want the one's that start with "Copy".

>>> "20070731_test1".startswith(yesterday_date)
True
>>> "Copy20070731_test1".startswith(yesterday_date)
False

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
   "Frankly I have no feelings towards penguins one way or the other"
-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python end of file marker similar to perl's __END__

2007-08-02 Thread Steven D'Aprano
On Thu, 02 Aug 2007 10:00:04 +1000, Ben Finney wrote:

> beginner <[EMAIL PROTECTED]> writes:
> 
>> Thanks everyone for responding. It doesn't look like python has
>> it. I would definitely miss it. As Steve said, the nice thing about
>> __END__ is that things below __END__ do not have to have legit
>> syntax.
> 
> I think the unaddressed question is: Why is there so much code in your
> module with invalid syntax that this trick would be useful?

It's not just "bad syntax" that makes the triple-quote or comment trick
useful. Sometimes you're experimenting, or perhaps tinkering is a better
description. Your aim isn't to end up with a working piece of code, but to
learn something (e.g. "how do decorators work?"). You may end up with
working code at the end, but the finished code isn't the aim of the
exercise and may not be kept.

Because you're experimenting, you might end up with ten different versions
of a function, and not all of them will compile, let alone execute
correctly. It's handy to be able to comment them out and reload() the
file, and while some editors will do bulk comment/uncomment of text, the
triple-quoted string trick is easy enough that you can use it in
Microsoft's Notepad.


>> That let me focus on the lines of code I am debugging and do not
>> have to worry about some bad syntax down the line. This feature is
>> especially handy if I am, saying, replacing modoules or changing
>> data structures.
> 
> I would strongly recommend you examine what part of your practice is
> leading you to write so much code with invalid syntax, without
> immediately testing and fixing it. Eliminate that part of the process
> -- possibly with test-driven development.

While the discipline of TDD is good and useful, there's a time and place
for unstructured and informal experimentation too.


-- 
Steven.

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


Re: standalone process to interact with the web

2007-08-02 Thread beginner
On Aug 1, 3:50 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> beginner wrote:
> > Hi Everyone,
>
> > I am looking for a way to allow a standalone python process to easily
> > interactive with a few web pages. It has to be able to easily receive
> > requests from the web and post data to the web.
>
> > I am thinking about implementing a standalone soap server, but I am
> > not sure which library is good.
>
> > Any suggestions?
>
> Forget SOAP. Use XMLRPC. SOAP is bloated, not to interoperable and the last
> time I checked (has been a while though) the python-implementations were
> troublesome.
>
> http://wanderingbarque.com/nonintersecting/2006/11/15/the-s-stands-fo...
>
> Diez

Thanks for the sgguestion. XML RPC is definitely a good candidate.

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


Re: Use variable in regular expression

2007-08-02 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> I know I can use a variable in regular expressions. I want to use a
> regex to find something based on the beginning of the string. I am
> using yesterday's date to find all of my data from yesterday.
> Yesterday's date is 20070731, and assigned to the variable
> "yesterday_date". I want to loop thru a directory and find all of the
> yesterday's data ONLY IF the feature class has the date at the
> BEGINNING of the filename.
> 
> Sample strings:
> 20070731_test1
> Copy20070731_test1
> 20070731_test2
> Copy20070731_test2
> 20070731_test3
> Copy20070731_test3
> 
> I don't want the one's that start with "Copy". I can't figure out the
> syntax of inserting the "^" into the regex. I've tried all of the
> following, with no luck:
> 
> re.compile(^yesterday_date)
> re.compile(r'^yesterday_date')
> re.compile(r'^[yesterday_date]')
> re.compile(r'[^yesterday_date]')
> 
> I don't know what I'm doing and I'm just guessing at this point. Can
> anyone help? Thanks.
> 
As is often the case, taking a larger look at the problem can reveal 
that Python has features that can help you without even getting down to 
more complex stuff.

You appear to require a list of the files whose names begin with a 
string representation of yesterday's date.

If you take a look at the glob module you will see that it has a glob() 
function, and if you were to call it as

 names = glob.glob(yesterday_date + "*")

it would return a list of the names of the files you are interested in.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: frequency analysis of a DB column

2007-08-02 Thread Carsten Haese
On Thu, 2007-08-02 at 00:38 -0300, Gabriel Genellina wrote:
> I'd start with:
> 
> select column, count(column), min(column), max(column)
>  from table
> group by column
> order by count(column) desc

What's the point of including min(column) and max(column)? They're
always going to be equal to column.

-- 
Carsten Haese
http://informixdb.sourceforge.net


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


Re: I am giving up perl because of assholes on clpm -- switching to Python

2007-08-02 Thread Jamie
In <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] mentions:
>Python is a better language, with php support, anyway, but I am fed up
>with attitudes of comp.lang.perl.misc. Assholes in this newsgroup ruin
>Perl experience for everyone. Instead of being helpful, snide remarks,
>back-biting, scare tactings, and so on proliferate and self
>reinforce. All honest people have left this sad newsgroup. Buy bye,
>assholes, I am not going to miss you!!!
>
>Martha

I've heard people tell the same story, that perl folks are... rude.

Actually, I've pretty much heard (and noticed) that about linux, too.

Yet, linux is still a good operating environment, so is perl.

You'll find rude people everywhere you look. While it may be true that
there is a higher percentage of hard-core tech folks who might lack
social skills, at least they don't err.. well, maybe they do.. byte. :-)

Seriously, it is one of the problems facing perl (and linux) people ARE
turned away by the attitude. It is rather embarassing/unflattering when
someone is critical of your work.

I see a lot of ideas about things should be "made easier" but I think 
thats the wrong course. We really just need to be nicer to new folks.

Jamie
-- 
http://www.geniegate.comCustom web programming
Perl * Java * UNIXUser Management Solutions
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use variable in regular expression

2007-08-02 Thread Steve Holden
[when replying to a mailing list or newsgroup response please make sure 
you include the list as a recipient, so the whole conversation is available]

André Martins wrote:
> 
>>  I know I can use a variable in regular expressions. I want to use a
>>  regex to find something based on the beginning of the string. I am
>>  using yesterday's date to find all of my data from yesterday.
>>  Yesterday's date is 20070731, and assigned to the variable
>>  "yesterday_date". I want to loop thru a directory and find all of the
>>  yesterday's data ONLY IF the feature class has the date at the
>>  BEGINNING of the filename.
> 
> If i understood, you have directores with files named 20070731, 20070722 ...
> 
> So, what about:
> 
> import os
> yesterday_date = '20070731'
> list = os.listdir (dir)
> for x in [x for x in list if x.startswith( yesterday_date ) ]:
> print x
> 
> 
> Is  not a option?
> 
If it works it's an option! Regular expressions should usually be a last 
resort, and the solution above seems perfectly acceptable to me.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -
-- 
http://mail.python.org/mailman/listinfo/python-list


IWCIA 08 - USA, 7-9 April 2008: Invitation

2007-08-02 Thread [EMAIL PROTECTED]
Dear Colleague,

I would like to bring to your attention information about a
forthcoming conference and to strongly encourage you to submit a paper
or papers to it.

This is the 12th International Workshop on Combinatorial Image
Analysis (IWCIA 08) which will take place in Buffalo, USA, 7-9 April
2008. Comprehensive information about the conference is available at
its website http://www.cs.fredonia.edu/iwcia08 (or google IWCIA 08).
>From there you will see that IWCIA 08 will be a very top conference,
with distinguished keynote speakers (one of them a Nobel Laureate, the
other four are of the highest possible rank and recognition as well).
The proceedings will be published by Springer (LNCS) and by Taylor and
Francis (for submissions to the Special Track on Applications). The
extended versions of the best papers will be published in special
issues of Pattern Recognition, Elsevier (for theoretical papers) and
in the International Journal of Imaging Systems and Technology, Wiley
(for papers of the Special Track on Applications).

I am involved in the organization of the Special Track on Applications
of IWCIA 08, and can assure you that it will provide the authors with
an exceptional opportunity to present their work and publish it by a
reputable publisher and possibly in a journal (indexed by Science
Citation Index Expanded and several other indexes), to discuss topics
of common interest with scientists from all over the world as well as
with representatives of the industry from the US and possibly other
countries.

Having in mind the area of your research and experience, I would like
to invite you to submit a paper (or papers) to IWCIA 08 and especially
to its Special Track on Applications. I am certain that both your and
the conference will benefit from your submission.

Best regards,

Joao Manuel R. S. Tavares
(IWCIA 08 co-organizer)

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


Re: i am new to python-Please somebody help

2007-08-02 Thread Steven D'Aprano
On Thu, 02 Aug 2007 09:31:43 +, cool.vimalsmail wrote:
[snip]

You would be better off actually writing a sensible subject line instead
of grovelling. 

Subject: How to use gzip in Python? [beginner]

Then, having written a good subject line, it might have suggested a good
search string for Google: "gzip python"

http://www.google.com.au/search?&q=gzip+python

The first two links found will answer your question.


-- 
Steven.

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


Re: standalone process to interact with the web

2007-08-02 Thread beginner
On Aug 1, 5:04 am, Bruno Desthuilliers  wrote:
> beginner a écrit :
> (snip)
>
> > Yes exactly. I just don't want to reinvent the wheel as I imagine
> > there are already tons of libraries and frameworks that support RPC or
> > the like functions.
>
> Why go thru the pain of RPC, SOAP or such bloated horrors ? Why not just
> use plain old HTTP with a RESTful API ? Then you just need to make your
> app wsgi compliant.

I am not familiar with RESTful API. I will look into it.

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

Re: Python end of file marker similar to perl's __END__

2007-08-02 Thread Neil Cerutti
On 2007-08-02, Magnus Lycka <[EMAIL PROTECTED]> wrote:
> Neil Cerutti wrote:
>> On 2007-08-01, Cameron Laird <[EMAIL PROTECTED]> wrote:  .
>>> I want to re-emphasize the "triple-quote it" tip mentioned
>>> earlier in this thread.  I think the original questioner
>>> will find this quite satisfying, if I understand his situ-
>>> ation at all.
>>>
>>> *I* certainly have source code with embedded "junk" 
>>> commented out as multi-line strings.
>> 
>> I used to do that, but now that I use doctests so much it's
>> infeasible to comment out arbitrary code that way, since they
>> can't necessarily nest.
>
> If you consistently use e.g. ''' for doc strings, you can use
> """ to comment out code blocks.

But then I couldn't use """ in my docstrings! ;) Actually, I
wound up converting all my multiline doctests to use
concatenation instead, since they were ruining my syntax
highlighting performance in Vim.

-- 
Neil Cerutti
We shall reach greater and greater platitudes of achievement. --Richard J.
Daley
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use variable in regular expression

2007-08-02 Thread André Martins
> I know I can use a variable in regular expressions. I want to use a
> regex to find something based on the beginning of the string. I am
> using yesterday's date to find all of my data from yesterday.
> Yesterday's date is 20070731, and assigned to the variable
> "yesterday_date". I want to loop thru a directory and find all of the
> yesterday's data ONLY IF the feature class has the date at the
> BEGINNING of the filename.

If i understood, you have directores with files named 20070731, 20070722 ...

So, what about:

import os
yesterday_date = '20070731'
list = os.listdir (dir)
for x in [x for x in list if x.startswith( yesterday_date ) ]:
print x


Is  not a option?

[]'s
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python end of file marker similar to perl's __END__

2007-08-02 Thread kyosohma
On Aug 2, 8:08 am, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> On 2007-08-02, Magnus Lycka <[EMAIL PROTECTED]> wrote:
>
>
>
> > Neil Cerutti wrote:
> >> On 2007-08-01, Cameron Laird <[EMAIL PROTECTED]> wrote: .
> >>> I want to re-emphasize the "triple-quote it" tip mentioned
> >>> earlier in this thread.  I think the original questioner
> >>> will find this quite satisfying, if I understand his situ-
> >>> ation at all.
>
> >>> *I* certainly have source code with embedded "junk"
> >>> commented out as multi-line strings.
>
> >> I used to do that, but now that I use doctests so much it's
> >> infeasible to comment out arbitrary code that way, since they
> >> can't necessarily nest.
>
> > If you consistently use e.g. ''' for doc strings, you can use
> > """ to comment out code blocks.
>
> But then I couldn't use """ in my docstrings! ;) Actually, I
> wound up converting all my multiline doctests to use
> concatenation instead, since they were ruining my syntax
> highlighting performance in Vim.
>
> --
> Neil Cerutti
> We shall reach greater and greater platitudes of achievement. --Richard J.
> Daley

Python comes with an IDE that can do bulk commenting or uncommenting.
It's IDLE. Just select the test to comment out and press ALT+3. To
uncomment, press ALT+4.

It's cool!

Mike

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


Case study: library class inheritance with property declarations

2007-08-02 Thread cdleary
Hi all,

It's possible that I'm missing the obvious -- I've been up for over 24
hours and I'm most likely dehydrated from mass coffee intake, but I
figure many people in similar circumstances will be searching
comp.lang.python one day, so here goes!


class LibraryClass(object):

"""
A class whose implementation is out of my hands.
"""

def __init__(self):
"""
Follows good dynamic-language form and binds all instance
variables at initialization time.
"""
# Omitted: complex initialization functionality.
self.useful_attr = None


class MyInheritedClass(LibraryClass):

"""
My refinement of the functionality offered by the LibraryClass. I
now want the instance to initialize with a reference to an
external
object, and the useful_attr defined in the superclass will now
reference an attribute of that external object via fget.

Changing the attribute of the external object has undefined
behavior, so I want to omit an fset in the property declaration;
however, I have to provide some way for the superclass to
initialize useful_attr -- I can't change the superclass' code, as
it
resides in a library that is out of my hands.
"""

def __init__(self, external_obj):
LibraryClass.__init__(self)
self._external_obj = external_obj

def get_useful_attr(self):
return self._external_obj.proxy_useful_attr

useful_attr = property(fget=get_useful_attr)


def test():
class _Fake(object):
pass
external_obj = _Fake()
external_obj.proxy_useful_attr = 12
spam = MyInheritedClass(external_obj)


if __name__ == '__main__':
test()
EOF


If you're one of those people who doesn't like laboriously reading
contrived examples (elitists ;) I'll boil it down for you: Library
class initializes some attribute, but derived class wants to eliminate
fsets for said attribute. As a result, our ideal solution

Of course, this means that the derived class will raise an error in
some circumstances where the base class wouldn't (when you're setting
that attribute), but one can assume that the inheritance is
worthwhile.

How do I come up with silly solutions to circumvent this? Let me count
the ways...

1. So-and-so: make an fset that does nothing. This ignores (what
should be) errors in code that uses MyInheritedClass in an attempt to
accommodate a useless statement in the base class -- surely non-ideal.
2. The ugly one: since you can probably view the library, copy and
paste the complex initialization functionality in the above, but leave
out the bad statement. This not only forfeits the ideals of
inheritance, but makes you totally incompatible with future library
changes.
3. Cheerleader: Pure evil. On top of the ugliness of 2, you assume
that across library revisions the indenting won't change and that the
troublesome statement will remain on the same line, and pull off one
of these babies:

def super_evil_test():
from inspect import getsourcelines
exec(''.join([line[4:] for line in
  getsourcelines(LibraryClass.__init__)[0][:-1]]))
LibraryClass.__init__ = __init__
test() # Passes, but several angels no longer get their wings

Totally kidding, everybody! I hope Guido doesn't read this thread...

And this concludes the sleep deprived rambling that follows the
somewhat interesting case in point. Thoughts?

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


Re: Determining if file is valid image file

2007-08-02 Thread André
On Aug 2, 11:14 am, André <[EMAIL PROTECTED]> wrote:
> Other than installing PIL, is there a "simple" way using Python only
> to determine if a file is a valid image file?
>
> I'd be happy if I could at least identify valid images files for gif,
> jpeg and png.   Pointers to existing modules or examples would be
> appreciated.
>
> The reason why I'd prefer not using PIL is that I'd like to bundle
> such a function/module in my app.
>
> André

I should have added: I'm interesting in validating the file *content*
- not the filename :-)

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


Re: i am new to python-Please somebody help

2007-08-02 Thread gregarican
On Aug 2, 8:51 am, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Thu, 02 Aug 2007 09:31:43 +, cool.vimalsmail wrote:
>
> [snip]
>
> You would be better off actually writing a sensible subject line instead
> of grovelling.
>
> Subject: How to use gzip in Python? [beginner]
>
> Then, having written a good subject line, it might have suggested a good
> search string for Google: "gzip python"
>
> http://www.google.com.au/search?&q=gzip+python
>
> The first two links found will answer your question.
>
> --
> Steven.

This link answers my question --> 
http://www.google.com/search?hl=en&q=Python+list+rudeness.
Honestly, I have developed in both Ruby and Python for years now and
have consistently found that the Ruby community if more newbie-
friendly than Python's. Your points are well-taken in how to properly
post and how to do your own homework. Message correct. Delivery
lacking...

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


Re: Case study: library class inheritance with property declarations

2007-08-02 Thread cdleary
On Aug 2, 6:49 am, [EMAIL PROTECTED] wrote:
> Hi all,
>
> It's possible that I'm missing the obvious -- I've been up for over 24
> hours and I'm most likely dehydrated from mass coffee intake, but I
> figure many people in similar circumstances will be searching
> comp.lang.python one day, so here goes!
>
> class LibraryClass(object):
>
> """
> A class whose implementation is out of my hands.
> """
>
> def __init__(self):
> """
> Follows good dynamic-language form and binds all instance
> variables at initialization time.
> """
> # Omitted: complex initialization functionality.
> self.useful_attr = None
>
> class MyInheritedClass(LibraryClass):
>
> """
> My refinement of the functionality offered by the LibraryClass. I
> now want the instance to initialize with a reference to an
> external
> object, and the useful_attr defined in the superclass will now
> reference an attribute of that external object via fget.
>
> Changing the attribute of the external object has undefined
> behavior, so I want to omit an fset in the property declaration;
> however, I have to provide some way for the superclass to
> initialize useful_attr -- I can't change the superclass' code, as
> it
> resides in a library that is out of my hands.
> """
>
> def __init__(self, external_obj):
> LibraryClass.__init__(self)
> self._external_obj = external_obj
>
> def get_useful_attr(self):
> return self._external_obj.proxy_useful_attr
>
> useful_attr = property(fget=get_useful_attr)
>
> def test():
> class _Fake(object):
> pass
> external_obj = _Fake()
> external_obj.proxy_useful_attr = 12
> spam = MyInheritedClass(external_obj)
>
> if __name__ == '__main__':
> test()
> EOF
>
> If you're one of those people who doesn't like laboriously reading
> contrived examples (elitists ;) I'll boil it down for you: Library
> class initializes some attribute, but derived class wants to eliminate
> fsets for said attribute. As a result, our ideal solution
>
> Of course, this means that the derived class will raise an error in
> some circumstances where the base class wouldn't (when you're setting
> that attribute), but one can assume that the inheritance is
> worthwhile.
>
> How do I come up with silly solutions to circumvent this? Let me count
> the ways...
>
> 1. So-and-so: make an fset that does nothing. This ignores (what
> should be) errors in code that uses MyInheritedClass in an attempt to
> accommodate a useless statement in the base class -- surely non-ideal.
> 2. The ugly one: since you can probably view the library, copy and
> paste the complex initialization functionality in the above, but leave
> out the bad statement. This not only forfeits the ideals of
> inheritance, but makes you totally incompatible with future library
> changes.
> 3. Cheerleader: Pure evil. On top of the ugliness of 2, you assume
> that across library revisions the indenting won't change and that the
> troublesome statement will remain on the same line, and pull off one
> of these babies:
>
> def super_evil_test():
> from inspect import getsourcelines
> exec(''.join([line[4:] for line in
>   getsourcelines(LibraryClass.__init__)[0][:-1]]))
> LibraryClass.__init__ = __init__
> test() # Passes, but several angels no longer get their wings
>
> Totally kidding, everybody! I hope Guido doesn't read this thread...
>
> And this concludes the sleep deprived rambling that follows the
> somewhat interesting case in point. Thoughts?

I'm sorry -- the solution was not /enough/ coffee. Got another cup and
sat down with the type/class unification doc, and found this thought-
stimulating portion:

http://www.python.org/download/releases/2.2/descrintro/#property
If you want to override the __get__ operation for properties when used
as a class attribute, you can subclass property - it is a new-style
type itself - to extend its __get__ method, or you can define a
descriptor type from scratch by creating a new-style class that
defines __get__, __set__ and __delete__ methods.
...
The get method won't be called when the property is accessed as a
class attribute (C.x) instead of as an instance attribute (C().x).


Seeing as how property is just a wrapper class, we don't need to
declare it in the class body, though it /is/ the convention and the
way it's done in all the docs I've seen. We fix our inherited class to
be the following:

[snip]
class MyInheritedClass(LibraryClass):

"""
My refinement of the functionality offered by the LibraryClass. I
now want the instance to initialize with a reference to an
external
object, and the useful_attr defined in the superclass will now
reference an attribute of that external object via fget.

Changing the attribute of the external object has undefined
behavior, so I want to omit an fset in the property declaration;
howe

Re: Directory

2007-08-02 Thread Larry Bates
Rohan wrote:
> I would like to get a list of sub directories in a directory.
> If I use os.listdir i get a list of directories and files in that .
> i only want the list of directories in a directory and not the files
> in it.
> anyone has an idea regarding this.
> 

import os
listofdirs=[d for d in os.listdir(mydir) if os.pathisdir(d)]

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


Re: Determining if file is valid image file

2007-08-02 Thread Thomas Jollans
On Thursday 02 August 2007, André wrote:
> On Aug 2, 11:14 am, André <[EMAIL PROTECTED]> wrote:
> > Other than installing PIL, is there a "simple" way using Python only
> > to determine if a file is a valid image file?
> >
> > I'd be happy if I could at least identify valid images files for gif,
> > jpeg and png.   Pointers to existing modules or examples would be
> > appreciated.
> >
> > The reason why I'd prefer not using PIL is that I'd like to bundle
> > such a function/module in my app.
>
> I should have added: I'm interesting in validating the file *content*
> - not the filename :-)

The file name has nothing to do with the type :-P

A straightforward way you won't like: read the specs for all formats you're 
interested in and write the function yourself ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determining if file is valid image file

2007-08-02 Thread Larry Bates
André wrote:
> On Aug 2, 11:14 am, André <[EMAIL PROTECTED]> wrote:
>> Other than installing PIL, is there a "simple" way using Python only
>> to determine if a file is a valid image file?
>>
>> I'd be happy if I could at least identify valid images files for gif,
>> jpeg and png.   Pointers to existing modules or examples would be
>> appreciated.
>>
>> The reason why I'd prefer not using PIL is that I'd like to bundle
>> such a function/module in my app.
>>
>> André
> 
> I should have added: I'm interesting in validating the file *content*
> - not the filename :-)
> 
And what's wrong with bundling PIL in your application?

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


Re: Case study: library class inheritance with property declarations

2007-08-02 Thread cdleary
On Aug 2, 7:08 am, [EMAIL PROTECTED] wrote:
> On Aug 2, 6:49 am, [EMAIL PROTECTED] wrote:
>
>
>
> > Hi all,
>
> > It's possible that I'm missing the obvious -- I've been up for over 24
> > hours and I'm most likely dehydrated from mass coffee intake, but I
> > figure many people in similar circumstances will be searching
> > comp.lang.python one day, so here goes!
>
> > class LibraryClass(object):
>
> > """
> > A class whose implementation is out of my hands.
> > """
>
> > def __init__(self):
> > """
> > Follows good dynamic-language form and binds all instance
> > variables at initialization time.
> > """
> > # Omitted: complex initialization functionality.
> > self.useful_attr = None
>
> > class MyInheritedClass(LibraryClass):
>
> > """
> > My refinement of the functionality offered by the LibraryClass. I
> > now want the instance to initialize with a reference to an
> > external
> > object, and the useful_attr defined in the superclass will now
> > reference an attribute of that external object via fget.
>
> > Changing the attribute of the external object has undefined
> > behavior, so I want to omit an fset in the property declaration;
> > however, I have to provide some way for the superclass to
> > initialize useful_attr -- I can't change the superclass' code, as
> > it
> > resides in a library that is out of my hands.
> > """
>
> > def __init__(self, external_obj):
> > LibraryClass.__init__(self)
> > self._external_obj = external_obj
>
> > def get_useful_attr(self):
> > return self._external_obj.proxy_useful_attr
>
> > useful_attr = property(fget=get_useful_attr)
>
> > def test():
> > class _Fake(object):
> > pass
> > external_obj = _Fake()
> > external_obj.proxy_useful_attr = 12
> > spam = MyInheritedClass(external_obj)
>
> > if __name__ == '__main__':
> > test()
> > EOF
>
> > If you're one of those people who doesn't like laboriously reading
> > contrived examples (elitists ;) I'll boil it down for you: Library
> > class initializes some attribute, but derived class wants to eliminate
> > fsets for said attribute. As a result, our ideal solution
>
> > Of course, this means that the derived class will raise an error in
> > some circumstances where the base class wouldn't (when you're setting
> > that attribute), but one can assume that the inheritance is
> > worthwhile.
>
> > How do I come up with silly solutions to circumvent this? Let me count
> > the ways...
>
> > 1. So-and-so: make an fset that does nothing. This ignores (what
> > should be) errors in code that uses MyInheritedClass in an attempt to
> > accommodate a useless statement in the base class -- surely non-ideal.
> > 2. The ugly one: since you can probably view the library, copy and
> > paste the complex initialization functionality in the above, but leave
> > out the bad statement. This not only forfeits the ideals of
> > inheritance, but makes you totally incompatible with future library
> > changes.
> > 3. Cheerleader: Pure evil. On top of the ugliness of 2, you assume
> > that across library revisions the indenting won't change and that the
> > troublesome statement will remain on the same line, and pull off one
> > of these babies:
>
> > def super_evil_test():
> > from inspect import getsourcelines
> > exec(''.join([line[4:] for line in
> >   getsourcelines(LibraryClass.__init__)[0][:-1]]))
> > LibraryClass.__init__ = __init__
> > test() # Passes, but several angels no longer get their wings
>
> > Totally kidding, everybody! I hope Guido doesn't read this thread...
>
> > And this concludes the sleep deprived rambling that follows the
> > somewhat interesting case in point. Thoughts?
>
> I'm sorry -- the solution was not /enough/ coffee. Got another cup and
> sat down with the type/class unification doc, and found this thought-
> stimulating portion:
>
> http://www.python.org/download/releases/2.2/descrintro/#property
> If you want to override the __get__ operation for properties when used
> as a class attribute, you can subclass property - it is a new-style
> type itself - to extend its __get__ method, or you can define a
> descriptor type from scratch by creating a new-style class that
> defines __get__, __set__ and __delete__ methods.
> ...
> The get method won't be called when the property is accessed as a
> class attribute (C.x) instead of as an instance attribute (C().x).
>
> Seeing as how property is just a wrapper class, we don't need to
> declare it in the class body, though it /is/ the convention and the
> way it's done in all the docs I've seen. We fix our inherited class to
> be the following:
>
> [snip]
> class MyInheritedClass(LibraryClass):
>
> """
> My refinement of the functionality offered by the LibraryClass. I
> now want the instance to initialize with a reference to an
> external
> object, and 

Re: Determining if file is valid image file

2007-08-02 Thread kyosohma
On Aug 2, 9:35 am, Thomas Jollans <[EMAIL PROTECTED]> wrote:
> On Thursday 02 August 2007, André wrote:
>
> > On Aug 2, 11:14 am, André <[EMAIL PROTECTED]> wrote:
> > > Other than installing PIL, is there a "simple" way using Python only
> > > to determine if a file is a valid image file?
>
> > > I'd be happy if I could at least identify valid images files for gif,
> > > jpeg and png.   Pointers to existing modules or examples would be
> > > appreciated.
>
> > > The reason why I'd prefer not using PIL is that I'd like to bundle
> > > such a function/module in my app.
>
> > I should have added: I'm interesting in validating the file *content*
> > - not the filename :-)
>
> The file name has nothing to do with the type :-P
>
> A straightforward way you won't like: read the specs for all formats you're
> interested in and write the function yourself ;-)

Use the md5 module to create checksums. Links below:

http://www.peterbe.com/plog/using-md5-to-check-equality-between-files
http://effbot.org/librarybook/md5.htm
http://docs.python.org/lib/module-md5.html

Larry is right too...what's wrong with bundling PIL or any third party
module?

Mike

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


Re: Determining if file is valid image file

2007-08-02 Thread Jarek Zgoda
André napisał(a):

>> Other than installing PIL, is there a "simple" way using Python only
>> to determine if a file is a valid image file?
>>
>> I'd be happy if I could at least identify valid images files for gif,
>> jpeg and png.   Pointers to existing modules or examples would be
>> appreciated.
>>
>> The reason why I'd prefer not using PIL is that I'd like to bundle
>> such a function/module in my app.
>>
>> André
> 
> I should have added: I'm interesting in validating the file *content*
> - not the filename :-)

Is the module imghdr enough for your needs?

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determining if file is valid image file

2007-08-02 Thread André
On Aug 2, 11:34 am, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> André napisa³(a):
>
> >> Other than installing PIL, is there a "simple" way using Python only
> >> to determine if a file is a valid image file?
>
> >> I'd be happy if I could at least identify valid images files for gif,
> >> jpeg and png.   Pointers to existing modules or examples would be
> >> appreciated.
>
> >> The reason why I'd prefer not using PIL is that I'd like to bundle
> >> such a function/module in my app.
>
> >> André
>
> > I should have added: I'm interesting in validating the file *content*
> > - not the filename :-)
>
> Is the module imghdr enough for your needs?
>

Yes, thanks.


> --
> Jarek Zgoda
> Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101
>
> "We read Knuth so you don't have to." (Tim Peters)


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


Determining if file is valid image file

2007-08-02 Thread André
Other than installing PIL, is there a "simple" way using Python only
to determine if a file is a valid image file?

I'd be happy if I could at least identify valid images files for gif,
jpeg and png.   Pointers to existing modules or examples would be
appreciated.

The reason why I'd prefer not using PIL is that I'd like to bundle
such a function/module in my app.

André

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


Re: backup/restore postgresql database

2007-08-02 Thread kyosohma
On Aug 2, 1:55 am, Acm <[EMAIL PROTECTED]> wrote:
> I am working with Python 2.5 and Postgresql 8.2.4.
>
> I would like to know how to perform the backup and restore operations
> on postgresql through a python API (e.g. psycopg2).
>
> Thank you.


I don't know much about postgres, but here's what my google-fu turned
up:

http://www.koders.com/python/fidF98B0B88C167C4B9862D8EF6C0CC9BAAC33718DB.aspx?s=cdef%3Aparser
http://python.projects.postgresql.org/
http://pypgsql.sourceforge.net/
http://www.pygresql.org/

You can probably use the subprocess module to connect to it and use
the pg_dump command as well that is documented here:
http://www.postgresql.org/docs/8.1/static/backup.html

Mike

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


Re: Determining if file is valid image file

2007-08-02 Thread André
On Aug 2, 11:38 am, [EMAIL PROTECTED] wrote:
> On Aug 2, 9:35 am, Thomas Jollans <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Thursday 02 August 2007, André wrote:
>
> > > On Aug 2, 11:14 am, André <[EMAIL PROTECTED]> wrote:
> > > > Other than installing PIL, is there a "simple" way using Python only
> > > > to determine if a file is a valid image file?
>
> > > > I'd be happy if I could at least identify valid images files for gif,
> > > > jpeg and png.   Pointers to existing modules or examples would be
> > > > appreciated.
>
> > > > The reason why I'd prefer not using PIL is that I'd like to bundle
> > > > such a function/module in my app.
>
> > > I should have added: I'm interesting in validating the file *content*
> > > - not the filename :-)
>
> > The file name has nothing to do with the type :-P
>
> > A straightforward way you won't like: read the specs for all formats you're
> > interested in and write the function yourself ;-)
>
> Use the md5 module to create checksums. Links below:
>

Sorry, I fail to see how this helps me to identify if a file I
retrieve from somewhere is a valid image file...

> http://www.peterbe.com/plog/using-md5-to-check-equality-between-fileshttp://effbot.org/librarybook/md5.htmhttp://docs.python.org/lib/module-md5.html
>
> Larry is right too...what's wrong with bundling PIL or any third party
> module?
>

Why not bundling PIL?: Because I'm trying to keep the size of my app
as small as possible.
I don't mind bundling some other modules from third parties (in fact,
I already do include
three modules from ElementTree...).

André

> Mike


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


Re: Wing IDE for Python v. 3.0 beta1 released

2007-08-02 Thread sdeibel
On Aug 1, 5:45 pm, "Joshua J. Kugler" <[EMAIL PROTECTED]> wrote:
> I tend to let questions slide when they are answered in the documentation or
> on the web site.  Maybe theWingdevelopers/support personnel are the same
> way.

Just to clarify:  We never do that.  If you don't hear from us in
response to a
question, something has gone wrong (either we didn't get your email or
ours got filtered).

In this case, there was a typo in the reply-to email message and I
didn't manage
to figure out the correct email address to reply to until now.

Stephan Deibel
Wingware

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


Re: Determining if file is valid image file

2007-08-02 Thread Dave Hughes
André wrote:

> Other than installing PIL, is there a "simple" way using Python only
> to determine if a file is a valid image file?
> 
> I'd be happy if I could at least identify valid images files for gif,
> jpeg and png.   Pointers to existing modules or examples would be
> appreciated.
> 
> The reason why I'd prefer not using PIL is that I'd like to bundle
> such a function/module in my app.

Any reason you don't want to bundle PIL? The license looks like a
fairly standard BSD style license to me which I don't think precludes
you from bundling it (other than having to reproduce the (very small)
license text in any documentation).

Otherwise, it depends on exactly what you mean by "valid". You could do
something as simple as check the "magic" number in the header of the
file. Most image formats have something like this:

* PNG: byte sequence 89 50 4E 47 0D 0A 1A 0A
* GIF: "GIF89a" or "GIF87a"
* JPG: byte sequence FF D8 FF E0 nn nn 4A 46  49 46 00 (for JFIF)

Naturally, this won't guarantee the rest of the file is valid, but
might be sufficient for your purposes (it's one of the methods the
"file" command uses for recognizing file types).


HTH,

Dave.
-- 

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


Re: Awkward format string

2007-08-02 Thread beginner
On Aug 2, 3:32 am, Bruno Desthuilliers  wrote:
> beginner a écrit :
>
> > Hi,
>
> > In order to print out the contents of a list, sometimes I have to use
> > very awkward constructions. For example, I have to convert the
> > datetime.datetime type to string first, construct a new list,
>
> s/list/tuple/
>
> > and then
> > send it to print. The following is an example.
>
> >x=(e[0].strftime("%Y-%m-%d"), e[1].strftime("%Y-%m-%d"))+e[2:]
> >print  >>f, "%s\t%s\t%d\t%f\t%f\t%f\t%d" % x
>
> > e is a tuple. x is my new tuple.
>
> > Does anyone know better ways of handling this?
>
>  >>> from datetime import datetime
>  >>> dt = datetime(2007,8,2)
>  >>> dt
> datetime.datetime(2007, 8, 2, 0, 0)
>  >>> str(dt)
> '2007-08-02 00:00:00'
>  >>> "%s" % dt
> '2007-08-02 00:00:00'
>  >>> dt.date()
> datetime.date(2007, 8, 2)
>  >>> str(dt.date())
> '2007-08-02'
>
> Do you really need datetime objects ? If not, using date objects instead
> would JustWork(tm) - at least until someone ask you to use another date
> format !-)
>
> Else, and since you seem to have a taste for functional programming:
>
> from datetime import datetime
> from functools import partial
>
> def iformat(e):
>  fake = lambda obj, dummy: obj
>  for item in e:
>  yield getattr(item, 'strftime', partial(fake, item))('%Y-%m-%d')
>
> e = (datetime(2007,8,1),datetime(2007,8,2) ,42, 0.1, 0.2, 0.3, 1138)
> print tuple(iformat(e))
> print "%s\t%s\t%d\t%f\t%f\t%f\t%d" % tuple(iformat(e))

Thanks.

The 'functional' taste is still under development. It hasn't reached
production quality yet. :-)

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

Re: Wing IDE for Python v. 3.0 beta1 released

2007-08-02 Thread sdeibel
On Aug 1, 6:42 pm, John K Masters <[EMAIL PROTECTED]> wrote:
> To suggest that, because the autocompletion worked on one method of a
> module and not on another was because I had not configured the
> PYTHONPATH properly is at least insulting.

We certainly didn't intend to be insulting.  This it the most common
cause of
auto-completion problems but you are right that it's a mis-diagnosis
on our
part if it was just one method.  We respond to sometimes hundreds of
emails
a day ,so we do make mistakes.

It may be solved by using Reanalyze File from the right-click context
menu
on the editor but there's no gaurantee.  This is incredibly complex
code with
many layers of highly optimized tokenizing, analysis, inference,
caching,
and then display in the various tools in Wing so it often takes a bit
more time
to find where the bug is.

By the way, Wing 3.0 beta1 fixes a number of bugs that would lead to
bad analysis, including missing methods as a result of failure to
track edits in a file properly.  It also improves reading completion
info
out of extension modules and properly handles several forms of
import where it fell on its face previously.

Hope that's useful... please let me know if not.

- Stephan

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


RE: Bug in Time module, or in my understanding?

2007-08-02 Thread Hamilton, William
> From: Joshua J. Kugler
> 
> I am getting results like these with the time module:
> 
> >>> import time
> >>> int(time.mktime(time.strptime('2007-03-11 02:00:00', '%Y-%m-%d
%H:%M
> %S')))
> 1173610800
> >>> int(time.mktime(time.strptime('2007-03-11 03:00:00', '%Y-%m-%d
%H:%M
> %S')))
> 1173610800
> >>> time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1173610800))
> '2007-03-11 03:00:00'
> 
> I know it probably has something to do with daylight savings, but how
can
> I
> get back out that which I put in?  The times concerned are all
standard
> time, so how can I keep the time module from asserting its belief that
I
> want to convert to daylight savings?
> 
> Incidentally, it only happens with times on 2007-03-11  from 02:00:00
to
> 02:59:59, and not with time data from past years.
> 

I get similar results, except with hours 01:00:00 and 02:00:00.  I am in
US Central time (GMT-6).

>>> int(time.mktime(time.strptime('2007-03-11 00:00:00','%Y-%m-%d
%H:%M:%S')))
1173592800
>>> int(time.mktime(time.strptime('2007-03-11 01:00:00','%Y-%m-%d
%H:%M:%S')))
1173596400
>>> int(time.mktime(time.strptime('2007-03-11 02:00:00','%Y-%m-%d
%H:%M:%S')))
1173596400
>>> int(time.mktime(time.strptime('2007-03-11 03:00:00','%Y-%m-%d
%H:%M:%S')))
117360


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


Re: sending very large packets over the network

2007-08-02 Thread Azazello
On Aug 1, 8:50 pm, Gary Herron <[EMAIL PROTECTED]> wrote:
> Walker Lindley wrote:
> > OK, I'm back with another networking question. I'm trying to seend
> > large amounts of information over TCP (the length of data being given
> > to send() is on the order of 16000 characters in length).
> > Unfortunately on the receiving end, the packets appear to be
> > truncated. So I wrote some code that continuously tries to send bigger
> > and bigger packets until it fails and noticed that it never fails at
> > the same length. I'm not even sure these two things are related, but
> > is there some undocumented (or documented and I missed it) maximum
> > size for data you can pass to send()?
>
> For ethernet connections the size is often about 1500.  But the size
> depends on the underlying protocol, and even if you know the underlying
> protocol along the full route, you can't rely on packets that are
> received being the same as those that are sent.
>
> TCP/IP is a *stream* connection.  What you are guaranteed is this:  All
> the bytes that are sent from one end will be received eventually on the
> other end, in the proper order.  (Or failing that, you will receive an
> error notification.)  No guarantee is made about the packet sizes on
> either end, and you can't even rely on the packets being the same in
> number or length on the two ends.
>
> Your send code can try sending a packet of any size, but it must be
> prepared to examine the number of bytes actually sent, and retry with
> the remainder in a loop until all bytes are sent.Similarly your
> receiving code must loop around the receive accepting whatever sized
> packets makes it through the connection.
>
> In many TCP/IP connections, it seems that the packets received are
> one-for-one with the packets sent, but relying on this *IS AN ERROR*
> that will bite you.  It fails to across the internet (sometimes) and
> when (at least some) wireless cards are involved.
>
> You may be better off using a package that knows all this and handles it
> properly.  Modules asyncore and asynchat are one possibility.
>
> Gary Herron
>
>
>
>
>
> > the sample code is as follows
> > #server
> > import socket
>
> > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> > s.bind(("", 2000))
> > s.listen(0)
> > sock, addrinfo = s.accept()
> > for i in range(2 ** 16):
> >  length = int(sock.recv(16))
> >  print "excpecting data of length:", length
> >  data = sock.recv(length)
> >  print "received data of length:", len(data)
> >  print
> > s.close()
> > sock.close()
>
> > #client
> > import socket
> > import time
>
> > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> > s.bind(("", 2001))
> > s.connect(("localhost", 2000))
> > for i in range(2 ** 16):
> >  packet = "h" * i
> >  s.send("%16d" % len(packet))
> >  print "attempting to send data of length:", len(packet)
> >  tmp = s.send(packet)
> >  print "actually sent data of length:", tmp
> >  print
> >  time.sleep(.001)
> > s.close()
>
> > i just put them in different files and ran them from the command line.
> > Any help or suggestions would be greatly appreciated. Thanks.
>
> > -Walker
>
> > --
> > This e-mail is licensed under the Creative Commons
> > Attribution-NoDerivs 2.5 License. To view a copy of this license,
> > visithttp://creativecommons.org/licenses/by-nd/2.5/or send a letter
> > to Creative Commons, 543 Howard Street, 5th Floor, San Francisco,
> > California, 94105, USA.- Hide quoted text -
>
> - Show quoted text -

I'm not an expert on networking so take my advice with a grain of
salt!

My guess is that you're encountering race-like conditions between the
send and recv. commmands because you're running your communication
command 2^16 times, hoping that send and recv. are synchronous on
every step.  This is especially true when you're running other
commands in your data sending loops! Prints take quite a lot of time.
Also, the send command in C (i'm not sure if this is true in python)
does not guarantee that all of your data gets out.

I'm assuming that you're somewhat new to networking so I would
recommend shying away from running an Asynchronous polling server.
Although it is probably a better way to do this.

My suggestions:

Write a while loop in the server with some end of stream checking,
timeouts, et cetera. This will give you a bit of flexibility and
feedback when things go to pot.  Use the sendall() command  in your
client because it throws an exception if data isn't properly sent. and
will eliminate a unsightly for loop.

Client

socket.sendall(data)

Something akin to this old piece of test code

datastream = ''

## A timeout exception is thrown if the receiver is waiting on the
line for .25 seconds
socket.settimeout(.25)

while 1:
try:
buf = socket.recv(1024) ## If data on line put in buffer
except socket.timeout:  ## Data buffer timeout,  breaks
while loop
break
if buf == '': ## If an empty buffer, jump to top of loop (beginning
of file c

Memory Leak with Tkinter Canvas (Python 2.5 Win32)

2007-08-02 Thread frikk
Hey everyone.  I have been working with python for a couple years now,
but just recently built my first program with a GUI.  I decided to
start with Tkinter since it is included with the base package,
although wxWindows will likely be my next choice.  Tkinter seems to be
pretty slow for my needs.

Anyway - I am building a genetic algorithm simulator.  I have a grid
where an Ant moves around.  It is infeasible for me to update the grid
every simulation step - so I just do it at the end.  But what I've
realized is that my program performs worse and worse when I update the
grid.  Turns out there is a memory leak somewhere and I don't think it
is in my code.  The memory leak occurs only when I write (via
create_rectangle) to the canvas widget.  I wrote the following small
script to demonstrate this problem (see below).  Every time the button
is pressed, _1040KB_ is added to the RAM of wpython.exe.  This adds up
FAST.   I have not verified this on my OS X box.

As you can see- I am doing nothing other than drawing a lot of
rectangles on the canvas.  I have two questions.

  1.  Is this a bug in my usage of Tkinter? Am I somehow leaving
objects laying around that aren't being deleted? Is create_rectangle
not the appropriate function to use?)
  2.  Is there a better, quicker way to update a "grid"-like object?

Thanks,
Blaine

Current System:
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win32
Windows XP SP2 - all recent patches and updates

Script:

from Tkinter import *

canv = None
HEIGHT=600
WIDTH=600
def clear_grid():
for i in range(0,HEIGHT/10):
for j in range(0, HEIGHT/10):
canv.create_rectangle(i*10,j*10, \
  i*10+10, j*10+10, \
  fill = "white")

def draw_window(master):
global canv
frame = Frame(master)

btn_grid = Button(frame, text="draw grid", command=clear_grid)
btn_grid.pack(side=TOP)

canv = Canvas(frame, height=HEIGHT, width=WIDTH, bg='white')
canv.pack()
frame.pack()

root = Tk()
draw_window(root)
mainloop()

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


Re: beginner in python

2007-08-02 Thread Tim Williams
On 02/08/07, Beema shafreen <[EMAIL PROTECTED]> wrote:
> Hi everybody ,
>   I am a beginner in python,
>  I have to fetch the redundant entries from a file,
>
> code:
>
> import re
> L = []
> fh = open('ARCHITECTURE_MAIN.txt',
> 'r')
> for line in fh.readlines():
> data =line.strip()
> #   splitted = data.split('#')
> L.append(data)
> fh.close()
>
>
>
> M=L
> for x in L:
> x = x.split('#')
> for y in M:
> y = y.split('#')
> x_data = x[0],x[1],x[2],x[3]
> #print x_data
> y_data = y[0],y[1],y[2],y[3]
> #print y_dat
> if x_data[0] == y_data[0]:
>   print x_data
>
>
> i get the result as a tupule,
> the text file which has datas separated by hash
> entry#isoform#start#stop#  i have to check upto this
>
> 00250_1#ARCH_104#61#89#Literature#9224948#00250
> 00250_1#ARCH_104#97#126#Literature#9224948#00250
> 00250_1#ARCH_104#139#186#Literature#9224948#00250
> 00251_1#ARCH_463#7#59#SMART##00251
> 00251_1#ARCH_463#91#121#SMART##00251
> 00251_1#ARCH_463#251#414#SMART##00251
> 00251_1#ARCH_463#540#624#SMART##00251
> 00252_1#ARCH_474#1#21#Literature#8136357#00252
> 00252_1#ARCH_393#481#501#Literature#8136357#00252
> 00252_1#ARCH_463#523#553#SMART##00252
> 00253_1#ARCH_82#37#362#SMART##00253
> 00253_1#ARCH_54#365#522#SMART##00253
> 00253_1#ARCH_104#589#617#SMART##00253
> 00253_1#ARCH_104#619#647#SMART##00253
> 00253_1#ARCH_104#684#712#SMART##00253
> 00254_1#ARCH_82#27#352#SMART##00254
> 00254_1#ARCH_54#355#510#SMART##00254
> 00254_1#ARCH_104#576#604#SMART##00254
> 00254_1#ARCH_104#606#634#SMART##00254
> 00254_1#ARCH_104#671#699#SMART##00254
> 00255_1#ARCH_82#56#425#SMART##00255
> 00255_1#ARCH_54#428#582#SMART##00255
> 00255_1#ARCH_104#696#724#SMART##00255
>
>
>
>
> can you suggest me ,what are the improvement i have to make in the above
> code
> regards
> shafreen

Shafreen,   your code snippet (as you posted it) prints any lines that
end with an entry code equal the entry code on the last line of the
file, with these lines split at #.

The whole thing (as you posted it) could probably be written something
like this:

===
# not tested or optimised

fh = open('ARCHITECTURE_MAIN.txt').read().splitlines()
last_code = fh[-1].split('#')[0]
for line in fh:
if out_line.startswith(last_code):
print out_line.split('#')
# it will always print at least the last line of the file
===

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


Re: Pythonic way for missing dict keys

2007-08-02 Thread Alex Martelli
Bruno Desthuilliers <[EMAIL PROTECTED]>
wrote:

> Alex Popescu a écrit :
> > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote in
> > news:[EMAIL PROTECTED]: 
> (snip)
> >> if hasattr(obj, '__call__'):
> >># it's a callable
> >>
> >> but I don't find it so Pythonic to have to check for a __magic__
> >> method. 
> > 
> > It looks like Python devs have decided it is Pythonic, because it is
> > already in the PEP. 
> 
> I do know, and I disagree with this decision.
> 
> FWIW, repr(obj) is mostly syntactic sugar for obj.__repr__(), 
> getattr(obj, name) for obj.__getattr__(name), type(obj) for 
> obj.__class__  etc... IOW, we do have a lot of builtin functions that
> mostly encapsulate calls to __magic__ methods, and I definitively don't
> understand why this specific one (=> callable(obj)) should disappear. I

Maybe because it DOESN'T "encapsulate a call" to a magic method, but
rather the mere check for the presence of one?

> usually have lot of respect for Guido's talent as a language designer
> (obviously since Python is still MFL), but I have to say I find this 
> particular decision just plain stupid. Sorry.

The mere check of whether an object possesses some important special
method is best accomplished through the abstract-base-classes machinery
(new in Python 3.0: see ).  At
this time there is no Callable ABC, but you're welcome to argue for it
on the python-3000 mailing list (please do check the archives and/or
check privately with the PEP owner first to avoid duplication).


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


Re: Case study: library class inheritance with property declarations

2007-08-02 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> On Aug 2, 7:08 am, [EMAIL PROTECTED] wrote:
>> On Aug 2, 6:49 am, [EMAIL PROTECTED] wrote:
>>
>>
>>
>>> Hi all,
>>> It's possible that I'm missing the obvious -- I've been up for over 24
>>> hours and I'm most likely dehydrated from mass coffee intake, but I
>>> figure many people in similar circumstances will be searching
>>> comp.lang.python one day, so here goes!
>>> class LibraryClass(object):
>>> """
>>> A class whose implementation is out of my hands.
>>> """
>>> def __init__(self):
>>> """
>>> Follows good dynamic-language form and binds all instance
>>> variables at initialization time.
>>> """
>>> # Omitted: complex initialization functionality.
>>> self.useful_attr = None
>>> class MyInheritedClass(LibraryClass):
>>> """
>>> My refinement of the functionality offered by the LibraryClass. I
>>> now want the instance to initialize with a reference to an
>>> external
>>> object, and the useful_attr defined in the superclass will now
>>> reference an attribute of that external object via fget.
>>> Changing the attribute of the external object has undefined
>>> behavior, so I want to omit an fset in the property declaration;
>>> however, I have to provide some way for the superclass to
>>> initialize useful_attr -- I can't change the superclass' code, as
>>> it
>>> resides in a library that is out of my hands.
>>> """
>>> def __init__(self, external_obj):
>>> LibraryClass.__init__(self)
>>> self._external_obj = external_obj
>>> def get_useful_attr(self):
>>> return self._external_obj.proxy_useful_attr
>>> useful_attr = property(fget=get_useful_attr)
>>> def test():
>>> class _Fake(object):
>>> pass
>>> external_obj = _Fake()
>>> external_obj.proxy_useful_attr = 12
>>> spam = MyInheritedClass(external_obj)
>>> if __name__ == '__main__':
>>> test()
>>> EOF
>>> If you're one of those people who doesn't like laboriously reading
>>> contrived examples (elitists ;) I'll boil it down for you: Library
>>> class initializes some attribute, but derived class wants to eliminate
>>> fsets for said attribute. As a result, our ideal solution
>>> Of course, this means that the derived class will raise an error in
>>> some circumstances where the base class wouldn't (when you're setting
>>> that attribute), but one can assume that the inheritance is
>>> worthwhile.
>>> How do I come up with silly solutions to circumvent this? Let me count
>>> the ways...
>>> 1. So-and-so: make an fset that does nothing. This ignores (what
>>> should be) errors in code that uses MyInheritedClass in an attempt to
>>> accommodate a useless statement in the base class -- surely non-ideal.
>>> 2. The ugly one: since you can probably view the library, copy and
>>> paste the complex initialization functionality in the above, but leave
>>> out the bad statement. This not only forfeits the ideals of
>>> inheritance, but makes you totally incompatible with future library
>>> changes.
>>> 3. Cheerleader: Pure evil. On top of the ugliness of 2, you assume
>>> that across library revisions the indenting won't change and that the
>>> troublesome statement will remain on the same line, and pull off one
>>> of these babies:
>>> def super_evil_test():
>>> from inspect import getsourcelines
>>> exec(''.join([line[4:] for line in
>>>   getsourcelines(LibraryClass.__init__)[0][:-1]]))
>>> LibraryClass.__init__ = __init__
>>> test() # Passes, but several angels no longer get their wings
>>> Totally kidding, everybody! I hope Guido doesn't read this thread...
>>> And this concludes the sleep deprived rambling that follows the
>>> somewhat interesting case in point. Thoughts?
>> I'm sorry -- the solution was not /enough/ coffee. Got another cup and
>> sat down with the type/class unification doc, and found this thought-
>> stimulating portion:
>>
>> http://www.python.org/download/releases/2.2/descrintro/#property
>> If you want to override the __get__ operation for properties when used
>> as a class attribute, you can subclass property - it is a new-style
>> type itself - to extend its __get__ method, or you can define a
>> descriptor type from scratch by creating a new-style class that
>> defines __get__, __set__ and __delete__ methods.
>> ...
>> The get method won't be called when the property is accessed as a
>> class attribute (C.x) instead of as an instance attribute (C().x).
>>
>> Seeing as how property is just a wrapper class, we don't need to
>> declare it in the class body, though it /is/ the convention and the
>> way it's done in all the docs I've seen. We fix our inherited class to
>> be the following:
>>
>> [snip]
>> class MyInheritedClass(LibraryClass):
>>
>> """
>> My refinement of the functionality offered by the LibraryClass. I
>> now want the instance to initialize with a reference to an
>> external
>

python 3.0, pywin32 and scipy

2007-08-02 Thread vml
Hello,


I am trying to promote python in my job, my collegue only see matlab
and microsoft scripting language.
I understood that there willl be no backward compatibility between
python 2.x and 3.0, does it means that:

- my script using pywin32 for the COM layer and scipy for the maths
won't work under 3.0
- will we have the equivalent of pywin32 and scipy in python ?

I will be incharge of designing a python module which will be a
'matrix calculator' in our current software. Will it be compatible
with python 3.0 ? I guess no.

What can I answer to my collegue who will say 'Python is changing and
the stuff you are doing now is useless'?

how can I argue against matlab and c# ?

thanks very much

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


Re: standalone process to interact with the web

2007-08-02 Thread Bruno Desthuilliers
beginner a écrit :
> On Aug 1, 5:04 am, Bruno Desthuilliers  [EMAIL PROTECTED]> wrote:
>> beginner a écrit :
>> (snip)
>>
>>> Yes exactly. I just don't want to reinvent the wheel as I imagine
>>> there are already tons of libraries and frameworks that support RPC or
>>> the like functions.
>> Why go thru the pain of RPC, SOAP or such bloated horrors ? Why not just
>> use plain old HTTP with a RESTful API ? Then you just need to make your
>> app wsgi compliant.
> 
> I am not familiar with RESTful API. I will look into it.
> 
It's nothing else than the correct use of the HTTP protocol. And it's 
much more simpler than all those XMLRPC, SOAP and whatnot monstruosities.
-- 
http://mail.python.org/mailman/listinfo/python-list


Error subclassing datetime.date and pickling

2007-08-02 Thread Mike Rooney
Hi everyone, this is my first post to this list. I am trying to create a 
subclass of datetime.date and pickle it, but I get errors on loading it 
back. I have created a VERY simple demo of this:

import datetime

class MyDate(datetime.date):
"""
This should be pickleable.
   
>>> md = MyDate(2007, 1, 6)
>>> import pickle
>>> pickle.dump(md, open("test.pickle", 'w'))
>>> mdp = pickle.load(open("test.pickle"))
>>> import os; os.remove("test.pickle")
"""
def __init__(self, y, m, d):
datetime.date.__init__(self, y, m, d)
   
if __name__ == "__main__":
import doctest
doctest.testmod()


The traceback that occurs is:

Traceback (most recent call last):
  File "C:\Python25\lib\doctest.py", line 1212, in __run
compileflags, 1) in test.globs
  File "", line 1, in 
mdp = pickle.load(open("test.pickle"))
  File "C:\Python25\lib\pickle.py", line 1370, in load
return Unpickler(file).load()
  File "C:\Python25\lib\pickle.py", line 858, in load
dispatch[key](self)
  File "C:\Python25\lib\pickle.py", line 1133, in load_red
value = func(*args)
TypeError: __init__() takes exactly 4 arguments (2 given)


I have found a few relating issues:
 - 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=952807&group_id=5470
 - 
http://sourceforge.net/tracker/index.php?func=detail&aid=720908&group_id=5470&atid=105470

But these are both rather old and are marked as fixed. I am running 
Python 2.5.1 on Windows XP SP2. Any help here would be greatly appreciated!

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


Re: Pythonic way for missing dict keys

2007-08-02 Thread Bruno Desthuilliers
Alex Martelli a écrit :
> Bruno Desthuilliers <[EMAIL PROTECTED]>
> wrote:
> 
>> Alex Popescu a écrit :
>>> Bruno Desthuilliers <[EMAIL PROTECTED]> wrote in
>>> news:[EMAIL PROTECTED]: 
>> (snip)
 if hasattr(obj, '__call__'):
# it's a callable

 but I don't find it so Pythonic to have to check for a __magic__
 method. 
>>> It looks like Python devs have decided it is Pythonic, because it is
>>> already in the PEP. 
>> I do know, and I disagree with this decision.
>>
>> FWIW, repr(obj) is mostly syntactic sugar for obj.__repr__(), 
>> getattr(obj, name) for obj.__getattr__(name), type(obj) for 
>> obj.__class__  etc... IOW, we do have a lot of builtin functions that
>> mostly encapsulate calls to __magic__ methods, and I definitively don't
>> understand why this specific one (=> callable(obj)) should disappear. I
> 
> Maybe because it DOESN'T "encapsulate a call" to a magic method, but
> rather the mere check for the presence of one?

Yes, true. But it doesn't make such a big difference IMHO : it's about 
decoupling API (the builtin funcs) from implementation (accessing | 
calling | checking for the presence of a given implementation attribute).

>> usually have lot of respect for Guido's talent as a language designer
>> (obviously since Python is still MFL), but I have to say I find this 
>> particular decision just plain stupid. Sorry.
> 
> The mere check of whether an object possesses some important special
> method is best accomplished through the abstract-base-classes machinery
> (new in Python 3.0: see ).  At
> this time there is no Callable ABC, but you're welcome to argue for it
> on the python-3000 mailing list (please do check the archives and/or
> check privately with the PEP owner first to avoid duplication).

I'll have a look. Thanks for the pointers.
-- 
http://mail.python.org/mailman/listinfo/python-list


Cross compiling 2.5.1

2007-08-02 Thread winkatl1213
I was wondering if anyone could help me with cross-compiling Python
2.5.1 to a MIPS target.

The approach I'm using is based off the suggestion in the README file
that comes with the python source distribution.

I managed to get the configure script to run using the following
command line:

$ ../Python-2.5.1/configure --host=mips-linux --enable-shared

Next I run make and it builds the python interpreter and shared
library.  However, it then attempts to run the interpreter to complete
the rest of the build process, and that of coarse fails.

I read several posts on the internet from people who applied patches
to the python source to enable cross-compling, but my impression was
that 2.5.1 had merged some of this work.

Can anyone give me some suggestions on how I get the makery to use the
build interpreter instead of the host interpreter to complete the
build process?

Thanks in advance for any suggestions.

Jeff

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


wxpython with python 2.5

2007-08-02 Thread G
Hello,


 I am trying to get wxpython to run with python 2.5 without any success.
wx works prefectly in python 2.4. below is the error code i get when i try
to run the code.
File "demo.py", line 3, in 
import Main
  File "/tmp/wxPython/Main.py", line 32, in 
import wx  # This module uses the new wx namespace
ImportError: No module named wx

Any help in getting wxpython to run in 2.5 would be greatly appreciated.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: python 3.0, pywin32 and scipy

2007-08-02 Thread Steve Holden
vml wrote:
> Hello,
> 
> 
> I am trying to promote python in my job, my collegue only see matlab
> and microsoft scripting language.
> I understood that there willl be no backward compatibility between
> python 2.x and 3.0, does it means that:
> 
> - my script using pywin32 for the COM layer and scipy for the maths
> won't work under 3.0
> - will we have the equivalent of pywin32 and scipy in python ?
> 
> I will be incharge of designing a python module which will be a
> 'matrix calculator' in our current software. Will it be compatible
> with python 3.0 ? I guess no.
> 
> What can I answer to my collegue who will say 'Python is changing and
> the stuff you are doing now is useless'?
> 
> how can I argue against matlab and c# ?
> 
> thanks very much
> 
Tell them that the majority of incompatibilities will be taken care of 
by an automated translation mechanism, and that the 2.X range will be 
maintained in parallel with the 3.X range, with features backported when 
it is feasible to do so, so there will be no *need* to migrate to 3.X 
until *at least* 3.1 (which will likely take us two years into the future).

You might also remind them that Microsoft have continually broken 
backwards compatibility, and that this is a one-off deal that will make 
Python better and more consistent (not that they'll be interested in 
that, since they seem to have closed minds).

Finally, look for Python users who have migrated from Matlab (of which 
there are many) and get their opinions on why. I have used C# on a 
couple of projects now and it's an OK language, but it can't hold a 
candle to Python, which is now firmly in the .NET environment with 
Microsoft's IronPython open source implementation.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: i am new to python-Please somebody help

2007-08-02 Thread Hyuga
On Aug 2, 8:51 am, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Thu, 02 Aug 2007 09:31:43 +, cool.vimalsmail wrote:
>
> [snip]
>
> You would be better off actually writing a sensible subject line instead
> of grovelling.
>
> Subject: How to use gzip in Python? [beginner]
>
> Then, having written a good subject line, it might have suggested a good
> search string for Google: "gzip python"
>
> http://www.google.com.au/search?&q=gzip+python
>
> The first two links found will answer your question.
>
> --
> Steven.


Unlike gregarican, I mostly agree with the content of your post.
Except for your subject line suggestion.  Why on earth would you
recommend someone use the obnoxious "How to __ ?" question
format?  Yes, I know it's extremely common, but it's completely
nonsensical English.  Just try saying it out loud with an inquiring
inflection on the last word.  Sounds ridiculous doesn't it?  At least
without the question mark it means that the thread is on the topic of
"How to _".


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


Re: wxpython with python 2.5

2007-08-02 Thread Chris Mellon
On 8/2/07, G <[EMAIL PROTECTED]> wrote:
> Hello,
>
>
>  I am trying to get wxpython to run with python 2.5 without any success.
> wx works prefectly in python 2.4. below is the error code i get when i try
> to run the code.
> File "demo.py", line 3, in 
> import Main
>   File "/tmp/wxPython/Main.py", line 32, in 
> import wx  # This module uses the new wx namespace
> ImportError: No module named wx
>
> Any help in getting wxpython to run in 2.5 would be greatly appreciated.
>


Download the python 2.5 package.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxpython with python 2.5

2007-08-02 Thread Steve Holden
G wrote:
> Hello,
> 
> 
>  I am trying to get wxpython to run with python 2.5 without any 
> success. wx works prefectly in python 2.4. below is the error code i get 
> when i try to run the code.
> File "demo.py", line 3, in 
> import Main
>   File "/tmp/wxPython/Main.py", line 32, in 
> import wx  # This module uses the new wx namespace
> ImportError: No module named wx
> 
> Any help in getting wxpython to run in 2.5 would be greatly appreciated.
> 
How did you install it, and was it a version specifically made to run 
with Python 2.5? You can't just install 2.5 and have it pick up all the 
libraries you installed for 2.4, you have to download and install 
updated versions.

At the moment it doesn't look as though 2.5 is seeing wxPython at all.

Sorry if this isn't the problem.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: beginner in python

2007-08-02 Thread Andy Cheesman
It looks like you are doing some sort of molecular science thing.
Have you come across openbabel and the python bindings pybel
(http://openbabel.sourceforge.net/wiki/Python#Pybel). I don't know how
well they work but they might save you some effort. Also, check out
pymol,(http://pymol.sourceforge.net/) they might have some of the
functionality which you desire already coded!

HTH
Andy

Steve Holden wrote:
> Beema shafreen wrote:
>> hi everybody,
>>I am beginner in python
>>  I have to calculate the euclidean distance between the atoms from a pdb 
>> file
>> i have written the the code and its shows me some error ,
>> the code:
>> import re
>> import string
>> import math
>> ab =[]
>> x_value = []
>> y_value = []
>> z_value = []
>> fh = open("1K5N.pdb",'r')
>> for atom in fh.readlines():
>>a = atom.strip()
>>pattern= re.compile('^ATOM.*')
>>atom_file= pattern.search(a)
>>if  atom_file:
>>atom_data = atom_file.group()
>>x_coordinate = atom_data[31:38]
>>y_coordinate = atom_data[39:46]
>>z_coordinate = atom_data[47:54]
>>x_value.append(x_coordinate)
>>y_value.append(y_coordinate)
>>z_value.append(z_coordinate)
>> for x in range(len(x_value)):
>>  x_co = float(x_value[x])-float(x_value[x+1])
>>  y_co = float(y_value[x])-float(y_value[x+1])
>>  z_co = float(z_value[x])-float(z_value[x+1])
>>  data = math.sqrt(x_co)*(x_co)+(y_co)*(y_co)+(z_co)*(z_co)
>>  print data
>> ~
>> and the error ,message
>>  File "pdb_fetching.py", line 22, in ?
>> x_co = float(x_value[x])-float(x_value[x+1])
>> IndexError: list index out of range
>>
>>
>> can you suggest me the mistake i have made
>>
> suppose you have an x_value list of length 6. Valid indexes go from 0 to 
> 5. Then x is going to start at 0 and go up to 5. The last time around 
> the loop the expression "x_value[x+1]" is going to try and use 6 as an 
> index, thus trying to address past the end of the list.
> 
> Since the data values are the RMS differences between successive points, 
> there are only five differences for a six-element list.
> 
> Try using
> 
>  for x in range(len(x_value)-1):
> 
> instead.
> 
> By the way, you presented your question very well - all necessary 
> information was there, and you didn't put in any mistaken guesses about 
> what might be going wrong. Well done, and welcome to Python! You will 
> find you can learn it very quickly.
> 
> regards
>   Steve
-- 
http://mail.python.org/mailman/listinfo/python-list


File access

2007-08-02 Thread JD
Hi,

What I am trying to do is to run a subprocess on another machine using
subprocess.Popen, this subprocess contuinue writing something into a
file when it is runing.

After submit this subprocess, I tried to open the file and readlines()
in the loop (with a delay) in the loop) when the subprocess was
runing.

The problem is I could not get anything untill the subprocess
finished.

I also tried to run another python programm when the subprocess is
runing, I could get what I want.

Does anyone know why? Thanks!

JD

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


Re: a dict trick

2007-08-02 Thread Michael J. Fromberger
In article <[EMAIL PROTECTED]>,
 james_027 <[EMAIL PROTECTED]> wrote:

> hi
> 
> for example I have this dictionary
> 
> dict = {'name':'james', 'language':'english'}
> 
> value = 'sex' in dict and dict['sex'] or 'unknown'
> 
> is a right pythonic of doing this one? I am trying to get a value from
> the dict, but if the key doesn't exist I will provide one.

Hi, James,

You might prefer:

  d = {'name': 'James', 'language': 'English'}

  value = d.get('sex', 'unknown')

This accomplishes what your above code does, using a method of the 
built-in dict object.

If you also wish to ADD the new value to the dictionary, you may also 
use the following:

  value = d.setdefault('sex', 'unknown')

This returns the same value as the above, but also adds the key 'sex' to 
the dictionary as a side-effect, with value 'unknown'.

Cheers,
-M

-- 
Michael J. Fromberger | Lecturer, Dept. of Computer Science
http://www.dartmouth.edu/~sting/  | Dartmouth College, Hanover, NH, USA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: standalone process to interact with the web

2007-08-02 Thread Diez B. Roggisch
Bruno Desthuilliers schrieb:
> beginner a écrit :
>> On Aug 1, 5:04 am, Bruno Desthuilliers > [EMAIL PROTECTED]> wrote:
>>> beginner a écrit :
>>> (snip)
>>>
 Yes exactly. I just don't want to reinvent the wheel as I imagine
 there are already tons of libraries and frameworks that support RPC or
 the like functions.
>>> Why go thru the pain of RPC, SOAP or such bloated horrors ? Why not just
>>> use plain old HTTP with a RESTful API ? Then you just need to make your
>>> app wsgi compliant.
>>
>> I am not familiar with RESTful API. I will look into it.
>>
> It's nothing else than the correct use of the HTTP protocol. And it's 
> much more simpler than all those XMLRPC, SOAP and whatnot monstruosities.

While I'm with you regarding the monstrosity of SOAP, XMLRPC certainly 
isn't among the crappy IPC-protocols. Using it, you get type marshalling 
for some simple, yet important cases for free. Including such things as 
argument-order, and ordered values. Which for example make transmitting 
a dict a trivial operation of transmitting the two sequences of key/values.

I don't see that with REST.

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


Re: Wing IDE for Python v. 3.0 beta1 released

2007-08-02 Thread John K Masters
On 08:00 Thu 02 Aug , [EMAIL PROTECTED] wrote:
> On Aug 1, 6:42 pm, John K Masters <[EMAIL PROTECTED]> wrote:
> > To suggest that, because the autocompletion worked on one method of a
> > module and not on another was because I had not configured the
> > PYTHONPATH properly is at least insulting.
> 
> We certainly didn't intend to be insulting.  This it the most common
> cause of
> auto-completion problems but you are right that it's a mis-diagnosis
> on our
> part if it was just one method.  We respond to sometimes hundreds of
> emails
> a day ,so we do make mistakes.
> 
> It may be solved by using Reanalyze File from the right-click context
> menu
> on the editor but there's no gaurantee.  This is incredibly complex
> code with
> many layers of highly optimized tokenizing, analysis, inference,
> caching,
> and then display in the various tools in Wing so it often takes a bit
> more time
> to find where the bug is.
> 
> By the way, Wing 3.0 beta1 fixes a number of bugs that would lead to
> bad analysis, including missing methods as a result of failure to
> track edits in a file properly.  It also improves reading completion
> info
> out of extension modules and properly handles several forms of
> import where it fell on its face previously.
> 
> Hope that's useful... please let me know if not.
> 
> - Stephan
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list

This is the point at which I eat cartloads of humble pie and crawl
backwards out of the room muttering my apologies. Not only had I sent my
email to Wingware, I had mis-spelled it. The good people at Wingware
kindly emailed me following my post here. 

My only (feeble) excuse is that I have just lost the backspace key in my
vim config and it's causing me loads of problems when I write emails. 

Once again I apologise profusely. I shall certainly purchase wingware
and will not hesitate to recommend it.

Regards, John
-- 
War is God's way of teaching Americans geography
Ambrose Bierce (1842 - 1914)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: i am new to python-Please somebody help

2007-08-02 Thread Terry Reedy

"gregarican" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| friendly than Python's. Your points are well-taken in how to properly
| post and how to do your own homework. Message correct. Delivery
| lacking...

Sorry, I saw nothing rude in Steven's straightforward and indeed polite 
suggestion.  Your post, however, 

tjr



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


Re: File access

2007-08-02 Thread Adrian Petrescu
On Aug 2, 12:41 pm, JD <[EMAIL PROTECTED]> wrote:
> Hi,
>
> What I am trying to do is to run a subprocess on another machine using
> subprocess.Popen, this subprocess contuinue writing something into a
> file when it is runing.
>
> After submit this subprocess, I tried to open the file and readlines()
> in the loop (with a delay) in the loop) when the subprocess was
> runing.
>
> The problem is I could not get anything untill the subprocess
> finished.
>
> I also tried to run another python programm when the subprocess is
> runing, I could get what I want.
>
> Does anyone know why? Thanks!
>
> JD

Could the problem be that the subprocess only flushes the output
buffer when it terminates, and so until the subprocess "finishes", as
you say, the file is empty because the data is still in the buffer?
Trying throwing some flushes into the code and see if it helps.

Or am I misunderstanding your question?

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


Re: File access

2007-08-02 Thread JD
Thanks for answering,

No, the data was writing into the file when the subprocess was
runing.

For example, every second it will write something into the file.

I tried to run another python program aside and it sucessfully read
the file when the subprocess was runing.

JD

On Aug 2, 11:00 am, Adrian Petrescu <[EMAIL PROTECTED]> wrote:
> On Aug 2, 12:41 pm, JD <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
>
> > What I am trying to do is to run a subprocess on another machine using
> > subprocess.Popen, this subprocess contuinue writing something into a
> > file when it is runing.
>
> > After submit this subprocess, I tried to open the file and readlines()
> > in the loop (with a delay) in the loop) when the subprocess was
> > runing.
>
> > The problem is I could not get anything untill the subprocess
> > finished.
>
> > I also tried to run another python programm when the subprocess is
> > runing, I could get what I want.
>
> > Does anyone know why? Thanks!
>
> > JD
>
> Could the problem be that the subprocess only flushes the output
> buffer when it terminates, and so until the subprocess "finishes", as
> you say, the file is empty because the data is still in the buffer?
> Trying throwing some flushes into the code and see if it helps.
>
> Or am I misunderstanding your question?


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


problems playing with dates from any month.

2007-08-02 Thread krishnakant Mane
hello,
I have a very strange problem and I can't find any solution for that.
I am working on an accounting package which I wish to develop in python.
the simple problem is that I want to knoe how I can know if the given
date is the nth day of a month.
for example if a customer is supposed to pay his installment on every
5th of all months,
I want to know if today is the fifth day (jan the fifth, feb the fifth
etc) for any given month.
I have not found any such function.
if I have looked (or over looked ) in the wrong places I am really sorry.
secondly I also want to know the way in which I can convert a given
string to a date object.
for example if I have a string "29/09/2005", I know it is a valid date
although it is in a string form.
now I want to convert the above string into a real date object.
how can I cast it this way?
regards,
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Emacs + python

2007-08-02 Thread Greg Donald
On 8/1/07, hg <[EMAIL PROTECTED]> wrote:
> Are there any cscope & ECB equivalent for Python ?

ECB is not language specific.  It works the same for browsing Python
code as any other language.


-- 
Greg Donald
http://destiney.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problems playing with dates from any month.

2007-08-02 Thread Ian Clark
krishnakant Mane wrote:
> hello,
> I have a very strange problem and I can't find any solution for that.
> I am working on an accounting package which I wish to develop in python.
> the simple problem is that I want to knoe how I can know if the given
> date is the nth day of a month.
> for example if a customer is supposed to pay his installment on every
> 5th of all months,
> I want to know if today is the fifth day (jan the fifth, feb the fifth
> etc) for any given month.
> I have not found any such function.
> if I have looked (or over looked ) in the wrong places I am really sorry.
> secondly I also want to know the way in which I can convert a given
> string to a date object.
> for example if I have a string "29/09/2005", I know it is a valid date
> although it is in a string form.
> now I want to convert the above string into a real date object.
> how can I cast it this way?
> regards,
> Krishnakant.

http://docs.python.org/lib/node85.html

Then it's just:

if date_obj.day == 5:
 print 'It's the fifth day of the month'

Ian

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


Email

2007-08-02 Thread Rohan
I was wondering if there could be an arrangement where a file could be
attached and send as an email.
For ex
f = open(add.txt,w)
f.write('python')
f.close()

Now I would like to send an email with add.txt as an attachment, is it
possible ?
some one give me a pointer towards this.

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


Re: problems playing with dates from any month.

2007-08-02 Thread kyosohma
On Aug 2, 12:31 pm, "krishnakant Mane" <[EMAIL PROTECTED]> wrote:
> hello,
> I have a very strange problem and I can't find any solution for that.
> I am working on an accounting package which I wish to develop in python.
> the simple problem is that I want to knoe how I can know if the given
> date is the nth day of a month.
> for example if a customer is supposed to pay his installment on every
> 5th of all months,
> I want to know if today is the fifth day (jan the fifth, feb the fifth
> etc) for any given month.
> I have not found any such function.
> if I have looked (or over looked ) in the wrong places I am really sorry.
> secondly I also want to know the way in which I can convert a given
> string to a date object.
> for example if I have a string "29/09/2005", I know it is a valid date
> although it is in a string form.
> now I want to convert the above string into a real date object.
> how can I cast it this way?
> regards,
> Krishnakant.

You should also check this place out: http://labix.org/python-dateutil

Lots of cool date manipulation using the dateutil module.

Mike

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


Re: problems playing with dates from any month.

2007-08-02 Thread krishnakant Mane
On 02/08/07, Ian Clark <[EMAIL PROTECTED]> wrote:

>
> http://docs.python.org/lib/node85.html
>
I looked there even before.
but could not figure out what the code did.
I know in that variable called s there was a string in a valid date format.
but when datetime.strptime was used, I did not understand the place
where a date object say d was created.
I would expect some thing like d = and the function.  but I did not fine that.
only reference was the datetime module and the documentation is not as good.
another question I am getting is that where is the list of all
formatting characters.  like for example Y is 4 digit year M is month
MM is month in 2 digits etc.
I am trying to locate a list of all these denoters.
can you provide me the place?


> Then it's just:
>
> if date_obj.day == 5:
>  print 'It's the fifth day of the month'
>
this was much better than the documentation, thanks,
regards,
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: File access

2007-08-02 Thread Larry Bates
JD wrote:
> Hi,
> 
> What I am trying to do is to run a subprocess on another machine using
> subprocess.Popen, this subprocess contuinue writing something into a
> file when it is runing.
> 
> After submit this subprocess, I tried to open the file and readlines()
> in the loop (with a delay) in the loop) when the subprocess was
> runing.
> 
> The problem is I could not get anything untill the subprocess
> finished.
> 
> I also tried to run another python programm when the subprocess is
> runing, I could get what I want.
> 
> Does anyone know why? Thanks!
> 
> JD
> 

I believe you are approaching this incorrectly.  You should probably be using a
socket server/socket client to communicate between these two.  Or perhaps you
could use a multi-user database table.  Writing/reading to files from two
different workstations and expecting them to by synchronized most likely won't 
work.

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


Re: python 3.0, pywin32 and scipy

2007-08-02 Thread Terry Reedy

"vml" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| I am trying to promote python in my job, my collegue only see matlab
| and microsoft scripting language.
| I understood that there willl be no backward compatibility between
| python 2.x and 3.0, does it means that:

Most of the basic language and syntax will be unchanged.  Many to most of 
the new features will be introduced in 2.6 also so you can add their usage 
gradually, as needed, without converting everything.  Most of the 
incompatibilities between 2.6+ and 3.0+ will be handled by 2to3.py.

| - my script using pywin32 for the COM layer and scipy for the maths
| won't work under 3.0
| - will we have the equivalent of pywin32 and scipy in python ?

As with all 3rd party addons, that will depend on the authors or author 
groups.  The same is true today for every new release, especially in 
regards to Windows binaries.

| I will be incharge of designing a python module which will be a
| 'matrix calculator' in our current software. Will it be compatible
| with python 3.0 ? I guess no.

But you will be able to use it *and distribute it* with Python2.5 
indefinitely.  Some people still run 1.5.2 code with the nearly decade old 
1.5.2 interpreter.  And I expect that there will be people running 2.5 code 
with Py2.5 a decade or more from now.

The PSF still distributes versions back to about the first.  Compare this 
with Microsoft pulling from distrubution the free version of VC2003 early 
in 2006, while maintaining the prohibition on anyone else distributing it. 
This has been a MAJOR nuisance for new Python-C-Windows developers who did 
not download it in time.

| What can I answer to my collegue who will say 'Python is changing and
| the stuff you are doing now is useless'?

Short answer: stuff that is useful now will continue to be useful until 
requirements change.

A possible longer answer: Google continues to make major use of Python 
without handcuffing themselves with such misunderstandings.  They hired 
Python's main developer both to write Python code for internal use and to 
continue Python's development as he saw fit.  They will be a test site for 
both the conversion process and the usability of the new version, giving 
Guido face-to-face feedback.  When both are good enough for Google's 
developers, they should be good enough for most of the rest of us too.

Terry Jan Reedy



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


  1   2   >