Re: [Tutor] Formatting text file with python

2018-02-07 Thread Alan Gauld via Tutor
On 06/02/18 21:07, Hüseyin Ertuğrul wrote: > "hMailServer SpamProtection rejected RCPT (Sender: > valeria0...@mikelsonconstruction.com, IP:187.62.63.218, Reason: Rejected by > Spamhaus.)" > "hMailServer SpamProtection rejected RCPT (Sender: veronika07...@etb.net.co, > IP:190.25.189.74, Reason:

[Tutor] Formatting text file with python

2018-02-07 Thread Hüseyin Ertuğrul
Hello friends, I want to format the log (text) file my email's server. The text file (named s1.txt) contains the following information, text file has about 3000 lines. "hMailServer SpamProtection rejected RCPT (Sender: valeria0...@mikelsonconstruction.com, IP:187.62.63.218, Reason: Rejected by

Re: [Tutor] formatting xml (again)

2016-12-28 Thread richard kappler
It occurred to me last night on the drive home that I should just run this through an xml parser, then lo and behold this email was sitting in my inbox when I got home. Having tried that, my data is not as clean as I first thought. It seems like a fairly simple fix, but durned if I can figure out

Re: [Tutor] formatting xml (again)

2016-12-27 Thread David Rock
* Alan Gauld via Tutor [2016-12-28 00:40]: > On 27/12/16 19:44, richard kappler wrote: > > Using python 2.7 - I have a large log file we recorded of streamed xml data > > that I now need to feed into another app for stress testing. The problem is > > the data comes in 2 formats. > > > > 1. each '

Re: [Tutor] formatting xml (again)

2016-12-27 Thread Alan Gauld via Tutor
On 27/12/16 19:44, richard kappler wrote: > Using python 2.7 - I have a large log file we recorded of streamed xml data > that I now need to feed into another app for stress testing. The problem is > the data comes in 2 formats. > > 1. each 'event' is a full set of xml data with opening and closin

Re: [Tutor] formatting xml (again)

2016-12-27 Thread David Rock
* richard kappler [2016-12-27 16:05]: > The input is consistent in that it all has stx at the beginning of each > 'event.' I'm leaning towards regex. When you say: > > " find stx, stuff lines until I see the next stx, then dump and continue" > > Might I trouble you for an example of how you do t

Re: [Tutor] formatting xml (again)

2016-12-27 Thread richard kappler
The input is consistent in that it all has stx at the beginning of each 'event.' I'm leaning towards regex. When you say: " find stx, stuff lines until I see the next stx, then dump and continue" Might I trouble you for an example of how you do that? I can find stx, I can find etx using something

Re: [Tutor] formatting xml (again)

2016-12-27 Thread David Rock
* richard kappler [2016-12-27 15:39]: > I was actually working somewhat in that direction while I waited. I had in > mind to use something along the lines of: > > > stx = '\x02' > etx = '\x03' > line1 = "" > > with open('original.log', 'r') as f1: >with open('new.log', 'w') as f2: >

Re: [Tutor] formatting xml (again)

2016-12-27 Thread richard kappler
I was actually working somewhat in that direction while I waited. I had in mind to use something along the lines of: stx = '\x02' etx = '\x03' line1 = "" with open('original.log', 'r') as f1: with open('new.log', 'w') as f2: for line in f1: if stx in line:

Re: [Tutor] formatting xml (again)

2016-12-27 Thread David Rock
* richard kappler [2016-12-27 14:44]: > > I have tried to feed this raw into our other app (Splunk) and the app reads > each line (gedit numbered line) as an event. I want everything in between > each stx and etx to be one event. > > I have tried: > > # > wit

[Tutor] formatting xml (again)

2016-12-27 Thread richard kappler
Using python 2.7 - I have a large log file we recorded of streamed xml data that I now need to feed into another app for stress testing. The problem is the data comes in 2 formats. 1. each 'event' is a full set of xml data with opening and closing tags + x02 and x03 (stx and etx) 2. some events h

Re: [Tutor] formatting strings

2015-05-08 Thread Steven D'Aprano
On Fri, May 08, 2015 at 05:11:49PM -0700, Danny Yoo wrote: > Also, you can write a loop that goes from 1 to N by using range(). For > example: > > > for n in range(1, N+1): > print(n, 2*n) > > > The while loop that you have does work, but t

Re: [Tutor] formatting strings

2015-05-08 Thread Steven D'Aprano
On Thu, May 07, 2015 at 06:57:30PM +, Tudor, Bogdan - tudby001 wrote: > Hi, > > This is my first time. > I am using python 3.4.3 on windows 7 64bit. > > I am trying to make a binary counter that will prompt for and read a > decimal number (whole number). Then display all decimal numbers > s

Re: [Tutor] formatting strings

2015-05-08 Thread Danny Yoo
> I am trying to make a binary counter that will prompt for and read a decimal > number (whole number). Then display all decimal numbers starting from 1 up to > and including the decimal number entered along with the binary representation > of the numbers to the screen. You might consider writi

Re: [Tutor] formatting strings

2015-05-08 Thread Dave Angel
On 05/07/2015 02:57 PM, Tudor, Bogdan - tudby001 wrote: Hi, This is my first time. First time doing what? Presumably the first time on this forum. But what is your history of using Python, or of programming in general? I am using python 3.4.3 on windows 7 64bit. I am trying to make a bi

[Tutor] formatting strings

2015-05-08 Thread Tudor, Bogdan - tudby001
Hi, This is my first time. I am using python 3.4.3 on windows 7 64bit. I am trying to make a binary counter that will prompt for and read a decimal number (whole number). Then display all decimal numbers starting from 1 up to and including the decimal number entered along with the binary repres

Re: [Tutor] formatting datetime.timedelta to "HH:MM:SS"

2013-12-12 Thread eryksun
On Wed, Dec 11, 2013 at 8:37 AM, Mark Lawrence wrote: > > print('{}:{}:{}'.format(now.hour, now.minute, now.year)) > > Sorry I can never remember the formatting types to go between {} so look for > them around here http://docs.python.org/3/library/string.html#formatstrings For datetime's date, ti

Re: [Tutor] formatting datetime.timedelta to "HH:MM:SS"

2013-12-11 Thread Jignesh Sutar
> > Yes, because exe-time is not a ate, a point in time, but a time delta (a > difference), thus does not hold the same attributes. Write out dir() on > 'now' and on 'exe_time' to get more info. [dir() tells you about what info > an object knows, and what methods it understands).] Thanks Denis, t

Re: [Tutor] formatting datetime.timedelta to "HH:MM:SS"

2013-12-11 Thread spir
On 12/11/2013 06:40 PM, Jignesh Sutar wrote: c = b-a print "%s days, %.2dh: %.2dm: %.2ds" % (c.days,c.seconds//3600,(c.seconds//60)%60, c.seconds%60) This is a correct and general solution. Maybe worth being built-in, in fact, in my view. Denis __

Re: [Tutor] formatting datetime.timedelta to "HH:MM:SS"

2013-12-11 Thread spir
On 12/11/2013 02:55 PM, Jignesh Sutar wrote: Thanks Mark, print('%02d:%02d:%04d' % (now.hour, now.minute, now.year)) That works for; now = datetime.now() but not for; exe_time = endTime-startTime Yes, because exe-time is not a ate, a point in time, but a time delta (a difference), thus doe

Re: [Tutor] formatting datetime.timedelta to "HH:MM:SS"

2013-12-11 Thread Danny Yoo
For reference, you can also see: http://stackoverflow.com/questions/8906926/formatting-python-timedelta-objects which shows a similar approach. The accepted solution there uses the divmod() function to simplify a little bit of the math. ___ Tutor

Re: [Tutor] formatting datetime.timedelta to "HH:MM:SS"

2013-12-11 Thread Jignesh Sutar
Thanks folks, I think I have this as a working solution: import datetime, time a= datetime.datetime.now() time.sleep(7.1564651443644) b= datetime.datetime.now() #for testing longer time periods #a= datetime.datetime(2003, 8, 4, 8, 31, 4,0) #b= datetime.datetime(2004, 8, 5, 19, 32, 6,0) c = b-a pri

Re: [Tutor] formatting datetime.timedelta to "HH:MM:SS"

2013-12-11 Thread Ricardo Aráoz
El 11/12/13 10:37, Mark Lawrence escribió: On 11/12/2013 13:12, Jignesh Sutar wrote: print str(exe_time).split('.')[0] Sorry, I guess my question was why I can't use something similar to below on exe_time (of type datetime.timedelta)? Rather than doing string manipulation on decimals or colo

Re: [Tutor] formatting datetime.timedelta to "HH:MM:SS"

2013-12-11 Thread Mark Lawrence
[top posting fixed] On 11 December 2013 13:37, Mark Lawrence mailto:breamore...@yahoo.co.uk>> wrote: On 11/12/2013 13:12, Jignesh Sutar wrote: print str(exe_time).split('.')[0] Sorry, I guess my question was why I can't use something similar to below on exe_ti

Re: [Tutor] formatting datetime.timedelta to "HH:MM:SS"

2013-12-11 Thread Jignesh Sutar
Thanks Mark, print('%02d:%02d:%04d' % (now.hour, now.minute, now.year)) That works for; now = datetime.now() but not for; exe_time = endTime-startTime Thanks, Jignesh On 11 December 2013 13:37, Mark Lawrence wrote: > On 11/12/2013 13:12, Jignesh Sutar wrote: > >> print str(exe_time).s

Re: [Tutor] formatting datetime.timedelta to "HH:MM:SS"

2013-12-11 Thread Mark Lawrence
On 11/12/2013 13:12, Jignesh Sutar wrote: print str(exe_time).split('.')[0] Sorry, I guess my question was why I can't use something similar to below on exe_time (of type datetime.timedelta)? Rather than doing string manipulation on decimals or colons to extract the same. now = datetime.now(

Re: [Tutor] formatting datetime.timedelta to "HH:MM:SS"

2013-12-11 Thread Jignesh Sutar
> > print str(exe_time).split('.')[0] Sorry, I guess my question was why I can't use something similar to below on exe_time (of type datetime.timedelta)? Rather than doing string manipulation on decimals or colons to extract the same. now = datetime.now() print now.hour print now.minute print no

Re: [Tutor] formatting datetime.timedelta to "HH:MM:SS"

2013-12-11 Thread David Robinow
On Wed, Dec 11, 2013 at 5:55 AM, Jignesh Sutar wrote: > Hi, > > I've googled around extensively to try figure this out assuming it should be > straight forward (and it probably is) but I'm clearly missing something. > > I'm trying to get the total run time of the program but have the final time >

[Tutor] formatting datetime.timedelta to "HH:MM:SS"

2013-12-11 Thread Jignesh Sutar
Hi, I've googled around extensively to try figure this out assuming it should be straight forward (and it probably is) but I'm clearly missing something. I'm trying to get the total run time of the program but have the final time being displayed in a particular format. I.e. without the seconds in

Re: [Tutor] Formatting questions regarding datetime.isoformat()

2012-09-06 Thread eryksun
On Thu, Sep 6, 2012 at 3:50 AM, Dave Angel wrote: > On 09/06/2012 03:35 AM, eryksun wrote: >> >> Or you could use datetime.now(dateutil.tz.tzutc()) for a UTC tzinfo. >> It doesn't matter if you're only interested in the timedelta. > > Actually, it can matter. Whenever possible, produce all times

Re: [Tutor] Formatting questions regarding datetime.isoformat()

2012-09-06 Thread Peter Otten
staticsafe wrote: > Hello, > > I am running Python 2.6.6 on a Debian Squeeze system. I am using two > modules in this bit of code - datetime and python-tvrage (available on > pypy here: http://pypi.python.org/pypi/python-tvrage/). > > My goal is to find the time remaining until a certain show ai

Re: [Tutor] Formatting questions regarding datetime.isoformat()

2012-09-06 Thread eryksun
On Wed, Sep 5, 2012 at 11:00 PM, staticsafe wrote: > > In [68]: showinfo['RFC3339'] > Out[68]: '2012-09-10T21:00:00-4:00' You can parse the ISO format using the dateutil module: http://labix.org/python-dateutil >>> from dateutil.parser import parse >>> show_time = parse('2012-09-10T21:0

[Tutor] Formatting questions regarding datetime.isoformat()

2012-09-05 Thread staticsafe
Hello, I am running Python 2.6.6 on a Debian Squeeze system. I am using two modules in this bit of code - datetime and python-tvrage (available on pypy here: http://pypi.python.org/pypi/python-tvrage/). My goal is to find the time remaining until a certain show airs. Here is some code I have writ

Re: [Tutor] formatting sql Was: Some help Please

2012-02-15 Thread James Reynolds
On Wed, Feb 15, 2012 at 1:30 PM, Alan Gauld wrote: > On 15/02/12 18:03, James Reynolds wrote: > > >In you table the acc_id is 'mn0001' >> >In your sql Acc_ID = 'MN0001' >> >Why the difference in case? >> >> Normally, sql doesn't care about case with respect to table names. I >> believ

Re: [Tutor] formatting sql Was: Some help Please

2012-02-15 Thread Alan Gauld
On 15/02/12 18:03, James Reynolds wrote: >In you table the acc_id is 'mn0001' >In your sql Acc_ID = 'MN0001' >Why the difference in case? Normally, sql doesn't care about case with respect to table names. I believe in certain implementations they are always lower case, even if you p

Re: [Tutor] formatting sql Was: Some help Please

2012-02-15 Thread James Reynolds
On Wed, Feb 15, 2012 at 12:13 PM, bob gailer wrote: > Welcome to python help. We are a few volunteers who donate time to assist. > > To assist you better: > 1 - provide a meaningful subject line - such as "formatting sql" > 2 - tell us what OS and Python version you are using. > 3 - what is your

[Tutor] formatting sql Was: Some help Please

2012-02-15 Thread bob gailer
Welcome to python help. We are a few volunteers who donate time to assist. To assist you better: 1 - provide a meaningful subject line - such as "formatting sql" 2 - tell us what OS and Python version you are using. 3 - what is your prior Python experience? On 2/15/2012 9:17 AM, JOSEPH MARTIN M

Re: [Tutor] Formatting a string

2011-02-01 Thread Becky Mcquilling
Thanks, as always. It all works. Becky On Tue, Feb 1, 2011 at 7:08 AM, Alan Gauld wrote: > "Becky Mcquilling" wrote > > > Basically, I need to format a string as an example: >> >> "He is {what}.format("{wild}") >> >> I want to insert wild in place of what and output the resulting text WITH >>

Re: [Tutor] Formatting a string

2011-02-01 Thread Alan Gauld
"Becky Mcquilling" wrote Basically, I need to format a string as an example: "He is {what}.format("{wild}") I want to insert wild in place of what and output the resulting text WITH the curly braces. what = 'wild' "Here is {what}".format(what=what) 'Here is wild' "Here is {what}".forma

Re: [Tutor] Formatting a string

2011-02-01 Thread Karim
Complete test copy & paste: karim@Requiem4Dream:~$ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> "He is {what}".format(what="{wild}") 'He is {wild}' >>> I don't get the missing "."

Re: [Tutor] Formatting a string

2011-02-01 Thread col speed
You're missing a "." that if your computer is the same as mine, looks like something left behind by a mosquito On 1 February 2011 18:33, Karim wrote: > > Hello, > > >>> "He is {what}".format(what="{wild}") > 'He is {wild}' > > Regards > Karim > > > On 02/01/2011 09:44 AM, Becky Mcquilling wrote:

Re: [Tutor] Formatting a string

2011-02-01 Thread Karim
Hello, >>> "He is {what}".format(what="{wild}") 'He is {wild}' Regards Karim On 02/01/2011 09:44 AM, Becky Mcquilling wrote: Quick question to the group to solve an immediate problem and then if anyone has a dead simple reference on formatting strings it would be greatly appreciated as I'm f

[Tutor] Formatting a string

2011-02-01 Thread Becky Mcquilling
Quick question to the group to solve an immediate problem and then if anyone has a dead simple reference on formatting strings it would be greatly appreciated as I'm finding this to be pretty confusing. Basically, I need to format a string as an example: "He is {what}.format("{wild}") I want to

Re: [Tutor] Formatting date/time

2010-08-04 Thread Eduardo Vieira
On Wed, Aug 4, 2010 at 12:45 PM, Eric Hamiter wrote: > There are a few solutions here: > > http://stackoverflow.com/questions/904928/python-strftime-date-decimal-remove-0 > > Eric > > > On Wed, Aug 4, 2010 at 1:30 PM, Eduardo Vieira > wrote: >> >> I'm trying this example from python docs: >> from

Re: [Tutor] Formatting date/time

2010-08-04 Thread Joel Goldstick
On Wed, Aug 4, 2010 at 2:45 PM, Eric Hamiter wrote: > There are a few solutions here: > > > http://stackoverflow.com/questions/904928/python-strftime-date-decimal-remove-0 > > Eric > > > > On Wed, Aug 4, 2010 at 1:30 PM, Eduardo Vieira wrote: > >> I'm trying this example from python docs: >> from

Re: [Tutor] Formatting date/time

2010-08-04 Thread Eric Hamiter
There are a few solutions here: http://stackoverflow.com/questions/904928/python-strftime-date-decimal-remove-0 Eric On Wed, Aug 4, 2010 at 1:30 PM, Eduardo Vieira wrote: > I'm trying this example from python docs: > from time import gmtime, strftime > strftime("%a, %d %b %Y %H:%M:%S +", g

[Tutor] Formatting date/time

2010-08-04 Thread Eduardo Vieira
I'm trying this example from python docs: from time import gmtime, strftime strftime("%a, %d %b %Y %H:%M:%S +", gmtime()) Output = 'Wed, 04 Aug 2010 17:58:42 +' Is not there a string formatting option for the day without a leading zero? Like: 'Wed, 4 Aug 2010 17:58:42 +' It looks like

Re: [Tutor] formatting*

2010-01-09 Thread Alan Gauld
"Lowell Tackett" wrote In the meantime, posing this query took me somewhere I hadn't imagined... I got turned on to the 'Gmane' mailsite, which pretty much solved all my issues, plus presented a much nicer 'reading room'. I actually use it as a news feed into Outlook Express. I only occasi

Re: [Tutor] formatting*

2010-01-08 Thread Lowell Tackett
>From the virtual desk of Lowell Tackett --- On Fri, 1/8/10, spir wrote: > From: spir > Subject: Re: [Tutor] formatting* > To: tutor@python.org > Date: Friday, January 8, 2010, 7:27 AM > Lowell Tackett dixit: > > Yo, that's because you're viewing the s

Re: [Tutor] formatting*

2010-01-08 Thread spir
Lowell Tackett dixit: > An odd aside, however--I went into the Tutor Archives forum and pulled up the > Page Source (HTML formatting template) and lo and behold all my paragraphs > were correctly formatted (i.e. page-wrapped just as they had been when they > left my mail notepad) and displayed

Re: [Tutor] formatting*

2010-01-07 Thread Lowell Tackett
1/7/10, Alan Gauld wrote: From: Alan Gauld Subject: Re: [Tutor] formatting* To: tutor@python.org Date: Thursday, January 7, 2010, 7:25 PM "Lowell Tackett" wrote > Well, not a lot of luck. What I use is Yahoo mail (whatever that is---a > "thick" client??), > and t

Re: [Tutor] formatting*

2010-01-07 Thread Alan Gauld
"Lowell Tackett" wrote Well, not a lot of luck. What I use is Yahoo mail (whatever that is---a "thick" client??), and thus far I can't find any tool bars that offer help. A thick client is an application that runs on your desktop with built in intelligence. A thin client is a GUI within a

Re: [Tutor] formatting*

2010-01-07 Thread Lowell Tackett
d behold all my paragraphs were correctly formatted (i.e. page-wrapped just as they had been when they left my mail notepad) and displayed correctly--on the source page.  So,who knows...(?) >From the virtual desk of Lowell Tackett  --- On Thu, 1/7/10, ALAN GAULD wrote: From: ALAN GAULD S

Re: [Tutor] formatting*

2010-01-07 Thread ALAN GAULD
> I'm using Mandrake 10.1 [Linux] OS to view the internet thru Firefox. > In my mailbox, everything is fine--my stuff formats well (and when it > comes back to me as Tutor 'mail' it also formats correctly). > > The problem is over at the Tutor Archives (mail.python.org/pipermail/tutor), > i.e

Re: [Tutor] formatting*

2010-01-07 Thread Lowell Tackett
ur questions with some degree of understandability. >From the virtual desk of Lowell Tackett  --- On Thu, 1/7/10, Alan Gauld wrote: From: Alan Gauld Subject: Re: [Tutor] formatting* To: tutor@python.org Date: Thursday, January 7, 2010, 4:59 PM "Lowell Tackett" wrote > *No, not

Re: [Tutor] formatting*

2010-01-07 Thread Alan Gauld
"Lowell Tackett" wrote *No, not in Python...in this Tutor format. How do I include line breaks in text so the lines in the Tutor Archives wrap (as opposed to stretching halfway to Idaho)? How are you viewing the messages? I have never seen that problem. Are you using a web browser or a new

[Tutor] formatting*

2010-01-07 Thread Lowell Tackett
*No, not in Python...in this Tutor format.  How do I include line breaks in text so the lines in the Tutor Archives wrap (as opposed to stretching halfway to Idaho)? >From the virtual desk of Lowell Tackett  ___ Tutor maillist - Tutor@pytho

Re: [Tutor] Formatting zip module arguments correctly

2009-04-05 Thread Mark Tolonen
The error indicates your source file cannot be read. Did you have it open in an editor that locks it for exclusive use when you ran your program? Also, the command: zipfile.ZipFile(target, 'w').write(source) writes backup_list to the target zipfile, and returns None, assigning the return

Re: [Tutor] Formatting zip module arguments correctly

2009-04-05 Thread Alan Gauld
"Benjamin Serrato" wrote formatting of my zip arguments is incorrect. Since I am unsure how to communicate best so I will show the code, the error message, and what I believe is happening. Thats pretty close to communicating the best way! :-) zip_command = zipfile.ZipFile(target, 'w').writ

Re: [Tutor] Formatting zip module arguments correctly

2009-04-05 Thread Kent Johnson
On Sun, Apr 5, 2009 at 4:54 PM, Benjamin Serrato wrote: > Please tell me why this code fails. I am new and I don't understand why my > formatting of my zip arguments is incorrect. Since I am unsure how to > communicate best so I will show the code, the error message, and what I > believe is happen

Re: [Tutor] Formatting zip module arguments correctly

2009-04-05 Thread bob gailer
Benjamin Serrato wrote: > Please tell me why this code fails. I am new and I don't understand why my formatting of my zip arguments is incorrect. Since I am unsure how to communicate best so I will show the code, the error message, and what I believe is happening. > > #!c:\python30 > # Filenam

[Tutor] Formatting zip module arguments correctly

2009-04-05 Thread Benjamin Serrato
Please tell me why this code fails. I am new and I don't understand why my formatting of my zip arguments is incorrect. Since I am unsure how to communicate best so I will show the code, the error message, and what I believe is happening. #!c:\python30 # Filename: backup_ver5.py import os import

[Tutor] Formatting

2009-02-25 Thread prasad rao
hi for license in licenses: m = licenseRe.search(license) print m.group(1, 2) ('ABTA', 'No.56542') ('ATOL', None) ('IATA', None) ('ITMA', None) Yes It is working Thank you Prasad ___ Tutor maillist - Tutor@python.org http://mail.python.or

Re: [Tutor] Formatting

2009-02-24 Thread Senthil Kumaran
On Wed, Feb 25, 2009 at 10:37 AM, prasad rao wrote: > > licenseRe = re.compile(r'\(([A-Z]+)\)( No. (\d+))?') Change that to: licenseRe = re.compile(r'\(([A-Z]+)\)\s*(No.\d+)?') It now works. Thanks, Senthil ___ Tutor maillist - Tutor@python.org ht

[Tutor] Formatting

2009-02-24 Thread prasad rao
hi. s = 'Association of British Travel Agents (ABTA) No.56542\nAir Travel Organisation Licence (ATOL)\nAppointed Agents ofIATA (IATA)\nIncentive Travel & Meet. Association (ITMA)' licenses = re.split("\n+", s) licenseRe = re.compile(r'\(([A-Z]+)\)( No. (\d+))?') >>> for license in licenses:

Re: [Tutor] Formatting timedelta objects

2007-12-10 Thread wesley chun
>This is probably something simple but I can't seem to find a way to > format a timedelta object for printing? I need to be able to print it in > a HH:MM:SS format but without the microseconds part (which is what you > get if you str() it). hi noufal, there's no real easy way to do this sinc

Re: [Tutor] Formatting timedelta objects

2007-12-10 Thread John Fouhy
On 11/12/2007, Noufal Ibrahim <[EMAIL PROTECTED]> wrote: > Hello everyone, >This is probably something simple but I can't seem to find a way to > format a timedelta object for printing? I need to be able to print it in > a HH:MM:SS format but without the microseconds part (which is what you > g

[Tutor] Formatting timedelta objects

2007-12-10 Thread Noufal Ibrahim
Hello everyone, This is probably something simple but I can't seem to find a way to format a timedelta object for printing? I need to be able to print it in a HH:MM:SS format but without the microseconds part (which is what you get if you str() it). Any pointers? Thanks. -- ~noufal ht

Re: [Tutor] Formatting output into columns

2007-08-31 Thread Scott Oertel
Luke Paireepinart wrote: > Scott Oertel wrote: >> Someone asked me this question the other day, and I couldn't think of >> any easy way of printing the output besides what I came up with pasted >> below. >> >> So what you have is a file with words in it as such: >> >> apple >> john >> bean >> joke

Re: [Tutor] Formatting output into columns

2007-08-30 Thread Luke Paireepinart
Scott Oertel wrote: > Someone asked me this question the other day, and I couldn't think of > any easy way of printing the output besides what I came up with pasted > below. > > So what you have is a file with words in it as such: > > apple > john > bean > joke > ample > python > nice > > and you w

Re: [Tutor] Formatting output into columns

2007-08-30 Thread Kent Johnson
Alan Gauld wrote: > "Scott Oertel" <[EMAIL PROTECTED]> wrote >> Do you have any good documentation that could shed some more light >> on >> exactly how to use format strings in such a way? > > The docs contain the basic documentation http://docs.python.org/lib/typesseq-strings.html > # there's

Re: [Tutor] Formatting output into columns

2007-08-30 Thread Alan Gauld
"Scott Oertel" <[EMAIL PROTECTED]> wrote >> Use format strings. You can calculate the column widths by >> analyzing >> the data then create a format string for the required number of >> columns. >> Finally insert the data on each row from a tuple. >> > Do you have any good documentation that cou

Re: [Tutor] Formatting output into columns

2007-08-30 Thread Kent Johnson
Scott Oertel wrote: > #!/usr/bin/env python > > data = {} > lrgColumn = 0 > > for line in open("test.txt","r").read().splitlines(): > char = line[0].lower() > if not char in data: > data[char] = [line] > else: > data[char].append(line) I like data.setdefault(char,

Re: [Tutor] Formatting output into columns

2007-08-30 Thread Scott Oertel
Alan Gauld wrote: > "Scott Oertel" <[EMAIL PROTECTED]> wrote > > >> and you want to sort and output the text into columns as such: >> >> a p j b n >> apple python john bean nice >> ample joke >> >> and

Re: [Tutor] Formatting output into columns

2007-08-30 Thread Alan Gauld
"Scott Oertel" <[EMAIL PROTECTED]> wrote > and you want to sort and output the text into columns as such: > > a p j b n > apple python john bean nice > ample joke > > and this is what works, but I would

[Tutor] Formatting output into columns

2007-08-30 Thread Scott Oertel
Someone asked me this question the other day, and I couldn't think of any easy way of printing the output besides what I came up with pasted below. So what you have is a file with words in it as such: apple john bean joke ample python nice and you want to sort and output the text into columns as