Re: While loop - print several times but on 1 line.

2006-01-26 Thread bruno at modulix
Jeffrey Schwab wrote: > Danny wrote: > >> Great! It's been solved. >> >> The line, as Glaudio said has a "," at the end and that makes it go >> onto one line, thanks so much man! >> >> var = 0 >> while <= 5: >> print a[t[var]], >> var = var +1 >> prints perfectly, thanks so much guys. > >

Re: ImportError: No module name MySQLdb

2006-01-26 Thread Fred
Re-reading my message I noticed a stupid error, not effecting my problem but annoying, I assigned variables and then did not use them, then included import cgi for my regular script. This is how the command line script should look: #!/usr/bin/python import MySQLdb db=MySQLdb.connect(host = '192.

isplit

2006-01-26 Thread bearophileHUGS
I have a file of lines that contains some extraneous chars, this the basic version of code to process it: IDtable = "".join(map(chr, xrange(256))) text = file("...", "rb").read().translate(IDtable, toRemove) for raw_line in file(file_name): line = raw_line.translate(IDtable, toRemove) ... A

en la misma linea

2006-01-26 Thread Sebastian Bassi
Hola, Aca con una pregunta basica: A veces veo que hay programas que tienen varias instrucciones en la misma linea, cuando lo que aprendi de Python era que se usaba el espaciado para mantener la estructura (indent). Por ejemplo: if name != 'comic': return Hay un return despues de los dos puntos, n

Re: Converting date to milliseconds since 1-1-70

2006-01-26 Thread Xavier Morel
NateM wrote: > Thank you! If I am reading in dates as strings from a text file, like > "5/11/1998", how do I convert that to a format I can pass into mktime? > Thanks again. > Check time.strptime() -- http://mail.python.org/mailman/listinfo/python-list

Re: While loop - print several times but on 1 line.

2006-01-26 Thread bruno at modulix
Danny wrote: > I think I should paste some of the programs code a little more of what I > want... probably... > var = 0 > while var <= 5: > print a[t[var]] > var = var +1 > > a is a dectionary (very big) and t is a string of text. (if that's > important right now). It might be important

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Jeffrey Schwab
Danny wrote: > Great! It's been solved. > > The line, as Glaudio said has a "," at the end and that makes it go onto > one line, thanks so much man! > > var = 0 > while <= 5: > print a[t[var]], > var = var +1 > prints perfectly, thanks so much guys. Looping over indexes is kinda unpyth

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Sion Arrowsmith
Danny <[EMAIL PROTECTED]> wrote: >The programs output will be: >text >text >(etc) > >How could I make this print: texttexttexttexttext? >Ive researched and looked through google and so far I can't find >anything that will help (or revelent for that matter). I'm kind of surprised this isn't a FAQ

Re: ZODB and Zope on one Linux machine, how?

2006-01-26 Thread Rene Pijlman
Terry Hancock: >Rene Pijlman: >> Option 1: >> Install ZODB in the Python installation in the usual way. >> Should I expect problems when I install and run zope with >> that Python installation? > >I think this should work, actually. > >ZODB is just like other databases in that each application >is

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Fredrik Lundh
Danny wrote: > Great! It's been solved. > > The line, as Glaudio said has a "," at the end and that makes it go onto > one line, thanks so much man! > > var = 0 > while <= 5: >print a[t[var]], >var = var +1 > prints perfectly, thanks so much guys. if you wanted spaces between the items, w

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Fredrik Lundh
Danny wrote: > I think I should paste some of the programs code a little more of what I > want... > > var = 0 > while var <= 5: > print a[t[var]] > var = var +1 > > a is a dectionary (very big) and t is a string of text. (if that's > important right now). > > I'm just trying to make the

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Danny
Great! It's been solved. The line, as Glaudio said has a "," at the end and that makes it go onto one line, thanks so much man! var = 0 while <= 5: print a[t[var]], var = var +1 prints perfectly, thanks so much guys. -- http://mail.python.org/mailman/listinfo/python-list

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Claudio Grondi
Danny wrote: > I think I should paste some of the programs code a little more of what I > want... > > var = 0 > while var <= 5: > print a[t[var]] > var = var +1 > > a is a dectionary (very big) and t is a string of text. (if that's > important right now). > > I'm just trying to make th

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Danny
I think I should paste some of the programs code a little more of what I want... var = 0 while var <= 5: print a[t[var]] var = var +1 a is a dectionary (very big) and t is a string of text. (if that's important right now). I'm just trying to make the value of a[t[var]] print on one l

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Stefan Neumann
Danny wrote: > How could I make this print: texttexttexttexttext? > Ive researched and looked through google and so far I can't find > anything that will help (or revelent for that matter). I am not quite sure, if I simplify the problem but i thought about something like that: >>> prin

Re: Possible memory leak?

2006-01-26 Thread Fredrik Lundh
Steven D'Aprano wrote: > > Of course. I was just trying to make a point about string accumulation being > > O(n) and not O(n^2). > > But according to Fredrik, string accumulation is still quadratic, even > with the optimizations added to Python 2.4. Quoting: > > "it only means that if the interpre

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Heiko Wundram
Danny wrote: > As a shortcut: print "text"*5 --- Heiko. -- http://mail.python.org/mailman/listinfo/python-list

Re: good library for pdf

2006-01-26 Thread Steve Holden
Enrique Palomo Jiménez wrote: > Hi all, > > I want to take an existing pdf and add it a non-opaque watermark. > I have tried it in postscript but postscript hava an opaque imaging model. > Pdf allows it. I can do it with acrobat 6.0, but i need to add the watermark > in batch mode or inside an ap

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Diez B. Roggisch
Danny wrote: > Hello there. > > I'm creating a little text changer in Python. In the program there is a > while loop. The problem is that a while loop will have 1 print statement > and it will loop until it gets to the end of the text. > Example: > > num = 5 // Set num to 5 > while num >= 1: /

Re: Python code written in 1998, how to improve/change it?

2006-01-26 Thread Bengt Richter
On Wed, 25 Jan 2006 15:50:27 -0600, [EMAIL PROTECTED] wrote: > >>> If they need to resume their calculations from where they left off >>> after the last yield. > >Wolfgang> Well, no, independently from that. > >Wolfgang> Just to avoid to inital overhead of the function call. > >Ho

While loop - print several times but on 1 line.

2006-01-26 Thread Danny
Hello there. I'm creating a little text changer in Python. In the program there is a while loop. The problem is that a while loop will have 1 print statement and it will loop until it gets to the end of the text. Example: num = 5 // Set num to 5 while num >= 1: // loop 5 times. print

Re: ImportError: No module name MySQLdb

2006-01-26 Thread Steve Holden
Fred wrote: > I hope someone can help me with the below problem... > > Thanks, > Fred > > My enviroment: > -- > Slackware Linux 10.2 > Python 2.4.2 > MySql version 4.1.14 > MySql-Python 1.2.0 > > What I am trying to do: > --- > Using MySQL, Python,

Re: How to handle two-level option processing with optparse

2006-01-26 Thread Steve Holden
R. Bernstein wrote: > Giovanni Bajo suggests: > > >>If you call OptionParser.disable_interspersed_args() on your parser, >>it will stop parsing at the first positional argument, leaving other >>options unparsed. > > > Wow - that was a quick answer! Thanks - it works great! > > I see how I miss

Re: good library for pdf

2006-01-26 Thread Robin Becker
Rob Cowie wrote: > Take a look at www.reportlab.org. The ReportLab library includes a > graphics module that might well do what you need. I'm not sure at > present if it allows one to set alpha-channels to achieve transparency. > ReportLab allows one to set a transparent image colour mask which i

Re: Mining strings from a HTML document.

2006-01-26 Thread Derick van Niekerk
Runsun Pan helped me out with the following: You can also try the following very primitive solution that I sometimes use to extract simple information in a quick and dirty way: def extract(text,s1,s2): ''' Extract strings wrapped between s1 and s2. >>> t="""this is a

good library for pdf

2006-01-26 Thread Enrique Palomo Jiménez
Hi all, I want to take an existing pdf and add it a non-opaque watermark. I have tried it in postscript but postscript hava an opaque imaging model. Pdf allows it. I can do it with acrobat 6.0, but i need to add the watermark in batch mode or inside an application. I've found lowagie library for

Re: good library for pdf

2006-01-26 Thread Rob Cowie
Take a look at www.reportlab.org. The ReportLab library includes a graphics module that might well do what you need. I'm not sure at present if it allows one to set alpha-channels to achieve transparency. Also, if you have access to a mac running OS X 10.4, the Automator application has a prebuilt

history

2006-01-26 Thread yqyq22
Dear all, another little question, I use idle 1.1.2, is there a way to use a history for the command line? thanks in advance -- http://mail.python.org/mailman/listinfo/python-list

Re: How to handle two-level option processing with optparse

2006-01-26 Thread R. Bernstein
Giovanni Bajo suggests: > If you call OptionParser.disable_interspersed_args() on your parser, > it will stop parsing at the first positional argument, leaving other > options unparsed. Wow - that was a quick answer! Thanks - it works great! I see how I missed this. Neither disable_.. or enable_

Re: Assigning to self.__class__

2006-01-26 Thread Heiko Wundram
bruno at modulix wrote: > Paul McGuire wrote: >> or am I taking advantage of a fortuitous accident, which may get >> undone at a future time? > > It's certainly not a fortuitous accident. And even the (printed) cookbook has examples which assign to self.__class__... I guess this means this featu

Re: ImportError: No module name MySQLdb

2006-01-26 Thread bruno at modulix
Fred wrote: > I hope someone can help me with the below problem... > > Thanks, > Fred > > My enviroment: > -- > Slackware Linux 10.2 > Python 2.4.2 > MySql version 4.1.14 > MySql-Python 1.2.0 > > What I am trying to do: > --- > Using MySQL, Python,

Re: Assigning to self.__class__

2006-01-26 Thread bruno at modulix
Paul McGuire wrote: > I have some places in pyparsing where I've found that the most > straightforward way to adjust an instance's behavior is to change its class. Hooray ! You've just (re)discovered the state pattern... for which the most stupid simple implementation in Python is to : >(snip) as

Assigning to self.__class__

2006-01-26 Thread Paul McGuire
I have some places in pyparsing where I've found that the most straightforward way to adjust an instance's behavior is to change its class. I do this by assigning to self.__class__, and things all work fine. (Converting to use of __new__ is not an option - in one case, the change is temporary, and

Re: Problem compiling Tkinter program with bmp images using py2

2006-01-26 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > and put them on the widgets like this: > > Label(win, text=message, background=rgb(150,150,120), image=photo2).pack() > ... > > Now, I want the same program to run as exe file on another computer, > so I compiled it with py2exe. I copied the bmp's to the same folder as >

Re: Best way to extract an item from a set of len 1

2006-01-26 Thread Peter Otten
Alex Martelli wrote: > Rene Pijlman <[EMAIL PROTECTED]> wrote: >> Peter Otten: >> s = set(["one-and-only"]) >> item, = s >... >> >The comma may easily be missed, though. >> >> You could write: >> >> (item,) = s >> >> But I'm not sure if this introduces additional overhead. >

Re: Mining strings from a HTML document.

2006-01-26 Thread Derick van Niekerk
I'm battling to understand this. I am switching to python while in a production environment so I am tossed into the deep end. Python seems easier to learn than other languages, but some of the conventions still trip me up. Thanks for the link - I'll have to go through all the previous chapters to u

<    1   2   3