Re: os.system in a service

2009-08-06 Thread Diez B. Roggisch
Gabriel Genellina schrieb: En Wed, 05 Aug 2009 13:07:39 -0300, Lawrence Wong escribió: I wrote a program which runs a .bat file using os.system like: 'os.system(pathToBatFile)' and everything was good. Then I decided to turn my program into a service as opposed to being run with the comman

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-06 Thread Hendrik van Rooyen
On Wednesday 05 August 2009 16:46:13 Martin P. Hellwig wrote: > Hi List, > > On several occasions I have needed (and build) a parser that reads a > binary piece of data with custom structure. For example (bogus one): > > BE > +-+-+-+-+--++ > > | V

How to comment on a Python PEP?

2009-08-06 Thread Dr. Phillip M. Feldman
Is there a mechanism for submitting comments on a Python PEP? -- View this message in context: http://www.nabble.com/How-to-comment-on-a-Python-PEP--tp24840417p24840417.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python

Re: Datetime with float seconds

2009-08-06 Thread kpal
On Aug 6, 7:43 am, Hendrik van Rooyen wrote: > I am curious as to what would require less than microsecond > timing - about the only thing I can think of would be something > involving measuring the speed of light, where nanoseconds > or better would be nice. You are right :-) I am trying to wri

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-06 Thread Hendrik van Rooyen
On Wednesday 05 August 2009 20:12:05 Paul Rubin wrote: > "Martin P. Hellwig" writes: > > what I usually do is read the packet in binary mode, convert the > > output to a concatenated 'binary string'(i.e. '0101011000110') and > > Something wrong with reading the data words as an integer and using >

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-06 Thread Hendrik van Rooyen
On Wednesday 05 August 2009 21:41:26 Martin P. Hellwig wrote: > Yes you are (of course) right, my 'dream' solution would be something > that accepts slice indeces on bit level. Your reasoning did reveal some > flaws in my approach though ;-) This is the first time I have been compared to the sand

Re: merge two png pic

2009-08-06 Thread Xavier Ho
On Thu, Aug 6, 2009 at 12:17 PM, cocobear wrote: > > I want to view image use Windows Pic View. > > If you run out of memory trying to combining those images into a 30k by 40k pixels image, the Windows Pic View isn't going to be able to display it either. Regards, Ching-Yun "Xavier" Ho, Technic

Re: Subclassing Python's dict

2009-08-06 Thread Xavier Ho
On Thu, Aug 6, 2009 at 1:19 PM, alex23 wrote: > Xavier Ho wrote: > > You should subclass collections.UserDict, and not the default dict class. > > Refer to the collections module. > > Xavier, why do you think that is the correct approach? I'll be honest first and say that I do not completely un

Re: String to valid Python identifier

2009-08-06 Thread Martin v. Löwis
> Is there any easy function in the stdlib to convert any random string in > a valid Python identifier .. possibly by replacing non-valid characters > with _ ? I think this is fairly underspecified as a problem statement. A solution that would meet your specification would be def mkident(s):

Re: remove last 76 letters from string

2009-08-06 Thread Iain King
> print >>nucleotides, seq[-76] >      last_part = line.rstrip()[-76 : ] You all mean: seq[:-76] , right? (assuming you've already stripped any junk off the end of the string) Iain -- http://mail.python.org/mailman/listinfo/python-list

Re: os.system in a service

2009-08-06 Thread Gabriel Genellina
En Thu, 06 Aug 2009 03:59:13 -0300, Diez B. Roggisch escribió: Gabriel Genellina schrieb: En Wed, 05 Aug 2009 13:07:39 -0300, Lawrence Wong escribió: I wrote a program which runs a .bat file using os.system like: 'os.system(pathToBatFile)' and everything was good. Then I decided to tu

Re: remove last 76 letters from string

2009-08-06 Thread Xavier Ho
On Thu, Aug 6, 2009 at 6:28 PM, Iain King wrote: > > print >>nucleotides, seq[-76] > > > last_part = line.rstrip()[-76 : ] > > You all mean: seq[:-76] , right? (assuming you've already stripped > any junk off the end of the string) > I think so, probably both of them typo'd. (What

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-06 Thread sgriffiths
On Aug 5, 3:46 pm, "Martin P. Hellwig" wrote: > Hi List, > > On several occasions I have needed (and build) a parser that reads a > binary piece of data with custom structure. For example (bogus one): > > BE > +-+-+-+-+--++ > | Version | Command

Re: How to comment on a Python PEP?

2009-08-06 Thread Martin v. Löwis
> Is there a mechanism for submitting comments on a Python PEP? You post to python-dev or comp.lang.python, and you CC the author. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

handling kill signal

2009-08-06 Thread sanju ps
I want to handle a kill signal..In my program i wrote like this def handler(signum, frame): print "Signal",signum delete_temp_file() exit(1) signal.signal(signal.SIGTERM, handler) And when i tried pkill processid .program is exited but not deleting the temp file -- http://mail.python

Re: remove last 76 letters from string

2009-08-06 Thread MRAB
Iain King wrote: print >>nucleotides, seq[-76] last_part = line.rstrip()[-76 : ] You all mean: seq[:-76] , right? (assuming you've already stripped any junk off the end of the string) The OP said "cut out the last 76 letters (nucleotides) from each individual sequence and sen

Re: Problem in installing PyGreSQL

2009-08-06 Thread Thangappan.M
I have downloaded the psycopg2 tar file from the following link. http://initd.org/tracker/psycopg I have done the following things. * Extracting the files from the tar file * tried to execute python ./setup.py build It gives the following error. #python ./setup.py build runni

Cython + setuptools not working with .pyx,only with .c-files

2009-08-06 Thread Diez B. Roggisch
Hi, I'm trying to build a Cython-extension as Egg. However, this doesn't work - I can either use distutils to build the extension, creating a myextension.c-file on the way. If that's there, I can use setuptools to build the egg. But when I remove the .c-file, the .pyx-file isn't used to re-gen

Re: Subclassing Python's dict

2009-08-06 Thread Carl Banks
On Aug 5, 7:39 am, Bruno Desthuilliers wrote: > Sergey Simonenko a écrit : > > > Hi, > > > I subclass builtin 'dict' in my application and experience some problems > > with it. > > > The whole issue is that I should redefine 'setdefault' and 'update' > > methods after redefining '__setitem__' or/a

Re: Using Python to automate builds

2009-08-06 Thread David Cournapeau
On Thu, Aug 6, 2009 at 12:39 AM, Kosta wrote: > > Setenv.bat sets up the path and other environment variables build.exe > needs to compile and link (and even binplace) its utilities.  So > building itself is not the issue.  The problem is that if I call > setenv.bat from Python and then build.exe,

RE: os.system in a service

2009-08-06 Thread Lawrence Wong
I actually found the solution. I was trying to copy a file from another computer to the current one. My 'access was denied'. So I had to go to my service at Admin Tools --> Services and 'Log on as' the Administrator. Was ok after that. Thanks for your responses everyone. > To: python-li

Re: Cython + setuptools not working with .pyx,only with .c-files

2009-08-06 Thread David Cournapeau
On Thu, Aug 6, 2009 at 7:38 PM, Diez B. Roggisch wrote: > Hi, > > > I'm trying to build a Cython-extension as Egg. > > However, this doesn't work - I can either use distutils to build the > extension, creating a myextension.c-file on the way. > > If that's there, I can use setuptools to build the e

inspect.stack() performance

2009-08-06 Thread Doron Tal
I use inspect.stack() to extract some info, such as file name, function name and line number, for the sake of logging (home brew logger). I tested to see how much time it takes to execute the command: Python 2.4.3 (#1, Jan 21 2009, 01:11:33) [GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2 Type "

one method of COM object needs a variant type variable

2009-08-06 Thread MICHÁLEK Jan Mgr .
How i can use this type in win32.com? One method of com object (geomedia storage service) needs this variable for storage geometry of geometry object (this variable will be writen into blob in DB). Is possible make this variable in py?? Thanks Jelen/Stack -- http://mail.python.org/mailman/listi

Re: Overlap in python

2009-08-06 Thread Marcus Wanner
On 8/5/2009 10:56 AM, nn wrote: On Aug 5, 7:13 am, Marcus Wanner wrote: On 8/4/2009 6:09 PM, MRAB wrote: >>> parts = [(5, 9, "a"), (7, 10, "b"), (3, 6, "c"), (15, 20, "d"), (18, 23, "e")] >>> parts.sort() >>> parts [(3, 6, 'c'), (5, 9, 'a'), (7, 10, 'b'), (15, 20, 'd'), (18, 23, 'e')] >>>

Re: Python docs disappointing - group effort to hire writers?

2009-08-06 Thread Terry Reedy
RayS wrote: At 08:35 PM 8/5/2009 -0700, r wrote: """... Any real sense of community is undermined -- or even destroyed -- to be replaced by virtual equivalents that strive, unsuccessfully, to synthesize a sense of community.""" I've brought up the idea of the quasi-community doc that PHP uses

Re: remove last 76 letters from string

2009-08-06 Thread Iain King
On Aug 6, 11:34 am, MRAB wrote: > Iain King wrote: > >>      print >>nucleotides, seq[-76] > > >>      last_part = line.rstrip()[-76 : ] > > > You all mean:   seq[:-76]   , right? (assuming you've already stripped > > any junk off the end of the string) > > The OP said "cut out the last 76 letters

Re: unicode() vs. s.decode()

2009-08-06 Thread Jason Tackaberry
On Thu, 2009-08-06 at 01:31 +, John Machin wrote: > Faster by an enormous margin; attributing this to the cost of attribute lookup > seems implausible. Ok, fair point. I don't think the time difference fully registered when I composed that message. Testing a global access (LOAD_GLOBAL) versu

Re: unicode() vs. s.decode()

2009-08-06 Thread Thorsten Kampe
* Michael Ströder (Wed, 05 Aug 2009 16:43:09 +0200) > These both expressions are equivalent but which is faster or should be > used for any reason? > > u = unicode(s,'utf-8') > > u = s.decode('utf-8') # looks nicer "decode" was added in Python 2.2 for the sake of symmetry to encode(). It's esse

Re: Python docs disappointing - group effort to hire writers?

2009-08-06 Thread Kee Nethery
On Aug 6, 2009, at 6:55 AM, Terry Reedy wrote: RayS wrote: At 08:35 PM 8/5/2009 -0700, r wrote: """... Any real sense of community is undermined -- or even destroyed -- to be replaced by virtual equivalents that strive, unsuccessfully, to synthesize a sense of community.""" I've brought up th

ANN: Python for Bioinformatics book

2009-08-06 Thread Sebastian Bassi
"Python for Bioinformatics" ISBN 1584889292 Amazon: http://www.tinyurl.com/biopython Publisher: http://www.crcpress.com/product/isbn/9781584889298 This book introduces programming concepts to life science researchers, bioinformaticians, support staff, students, and everyone who is interested in ap

Help making this script better

2009-08-06 Thread jakecjacobson
Hi, After much Google searching and trial & error, I was able to write a Python script that posts XML files to a REST API using HTTPS and passing PEM cert & key file. It seems to be working but would like some pointers on how to handle errors. I am using Python 2.4, I don't have the capability t

Re: ANN: Python for Bioinformatics book

2009-08-06 Thread Bearophile
Sebastian Bassi: > All code is also available at thehttp://py3.us/##where ## is the code number, > for example:http://py3.us/57< The book looks interesting, but that doesn't look like a good way to show/offer the code. I suggest to also put it into a zip that can be downloaded. Bye, bearophile

Re: ANN: Python for Bioinformatics book

2009-08-06 Thread Sebastian Bassi
On Thu, Aug 6, 2009 at 11:52 AM, Bearophile wrote: > The book looks interesting, but that doesn't look like a good way to > show/offer the code. I suggest to also put it into a zip that can be > downloaded. Code is also in a directory in the DVD and also inside the virtual machine. Anyway I think

Help with regex

2009-08-06 Thread Robert Dailey
Hey guys, I'm creating a python script that is going to try to search a text file for any text that matches my regular expression. The thing it is looking for is: FILEVERSION #,#,#,# The # symbol represents any number that can be any length 1 or greater. Example: FILEVERSION 1,45,10082,3 The r

Re: Python configuration question when python scripts are executed using Appweb as web server.

2009-08-06 Thread IronyOfLife
Hi Gabriel On Aug 5, 4:18 pm, "Gabriel Genellina" wrote: > En Tue, 04 Aug 2009 10:15:24 -0300, IronyOfLife > escribió: > > > On Aug 3, 8:42 pm, "Gabriel Genellina" wrote: > >> En Mon, 03 Aug 2009 11:04:07 -0300, IronyOfLife   > >> escribió: > > >> > I have installed python 2.6.2 in windows xp

Re: Python docs disappointing - group effort to hire writers?

2009-08-06 Thread alex23
Kee Nethery wrote: > As I struggle through trying to figure out how to make python do   > simple stuff for me, I frequently generate samples. If some volunteer   > here would point me towards the documentation that would tell me how I   > can alter the existing Python docs to include sample code, I

Re: Help with regex

2009-08-06 Thread MRAB
Robert Dailey wrote: Hey guys, I'm creating a python script that is going to try to search a text file for any text that matches my regular expression. The thing it is looking for is: FILEVERSION #,#,#,# The # symbol represents any number that can be any length 1 or greater. Example: FILEVERS

Re: Help with regex

2009-08-06 Thread alex23
On Aug 7, 1:35 am, Robert Dailey wrote: > I'm creating a python script that is going to try to search a text > file for any text that matches my regular expression. The thing it is > looking for is: > > FILEVERSION 1,45,10082,3 Would it be easier to do it without regex? The following is untested

Character encoding & the copyright symbol

2009-08-06 Thread Robert Dailey
Hello, I'm loading a file via open() in Python 3.1 and I'm getting the following error when I try to print the contents of the file that I obtained through a call to read(): UnicodeEncodeError: 'charmap' codec can't encode character '\xa9' in position 1650: character maps to The file is defined

Re: How to comment on a Python PEP?

2009-08-06 Thread Robert Kern
On 2009-08-06 03:42, "Martin v. Löwis" wrote: Is there a mechanism for submitting comments on a Python PEP? You post to python-dev or comp.lang.python, and you CC the author. And be sure to put the PEP number in the Subject: line. -- Robert Kern "I have come to believe that the whole world

Re: Help with regex

2009-08-06 Thread Robert Dailey
On Aug 6, 11:02 am, MRAB wrote: > Robert Dailey wrote: > > Hey guys, > > > I'm creating a python script that is going to try to search a text > > file for any text that matches my regular expression. The thing it is > > looking for is: > > > FILEVERSION #,#,#,# > > > The # symbol represents any nu

Re: Web page data and urllib2.urlopen

2009-08-06 Thread ryles
On Aug 5, 4:30 pm, Massi wrote: > Hi everyone, I'm using the urllib2 library to get the html source code > of web pages. In general it works great, but I'm having to do with a > financial web site which does not provide the souce code I expect. As > a matter of fact if you try: > > import urllib2

Re: Python docs disappointing - group effort to hire writers?

2009-08-06 Thread Paul Rubin
alex23 writes: > No offence, but the last thing the official documentation needs is > example code written by people learning how to code. Suggest changes, > request clarifications, submit samples for review, sure, but direct > modification by users? I've seen the PHP docs; thanks but no thanks.

Re: unicode() vs. s.decode()

2009-08-06 Thread Michael Ströder
Thorsten Kampe wrote: > * Michael Ströder (Wed, 05 Aug 2009 16:43:09 +0200) >> These both expressions are equivalent but which is faster or should be >> used for any reason? >> >> u = unicode(s,'utf-8') >> >> u = s.decode('utf-8') # looks nicer > > "decode" was added in Python 2.2 for the sake of

Re: Character encoding & the copyright symbol

2009-08-06 Thread Philip Semanchuk
On Aug 6, 2009, at 12:14 PM, Robert Dailey wrote: Hello, I'm loading a file via open() in Python 3.1 and I'm getting the following error when I try to print the contents of the file that I obtained through a call to read(): UnicodeEncodeError: 'charmap' codec can't encode character '\xa9' in

Re: Help with regex

2009-08-06 Thread MRAB
Robert Dailey wrote: On Aug 6, 11:02 am, MRAB wrote: Robert Dailey wrote: Hey guys, I'm creating a python script that is going to try to search a text file for any text that matches my regular expression. The thing it is looking for is: FILEVERSION #,#,#,# The # symbol represents any number th

Re: Character encoding & the copyright symbol

2009-08-06 Thread Richard Brodie
"Robert Dailey" wrote in message news:29ab0981-b95d-4435-91bd-a7a520419...@b15g2000yqd.googlegroups.com... > UnicodeEncodeError: 'charmap' codec can't encode character '\xa9' in > position 1650: character maps to > > The file is defined as ASCII. That's the problem: ASCII is a seven bit code.

Re: Help with regex

2009-08-06 Thread Roman
On 06/08/09 08:35, Robert Dailey wrote: > Hey guys, > > I'm creating a python script that is going to try to search a text > file for any text that matches my regular expression. The thing it is > looking for is: > > FILEVERSION #,#,#,# > > The # symbol represents any number that can be any leng

Re: Two Dimensional Array + ctypes

2009-08-06 Thread Sparky
On Aug 5, 11:19 pm, "Gabriel Genellina" wrote: > En Wed, 05 Aug 2009 20:12:09 -0300, Sparky escribió: > > > > > > > Hello! I am trying to call this method: > > > long _stdcall AIBurst(long *idnum, [...] > >                     long timeout, > >                     float (*voltages)[4], > >      

Re: Using easy_install, reduncant?

2009-08-06 Thread Adam N
On Jul 27, 7:53 pm, David Lyon wrote: > On Mon, 27 Jul 2009 09:42:06 -0700 (PDT), ray > wrote: > > > I am working on a Trac installation.  I am new to Python.  To install > > packages, it is suggested to use setuptools.  I have not understood > > the directions. > > > I execute ez_install.py. > >

Re: Character encoding & the copyright symbol

2009-08-06 Thread Robert Dailey
On Aug 6, 11:31 am, "Richard Brodie" wrote: > "Robert Dailey" wrote in message > > news:29ab0981-b95d-4435-91bd-a7a520419...@b15g2000yqd.googlegroups.com... > > > UnicodeEncodeError: 'charmap' codec can't encode character '\xa9' in > > position 1650: character maps to > > > The file is defined a

Re: Help with regex

2009-08-06 Thread Robert Dailey
On Aug 6, 11:12 am, Roman wrote: > On 06/08/09 08:35, Robert Dailey wrote: > > > > > > > Hey guys, > > > I'm creating a python script that is going to try to search a text > > file for any text that matches my regular expression. The thing it is > > looking for is: > > > FILEVERSION #,#,#,# > > >

Re: Character encoding & the copyright symbol

2009-08-06 Thread Albert Hopkins
On Thu, 2009-08-06 at 09:14 -0700, Robert Dailey wrote: > Hello, > > I'm loading a file via open() in Python 3.1 and I'm getting the > following error when I try to print the contents of the file that I > obtained through a call to read(): > > UnicodeEncodeError: 'charmap' codec can't encode char

Re: Character encoding & the copyright symbol

2009-08-06 Thread Philip Semanchuk
On Aug 6, 2009, at 12:41 PM, Robert Dailey wrote: On Aug 6, 11:31 am, "Richard Brodie" wrote: "Robert Dailey" wrote in message news:29ab0981-b95d-4435-91bd-a7a520419...@b15g2000yqd.googlegroups.com ... UnicodeEncodeError: 'charmap' codec can't encode character '\xa9' in position 1650: c

Re: Character encoding & the copyright symbol

2009-08-06 Thread Richard Brodie
"Robert Dailey" wrote in message news:f64f9830-c416-41b1-a510-c1e486271...@g19g2000vbi.googlegroups.com... > As you can see, I am trying to load the file with encoding 'cp1252' > which, according to the python 3.1 docs, translates to windows-1252. I > also tried 'latin_1', which translates to I

Re: Using Python to automate builds

2009-08-06 Thread Kosta
On Aug 6, 3:57 am, David Cournapeau wrote: > On Thu, Aug 6, 2009 at 12:39 AM, Kosta wrote: > > > Setenv.bat sets up the path and other environment variables build.exe > > needs to compile and link (and even binplace) its utilities.  So > > building itself is not the issue.  The problem is that if

Re: Overlap in python

2009-08-06 Thread John Ladasky
On Aug 4, 3:21 pm, Jay Bird wrote: > Hi everyone, > > I wanted to thank you all for your help and *excellent* discussion.  I > was able to utilize and embed the script by Grigor Lingl in the 6th > post of this discussion to get my program to work very quickly (I had > to do about 20 comparisons pe

Unexpected side-effects of assigning to sys.modules[__name__]

2009-08-06 Thread Steven D'Aprano
Given this module: #funny.py import sys print "Before:" print " __name__ =", __name__ print " sys.modules[__name__] =", sys.modules[__name__] sys.modules[__name__] = 123 print "After:" print " __name__ =", __name__ print " sys =", sys when I run it I get these results: [st...@sylar python]

Re: Help with regex

2009-08-06 Thread Nobody
On Thu, 06 Aug 2009 08:35:57 -0700, Robert Dailey wrote: > I'm creating a python script that is going to try to search a text > file for any text that matches my regular expression. The thing it is > looking for is: > > FILEVERSION #,#,#,# > > The # symbol represents any number that can be any l

Re: Unexpected side-effects of assigning to sys.modules[__name__]

2009-08-06 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: Given this module: #funny.py import sys print "Before:" print " __name__ =", __name__ print " sys.modules[__name__] =", sys.modules[__name__] sys.modules[__name__] = 123 print "After:" print " __name__ =", __name__ print " sys =", sys when I run it I get these result

Re: unicode() vs. s.decode()

2009-08-06 Thread Thorsten Kampe
* Michael Ströder (Thu, 06 Aug 2009 18:26:09 +0200) > Thorsten Kampe wrote: > > * Michael Ströder (Wed, 05 Aug 2009 16:43:09 +0200) > > I don't think any measurable speed increase will be noticeable > > between those two. > > Well, seems not to be true. Try yourself. I did (my console has UTF-8 as

Re: Character encoding & the copyright symbol

2009-08-06 Thread Nobody
On Thu, 06 Aug 2009 09:14:08 -0700, Robert Dailey wrote: > I'm loading a file via open() in Python 3.1 and I'm getting the > following error when I try to print the contents of the file that I > obtained through a call to read(): > > UnicodeEncodeError: 'charmap' codec can't encode character '\xa

Re: Python docs disappointing - group effort to hire writers?

2009-08-06 Thread r
On Aug 6, 11:20 am, Paul Rubin wrote: ...(snip) > There is something similar with the PostgreSQL docs.  There is also > Real World Haskell (http://book.realworld.haskell.org) which has a lot > of interspersed user comments.  It would be cool if Python's doc site > did

pylucene installation problem on Ubuntu 9.04

2009-08-06 Thread KK
hi all, I've trying to install pylucene on my linux box from last 2 days but not able to do so. first i tried to install it using apt-get like this, kk-laptop$ sudo apt-get install pylucene and it did install python2.5, python2.5-minimal and pylucene. I must mention one thing that I already had pyt

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-06 Thread Martin P. Hellwig
Thanks all for your insights and suggestions. It seems to me that there are a couple of ways to this bit manipulation and a couple of foreign modules to assist you with that. Would it be worth the while to do a PEP on this? Personally I think that it would be nice to have a standard module in

Re: Using Python to automate builds

2009-08-06 Thread Piet van Oostrum
> Kosta (K) wrote: >K> My interpretation of the above (and your email) is that using Popen >K> allows one to pass the Python environment to a child processs (in my >K> case, setenv.bat). I need the reverse, to propagate from the child >K> to the parent. I don't think there is any modern OS

Python-URL! - weekly Python news and links (Aug 6)

2009-08-06 Thread Gabriel Genellina
QOTW: "The economy rises and falls, money comes and goes, but a great conference has permanent good effects. Well, a lot more permanent than government fiscal policy, anyway." - Python Software Foundation Director "bitter-in-victory-gracious-in-defeat-ly y'rs" timbot Is python free of "

Re: Python docs disappointing

2009-08-06 Thread Wesley Chun
On Jul 31, 1:10 pm, kj wrote: > I'm pretty new to Python, and I like a lot overall, but I find the > documentation for Python rather poor, overall. > > I'm sure that Python experts don't have this problem: kj, welcome to Python! i'm sorry that you find the documentation lacking. the one thing a

Re: Character encoding & the copyright symbol

2009-08-06 Thread Martin v. Löwis
> As a side note, you should probably use something other than "file" for > the parameter name in GetFileContentsAsString() since file() is a Python > function. Python 3.1.1a0 (py3k:74094, Jul 19 2009, 13:39:42) [GCC 4.3.3] on linux2 Type "help", "copyright", "credits" or "license" for more inform

Re: Web page data and urllib2.urlopen

2009-08-06 Thread Piet van Oostrum
> Dave Angel (DA) wrote: >DA> Massi wrote: >>> Hi everyone, I'm using the urllib2 library to get the html source code >>> of web pages. In general it works great, but I'm having to do with a >>> financial web site which does not provide the souce code I expect. As >>> a matter of fact if you

Re: unicode() vs. s.decode()

2009-08-06 Thread Steven D'Aprano
On Thu, 06 Aug 2009 20:05:52 +0200, Thorsten Kampe wrote: > > That is significant! So the winner is: > > > > unicode('äöüÄÖÜß','utf-8') > > Unless you are planning to write a loop that decodes "äöüÄÖÜß" one > million times, these benchmarks are meaningless. What if you're writing a loop which t

Re: Character encoding & the copyright symbol

2009-08-06 Thread Philip Semanchuk
On Aug 6, 2009, at 3:14 PM, Martin v. Löwis wrote: As a side note, you should probably use something other than "file" for the parameter name in GetFileContentsAsString() since file() is a Python function. Python 3.1.1a0 (py3k:74094, Jul 19 2009, 13:39:42) [GCC 4.3.3] on linux2 Type "help

Re: pylucene installation problem on Ubuntu 9.04

2009-08-06 Thread Jon Clements
On 6 Aug, 19:49, KK wrote: > hi all, > I've trying to install pylucene on my linux box from last 2 days but > not able to do so. first i tried to install it using apt-get like > this, > kk-laptop$ sudo apt-get install pylucene > and it did install python2.5, python2.5-minimal and pylucene. I must

Re: pylucene installation problem on Ubuntu 9.04

2009-08-06 Thread Benjamin Kaplan
On Thu, Aug 6, 2009 at 2:49 PM, KK wrote: > > kk-laptop$ sudo apt-get install pylucene > and it did install python2.5, python2.5-minimal and pylucene. I must > mention one thing that I already had python2.6 on my box as the > default python i.e /usr/bin/python is linked to python2.6. Anyway s, > no

Re: Character encoding & the copyright symbol

2009-08-06 Thread Benjamin Kaplan
On Thu, Aug 6, 2009 at 12:41 PM, Robert Dailey wrote: > On Aug 6, 11:31 am, "Richard Brodie" wrote: >> "Robert Dailey" wrote in message >> >> news:29ab0981-b95d-4435-91bd-a7a520419...@b15g2000yqd.googlegroups.com... >> >> > UnicodeEncodeError: 'charmap' codec can't encode character '\xa9' in >> >

Re: Using Python to automate builds

2009-08-06 Thread Aahz
In article , Hendrik van Rooyen wrote: > >Bit slow - but hey, nobody's perfect. YM "pobody's nerfect" HTH HAND -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "...string iteration isn't about treating strings as sequences of strings, it's about treating string

Re: How to write replace string for object which will be substituted? [regexp]

2009-08-06 Thread Aahz
In article , ryniek90 wrote: > >I started learning regexp, and some things goes well, but most of them >still not. 1) 'Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.' --Jamie Zawinski, comp.emacs.xemacs, 8/1997 2) If you

Re: Using Python to automate builds

2009-08-06 Thread Kosta
On Aug 6, 11:58 am, Piet van Oostrum wrote: > > Kosta (K) wrote: > >K> My interpretation of the above (and your email) is that using Popen > >K> allows one to pass the Python environment to a child processs (in my > >K> case, setenv.bat).   I need the reverse, to propagate from the child > >K

Re: Character encoding & the copyright symbol

2009-08-06 Thread Dave Angel
Robert Dailey wrote: Hello, I'm loading a file via open() in Python 3.1 and I'm getting the following error when I try to print the contents of the file that I obtained through a call to read(): UnicodeEncodeError: 'charmap' codec can't encode character '\xa9' in position 1650: character maps t

Re: Subclassing Python's dict

2009-08-06 Thread Raymond Hettinger
> Are you referring to Python 3.0?  Python 2.6 does not have > collections.UserDict In Python2.6, it is in its own module. >>> from UserDict import UserDict Raymond -- http://mail.python.org/mailman/listinfo/python-list

How to write replace string for object which will be substituted? [regexp]

2009-08-06 Thread Ryniek90
2) If you really want to learn regexes, get a copy of _Mastering Regular Expressions_ by Friedl (either 2nd or 3rd edition) I made preview of that book, but some pages are disabled from preview. Has that book topics about Python regexp's? If so, i must buy it. -- http://mail.python.org/ma

Re: os.walk()

2009-08-06 Thread Chris Rebert
> On Tue, Aug 4, 2009 at 10:48 PM, Chris Rebert wrote: >> On Tue, Aug 4, 2009 at 7:06 PM, Michael Savarese wrote: >> > Greetings >> > Python newbie here, and thanks to all who have helped me previously. >> > Is there a way of grabbing file attributes while traversing with os.walk()? >> > It would

Re: How to write replace string for object which will be substituted? [regexp]

2009-08-06 Thread Chris Rebert
On Thu, Aug 6, 2009 at 2:03 PM, Ryniek90 wrote: >> 2) If you really want to learn regexes, get a copy of _Mastering Regular >> Expressions_ by Friedl (either 2nd or 3rd edition) >> > > I made preview of that book, but some pages are disabled from preview. Has > that book topics about Python regexp'

Re: Subclassing Python's dict

2009-08-06 Thread Raymond Hettinger
> Xavier Ho wrote: > > You should subclass collections.UserDict, and not the default dict class. > > Refer to the collections module. > > Xavier, why do you think that is the correct approach? The docs say > "The need for this class has been largely supplanted by the ability to > subclass directly

Re: Seeding the rand() Generator

2009-08-06 Thread Nils Ruettershoff
Hi Fred, I just saw your SQL Statement An example would be: SELECT first, second, third, fourth, fifth, sixth from sometable order by rand() limit 1 and I feel me constrained to give you an advice. Don't use this SQL statement to pick up a random row, your user and maybe DBA would

Re: os.path.exists() and Samba shares

2009-08-06 Thread BDZ
On Jul 31, 10:56 pm, "Gabriel Genellina" wrote: > En Fri, 31 Jul 2009 13:33:45 -0300, BDZ escribió: > > > > > On Jul 30, 4:41 pm, Loïc Domaigné > > wrote: > >> > Hello. I have written a Python 3.1 script running on Windows that uses > >> > os.path.exists() to connect to network shares. If the va

XML flaw

2009-08-06 Thread MRAB
Hi all, I've just read this article, which mentions Python: XML flaw threatens millions of apps with DoS attacks http://infoworld.com/print/86340 Something to worry about? -- http://mail.python.org/mailman/listinfo/python-list

Re: Unexpected side-effects of assigning to sys.modules[__name__]

2009-08-06 Thread Steven D'Aprano
On Thu, 06 Aug 2009 20:01:42 +0200, Jean-Michel Pichavant wrote: > > I'm completely perplexed by this behaviour. sys.modules() seems to be > > a regular dict, at least according to type(), and yet assigning to an > > item of it seems to have unexpected, and rather weird, side-effects. > > > > Wha

Re: Re: Web page data and urllib2.urlopen

2009-08-06 Thread Dave Angel
Piet van Oostrum wrote: DA> If Mozilla had seen a page with this line in an appropriate place, it'd DA> immediately begin loading the other page, at "someotherurl" But there's no DA> such line. DA> Next, I looked for javascript. The Mozilla page contains lots of DA> javascript, b

Re: Help with regex

2009-08-06 Thread Ethan Furman
Nobody wrote: On Thu, 06 Aug 2009 08:35:57 -0700, Robert Dailey wrote: I'm creating a python script that is going to try to search a text file for any text that matches my regular expression. The thing it is looking for is: FILEVERSION #,#,#,# The # symbol represents any number that can be a

Re: XML flaw

2009-08-06 Thread Chris Rebert
On Thu, Aug 6, 2009 at 3:05 PM, MRAB wrote: > Hi all, > > I've just read this article, which mentions Python: > > XML flaw threatens millions of apps with DoS attacks > http://infoworld.com/print/86340 > > Something to worry about? More detailed article: http://blogs.zdnet.com/open-source/?p=4609

Re: XML flaw

2009-08-06 Thread Mark Lawrence
MRAB wrote: Hi all, I've just read this article, which mentions Python: XML flaw threatens millions of apps with DoS attacks http://infoworld.com/print/86340 Something to worry about? No. Discussing letting Tom, Dick and Harriet loose on the Python documentaion is far more important than tri

Setuptools - help!

2009-08-06 Thread Peter Chant
Chaps, any ideas, I'm floundering - I don't quite get it. I have the following files, setup.py and main.py in a directory pphoto: # more setup.py from setuptools import setup, find_packages setup( name = "Pphoto", version = "0.1", packages = find_packages(), # other arguments he

Re: Setuptools - help!

2009-08-06 Thread Robert Kern
On 2009-08-06 18:04, Peter Chant wrote: Chaps, any ideas, I'm floundering - I don't quite get it. I have the following files, setup.py and main.py in a directory pphoto: # more setup.py from setuptools import setup, find_packages setup( name = "Pphoto", version = "0.1", packages

Python3: Using sorted(key=...)

2009-08-06 Thread Johannes Bauer
Hello list, I'm having trouble with a incredibly simple sort of a list containing ints and tuples: def myorder(x): if type(x) == int: return x else: return x[0] odata = sorted([ (a, b) for (a, b) in data["description"].items() ], key=myorder) stil

Re: heapq "key" arguments

2009-08-06 Thread Joshua Bronson
On Aug 3, 1:36 pm, Raymond Hettinger wrote: > [Joshua Bronson]: > > > According tohttp://docs.python.org/library/heapq.html, Python 2.5 > > added an optional "key" argument to heapq.nsmallest and > > heapq.nlargest. I could never understand why they didn't also add a > > "key" argument to the othe

Re: Help making this script better

2009-08-06 Thread Gabriel Genellina
En Thu, 06 Aug 2009 11:50:07 -0300, jakecjacobson escribió: After much Google searching and trial & error, I was able to write a Python script that posts XML files to a REST API using HTTPS and passing PEM cert & key file. It seems to be working but would like some pointers on how to handle

Re: Subclassing Python's dict

2009-08-06 Thread Gabriel Genellina
En Thu, 06 Aug 2009 05:26:22 -0300, Xavier Ho escribió: On Thu, Aug 6, 2009 at 1:19 PM, alex23 wrote: Xavier Ho wrote: > You should subclass collections.UserDict, and not the default dict class. Xavier, why do you think that is the correct approach? I'll be honest first and say that I do

Re: Help with regex

2009-08-06 Thread John Machin
On Aug 7, 7:23 am, Ethan Furman wrote: > Nobody wrote: > > On Thu, 06 Aug 2009 08:35:57 -0700, Robert Dailey wrote: > > >>I'm creating a python script that is going to try to search a text > >>file for any text that matches my regular expression. The thing it is > >>looking for is: > > >>FILEVERSI

  1   2   >