Re: Creating 50K text files in python

2009-03-18 Thread Laurent Rahuel
Hi, I don't know why you are forking shells using os.system. You should either use system commands to do the job or plain python, but mixing both should never be an option. Here is a plain portable python script (using the with statement. Your python should not be to old) from __future__

Re: read file into list of lists

2008-07-11 Thread Laurent Rahuel
Hello, A way to do it === from __future__ import with_statement res = [] with open("sentences.txt","r") as f: sentences = [elem for elem in f.read().split('\n') if elem] for sentence in sentences: res.append(sentence.split()) p

Re: Python in non-standard location erring with "No module named _sha256"

2008-05-21 Thread Laurent Rahuel
Maybe you run the configure, make, make install without addind devel packages on your system. I mean: openssl-devel readline-devel ... Regards, emallove wrote: > I'm running into the below "No modules named _sha256" issue, with a > python installed in a non-standard location. > > $ python > Py

Re: python noob, multiple file i/o

2007-03-16 Thread Laurent Rahuel
Maybe the walk method in os module is what you need http://docs.python.org/lib/os-file-dir.html Regards Jon Clements wrote: > On 16 Mar, 09:02, "Jon Clements" <[EMAIL PROTECTED]> wrote: >> On 16 Mar, 03:56, "hiro" <[EMAIL PROTECTED]> wrote: >> >> >> >> >> >> > Hi there, >> >> > I'm very new to p

Re: The Python interactive interpreter has no command history

2007-02-15 Thread Laurent Rahuel
Hi, You need to have readline installed. Laurent ThomasC wrote: > Hello, > > How to configure Python2.5's interactive interpreter to get command > history ? > > I always got ^[[A and ^[[B . > > Thank you !! > > Thomas# -- http://mail.python.org/mailman/listinfo/python-list

Re: "Correct" db adapter

2007-01-31 Thread Laurent Rahuel
Maybe you should take a look at sqlalchemy king kikapu wrote: > Hi to all, > > i have started a month ago to seriously studying Python. I am now > looking at the databases stuff > and i want the opinion of more experienced Python programmers (than > me) at the following : > > I see that there a

Re: how to remove c++ comments from a cpp file?

2007-01-26 Thread Laurent Rahuel
And using the codecs module [CODE] import codecs f = codecs.open("show_btchina.user.js","r","utf-8") modf = codecs.open("modified.js","w","utf-8") for line in f: idx = line.find(u"//") if idx==0: continue elif idx>0: line = line[:idx]+u'\n' modf.write(line) m

Re: My python programs need a GUI, wxPython or PyQt4?

2007-01-24 Thread Laurent Rahuel
Hi, I known this can be impossible but what about an "HTML" GUI ? Daniel Jonsson wrote: > So, I've reached the point where my building pipeline tools actually > needs to be used by other people in my company. By this reason I > actually need to think about the usability, and I've come to the > c

Re: Python Windows Editors

2007-01-21 Thread laurent rahuel
Hi, I guess you could take a look at pydev extension for eclipse and if you wan't an almost straight forward installation, you should consider this link : http://www.easyeclipse.org/site/distributions/python.html Regards, Laurent W. Watson a écrit : > I downloaded python-2.5.msi and installed

Re: getting the name of hyperlinks in a file

2007-01-15 Thread Laurent Rahuel
Hi, I guess you should take a look at BeautifulSoup (http://www.crummy.com/software/BeautifulSoup/). And take a clooser look at the findAll method. http://www.crummy.com/software/BeautifulSoup/documentation.html#The%20basic%20find%20method %20findAll(name,%20attrs,%20recursive,%20text,%20limit,%2

Re: find a .py path

2007-01-05 Thread laurent rahuel
Hi, What about : import os.path print os.path.abspath(__file__) hg a écrit : > Hi, > > Is there an easy way for a script being executed (from anywhere) to know > where is is ... something in os.path ? > > Thanks, > > hg > -- http://mail.python.org/mailman/listinfo/python-list

Re: importing / loading a module / class dynamically

2007-01-05 Thread laurent rahuel
Hi, Using exec or eval ISN'T what should be done ever. When you have troubles importing you should : - Add some repository to your sys.path and/or - Use the buildin import method and/or - Use Mr Eby's Importing module (http://python.org/pypi/Importing) Regards, Laurent hg a écrit : > Hi, > >

metaclass : parse all class once before doing anything else ?

2006-07-28 Thread Laurent Rahuel
Hi, I have a much to smart problem for my brain. Here is the deal : I got a metaclass named Foo Then I got two others classes: class Bar(Foo): pass class Baz(Foo): pass I know how to add some attrs, methods to Bar and Baz when the module is loaded but I need to do something m

Re: text representation of HTML

2006-07-19 Thread Laurent Rahuel
Hi, I guess stripogram would be more pythonic : http://sourceforge.net/project/showfiles.php?group_id=1083 Regards, Laurent Diez B. Roggisch wrote: > Ksenia Marasanova wrote: > >> Hi, >> >> I am looking for a library that will give me very simple text >> representation of HTML. >> For exampl

Re: style question

2006-06-26 Thread Laurent Rahuel
Hari Sekhon wrote: > Is it better to do: > > message = """This is line1. > This is line2 > This is line3\n""" > > or > > message = "This is line1.\n > message = message + "This is line2\n" > message = message + "This is line3\n" > > > Since the first method does not follow python's clean and

Re: how to comment lot of lines in python

2006-03-30 Thread Laurent Rahuel
[EMAIL PROTECTED] wrote: > Like in C we comment like > /* > Bunch of lines of code > */ > > Should we use docstring """ """ > > Or there is something else too ?? > > Every help is appreciated. > > Thanks Hi, Maybe this sounds simplier than regexp and so, just use the """ marker like this : "

Re: django and mod_python

2006-03-06 Thread Laurent Rahuel
Bruno Desthuilliers wrote: > [EMAIL PROTECTED] a écrit : >> Hi, >> >> I read the mod_python documentation on the Django site but I'm getting >> this error: >> >> EnvironmentError: Could not import DJANGO_SETTINGS_MODULE >> 'accesshiphop.settings' (is it on sys.path?): No module named >> accesshi

Re: How to creat a file?

2005-12-02 Thread Laurent RAHUEL
sandorf wrote: > I'm new to python. Have a simple question. > > "open" function can only open an existing file and raise a IOerror when > the given file does not exist. How can I creat a new file then? fic = open('test.txt', 'w') fic.write('Hello world') fic.close() -- http://mail.python.org/

Re: Converting a flat list to a list of tuples

2005-11-22 Thread Laurent Rahuel
metiu uitem wrote: > Say you have a flat list: > ['a', 1, 'b', 2, 'c', 3] > > How do you efficiently get > [['a', 1], ['b', 2], ['c', 3]] > > I was thinking of something along the lines of: > for (key,number) in list: > print key, number > > but it's not working... > > Thank you Hi, newLis

Re: "dynamical" importing

2005-10-19 Thread Laurent Rahuel
Hi, I guess you need to look at __import__ Regards, Laurent. Joerg Schuster wrote: > Hello, > > I need to import modules from user defined paths. I.e. I want to do > something > like: > > module_dir = sys.argv[1] > > my_path = os.path.join(module_dir, 'bin', 'my_module') > > from my_path i

Re: Reading a CSV file into a list of dictionaries

2005-06-07 Thread Laurent RAHUEL
John Machin wrote: > Laurent RAHUEL wrote: >> RFQ wrote: >> >> >>>Hi, I'm struggling here to do the following with any success: >>> >>>I have a comma delimited file where each line in the file is something >>>like: >>&

Re: Reading a CSV file into a list of dictionaries

2005-06-07 Thread Laurent RAHUEL
RFQ wrote: > Hi, I'm struggling here to do the following with any success: > > I have a comma delimited file where each line in the file is something > like: > > PNumber,3056,Contractor,XYZ Contracting,Architect,ABC Architects,... This is NOT a CSV file. A CSV file would be : PNumber,Contracto