Re: performance of tight loop

2010-12-13 Thread Ryan Kelly
On Tue, 2010-12-14 at 08:08 +0100, Ulrich Eckhardt wrote:
> Steven D'Aprano wrote:
> > Replacing "while True" with "while 1" may save a tiny bit of overhead.
> > Whether it is significant or not is another thing.
> 
> Is this the price for an intentional complexity or just a well-known
> optimizer deficiency?

At least on older pythons, you can assign to the name "True" so it's not
possible to optimize that loop - you must look up the name "True" on
each iteration.  For example, in python 2.6 this loop will exit after
one iteration:


>>> while True:
... True = False
...
>>>

To see the difference, take a look at the bytecode python generators for
the type types of loop:


>>> import dis
>>> def while1():
... while 1:
... pass
... 
>>> def whileTrue():
... while True:
... pass
... 
>>> dis.dis(while1)
  2   0 SETUP_LOOP   3 (to 6)

  3 >>3 JUMP_ABSOLUTE3
>>6 LOAD_CONST   0 (None)
  9 RETURN_VALUE
>>>
>>> dis.dis(whileTrue)
  2   0 SETUP_LOOP  12 (to 15)
>>3 LOAD_GLOBAL  0 (True)
  6 JUMP_IF_FALSE4 (to 13)
  9 POP_TOP 

  3  10 JUMP_ABSOLUTE3
>>   13 POP_TOP 
 14 POP_BLOCK
>>   15 LOAD_CONST   0 (None)
 18 RETURN_VALUE
   >>> 


Still, I just can't bring myself to write "while 1" in favour of "while
True" in code.


Python 3 does away with this madness entirely:


>>> while True:
... True = False
... 
  File "", line 2
SyntaxError: assignment to keyword
>>> 

Looking at the bytecode shows that in Python 3, "while 1" and "while
True" are indeed identical.


  Cheers,

 Ryan


-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: performance of tight loop

2010-12-13 Thread Ulrich Eckhardt
Steven D'Aprano wrote:
> Replacing "while True" with "while 1" may save a tiny bit of overhead.
> Whether it is significant or not is another thing.

Is this the price for an intentional complexity or just a well-known
optimizer deficiency?

Just curious...

Uli

-- 
Domino Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

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


Re: performance of tight loop

2010-12-13 Thread Ulrich Eckhardt
gry wrote:
> I have a little data generator that I'd like to go faster... any
> suggestions?
> maxint is usually 9223372036854775808(max 64bit int), but could
> occasionally be 99.
> width is usually 500 or 1600, rows ~ 5000.
> 
> from random import randint
> 
> def row(i, wd, mx):
> first = ['%d' % i]
> rest =  ['%d' % randint(1, mx) for i in range(wd - 1)]
> return first + rest

A few things here:
 * If you can, don't convert the ints to strings. I'm not 100% sure about
Python 2.4, but newer versions will automatically yield long instead of int
if the range exceeds that of an int, so even with large numbers that should
be safe.
 * Replace range with xrange.
 * Instead of creating and appending lists, you could also use a generator
expression.

> print ','.join(row(i, width, maxint))

All you do here is take a list of strings, build a single string from them
and then print the string. Why not iterate over the list (or, as suggested,
the generator) and print the elements?

Summary: Avoid unnecessary conversions. This includes int to string, but
also logical sequences into arrays.

Uli

-- 
Domino Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

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


Re: Added Python, WSGI to XAMPP

2010-12-13 Thread Gerry Reno
On 12/13/2010 11:13 PM, rusi wrote:
> On Dec 10, 2:29 am, Gerry Reno  wrote:
>   
>> If you have any need of a portable LAMP stack, I just finished writing
>> some How-To's for getting Python, VirtualEnv and WSGI frameworks running
>> with XAMPP:
>>
>> How-To: Add VirtualEnv and Pylons (WSGI framework) to XAMPP
>> 
>>
>> How-To: Add VirtualEnv and Django (WSGI framework) to XAMPP
>> 
>>
>> How-To: Add Python and mod_wsgi to XAMPP
>> 
>>
>> -Gerry
>> 
> What does XAMPP give (on linux) that the distro apache,mysql dont?
>   

It is a portable LAMP stack that is basically independent of your distro. 

If you want to upgrade PHP or Apache or whatever without disturbing your
distro PHP or Apache you can do this. 

If you want to try out cutting edge releases of things you can do this
on XAMPP without bothering your distro. 

It's an environment and what you can do with it is only limited by your
imagination.


-Gerry


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


Re: Added Python, WSGI to XAMPP

2010-12-13 Thread rusi
On Dec 10, 2:29 am, Gerry Reno  wrote:
> If you have any need of a portable LAMP stack, I just finished writing
> some How-To's for getting Python, VirtualEnv and WSGI frameworks running
> with XAMPP:
>
> How-To: Add VirtualEnv and Pylons (WSGI framework) to XAMPP
> 
>
> How-To: Add VirtualEnv and Django (WSGI framework) to XAMPP
> 
>
> How-To: Add Python and mod_wsgi to XAMPP
> 
>
> -Gerry

What does XAMPP give (on linux) that the distro apache,mysql dont?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: performance of tight loop

2010-12-13 Thread Steven D'Aprano
On Mon, 13 Dec 2010 18:50:38 -0800, gry wrote:

> [python-2.4.3, rh CentOS release 5.5 linux, 24 xeon cpu's, 24GB ram] I
> have a little data generator that I'd like to go faster... any
> suggestions?
> maxint is usually 9223372036854775808(max 64bit int), but could
> occasionally be 99.
> width is usually 500 or 1600, rows ~ 5000.
> 
> from random import randint
> 
> def row(i, wd, mx):
> first = ['%d' % i]
> rest =  ['%d' % randint(1, mx) for i in range(wd - 1)] 
> return first + rest
> ...
> while True:
> print "copy %s from stdin direct delimiter ',';" % table_name
> for i in range(i,i+rows):
> print ','.join(row(i, width, maxint))
> print '\.'


This isn't entirely clear to me. Why is the while loop indented? I assume 
it's part of some other function that you haven't shown us, rather than 
part of the function row().

Assuming this, I would say that the overhead of I/O (the print commands) 
will likely be tens or hundreds of times greater than the overhead of the 
loop, so you're probably not likely to see much appreciable benefit. You 
might save off a few seconds from something that runs for many minutes. I 
don't see the point, really.

If the print statements are informative rather than necessary, I would 
print every tenth (say) line rather than every line. That should save 
*lots* of time.

Replacing "while True" with "while 1" may save a tiny bit of overhead. 
Whether it is significant or not is another thing.

Replacing range with xrange should also make a difference, especially if 
rows is a large number.

Moving the code from row() inline, replacing string interpolation with 
calls to str(), may also help. Making local variables of any globals may 
also help a tiny bit. But as I said, you're shaving microseconds of 
overhead and spending millseconds printing -- the difference will be tiny.

But for what it's worth, I'd try this:


# Avoid globals in favour of locals.
from random import randint
_maxint = maxint
loop = xrange(i, i+rows)  # Where does i come from?
inner_loop = xrange(width)  # Note 1 more than before.
while 1:
print "copy %s from stdin direct delimiter ',';" % table_name
for i in loop:
row = [str(randint(1, _maxint)) for _ in inner_loop]
row[0] = str(i)  # replace in place
print ','.join(row)
print '\.'



Hope it helps.



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


Re: Catching user switching and getting current active user from root on linux

2010-12-13 Thread Tim Harig
On 2010-12-13, mpnordland  wrote:
> I think I do understand multiuser systems, although I'm sorry I did
> not make my self clear. Yes, I understand that there can be multiple
> people logged in, and yes if you really wanted to, you could login as

Apparantly you do not.  There is nothing that prevents me from downloading
from the web when I am not even at the computer.  The point people are
making is that there is no such thing as a single active user.  Any user
that has a running process is active.  Somebody is not going to appreciate
getting fired because somebody else scheduled a porn download at a time
when they happened to be flagged as the current user.

> yourself as many times as you want. This is not a server based
> program, it is intended for use in a normal environment. The people

There is nothing definitive about a so-called "normal" enviroment and
since you didn't really specify anything, we had go make assumtpions
for ourselves.

Note also that a server is a piece of software, it need not be running
on server class hardware.  There are probably several local servers
running on your system right now.

As is commonly the case, the reason that you are having trouble with this
problem is that you are trying to solve it wrong in the first place.
You told us how you thought you should solve it which meant that we
couldn't help you because we didn't know what problem you were trying to
solve in the first place.  For future reference, always give a 10,000ft
explanation of the problem that you are actually trying to solve rather
then just the microcosm of the problem that you feel is relevant.

> or someone else. The problem I have is I want monitor what sites the
> user visits, I need to know what sites were accessed by which user.
> So, a way to find which user is requesting what url is what I want.

As Carl has already pointed out, an authenticated proxy is the proper
way to get the individualized logging that you are looking for.
It is capable of logging each connection (including software from
which you might not have anticipated) with its own identified user of
origin. Even when several users are accessing the network at once, the
network connections can be tied directly to the person who initated
the connection.  Users cannot use somebody elses connection without
their authentication credentials.

With a little bit of scripting, the browser can be configured to
automatically use the user's credentials whenever the user account is
created so that the user never needs to enter their credentials manually
after logging in to their account.  All connections that attempt to
bypass the proxy should be firewalled.

> Have I passed the Turing test?

You still don't seem to understand how to use threads.  Heres a clue:
find a decent usenet client that actually displays them by default.  Or,
if you can't manage to get rid of that junky interface that is Google
Groups, at least select the option to view as a tree.  Then you might
be able to actually post your replies in the proper thread rather then
just appending on the the person who last posted.
-- 
http://mail.python.org/mailman/listinfo/python-list


performance of tight loop

2010-12-13 Thread gry
[python-2.4.3, rh CentOS release 5.5 linux, 24 xeon cpu's, 24GB ram]
I have a little data generator that I'd like to go faster... any
suggestions?
maxint is usually 9223372036854775808(max 64bit int), but could
occasionally be 99.
width is usually 500 or 1600, rows ~ 5000.

from random import randint

def row(i, wd, mx):
first = ['%d' % i]
rest =  ['%d' % randint(1, mx) for i in range(wd - 1)]
return first + rest
...
while True:
print "copy %s from stdin direct delimiter ',';" % table_name
for i in range(i,i+rows):
print ','.join(row(i, width, maxint))
print '\.'

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


Re: Added Python, WSGI to XAMPP

2010-12-13 Thread Gerry Reno
On 12/13/2010 07:12 PM, Chris Withers wrote:
> On 14/12/2010 00:14, Gerry Reno wrote:
>> On 12/13/2010 06:34 PM, Chris Withers wrote:
>>> On 09/12/2010 21:29, Gerry Reno wrote:
 How-To: Add VirtualEnv and Pylons (WSGI framework) to XAMPP
 
>>
>> Maybe, if there's no Zope.  Or we'll run away screaming...
>
> That is rather pathetically true...
>
> Ah well, each to their own...
>
> Chris
>
What I really don't like right off is that Pyramid is contorting the MVC
model just as Django did with their MTV model.  They are both making the
controller be the view and this confuses the hell out of people who come
from true MVC based projects.

The VIEW is the bits that stream out of the webserver back to the users
browser.  The CONTROLLER is the code that gathers all the pieces from
the model and constructs the python code that is then fed to the engine
that then creates the view.  And just because the controller navigates
the logic to dynamically contruct/render a view, that does not make 'it'
the view.

-Gerry

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


Re: Added Python, WSGI to XAMPP

2010-12-13 Thread Gerry Reno
On 12/13/2010 06:34 PM, Chris Withers wrote:
> On 09/12/2010 21:29, Gerry Reno wrote:
>> How-To: Add VirtualEnv and Pylons (WSGI framework) to XAMPP
>> 
>
> You mean Pyramid, right? ;-)
>
> Chris
>

Maybe, if there's no Zope.  Or we'll run away screaming...

Anyway, Pyramid is still only alpha.  But if it is a true WSGI framework
then as my technique shows it can certainly be made to work with XAMPP.


-Gerry


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


PyArg_ParseTuple question

2010-12-13 Thread Mark Crispin

In a C module, I want to pick up the arguments for a Python call like:
module.call("string1",["string2a", "string2b", "string2c"], "string3")
and stash these into:
char *arg1;
char *arg2[];
char *arg3;
All arguments are required, and we can assume that the arg2 vector is 
terminated with a null pointer.


It doesn't look like PyArg_ParseTuple will do this easily; and that 
instead I have to use either the "O!" format with a PyList prototype, or 
use "O&" and write a converter.


If I use "O!", at what level does it check?  In particular, does it just 
check that the argument is a list, so I can get away with something like:


static PyObject *call(PyObject *self, PyObject *args)
{
char *arg1, **arg2, *arg3;
PyObject *arg2obj;
PyObject *list = PyList_New(0);
PyObject *ret = NULL;
if(PyArg_ParseTuple(args, "sO!s", &arg1, list, &arg2obj, &arg3) {
// grovel over arg2obj to get the number of members and make
//  sure they are all strings
// allocate a big enough arg2
// copy the string pointers.
ret = doMyThing(arg1, arg2, arg3);
}
PyObject_del(list);
return ret;
}

By the way,...

Python has tossed me a couple of curve balls, but all in all it's been 
quite reasonable.  I still haven't read though the Python tutorial (I 
really do need to get up to speed on all the data types), but I've been 
able to get a tremendous amount of work done in a very short period of 
time.


Oh, I've made it SEGV a few times, but these were all blunders in my C 
module, such as a C method returning self to indicate success (oops!).


Python is the best development environment since LISP and SmallTalk nearly 
20 years ago.  Coming from me, that's quite high praise.


-- Mark --

http://panda.com/mrc
Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.
--
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: ActivePython 2.7.1.3 is now available

2010-12-13 Thread Sridhar Ratnakumar

On 2010-12-13, at 4:21 PM, Terry Reedy wrote:

> On 12/13/2010 4:23 PM, Sridhar Ratnakumar wrote:
> 
>>> The PSF 3.1 Windows installer ships with tcl/tk 8.5 and ttk support.
> 
>> Maybe that was changed in 3.1.3.
> 
> No, 3.1 (not sure of 3.0) has always used 8.5 on windows and included
> tkinter.ttk module.

Ok, good to know.

>> I did this for ActivePython 2.7,
>> 
> import Tkinter
> root = Tkinter.Tk()
> root.tk.eval('info patchlevel')
>> '8.5.9'
> 
> 8.5.2 here. Are there noticeable improvements?

Nothing I can think of except module updates and bug fixes[1],
http://wiki.tcl.tk/405

I don't know how dependencies are managed when building PSF installers. From my 
experience, updating to newer tcl/tk patchlevel releases never broke the 
ActivePython build.

-srid

[1] David wanted to use >=8.5.8 due to a specific bug fix, 
http://community.activestate.com/forum/version-859-under-mac-os-x-am-i-getting-it
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: ActivePython 2.7.1.3 is now available

2010-12-13 Thread Terry Reedy

On 12/13/2010 4:23 PM, Sridhar Ratnakumar wrote:


The PSF 3.1 Windows installer ships with tcl/tk 8.5 and ttk support.



Maybe that was changed in 3.1.3.


No, 3.1 (not sure of 3.0) has always used 8.5 on windows and included
tkinter.ttk module.



I did this for ActivePython 2.7,


import Tkinter
root = Tkinter.Tk()
root.tk.eval('info patchlevel')

'8.5.9'


8.5.2 here. Are there noticeable improvements?

--
Terry Jan Reedy

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


Re: Added Python, WSGI to XAMPP

2010-12-13 Thread Chris Withers

On 14/12/2010 00:14, Gerry Reno wrote:

On 12/13/2010 06:34 PM, Chris Withers wrote:

On 09/12/2010 21:29, Gerry Reno wrote:

How-To: Add VirtualEnv and Pylons (WSGI framework) to XAMPP



Maybe, if there's no Zope.  Or we'll run away screaming...


That is rather pathetically true...

Ah well, each to their own...

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
   - http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: Catching user switching and getting current active user from root on linux

2010-12-13 Thread Carl Banks
On Dec 13, 3:04 pm, mpnordland  wrote:
> I think I do understand multiuser systems, although I'm sorry I did
> not make my self clear. Yes, I understand that there can be multiple
> people logged in, and yes if you really wanted to, you could login as
> yourself as many times as you want. This is not a server based
> program, it is intended for use in a normal environment. The people
> using it will probably not be logging in multiple times as themselves,
> or someone else. The problem I have is I want monitor what sites the
> user visits, I need to know what sites were accessed by which user.
> So, a way to find which user is requesting what url is what I want.
> Have I passed the Turing test?

Install a web proxy.

In a pinch you can stat /dev/console to see who the owner is, which I
think was what they did last time I looked.

If you're ambitious there's some stuff you can do with netfilter to
attach user ids to network packets which you might be able to read
with your logging software.  How are you logging web site accesses
anyway?  That would be helpful to know.


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


Re: Added Python, WSGI to XAMPP

2010-12-13 Thread Chris Withers

On 09/12/2010 21:29, Gerry Reno wrote:

How-To: Add VirtualEnv and Pylons (WSGI framework) to XAMPP



You mean Pyramid, right? ;-)

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
   - http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: find memory leaks in running program

2010-12-13 Thread Chris Withers

On 07/12/2010 16:51, Marco Hornung wrote:

1. What are the best tools to analyze pythons memory stack, while it is running?


Look for the heapy stuff in the guppy package.


2. Is there a possibility to analyze the memory stack of a program with 
external programs? (without to change the source code - I am only interested in 
the object size)


heapy is your best bet.


3. Can I sort of "break" into the memory to see what objects consume how much 
memory?


The GC module might help here too, but really, heapy is what you want.

cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
   - http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: Reading by positions plain text files

2010-12-13 Thread javivd
On Dec 12, 11:21 pm, Dennis Lee Bieber  wrote:
> On Sun, 12 Dec 2010 07:02:13 -0800 (PST), javivd
>  declaimed the following in
> gmane.comp.python.general:
>
>
>
> > f = open(r'c:c:\somefile.txt', 'w')
>
> > f.write('0123456789\n0123456789\n0123456789')
>
>         Not the most explanatory sample data... It would be better if the
> records had different contents.
>
> > f.close()
>
> > f = open(r'c:\somefile.txt', 'r')
>
> > for line in f:
>
>         Here you extract one "line" from the file
>
> >     f.seek(3,0)
> >     print f.read(1) #just to know if its printing the rigth column
>
>         And here you ignored the entire line you read, seeking to the fourth
> byte from the beginning of the file, andreadingjust one byte from it.
>
>         I have no idea of how seek()/read() behaves relative to line
> iteration in the for loop... Given the small size of the test data set
> it is quite likely that the first "for line in f" resulted in the entire
> file being read into a buffer, and that buffer scanned to find the line
> ending and return the data preceding it; then the buffer position is set
> to after that line ending so the next "for line" continues from that
> point.
>
>         But in a situation with a large data set, or an unbuffered I/O
> system, the seek()/read() could easily result in resetting the file
> position used by the "for line", so that the second call returns
> "456789\n"... And all subsequent calls too, resulting in an infinite
> loop.
>
>         Presuming the assignment requires pulling multiple selected fields
> from individual records, where each record is of the same
> format/spacing, AND that the field selection can not be preprogrammed...
>
> Sample data file (use fixed width font to view):
> -=-=-=-=-=-
> Wulfraed       09Ranger  1915
> Bask Euren     13Cleric  1511
> Aethelwulf     07Mage    0908
> Cwiculf        08Mage    1008
> -=-=-=-=-=-
>
> Sample format definition file:
> -=-=-=-=-=-
> Name    0-14
> Level   15-16
> Class   17-24
> THAC0   25-26
> Armor   27-28
> -=-=-=-=-=-
>
> Code to process (Python 2.5, with minimal error handling):
> -=-=-=-=-=-
>
> class Extractor(object):
>     def __init__(self, formatFile):
>         ff = open(formatFile, "r")
>         self._format = {}
>         self._length = 0
>         for line in ff:
>             form = line.split("\t") #file must be tab separated
>             if len(form) != 2:
>                 print "Invalid file format definition: %s" % line
>                 continue
>             name = form[0]
>             columns = form[1].split("-")
>             if len(columns) == 1:   #single column definition
>                 start = int(columns[0])
>                 end = start
>             elif len(columns) == 2:
>                 start = int(columns[0])
>                 end = int(columns[1])
>             else:
>                 print "Invalid column definition: %s" % form[1]
>                 continue
>             self._format[name] = (start, end)
>             self._length = max(self._length, end)
>         ff.close()
>
>     def __call__(self, line):
>         data = {}
>         if len(line) < self._length:
>             print "Data line is too short for required format: ignored"
>         else:
>             for (name, (start, end)) in self._format.items():
>                 data[name] = line[start:end+1]
>         return data
>
> if __name__ == "__main__":
>     FORMATFILE = "SampleFormat.tsv"
>     DATAFILE = "SampleData.txt"
>
>     characterExtractor = Extractor(FORMATFILE)
>
>     df = open(DATAFILE, "r")
>     for line in df:
>         fields = characterExtractor(line)
>         for (name, value) in fields.items():
>             print "Field name: '%s'\t\tvalue: '%s'" % (name, value)
>         print
>
>     df.close()
> -=-=-=-=-=-
>
> Output from running above code:
> -=-=-=-=-=-
> Field name: 'Armor'             value: '15'
> Field name: 'THAC0'             value: '19'
> Field name: 'Level'             value: '09'
> Field name: 'Class'             value: 'Ranger  '
> Field name: 'Name'              value: 'Wulfraed       '
>
> Field name: 'Armor'             value: '11'
> Field name: 'THAC0'             value: '15'
> Field name: 'Level'             value: '13'
> Field name: 'Class'             value: 'Cleric  '
> Field name: 'Name'              value: 'Bask Euren     '
>
> Field name: 'Armor'             value: '08'
> Field name: 'THAC0'             value: '09'
> Field name: 'Level'             value: '07'
> Field name: 'Class'             value: 'Mage    '
> Field name: 'Name'              value: 'Aethelwulf     '
>
> Field name: 'Armor'             value: '08'
> Field name: 'THAC0'             value: '10'
> Field name: 'Level'             value: '08'
> Field name: 'Class'             value: 'Mage    '
> Field name: 'Name'              value: 'Cwiculf        '
> -=-=-=-=-=-
>
>         Note that string fields have not been trimmed, also numeric fields
> are still intextformat... The format definition

Re: "Download/windows" site page

2010-12-13 Thread Cristian Consonni
2010/12/13 Martin v. Loewis :
[...]
>> It is not mentioned "Windows 7".
>>
>> Is there some problem with 7 or it is simply an omission?
>
> It's simply an omission. You'll notice that Windows 2003 and Windows
> 2008, as well as Windows 2003 R2 and Windows 2008R2 are omitted as
> well. Likely, Python also works on Windows Media Center Edition, which
> is also omitted.
>
>> So, may somebody fix that?
>
> I'd rather not fix it by adding all product names that Microsoft has
> used for Windows. How about "Microsoft Windows (XP and later releases)"?

Sounds as a reasonable solution to me. Thank you.

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


Tkinter's unbind method

2010-12-13 Thread Emeka
Hello All
I have an uncompleted version of a game http://pastebin.com/gkhTaYPZ   I am
trying to code I have struggled to make method unbind work. But it has
refused to listen to me. Could someone come to my help?

Regards,
Emeka

http://pastebin.com/gkhTaYPZ
-- 
*Satajanus  Nig. Ltd


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


Re: Catching user switching and getting current active user from root on linux

2010-12-13 Thread mpnordland
I think I do understand multiuser systems, although I'm sorry I did
not make my self clear. Yes, I understand that there can be multiple
people logged in, and yes if you really wanted to, you could login as
yourself as many times as you want. This is not a server based
program, it is intended for use in a normal environment. The people
using it will probably not be logging in multiple times as themselves,
or someone else. The problem I have is I want monitor what sites the
user visits, I need to know what sites were accessed by which user.
So, a way to find which user is requesting what url is what I want.
Have I passed the Turing test?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Download/windows" site page

2010-12-13 Thread Martin v. Loewis
Am 13.12.2010 23:38, schrieb Cristian Consonni:
> Dear all,
> 
> I'm not sure this is the right place to point this out, but on this page:
> 
> http://www.python.org/download/windows/
> 
> It is not mentioned "Windows 7".
> 
> Is there some problem with 7 or it is simply an omission?

It's simply an omission. You'll notice that Windows 2003 and Windows
2008, as well as Windows 2003 R2 and Windows 2008R2 are omitted as
well. Likely, Python also works on Windows Media Center Edition, which
is also omitted.

> So, may somebody fix that?

I'd rather not fix it by adding all product names that Microsoft has
used for Windows. How about "Microsoft Windows (XP and later releases)"?

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


"Download/windows" site page

2010-12-13 Thread Cristian Consonni
Dear all,

I'm not sure this is the right place to point this out, but on this page:

http://www.python.org/download/windows/

It is not mentioned "Windows 7".

Is there some problem with 7 or it is simply an omission?
A friend of mine is refusing to install python on his machine because
"it does not say it is compatible with Windows 7" (sic).

So, may somebody fix that?

Thanks in advance.

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


Re: Sage's Python

2010-12-13 Thread Rhodri James

On Fri, 10 Dec 2010 17:11:55 -, Akand Islam  wrote:


In my system (Ubuntu 10.04) there are sage-4.6, python 2.6.5, tk8.5-
dev installed. When I give command from terminal "sage -f
python-2.6.5.p8" to get sage's python it shows following message:

 No command 'sage' found, did you mean:
 Command 'save' from package 'atfs' (universe)
 Command 'page' from package 'tcllib' (universe)
 sage: command not found

How can I get Sage's python to be worked so that I can import sage.all
in python shell?


The fact that you have no executable called "sage" suggests that you  
haven't actually installed it yet.  Check the Sage website, which has  
plenty of documentation, and try to figure out where you left the path on  
whichever method you used.


--
Rhodri James *-* Wildebeest Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


Re: run a function in another processor in python

2010-12-13 Thread News123
On 12/09/2010 10:54 AM, Astan Chee wrote:
> Hi,
> I've got a python script that calls a function many times with various
> arguments and returns a result. What I'm trying to do is run this
> function each on different processors and compile the result at the
> end based on the function result. The script looks something like
> this:
> 
> 
You could look at the multiprocessing module of
pythonhttp://docs.python.org/library/multiprocessing.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exception handling in Python 3.x

2010-12-13 Thread Arnaud Delobelle
Ethan Furman  writes:

> Ethan Furman wrote:
>> Arnaud Delobelle wrote:
>>>
>>> I missed the start of this discussion but there are two simpler ways:
>>>
>>> def func(iterable):
>>> for x in iterable:
>>> print(x)
>>> return
>>> raise ValueError("... empty iterable")
>>
>>
>> For the immediate case this is a cool solution.
>
>
> Drat -- I have to take that back -- the OP stated:
>
>> The intention is:
>>
>> * detect an empty iterator by catching StopIteration;
>> * if the iterator is empty, raise a ValueError;
>> * otherwise process the iterator.
>
>
> Presumably, the print(x) would be replaced with code that processed
> the entire iterable (including x, of course), and not just its first
> element.

As I had stated before, I didn't where the discussion started from.  I
replied to code posted by Steven D'Aprano and Paul Rubin.  My code
snippet was equivalent in functionality to theirs, only a little
simpler.

Now if one wants to raise an exception if an iterator is empty, else
process it somehow, it must mean that the iterator needs to have at
least one element for the processing to be meaningful and so it can be
thought of as a function of one element and of one iterator:

process(first, others)

which never needs to raise an exception (at least related to the number
of items in the iterator).  Therefore you can write your function as
follows: 

def func(iterable):
iterator = iter(iterable)
for first in iterable:
return process(first, iterator)
else:
raise ValueError("need non-empty iterable")

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


Re: Request for feedback on API design

2010-12-13 Thread Ethan Furman

Steven D'Aprano wrote:

I am soliciting feedback regarding the API of my statistics module:

http://code.google.com/p/pycalcstats/


Specifically the following couple of issues:

(1) Multivariate statistics such as covariance have two obvious APIs:

A pass the X and Y values as two separate iterable arguments, e.g.: 
  cov([1, 2, 3], [4, 5, 6])


B pass the X and Y values as a single iterable of tuples, e.g.:
  cov([(1, 4), (2, 5), (3, 6)]

I currently support both APIs. Do people prefer one, or the other, or 
both? If there is a clear preference for one over the other, I may drop 
support for the other.




Don't currently need/use stats, but B seems clearer to me.

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


Re: ANN: ActivePython 2.7.1.3 is now available

2010-12-13 Thread Sridhar Ratnakumar

On 2010-12-13, at 11:50 AM, Terry Reedy wrote:

> On 12/13/2010 1:48 PM, Sridhar Ratnakumar wrote:
> 
>> We generally build with the latest compatible version of extensions
>> (except for Tcl/Tk on 2.5/2.6/3.1 as python.org still uses 8.4) ...
> 
> The PSF 3.1 Windows installer ships with tcl/tk 8.5 and ttk support.
> You ought to too.

ActivePython (APy) 2.5+/3.1+ already use Tcl/Tk 8.5 ... I was referring to the 
PSF installers (hence the mismatch in versions between APy and PSF). Maybe that 
was changed in 3.1.3.

>> but that should not be an issue with 2.7 as I believe that the
>> python.org MSI installer is now using Tcl/Tk 8.5 (albeit with an
>> older patch-level version?) to support the new `ttk` module in 2.7+.
> 
> For 3.1.3 and 3.2, the tcl/tk85.libs are dated 8/28/2010. Don't know what 
> that means though.

I did this for ActivePython 2.7,

>>> import Tkinter
>>> root = Tkinter.Tk()
>>> root.tk.eval('info patchlevel')
'8.5.9'
>>>

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


Re: Exception handling in Python 3.x

2010-12-13 Thread Ethan Furman

Ethan Furman wrote:

Arnaud Delobelle wrote:


I missed the start of this discussion but there are two simpler ways:

def func(iterable):
for x in iterable:
print(x)
return
raise ValueError("... empty iterable")



For the immediate case this is a cool solution.



Drat -- I have to take that back -- the OP stated:

> The intention is:
>
> * detect an empty iterator by catching StopIteration;
> * if the iterator is empty, raise a ValueError;
> * otherwise process the iterator.


Presumably, the print(x) would be replaced with code that processed the 
entire iterable (including x, of course), and not just its first element.


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


Re: Is there any way to SSH from Python ?!

2010-12-13 Thread Godson Gera
On Mon, Dec 13, 2010 at 10:33 AM, Darshak Bavishi  wrote:

> Hi Experts,
>
> I need to know that is there any way to SSH (From Windows Host) to Unix
> machine ?!
>
> If Yes than How ?
>
> Because when i use telenet it not showing the no result !! As earlier it
> was suggested that i should try with exit first and than read_all()
> but still issue persist and getting hang
>
> import getpass
> import sys
> import telnetlib
> import time
> HOST = "*.*.*.*"
> #user = raw_input("Enter your remote account: ")
> #password = getpass.getpass()
> user = "Darshak2"
> password = ""
> tn = telnetlib.Telnet(HOST , 5400)
> print "1"
> tn.read_until("login:" , 5)
> print "2"
> tn.write(user + "\n")
> print "3"
> if password:
> tn.read_until("Password: ")
> tn.write(password + "\n")
>
> print "4"
> tn.write("set alarm = off" + "\n")
> tn.write("set event = off" + "\n")
> print "5"
> tn.write("Cd
> /Office-Parameters/Mobility-Config-Parameters/Subscriber-Query-by-IMSI-MSISDN-or-IMEI"
> + "\n")
> print "6"
> tn.write("\n")
> tn.write("\n")
> tn.write("vlrsubquery msisdn=***" + "\n")
> tn.write("\n")
> tn.write("exit" + "\n")
> print tn.read_all()
> tn.close()
>
> --
> BR
> Darshak Bavishi
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>

you can try read_very_eager() which won't block. Twisted has complete
support for SSH check it out http://twistedmatrix.com

-- 
Thanks & Regards,
Godson Gera
Asterisk Consultant India 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exception handling in Python 3.x

2010-12-13 Thread Ethan Furman

Ethan Furman wrote:

Please don't top-post.

Rob Richardson wrote:


-Original Message-


I missed the start of this discussion but there are two simpler ways:

def func(iterable):
for x in iterable:
print(x)
return
raise ValueError("... empty iterable")

Or using 3.x's next's optional second argument:

_nonext=object()
def func(iterable):
x = next(iter(iterable), _nonext)
if x is _nonext:
raise ValueError("... empty iterable")
print(x)



 > Arnaud,
 >
 > Wouldn't your first suggestion exit after the first element in
 > iterable?

No, it hit's return instead.


Doh -- Yes, it does.

It seems both solutions only get the first element, not all elements in 
the iterator...


Maybe this instead:

def func(iterable):
for x in iterable:
break
else:
raise ValueError("... empty iterable")
for xx in chain((x, ), iterable):
process(xx)

Can't say as I care for this -- better to fix the unwanted nesting in 
the tracebacks from raise.


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


Re: Exception handling in Python 3.x

2010-12-13 Thread Ethan Furman

Arnaud Delobelle wrote:


I missed the start of this discussion but there are two simpler ways:

def func(iterable):
for x in iterable:
print(x)
return
raise ValueError("... empty iterable")



For the immediate case this is a cool solution.

Unfortunately, it doesn't fix the unwanted nesting of exceptions problem.

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


Re: Exception handling in Python 3.x

2010-12-13 Thread Arnaud Delobelle
"Rob Richardson"  writes:

You shouldn't top-post!

> Arnaud,
>
> Wouldn't your first suggestion exit after the first element in iterable?

Yes, after printing that element, which is what the code I quoted did.

> And would your second suggestion throw an exception after normal
> processing of all elements in the interator?

No. It would have the same behaviour as the first one.

> RobR
>
> -Original Message-
>
>
> I missed the start of this discussion but there are two simpler ways:
>
> def func(iterable):
> for x in iterable:
> print(x)
> return
> raise ValueError("... empty iterable")
>
> Or using 3.x's next's optional second argument:
>
> _nonext=object()
> def func(iterable):
> x = next(iter(iterable), _nonext)
> if x is _nonext:
> raise ValueError("... empty iterable")
> print(x)
>
> -- 
> Arnaud

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


Re: Exception handling in Python 3.x

2010-12-13 Thread Ethan Furman

Please don't top-post.

Rob Richardson wrote:


-Original Message-


I missed the start of this discussion but there are two simpler ways:

def func(iterable):
for x in iterable:
print(x)
return
raise ValueError("... empty iterable")

Or using 3.x's next's optional second argument:

_nonext=object()
def func(iterable):
x = next(iter(iterable), _nonext)
if x is _nonext:
raise ValueError("... empty iterable")
print(x)



> Arnaud,
>
> Wouldn't your first suggestion exit after the first element in
> iterable?

No, it hit's return instead.

> And would your second suggestion throw an exception after normal
> processing of all elements in the interator?

Looks like the second solution doesn't process the entire iterable, just 
it's first element.


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


Re: Request for feedback on API design

2010-12-13 Thread Arnaud Delobelle
Steven D'Aprano  writes:

> I am soliciting feedback regarding the API of my statistics module:
>
> http://code.google.com/p/pycalcstats/
>
>
> Specifically the following couple of issues:
>
> (1) Multivariate statistics such as covariance have two obvious APIs:
>
> A pass the X and Y values as two separate iterable arguments, e.g.: 
>   cov([1, 2, 3], [4, 5, 6])
>
> B pass the X and Y values as a single iterable of tuples, e.g.:
>   cov([(1, 4), (2, 5), (3, 6)]
>
> I currently support both APIs. Do people prefer one, or the other, or 
> both? If there is a clear preference for one over the other, I may drop 
> support for the other.
>

I don't have an informed opinion on this.

> (2) Statistics text books often give formulae in terms of sums and 
> differences such as
>
> Sxx = n*Σ(x**2) - (Σx)**2

Interestingly, your Sxx is closely related to the variance:

if x is a list of n numbers then

Sxx == (n**2)*var(x)

And more generally if x and y have the same length n, then Sxy (*) is
related to the covariance

Sxy == (n**2)*cov(x, y)

So if you have a variance and covariance function, it would be redundant
to include Sxx and Sxy.  Another argument against including Sxx & co is
that their definition is not universally agreed upon.  For example, I
have seen

Sxx = Σ(x**2) - (Σx)**2/n

HTH

-- 
Arnaud

(*) Here I take Sxy to be  n*Σ(xy) - (Σx)(Σy), generalising from your
definition of Sxx.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Exception handling in Python 3.x

2010-12-13 Thread Rob Richardson
Arnaud,

Wouldn't your first suggestion exit after the first element in iterable?
And would your second suggestion throw an exception after normal
processing of all elements in the interator?

RobR

-Original Message-


I missed the start of this discussion but there are two simpler ways:

def func(iterable):
for x in iterable:
print(x)
return
raise ValueError("... empty iterable")

Or using 3.x's next's optional second argument:

_nonext=object()
def func(iterable):
x = next(iter(iterable), _nonext)
if x is _nonext:
raise ValueError("... empty iterable")
print(x)

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


Re: ANN: ActivePython 2.7.1.3 is now available

2010-12-13 Thread Terry Reedy

On 12/13/2010 1:48 PM, Sridhar Ratnakumar wrote:


We generally build with the latest compatible version of extensions
(except for Tcl/Tk on 2.5/2.6/3.1 as python.org still uses 8.4) ...


The PSF 3.1 Windows installer ships with tcl/tk 8.5 and ttk support.
You ought to too.


but that should not be an issue with 2.7 as I believe that the
python.org MSI installer is now using Tcl/Tk 8.5 (albeit with an
older patch-level version?) to support the new `ttk` module in 2.7+.


For 3.1.3 and 3.2, the tcl/tk85.libs are dated 8/28/2010. Don't know 
what that means though.


Terry Jan Reedy

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


Re: ANN: ActivePython 2.7.1.3 is now available

2010-12-13 Thread python
Sridhar,

> You can find the versions used in ActivePython here,
> http://docs.activestate.com/activepython/2.7/whatsincluded.html

Thank you - that page answered my questions.

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


Re: Exception handling in Python 3.x

2010-12-13 Thread Arnaud Delobelle
Paul Rubin  writes:

> Steven D'Aprano  writes:
>> Apart from this horrible idiom:
>>
>> def func(iterable):
>> it = iter(iterable)
>> failed = False
>> try:
>> x = next(it)
>> except StopIteration:
>> failed = True
>> if failed:
>> raise ValueError("can't process empty iterable")
>> print(x)
>>
>>
>> or similar, is there really no way to avoid these chained exceptions?
>
> Seems like yet another example of people doing messy things with
> exceptions that can easily be done with iterators and itertools:
>
> from itertools import islice
>
> def func(iterable):
>   xs = list(islice(iter(iterable), 1))
>   if len(xs) == 0:
>  raise ValueError(...)
>   print xs[0]
>
> It's really unfortunate, though, that Python 3 didn't offer a way to
> peek at the next element of an iterable and test emptiness directly.

I missed the start of this discussion but there are two simpler ways:

def func(iterable):
for x in iterable:
print(x)
return
raise ValueError("... empty iterable")

Or using 3.x's next's optional second argument:

_nonext=object()
def func(iterable):
x = next(iter(iterable), _nonext)
if x is _nonext:
raise ValueError("... empty iterable")
print(x)

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


Re: Directly calling python's function arguments dispatcher

2010-12-13 Thread Pascal Chambon

Le 12/12/2010 23:41, Peter Otten a écrit :

Pascal Chambon wrote:


   

I've encountered several times, when dealing with adaptation of function
signatures, the need for explicitly resolving complex argument sets into
a simple variable mapping. Explanations.


Consider that function:

def foo(a1, a2, *args, **kwargs):
  pass

calling foo(1, a2=2, a3=3)

will map these arguments to local variables like these:
{
'a1': 1,
'a2': 2,
'args': tuple(),
'kwarg's: {'a3': 3}
}

That's a quite complex resolution mechanism, which must handle
positional and keyword arguments, and deal with both collision and
missing argument cases.
 
   

Is that routine exposed to python, somewhere ? Does anybody know a
working implementation here or there ?
 

http://docs.python.org/library/inspect.html#inspect.getcallargs

   

Too sweet  \o/

Thanks a lot,
regards,
Pakal
--
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: ActivePython 2.7.1.3 is now available

2010-12-13 Thread Sridhar Ratnakumar

On 2010-12-13, at 10:38 AM, pyt...@bdurham.com wrote:

> [SRID] Release notes for 2.7.1.3 [...]
> [SRID] - Upgrade to Tcl/Tk 8.5.9 (`changes `_)
> Do the Windows versions of ActivePython 2.7.1.3 have different versions
> of Tcl/Tk, sqlite3(.dll), and/or openssl (_ssl.pyd?) than the python.org
> builds of Python 2.7.1?

You can find the versions used in ActivePython here,
http://docs.activestate.com/activepython/2.7/whatsincluded.html

We generally build with the latest compatible version of extensions (except for 
Tcl/Tk on 2.5/2.6/3.1 as python.org still uses 8.4) ... but that should not be 
an issue with 2.7 as I believe that the python.org MSI installer is now using 
Tcl/Tk 8.5 (albeit with an older patch-level version?) to support the new `ttk` 
module in 2.7+.

Does that answer your query?

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


Re: ANN: ActivePython 2.7.1.3 is now available

2010-12-13 Thread python
Sridhar,

Do the Windows versions of ActivePython 2.7.1.3 have different versions
of Tcl/Tk, sqlite3(.dll), and/or openssl (_ssl.pyd?) than the python.org
builds of Python 2.7.1?

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


ANN: ActivePython 2.7.1.3 is now available

2010-12-13 Thread Sridhar Ratnakumar
ActiveState is pleased to announce ActivePython 2.7.1.3, a complete, 
ready-to-install binary distribution of Python 2.7.

http://www.activestate.com/activepython/downloads

What's New in ActivePython-2.7.1.3
==

*Release date: 6-Dec-2010*

New Features & Upgrades
---

- Upgrade to Python 2.7.1 (`release notes
  `__)
- Upgrade to Tcl/Tk 8.5.9 (`changes `_)
- Security upgrade to openssl-0.9.8q
- [MacOSX] Tkinter now requires ActiveTcl 8.5 64-bit (not Apple's Tcl/Tk 8.5 on
  OSX)
- Upgrade to PyPM 1.2.6; noteworthy changes:

  - New command 'pypm log' to view log entries for last operation
  - Faster startup (performance) especially on Windows.
  - Rewrite of an improved dependency algorithm (#88038)
  - install/uninstall now accepts the --nodeps option
  - 'pypm install ' to directly download and install a .pypm file
  - 'pypm show' improvements
- 'pypm show' shows other installed packages depending on the shown package
- 'pypm show' accepts --rdepends to show the list of dependents
- 'pypm show' shows extra dependencies (for use in the 'install' cmd)
- 'pypm show' lists all available versions in the repository
- 'pypm freeze' to dump installed packages as requirements (like 'pip 
freeze')
  - Support for pip-stye requirements file ('pypm install -r requirements.txt')

- Upgraded the following packages:

  - Distribute-0.6.14
  - pip-0.8.2
  - SQLAlchemy-0.6.5
  - virtualenv-1.5.1

Noteworthy Changes & Bug Fixes
--

- Bug #87951: Exclude PyPM install db to prevent overwriting user's database.
- Bug #87600: create a `idleX.Y` script on unix
- [Windows] Installer upgrade: automatically uninstall previous versions - Bug 
#87783
- [Windows] Renamed "python27.exe" to "python2.7.exe" (Unix like)
- [Windows] Include "python2.exe"
- PyPM bug fixes:

  - Bug #2: Fix pickle incompatability (sqlite) on Python 3.x
  - Bug #87764: 'pypm upgrade' will not error out for missing packages
  - Bug #87902: fix infinite loops with cyclic package dependencies (eg: plone)
  - Bug #88370: Handle file-overwrite conflicts (implement --force)


What is ActivePython?
=

ActivePython is ActiveState's binary distribution of Python. Builds for 
Windows, Mac OS X, Linux are made freely available. Solaris, HP-UX and AIX 
builds, and access to older versions are available in ActivePython Business, 
Enterprise and OEM editions:

http://www.activestate.com/python

ActivePython includes the Python core and the many core extensions: zlib and 
bzip2 for data compression, the Berkeley DB (bsddb) and SQLite (sqlite3) 
database libraries, OpenSSL bindings for HTTPS support, the Tix GUI widgets for 
Tkinter, ElementTree for XML processing, ctypes (on supported platforms) for 
low-level library access, and others. The Windows distribution ships with 
PyWin32 -- a suite of Windows tools developed by Mark Hammond, including 
bindings to the Win32 API and Windows COM.

ActivePython 2.6, 2.7 and 3.1 also include a binary package manager for Python 
(PyPM) that can be used to install packages much easily. For example:

  C:\>pypm install mysql-python
  [...]

  C:\>python
  >>> import MySQLdb
  >>>

See this page for full details:

http://docs.activestate.com/activepython/2.7/whatsincluded.html

As well, ActivePython ships with a wealth of documentation for both new and 
experienced Python programmers. In addition to the core Python docs, 
ActivePython includes the "What's New in Python" series, "Dive into Python", 
the Python FAQs & HOWTOs, and the Python Enhancement Proposals (PEPs).

An online version of the docs can be found here:

http://docs.activestate.com/activepython/2.7/

We would welcome any and all feedback to:

activepython-feedb...@activestate.com

Please file bugs against ActivePython at:

http://bugs.activestate.com/enter_bug.cgi?product=ActivePython

Supported Platforms
===

ActivePython is available for the following platforms:

- Windows   (x86 and x64)
- Mac OS X  (x86 and x86_64; 10.5+)
- Linux (x86 and x86_64)

- Solaris/SPARC (32-bit and 64-bit) (Business, Enterprise or OEM edition only)
- Solaris/x86   (32-bit)(Business, Enterprise or OEM edition only)
- HP-UX/PA-RISC (32-bit)(Business, Enterprise or OEM edition only)
- HP-UX/IA-64   (32-bit and 64-bit) (Enterprise or OEM edition only)
- AIX/PowerPC   (32-bit and 64-bit) (Business, Enterprise or OEM edition only)

More information about the Business Edition can be found here:

http://www.activestate.com/business-edition

Custom builds are available in the Enterprise Edition:

http://www.activestate.com/enterprise-edition

Thanks, and enjoy!

The Python Team

--
Sridhar Ratnakumar
Python Developer
ActiveState, The Dynamic Language Experts

sridh...@activestate.com
http://www.activestate.com

Get insigh

Re: default argument in method

2010-12-13 Thread Steve Holden
On 12/13/2010 12:14 PM, Godson Gera wrote:
> 
> 
> On Sun, Dec 12, 2010 at 5:05 PM, ernest  > wrote:
> 
> Hi,
> 
> I'd like to have a reference to an instance attribute as
> default argument in a method. It doesn't work because
> "self" is not defined at the time the method signature is
> evaluated. For example:
> 
> class C(object):
>def __init__(self):
>self.foo = 5
>def m(self, val=self.foo):
>return val
> 
> Raises NameError because 'self' is not defined.
> 
> 
> You can defined foo outside the __init__ and can access it inside
> methods using self.foo
> 
> class C(object):
>  foo=5
>  def __init__(self):
>   print self.foo
>  def m(self,val=foo):
>   return val
> 
> class attributes can be accessed with out self before them in method
> signatures. However, becareful if you change the value of foo inside any
> method, the method signature will still hold on to old value.
> 
You are, of course, correct. It might be more accurate to say that if
C.foo is rebound this does not change the binding of the val default
value. "Change the value of foo" could be though to include "mutate a
mutable value", but in that case both C.foo and the method's val
parameter would still be bound to the same object.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/

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


Re: packaging and installing

2010-12-13 Thread Godson Gera
On Mon, Dec 13, 2010 at 10:46 PM, Brian Blais  wrote:

> Hello,
>
> I was wondering if there is any standard or suggested way of installing
> packages *without* going to the commandline.  I often have students who,
> from there experience in Windows, have never looked at the commandline
> before and it is a bit of a challenge to get them to install something (i.e.
> go to the commandline, cd over to the proper folder, type python setup.py
> install, etc...).  I've never seen a package with something like a
> "compileme.bat", but was wondering if there is some suggested way of doing
> this or some reasons *not* to do this.  I can always write my own (1-line)
> .bat file, but I didn't want to reinvent the wheel.  Perhaps there is a
> better way for me to do this, ideally in a platform independent way.
>

You don't even have to write a bat file. Python's distutils package allows
you to build exe file which creates generic windows wizard window for
installing packages.

Take a look at distutils package
http://docs.python.org/distutils/builtdist.html

-- 
Thanks & Regards,
Godson Gera
Asterisk consultant India 
-- 
http://mail.python.org/mailman/listinfo/python-list


packaging and installing

2010-12-13 Thread Brian Blais
Hello,

I was wondering if there is any standard or suggested way of installing 
packages *without* going to the commandline.  I often have students who, from 
there experience in Windows, have never looked at the commandline before and it 
is a bit of a challenge to get them to install something (i.e. go to the 
commandline, cd over to the proper folder, type python setup.py install, 
etc...).  I've never seen a package with something like a "compileme.bat", but 
was wondering if there is some suggested way of doing this or some reasons 
*not* to do this.  I can always write my own (1-line) .bat file, but I didn't 
want to reinvent the wheel.  Perhaps there is a better way for me to do this, 
ideally in a platform independent way.  


thanks,

Brian Blais

-- 
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/



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


Re: default argument in method

2010-12-13 Thread Godson Gera
On Sun, Dec 12, 2010 at 5:05 PM, ernest  wrote:

> Hi,
>
> I'd like to have a reference to an instance attribute as
> default argument in a method. It doesn't work because
> "self" is not defined at the time the method signature is
> evaluated. For example:
>
> class C(object):
>def __init__(self):
>self.foo = 5
>def m(self, val=self.foo):
>return val
>
> Raises NameError because 'self' is not defined.
>

You can defined foo outside the __init__ and can access it inside methods
using self.foo

class C(object):
 foo=5
 def __init__(self):
  print self.foo
 def m(self,val=foo):
  return val

class attributes can be accessed with out self before them in method
signatures. However, becareful if you change the value of foo inside any
method, the method signature will still hold on to old value.

-- 
Thanks & Regards,
Godson Gera
Python Consultant India 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: while True or while 1

2010-12-13 Thread Grant Edwards
On 2010-12-12, Steven D'Aprano  wrote:

> With the "while True" idiom in Python 2.x, you can easily exit out of an 
> infinite loop without using break:
>
 while True:
> ... print "Looping"
> ... True = 0
> ...
> Looping

 while True:  # Execute an infinite loop in 0 seconds.
> ... print "Looping"
> ...

>
> *wink*

Sadly, I've seen people do stuff like that in real programs...

-- 
Grant Edwards   grant.b.edwardsYow! I was making donuts
  at   and now I'm on a bus!
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unicode compare errors

2010-12-13 Thread Ross
On Dec 10, 4:09 pm, Nobody  wrote:
> On Fri, 10 Dec 2010 11:51:44 -0800, Ross wrote:
> > Since I can't control the encoding of the input file that users
> > submit, how to I get past this?  How do I make such comparisons be
> > True?
> On Fri, 10 Dec 2010 12:07:19 -0800, Ross wrote:
> > I found I could import codecs that allow me to read the file with my
> > desired encoding. Huzzah!
> > If I'm off-base and kludgey here and should be doing something
>
> Er, do you know the file's encoding or don't you? Using:
>
>     aFile = codecs.open(thisFile, encoding='utf-8')
>
> is telling Python that the file /is/ in utf-8. If it isn't in utf-8,
> you'll get decoding errors.
>
> If you are given a file with no known encoding, then you can't reliably
> determine what /characters/ it contains, and thus can't reliably compare
> the contents of the file against strings of characters, only against
> strings of bytes.
>
> About the best you can do is to use an autodetection library such as:
>
>        http://chardet.feedparser.org/

That's right I don't know what encoding the user will have used. The
use of autodetection sounds good - I'll look into that. Thx.

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


AttributeError while running ssh (from windows) paramiko need help

2010-12-13 Thread Darshak Bavishi
Hi Experts ,

while i am running following demo ssh script of paramiko -->


*import base64*
*import getpass*
*import os*
*import socket*
*import sys*
*import traceback*
*
*
*import paramiko*
*import interactive*
*
*
*
*
*# setup logging*
*paramiko.util.log_to_file('demo_simple.log')*
*
*
*# get hostname*
*username = ''*
*if len(sys.argv) > 1:*
*hostname = sys.argv[1]*
*if hostname.find('@') >= 0:*
*username, hostname = hostname.split('@')*
*else:*
*hostname = raw_input('Hostname: ')*
*if len(hostname) == 0:*
*print '*** Hostname required.'*
*sys.exit(1)*
*port = 22*
*if hostname.find(':') >= 0:*
*hostname, portstr = hostname.split(':')*
*port = int(portstr)*
*
*
*
*
*# get username*
*if username == '':*
*default_username = getpass.getuser()*
*username = raw_input('Username [%s]: ' % default_username)*
*if len(username) == 0:*
*username = default_username*
*password = getpass.getpass('Password for %...@%s: ' % (username, hostname))*
*
*
*
*
*# get host key, if we know one*
*hostkeytype = None*
*hostkey = None*
*try:*
*host_keys =
paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))*
*except IOError:*
*try:*
*# try ~/ssh/ too, because windows can't have a folder named ~/.ssh/
*
*host_keys =
paramiko.util.load_host_keys(os.path.expanduser('~/ssh/known_hosts'))*
*except IOError:*
*print '*** Unable to open host keys file'*
*host_keys = {}*
*
*
*if host_keys.has_key(hostname):*
*hostkeytype = host_keys[hostname].keys()[0]*
*hostkey = host_keys[hostname][hostkeytype]*
*print 'Using host key of type %s' % hostkeytype*
*
*
*
*
*# now, connect and use paramiko Transport to negotiate SSH2 across the
connection*
*try:*
*t = paramiko.Transport((hostname, port))*
*t.connect(username=username, password=password, hostkey=hostkey)*
*chan = t.open_session()*
*chan.get_pty()*
*chan.invoke_shell()*
*print '*** Here we go!'*
*print*
*interactive.interactive_shell(chan)*
*chan.close()*
*t.close()*
*
*
*except Exception, e:*
*print '*** Caught exception: %s: %s' % (e.__class__, e)*
*traceback.print_exc()*
*try:*
*t.close()*
*except:*
*pass*
*sys.exit(1)*


It gives error as follows :

*Warning (from warnings module):*
*  File "C:\Python26\lib\site-packages\Crypto\Hash\SHA.py", line 6*
*from sha import **
*DeprecationWarning: the sha module is deprecated; use the hashlib module
instead*
*
*
*Warning (from warnings module):*
*  File "C:\Python26\lib\site-packages\Crypto\Hash\MD5.py", line 6*
*from md5 import **
*DeprecationWarning: the md5 module is deprecated; use hashlib instead*
*Hostname: 10.135.15.41*
*Username [admin]: root*
*
*
*Warning (from warnings module):*
*  File "C:\Python26\lib\getpass.py", line 88*
*return fallback_getpass(prompt, stream)*
*GetPassWarning: Can not control echo on the terminal.*
*Warning: Password input may be echoed.*
*Password for r...@10.135.15.41: alcatel*
 Unable to open host keys file*
 Here we go!*
*
*
*Line-buffered terminal emulation. Press F6 or ^Z to send EOF.*
*
*
*
*
*
*
*Last login: Mon Dec 13 19:38:31 2010 from 10.135.19.50*
*
*
*
*
 Caught exception: : read*
*Traceback (most recent call last):*
*  File "C:\Python26\paramiko-1.7.4\demos\demo_simple.py", line 90, in
*
*interactive.interactive_shell(chan)*
*  File "C:\Python26\paramiko-1.7.4\demos\interactive.py", line 36, in
interactive_shell*
*windows_shell(chan)*
*  File "C:\Python26\paramiko-1.7.4\demos\interactive.py", line 91, in
windows_shell*
*d = sys.stdin.read(1)*
*  File "C:\Python26\lib\idlelib\rpc.py", line 560, in __getattr__*
*raise AttributeError, name*
*AttributeError: read*
*
*
*
*
 EOF 
*
*
*Traceback (most recent call last):*
*  File "C:\Python26\paramiko-1.7.4\demos\demo_simple.py", line 101, in
*
*sys.exit(1)*
*SystemExit: 1*
*
*
*can you tell me what is use of Hostkey and how to overcome this issue?!*
-- 
BR
Darshak Bavishi
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: class browser

2010-12-13 Thread Adam Tauno Williams
On Sun, 2010-12-12 at 05:01 -0800, rusi wrote:
> On Dec 8, 11:24 pm, Adam Tauno Williams 
> wrote:
> > On Wed, 2010-12-08 at 13:18 +0530, Rustom Mody wrote:
> > > If I have a medium to large python code base to browse/study, what are
> > > the class browsers available?
> > Monodevelop has good Python support which includes a working Python
> > class browser for Python projects & solutions.
> > 
> Ok downloaded mono.
> How do I import an existing project?

Just create a new Python project with the root of the project being the
root of your existing project;  then add the files [because you aren't
really importing an existing project - there is no existing project -
just a bunch of files and folders].  Monodevelop will create the
required solution files for the advanced features.


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


Re: Is there any way to SSH from Python ?!

2010-12-13 Thread Christian Heimes
Am 13.12.2010 12:41, schrieb Darshak Bavishi:
> Hi,
> 
> I have downloaded paramiko and installed it now it needs Pycrypto . So i
> tried to install pycrypto but its giving error of vcvarsall.bat
> so from christian suggestion i downloaded MinGW . But i have no idea how to
> install it in windows machine

Please use the prebuild Windows binaries from Michael Foord.

Christian

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


PyCon 2011 Registration and Financial aid open and available!

2010-12-13 Thread Jesse Noller
[Sorry for that last partial email]

I wanted to take a moment and let everyone know that the PyCon 2011
Registration system is now online and accepting registrations for the
conference!

http://us.pycon.org/2011/tickets/

PyCon 2011 is looking to be the biggest, and most impressive PyCon
yet, we've already booked one fantastic keynote speaker, and the
program committee is hard at work selecting the talks for the
conference - over 200 proposals were submitted! We're filling up the
poster sessions, a stunning number of tutorials are being reviewed -
this really does look like it's going to be huge.

Financial aid is also open and available:
http://us.pycon.org/2011/registration/financialaid/


Feel free to reach out to anyone on the PyCon 2011 team to ask any
questions you might have. We look forward to seeing you in Atlanta.

Jesse Noller
PyCon 2011
-- 
http://mail.python.org/mailman/listinfo/python-list


PyCon 2011 Registration and Financial aid open and available!

2010-12-13 Thread Jesse Noller
Just q
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there any way to SSH from Python ?!

2010-12-13 Thread Darshak Bavishi
Hi,

I have downloaded paramiko and installed it now it needs Pycrypto . So i
tried to install pycrypto but its giving error of vcvarsall.bat
so from christian suggestion i downloaded MinGW . But i have no idea how to
install it in windows machine

pls help me out of this!!

On Mon, Dec 13, 2010 at 5:04 PM, Felipe Vinturini <
felipe.vintur...@gmail.com> wrote:

>
>
> On Mon, Dec 13, 2010 at 3:11 AM, Darshak Bavishi <
> bavishi.dars...@gmail.com> wrote:
>
>>
>> i am trying from last week but no luck !!
>>
>> one thing only found that pexpect it not useful in windows
>>
>> pls help out of this
>>
>> On Mon, Dec 13, 2010 at 10:39 AM, Chris Rebert  wrote:
>>
>>> On Sun, Dec 12, 2010 at 9:03 PM, Darshak Bavishi
>>>  wrote:
>>> > Hi Experts,
>>> > I need to know that is there any way to SSH (From Windows Host) to Unix
>>> > machine ?!
>>> > If Yes than How ?
>>>
>>> http://www.lag.net/paramiko/
>>>
>>> Did you try googling "ssh python"?
>>>
>>> Cheers,
>>> Chris
>>> --
>>> http://blog.rebertia.com
>>>
>>
>>
>>
>> --
>> BR
>> Darshak Bavishi
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>>
> Hi!
>
> Here is a good link about SSH and paramiko:
> http://jessenoller.com/2009/02/05/ssh-programming-with-paramiko-completely-different/
>
> Regards,
> Felipe.
>



-- 
BR
Darshak Bavishi
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there any way to SSH from Python ?!

2010-12-13 Thread Felipe Vinturini
On Mon, Dec 13, 2010 at 3:11 AM, Darshak Bavishi
wrote:

>
> i am trying from last week but no luck !!
>
> one thing only found that pexpect it not useful in windows
>
> pls help out of this
>
> On Mon, Dec 13, 2010 at 10:39 AM, Chris Rebert  wrote:
>
>> On Sun, Dec 12, 2010 at 9:03 PM, Darshak Bavishi
>>  wrote:
>> > Hi Experts,
>> > I need to know that is there any way to SSH (From Windows Host) to Unix
>> > machine ?!
>> > If Yes than How ?
>>
>> http://www.lag.net/paramiko/
>>
>> Did you try googling "ssh python"?
>>
>> Cheers,
>> Chris
>> --
>> http://blog.rebertia.com
>>
>
>
>
> --
> BR
> Darshak Bavishi
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
Hi!

Here is a good link about SSH and paramiko:
http://jessenoller.com/2009/02/05/ssh-programming-with-paramiko-completely-different/

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


Re: while True or while 1

2010-12-13 Thread Jean-Michel Pichavant

Paul Rubin wrote:

Steven D'Aprano  writes:
  
I'm actually quite fond of the look of "while 1:", and sometimes use it, 
not because it's faster, but just because I like it.



for v in itertools.repeat(True):
 ...

;-)

while '__For_ever___' not in ['nit-picking']:

:)

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


Re: default argument in method

2010-12-13 Thread Jean-Michel Pichavant

ernest wrote:

Hi,

I'd like to have a reference to an instance attribute as
default argument in a method. It doesn't work because
"self" is not defined at the time the method signature is
evaluated. For example:

class C(object):
def __init__(self):
self.foo = 5
def m(self, val=self.foo):
return val

Raises NameError because 'self' is not defined.
The obvious solution is put val=None in the signature
and set val to the appropriate value inside the method
(if val is None: ...), but I wonder if there's another way.

Cheers,
Ernest
  

your 'val=None' is jus fine.

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


Re: Python critique

2010-12-13 Thread Jean-Michel Pichavant

Octavian Rasnita wrote:

From: "Steven D'Aprano" 
...
  

Can you please tell me how to write the following program in Python?

my $n = 1;

{
  my $n = 2;
  print "$n\n";
}

print "$n\n";

If this program if ran in Perl, it prints: 
2

1
  

Lots of ways. Here's one:


n = 1

class Scope:
   n = 2
   print n

print n



Here's another:

n = 1
print (lambda n=2: n)()
print n



Here's a third:

n = 1

def scope():
   n = 2
   print n

scope()
print n


Here's a fourth:

import sys
n = 1
(sys.stdout.write("%d\n" % n) for n in (2,)).next()
print n


In Python 3, this can be written more simply:

n = 1
[print(n) for n in (2,)]
print n





I have tried to write it, but I don't know how I can create that block
because it tells that there is an unexpected indent.
  
Functions, closures, classes and modules are scopes in Python. If you 
want a new scope, create one of those.




--
Steven




Hi Steven,

Thank you for your message. It is very helpful for me.
I don't fully understand the syntax of all these variants yet, but I can see 
that there are more scopes in Python than I thought, and this is very good.

Octavian

  
Local scopes like described above by Steven are not constructs that are 
used that often, not to solve any scoping issue (except for the first 
example maybe). It's more a demonstration that you can do it with python.
The reason is that Python developpers will not put themself in the 
situation where they need to use a variable 'orange' line 32 and use the 
same variable 'orange' line 33 to refer to something else.


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


Re: How to install pycrypto mode in windows ?!

2010-12-13 Thread Christian Heimes
Am 13.12.2010 11:20, schrieb Darshak Bavishi:
> Hi Experts ,
> 
> I am using python 2.6 and i had installed paramiko module which needs
> pycrypto but ,
> when i am installing pycrypto in windows its giving error as follows:
> 
[...]
> can u suggest any source to get pycrypto to avoid such events?!

Well, your problem is that you are using the sources of pycrypto.
vcvarsall.bat is a part of MS Visual Studio. You need either VS2008 or
MinGW32 to compile the sources of Windows. Better look for precompiled
binaries. Michael offers prebuild binaries on his site [1]. There are
fine, I'm using them on Windows, too.

Christian

[1] http://www.voidspace.org.uk/python/modules.shtml#pycrypto

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


How to install pycrypto mode in windows ?!

2010-12-13 Thread Darshak Bavishi
Hi Experts ,

I am using python 2.6 and i had installed paramiko module which needs
pycrypto but ,
when i am installing pycrypto in windows its giving error as follows:


creating build\lib.win32-2.6\Crypto\PublicKey
copying .\PublicKey\DSA.py -> build\lib.win32-2.6\Crypto\PublicKey
copying .\PublicKey\ElGamal.py -> build\lib.win32-2.6\Crypto\PublicKey
copying .\PublicKey\pubkey.py -> build\lib.win32-2.6\Crypto\PublicKey
copying .\PublicKey\qNEW.py -> build\lib.win32-2.6\Crypto\PublicKey
copying .\PublicKey\RSA.py -> build\lib.win32-2.6\Crypto\PublicKey
copying .\PublicKey\__init__.py -> build\lib.win32-2.6\Crypto\PublicKey
running build_ext
building 'Crypto.Hash.MD2' extension
error: Unable to find vcvarsall.bat

can u suggest any source to get pycrypto to avoid such events?!



-- 
BR
Darshak Bavishi
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Proposed changes to logging defaults

2010-12-13 Thread Jean-Michel Pichavant

Vinay Sajip wrote:

On Dec 10, 10:17 am, Jean-Michel Pichavant 
wrote:

Hi Jean-Michel,

I think Antoine answered your other points, so I'll address the last
one:

  

Last question, if no handler is found, why not simply drop the log
event, doing nothing ? It sounds pretty reasonable and less intrusive.



That is what happens at the moment if configured for production
(logging.raiseExceptions is False) - nothing happens, and the event is
discarded. For development (logging.raiseExceptions is True), the "No
handlers were found for logger XXX" is printed once, to assist
developers to detect misconfiguration. However, the original logged
event is still discarded.

The original philosophy (when logging was added to Python) was that
logging is an adjunct to the operation of the program using it - the
program should work the same way whether or not logging is configured.
However, the consensus on Python-dev is that the logging package
should do useful work, and not just act as an adjunct, i.e. notify the
user on warning and error conditions by default if no logging
configuration is set up. A program will now work differently depending
on whether logging is configured, but if it is not configured, the
default should be to display warnings and errors, unless explicitly
silenced (as per the Zen of Python).

These two approaches (original vs. proposed) are of course quite
different, and there's no way of satisfying both proponents of both
approaches, nor any easy way of measuring how many of each there are.
The proposed change moves logging closer to the current Python-dev
consensus, and means that messages currently written to sys.stderr by
stdlib modules could be logged instead, with the stdlib maintainers
writing those messages knowing that unless explicitly silenced, those
messages will appear to the user as they would via a
sys.stderr.write(). It will be good if this happens, so that
application writers will have better control over what messages are
displayed (when they need it), by configuring logging.

Remember - no changes to behaviour will occur if this change is
implemented and an application configures logging. It's only the no-
configuration case that will change.

To get the current behaviour after the proposed changes are
implemented, an application developer would have to do
logging.lastResort = None, which is a small price to pay (and more or
less equivalent in difficulty with what users who want verbosity by
default have to do, e.g. call basicConfig().

Regards,

Vinay Sajip
  

Thanks for the explanation.

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


Re: Objects and validation

2010-12-13 Thread bruno.desthuilli...@gmail.com
On 12 déc, 15:28, pyt...@lists.fastmail.net wrote:
> I have a routine in Python which is extracting information from a
> website. This information is read and inserted into objects.
>
> I currently have all the validations and checks implemented in the
> routines which are reading the HTML and creating the objects. It is
> however also possible to move all the validations into the class itself.
> What is considered the best practice for this: validation in the
> functions which read the information and creates the objects or in the
> class itself?
>

There's no one-size-fits-all answer to this question. Part of the work
really belongs to the layer that accepts data from the outside world,
part of it belong to the 'model' object itself. In any case, the
'model' object shouldn't have to worry about data conversion etc -
like, if one of the attribute is supposed to be a datetime, it's the
client code's responsability to provide a proper datetime object, not
a string that may (or not) be the textual representation of a date and
time.

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