Re: Ascii to Unicode.

2010-07-29 Thread Nobody
On Thu, 29 Jul 2010 23:49:40 +, Steven D'Aprano wrote: > It looks to me like Python uses a 16-bit implementation internally, It typically uses the platform's wchar_t, which is 16-bit on Windows and (typically) 32-bit on Unix. IIRC, it's possible to build Python with 32-bit Unicode on Windows

Re: combined functionality of ipython's %whos and pdb's next (without a resource heavy IDE)

2010-07-29 Thread Cappy2112
On Jul 29, 12:39 pm, "Benjamin J. Racine" wrote: > I am trying to combine the ability to move line-by-line through the code as > is done with pdb's "next" function with ipython's ability to list all > variables at once... without the use of a full-fledged IDE. > > I am not seeing how this might

Enabling/Disabling remote desktop - programmatically

2010-07-29 Thread Cappy2112
I've already posted this in the Python W32 list, but didn't get what I'm looking for. I want to know how to disable Remote Desktop after logging to into a remote machine, to prevent subsequent logins by other users logging me out. I currently have a Windows XP system configured for coworkers to

Re: Ascii to Unicode.

2010-07-29 Thread Mark Tolonen
"Joe Goldthwaite" wrote in message news:5a04846ed83745a8a99a944793792...@newmbp... Hi Steven, I read through the article you referenced. I understand Unicode better now. I wasn't completely ignorant of the subject. My confusion is more about how Python is handling Unicode than Unicode its

Re: measuring a function time

2010-07-29 Thread Rodrick Brown
Someone should port Perl's Benchmark.pm module to python that's such a useful module to measure a functions execution time and CPU usage. Sent from my iPhone 4. On Jul 29, 2010, at 3:43 PM, "Benjamin J. Racine" wrote: > I just use ipython's functions (that are themselves just calls to the tim

Re: Ascii to Unicode.

2010-07-29 Thread Steven D'Aprano
On Thu, 29 Jul 2010 11:14:24 -0700, Ethan Furman wrote: > Don't think of unicode as a byte stream. It's a bunch of numbers that > map to a bunch of symbols. Not only are Unicode strings a bunch of numbers ("code points", in Unicode terminology), but the numbers are not necessarily all the same

Re: Possible to include \n chars in doctest code samples or output?

2010-07-29 Thread Aahz
In article <4c3ff6f7$0$11101$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: > >Remember that doctests aren't intended for a comprehensive test suite. WDYM not intended? Disagree with Tim Peters much? ;-) -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ ".

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-29 Thread Steven D'Aprano
On Thu, 29 Jul 2010 19:29:24 +0200, Jean-Michel Pichavant wrote: > Steven D'Aprano wrote: >> [snip] >> >> super() is just as explicit as len(), or str.upper(). It says, >> explicitly, that it will call the method belonging to one or more >> superclass of the given class. >> > Come on Steven, yo

ANUSHKA HOT PICTURES FOR BOLLYWOOD FANS

2010-07-29 Thread anushkaphotos
ANUSHKA HOT PICTURES FOR BOLLYWOOD FANS - http://sites.google.com/site/anushkaphotosalert -- http://mail.python.org/mailman/listinfo/python-list

Re: default behavior

2010-07-29 Thread Steven D'Aprano
On Thu, 29 Jul 2010 21:43:05 +0300, Nick Raptis wrote: > On 07/29/2010 09:12 PM, wheres pythonmonks wrote: >> How do I build an "int1" type that has a default value of 1? > You mean something like: > >>> x = int() > >>> x > 0 > >>> def myint(value=1): > ... return int(value) > ... > >>> my

Re: Newbie question regarding SSL and certificate verification

2010-07-29 Thread geremy condra
On Thu, Jul 29, 2010 at 9:13 AM, Antoine Pitrou wrote: > On Wed, 28 Jul 2010 22:23:48 -0700 > geremy condra wrote: >> > >> >   The new Python SSL module in 2.6 and later has a huge built-in >> > security hole - it doesn't verify the domain against the >> > certificate.  As someone else put it, th

Re: measuring a function time

2010-07-29 Thread Benjamin J. Racine
I just use ipython's functions (that are themselves just calls to the time module functions) for timing my functions... Enter: %timeit? or %time At the Ipython command prompt to get started. Ben R. On Jul 29, 2010, at 7:43 AM, D'Arcy J.M. Cain wrote: > On Thu, 29 Jul 2010 08:45:23 -0400 > Jo

combined functionality of ipython's %whos and pdb's next (without a resource heavy IDE)

2010-07-29 Thread Benjamin J. Racine
I am trying to combine the ability to move line-by-line through the code as is done with pdb's "next" function with ipython's ability to list all variables at once... without the use of a full-fledged IDE. I am not seeing how this might be done. Many thanks for your help... Ben Racine -- http

Re: Ascii to Unicode.

2010-07-29 Thread MRAB
John Nagle wrote: On 7/28/2010 3:58 PM, Joe Goldthwaite wrote: This still seems odd to me. I would have thought that the unicode function would return a properly encoded byte stream that could then simply be written to disk. Instead it seems like you have to re-encode the byte stream to some

Re: default behavior

2010-07-29 Thread Christian Heimes
> Inheriting from "int" is not too helpful, because you can't assign > to the value of the base class. "self=1" won't do what you want. It's useful if you remember that you can set the default value by overwriting __new__. >>> class int1(int): ... def __new__(cls, value=1): ... retur

Re: default behavior

2010-07-29 Thread John Nagle
On 7/29/2010 11:12 AM, wheres pythonmonks wrote: Why is the default value of an int zero? x = int print x x() 0 How do I build an "int1" type that has a default value of 1? >>> class int1(object) : ...def __init__(self) : ... self.val = 1 ...def __call__(self) : ...

Re: Ascii to Unicode.

2010-07-29 Thread John Nagle
On 7/28/2010 3:58 PM, Joe Goldthwaite wrote: This still seems odd to me. I would have thought that the unicode function would return a properly encoded byte stream that could then simply be written to disk. Instead it seems like you have to re-encode the byte stream to some kind of escaped Ascii

Re: Tabular Package: importing file

2010-07-29 Thread Robert Kern
On 7/28/10 4:57 PM, Robert Faryabi wrote: Hi there; I'm using Tabular Package for manipulating tab-delimited data. There is a small problem that I cannot get my head around it. When I construct my tabarray from file, the black fields are replaced by "nan". Does any one knows how to just keep th

Re: Multiprocessing taking too much time

2010-07-29 Thread John Nagle
On 7/29/2010 11:08 AM, Shailendra wrote: Hi All, I have a following situation. ==PSUDO CODE START== class holds_big_array: big_array #has a big array def get_some_element(self, cond) # return some data from the array from the big array =

Re: default behavior

2010-07-29 Thread Nick Raptis
On 07/29/2010 09:12 PM, wheres pythonmonks wrote: How do I build an "int1" type that has a default value of 1? You mean something like: >>> x = int() >>> x 0 >>> def myint(value=1): ... return int(value) ... >>> myint() 1 >>> That's ugly on so many levels.. Anyway, basic types (and almost

Re: Ascii to Unicode.

2010-07-29 Thread Ethan Furman
Joe Goldthwaite wrote: Hi Ulrich, Ascii.csv isn't really a latin-1 encoded file. It's an ascii file with a few characters above the 128 range . . . It took me a while to get this point too (if you already have "gotten it", I apologize, but the above comment leads me to believe you haven't).

Re: default behavior

2010-07-29 Thread wheres pythonmonks
Thanks. I presume this will work for my nested example as well. Thanks again. On Thu, Jul 29, 2010 at 2:18 PM, Paul Rubin wrote: > wheres pythonmonks writes: >> How do I build an "int1" type that has a default value of 1? >> [Hopefully no speed penalty.] >> I am thinking about applications wit

Re: default behavior

2010-07-29 Thread Paul Rubin
wheres pythonmonks writes: > How do I build an "int1" type that has a default value of 1? > [Hopefully no speed penalty.] > I am thinking about applications with collections.defaultdict. You can supply an arbitary function to collections.defaultdict. It doesn't have to be a class. E.g. d =

Re: Ascii to Unicode.

2010-07-29 Thread Carey Tilden
On Thu, Jul 29, 2010 at 10:59 AM, Joe Goldthwaite wrote: > Hi Ulrich, > > Ascii.csv isn't really a latin-1 encoded file.  It's an ascii file with a > few characters above the 128 range that are causing Postgresql Unicode > errors.  Those characters work fine in the Windows world but they're not th

Re: Multiprocessing taking too much time

2010-07-29 Thread Joshua Kordani
The first thing that is generically tried when wishing to measure how long certain parts take is to record your own time snapshots in the code yourself. take the current time before an operation, take it after, subract, report it to yourself. Also, try working with an array that is actually b

Re: Ascii to Unicode.

2010-07-29 Thread Ethan Furman
Joe Goldthwaite wrote: Hi Steven, I read through the article you referenced. I understand Unicode better now. I wasn't completely ignorant of the subject. My confusion is more about how Python is handling Unicode than Unicode itself. I guess I'm fighting my own misconceptions. I do that a lot

default behavior

2010-07-29 Thread wheres pythonmonks
Why is the default value of an int zero? >>> x = int >>> print x >>> x() 0 >>> How do I build an "int1" type that has a default value of 1? [Hopefully no speed penalty.] I am thinking about applications with collections.defaultdict. What if I want to make a defaultdict of defaultdicts of lists?

Multiprocessing taking too much time

2010-07-29 Thread Shailendra
Hi All, I have a following situation. ==PSUDO CODE START== class holds_big_array:     big_array  #has a big array     def get_some_element(self, cond) # return some data from the array from the big array ==PSUDO CODE END I wanted

RE: Ascii to Unicode.

2010-07-29 Thread Joe Goldthwaite
Hi Ulrich, Ascii.csv isn't really a latin-1 encoded file. It's an ascii file with a few characters above the 128 range that are causing Postgresql Unicode errors. Those characters work fine in the Windows world but they're not the correct byte representation for Unicode. What I'm attempting to d

stdout of external program.

2010-07-29 Thread Paul Lemelle
HELP! :) I am trying to output the following program's output to either a file or variable, how can this be done? # Writing the output to a standard argv argument #1/usr/bin/python import sys for arg in sys.argv:   print arg #END Thanks, Paul -- http://mail.python.org/mailman/li

RE: Ascii to Unicode.

2010-07-29 Thread Joe Goldthwaite
Hi Steven, I read through the article you referenced. I understand Unicode better now. I wasn't completely ignorant of the subject. My confusion is more about how Python is handling Unicode than Unicode itself. I guess I'm fighting my own misconceptions. I do that a lot. It's hard for me to un

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-29 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: [snip] super() is just as explicit as len(), or str.upper(). It says, explicitly, that it will call the method belonging to one or more superclass of the given class. Come on Steven, you're better than this :) . Everybody can accurately guess what len and upper are d

solving Tix problem in ubuntu jaunty

2010-07-29 Thread jimgardener
hi, recently I switched to ubuntu jaunty and installed python 2.6.I installed lib-tk so that I can work on my gui apps using Tix and Tkinter.But ,it seems that the python version in jaunty ships a buggy tix version which gives a 'TclError:unknown color' error message (this happens when I try to use

Re: Newbie question regarding SSL and certificate verification

2010-07-29 Thread Antoine Pitrou
On Wed, 28 Jul 2010 22:23:48 -0700 geremy condra wrote: > > > >   The new Python SSL module in 2.6 and later has a huge built-in > > security hole - it doesn't verify the domain against the > > certificate.  As someone else put it, this means "you get to > > talk securely with your attacker." As l

Re: Newbie question regarding SSL and certificate verification

2010-07-29 Thread John Nagle
On 7/28/2010 10:23 PM, geremy condra wrote: On Wed, Jul 28, 2010 at 10:08 PM, John Nagle wrote: On 7/28/2010 6:26 PM, geremy condra wrote: On Wed, Jul 28, 2010 at 4:41 PM, Jeffrey Gaynorwrote: The new Python SSL module in 2.6 and later has a huge built-in security hole - it doesn't

Re: Nice way to cast a homogeneous tuple

2010-07-29 Thread Carl Banks
On Jul 28, 7:45 pm, Steven D'Aprano wrote: > On Wed, 28 Jul 2010 08:47:52 -0700, Carl Banks wrote: > > On Jul 28, 7:32 am, Steven D'Aprano > cybersource.com.au> wrote: > >> On Wed, 28 Jul 2010 09:35:52 -0400, wheres pythonmonks wrote: > >> > Thanks ... I thought int was a type-cast (like in C++)

Re: Newbie question regarding SSL and certificate verification

2010-07-29 Thread Christian Heimes
> I know very little about security, but one thing I think I know. Never > use security software version 1.0 or greater. It was written by an > author insufficiently paranoid. OpenSSL 1.0.0a was released about a month ago. ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question regarding SSL and certificate verification

2010-07-29 Thread David Robinow
On Thu, Jul 29, 2010 at 10:07 AM, Jeffrey Gaynor wrote: > ... > A final question -- how widely is M2Crypto used? Since I will have to now > pitch to our group that this is preferable the first questions they will ask > are about stability, who is using it and how secure is it really, especially

Re: measuring a function time

2010-07-29 Thread D'Arcy J.M. Cain
On Thu, 29 Jul 2010 08:45:23 -0400 Joe Riopel wrote: > On Thu, Jul 29, 2010 at 8:34 AM, Mahmood Naderan wrote: > > the output should be 7600 (s) for example. What is the best and easiest way > > to do that? > > Take a look at time.clock() I don't know if that's what he wants. The clock() metho

Re: Newbie question regarding SSL and certificate verification

2010-07-29 Thread Jeffrey Gaynor
Thank you! This is what I was looking for. A final question -- how widely is M2Crypto used? Since I will have to now pitch to our group that this is preferable the first questions they will ask are about stability, who is using it and how secure is it really, especially since it is at version

Re: measuring a function time

2010-07-29 Thread Mahmood Naderan
Thanks, the first method worked. However clock() doesn't. tic = time.time() time.sleep( 2 ) toc = time.time() print toc - tic   Result: 2.00269889832 >Take a look at time.clock() tic = time.clock() time.sleep( 2 ) toc = time.clock() print toc - tic   result: 0.0 >More importantly, the above tech

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-29 Thread Steven D'Aprano
On Thu, 29 Jul 2010 12:08:54 +0200, Jean-Michel Pichavant wrote: > Steven D'Aprano wrote: >> That incorrect. You can certainly use super() with classic classes in >> the hierarchy, and super() didn't even exist when they were created. >> The problem isn't super(), and people who give glib advise

Re: write xml to txt encoding

2010-07-29 Thread Stefan Behnel
William Johnston, 29.07.2010 14:12: I have a Python app that parses XML files and then writes to text files. XML or HTML? However, the output text file is "sometimes" encoded in some Asian language. Here is my code: encoding = "iso-8859-1" clean_sent = nltk.clean_html(sent.text) clean_s

Re: measuring a function time

2010-07-29 Thread Steven D'Aprano
On Thu, 29 Jul 2010 14:42:58 +0200, Matteo Landi wrote: > This should be enough > import time tic = time.time() function() toc = time.time() print toc - tic You're typing that in the interactive interpreter, which means the timer is counting the seconds while you're typing s

Re: measuring a function time

2010-07-29 Thread Joe Riopel
On Thu, Jul 29, 2010 at 8:34 AM, Mahmood Naderan wrote: > the output should be 7600 (s) for example. What is the best and easiest way > to do that? Take a look at time.clock() http://docs.python.org/library/time.html#time.clock "this is the function to use for benchmarking Python or timing algo

Re: measuring a function time

2010-07-29 Thread Matteo Landi
This should be enough >>>import time >>>tic = time.time() >>>function() >>>toc = time.time() >>>print toc - tic On Thu, Jul 29, 2010 at 2:34 PM, Mahmood Naderan wrote: > Hi, > I want to measure a function run time. I read > http://docs.python.org/library/time.html but I am confused and don't kno

measuring a function time

2010-07-29 Thread Mahmood Naderan
Hi, I want to measure a function run time. I read http://docs.python.org/library/time.html but I am confused and don't know which one is suitable. I don't know is daylight timing important or not or is Y2K issue important for my case or not I also don't know how epoch time is related to

write xml to txt encoding

2010-07-29 Thread William Johnston
Hello, I have a Python app that parses XML files and then writes to text files. However, the output text file is "sometimes" encoded in some Asian language. Here is my code: encoding = "iso-8859-1" clean_sent = nltk.clean_html(sent.text) clean_sent = clean_sent.encode(encoding,

Re: Ascii to Unicode.

2010-07-29 Thread Ulrich Eckhardt
Joe Goldthwaite wrote: > import unicodedata > > input = file('ascii.csv', 'rb') > output = file('unicode.csv','wb') > > for line in input.xreadlines(): > unicodestring = unicode(line, 'latin1') > output.write(unicodestring.encode('utf-8')) # This second encode >

Re: Performance ordered dictionary vs normal dictionary

2010-07-29 Thread Navkirat Singh
On 29-Jul-2010, at 2:50 PM, Hrvoje Niksic wrote: > sturlamolden writes: > >> On 29 Jul, 03:47, Navkirat Singh wrote: >> >>> I was wondering what would be better to do some medium to heavy book >>> keeping in memory - Ordered Dictionary or a plain simple Dictionary object?? >> >> It depends

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-29 Thread Joshua Kordani
Jean-Michel Pichavant wrote: Robert Kern wrote: On 7/23/10 7:08 PM, Lawrence D'Oliveiro wrote: In message, Robert Kern wrote: There are also utilities for mounting ISOs directly without burning them to a physical disk. You need special utilities to do this?? On at least some versions of

Re: Performance ordered dictionary vs normal dictionary

2010-07-29 Thread Hrvoje Niksic
sturlamolden writes: > On 29 Jul, 03:47, Navkirat Singh wrote: > >> I was wondering what would be better to do some medium to heavy book keeping >> in memory - Ordered Dictionary or a plain simple Dictionary object?? > > It depends on the problem. A dictionary is a hash table. An ordered > dict

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-29 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Sun, 25 Jul 2010 13:58:00 +1200, Gregory Ewing wrote: Lacrima wrote: But what if SuperClass1 is from third party library? If it hasn't been designed for super(), then you can't use super() with it. super() only works when *every* class in the hierarc

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-29 Thread Jean-Michel Pichavant
Robert Kern wrote: On 7/23/10 7:08 PM, Lawrence D'Oliveiro wrote: In message, Robert Kern wrote: There are also utilities for mounting ISOs directly without burning them to a physical disk. You need special utilities to do this?? On at least some versions of Windows, Yes. You need the

Re: loading configuration files that are themselves python

2010-07-29 Thread Jean-Michel Pichavant
Ben Finney wrote: Lawrence D'Oliveiro writes: In message <7j8w5tylmw@rapun.sel.cam.ac.uk>, Matthew Vernon wrote: Is there a more idiomatic way of loading in a configuration file that's python code ... Is it really a good idea to have a configuration language that’s Turing

Re: Nice way to cast a homogeneous tuple

2010-07-29 Thread Steven D'Aprano
On Thu, 29 Jul 2010 09:21:37 +0200, Ulrich Eckhardt wrote: > Steven D'Aprano wrote: >> Perhaps I have been misinformed, but my understanding of C type-casts >> is that (where possible), a cast like `int(var)` merely tells the >> compiler to temporarily disregard the type of var and treat it as if

Re: Performance ordered dictionary vs normal dictionary

2010-07-29 Thread Raymond Hettinger
On Jul 28, 6:47 pm, Navkirat Singh wrote: > I was wondering what would be better to do some medium > to heavy book keeping in memory - Ordered Dictionary > or a plain simple Dictionary object?? The current implementation of OrderedDict is based on regular dictionaries, so it performance cannot be

Re: Performance ordered dictionary vs normal dictionary

2010-07-29 Thread Shashwat Anand
> > > It depends on the problem. A dictionary is a hash table. An ordered > dictionary is a binary search tree (BST). Those are different data > structures. > > The main things to note is that: > > - Access is best-case O(1) for the hash table and O(log n) for the > BST. > > - Worst case behavior i

Re: Why is there no platform independent way of clearing a terminal?

2010-07-29 Thread Ulrich Eckhardt
Neil Cerutti wrote: > Perhaps emailing the tests to yourself would be a good solution. > Every tme the tests ran, you'd get a new email containing the > results. Nice idea, only that it's even less portable and requires manual setup... ;^) Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föc

Re: Nice way to cast a homogeneous tuple

2010-07-29 Thread Ulrich Eckhardt
Steven D'Aprano wrote: > Perhaps I have been misinformed, but my understanding of C type-casts is > that (where possible), a cast like `int(var)` merely tells the compiler > to temporarily disregard the type of var and treat it as if it were an > int. In other words, it's a compiler instruction rat