Re: [Tutor] rounding up to the nearest multiple of 8

2012-10-05 Thread Albert-Jan Roskam
- Original Message - > From: Steven D'Aprano > To: tutor@python.org > Cc: > Sent: Friday, October 5, 2012 8:54 AM > Subject: Re: [Tutor] rounding up to the nearest multiple of 8 > > On Thu, Oct 04, 2012 at 05:26:13PM -0400, eryksun wrote: >> On Thu, Oct 4, 2012 at 4:04 PM, Joel Goldsti

Re: [Tutor] rounding up to the nearest multiple of 8

2012-10-05 Thread eryksun
On Fri, Oct 5, 2012 at 2:54 AM, Steven D'Aprano wrote: > > py> from __future__ import division > py> from math import ceil > py> "%*s" % (int(ceil(len(mystring)/8)*8), mystring) > '123412341234' > > > Or left-justified: > > py> "%-*s" % (int(ceil(len(mystring)/8)*8), mystring) > '123412341234

Re: [Tutor] rounding up to the nearest multiple of 8

2012-10-05 Thread Asokan Pichai
If you are doing so many times, it may be worth precomputing the padding for a given length and adding it by a look up on the length. For example: SPACE = ' ' MAX = 1000 TAB = 8 paddding = [ SPACE * (n % TAB) for n in range(MAX) ] . s = padding[len(s)] + s . -

Re: [Tutor] I Need Help With Using Tkinter/Console/Creating GUIs

2012-10-05 Thread tayo rotimi
Thank you Steven; I am now running. I just followed your hint. I later noticed the author was actually referring to an earlier version of Python, with the console not looking the same with Python 3.2.  Regards. Tayo.___ Tutor maillist - Tutor@python

Re: [Tutor] Newbie help with .pyc

2012-10-05 Thread Mark Lawrence
On 05/10/2012 04:23, ken brockman wrote: I wonder if they might be a way for some on this forum to dispense advice and help others without the totally snide and obnoxious attitude? if it is so painfully annoying for you to deal with, why subject yourself to it? I suspect it is the sheer joy of

Re: [Tutor] rounding up to the nearest multiple of 8

2012-10-05 Thread eryksun
On Fri, Oct 5, 2012 at 4:24 AM, Albert-Jan Roskam wrote: > > import timeit > ver1 = timeit.timeit(""" > import math > value = "1234" > value = "%-*s" % (int(math.ceil(len(value)/8.0)*8), value) > """) > ver2 = timeit.timeit(""" > value = "1234" > value = value.ljust( len(value) + (-len(value) % 8)

Re: [Tutor] Newbie help with .pyc

2012-10-05 Thread Alan Gauld
On 05/10/12 10:07, Mark Lawrence wrote: On 05/10/2012 04:23, ken brockman wrote: I wonder if they might be a way for some on this forum to dispense advice and help others without the totally snide and obnoxious attitude? I'm firmly with Steven here. If people cannot be bothered to do any rese

Re: [Tutor] rounding up to the nearest multiple of 8

2012-10-05 Thread Albert-Jan Roskam
- Original Message - > From: Asokan Pichai > To: tutor@python.org > Cc: > Sent: Friday, October 5, 2012 11:06 AM > Subject: Re: [Tutor] rounding up to the nearest multiple of 8 > > If you are doing so many times, it may be worth precomputing the padding for a > given length and adding i

Re: [Tutor] rounding up to the nearest multiple of 8

2012-10-05 Thread Dave Angel
On 10/05/2012 07:23 AM, Albert-Jan Roskam wrote: > - Original Message - > >> From: Asokan Pichai >> To: tutor@python.org >> Cc: >> Sent: Friday, October 5, 2012 11:06 AM >> Subject: Re: [Tutor] rounding up to the nearest multiple of 8 >> >> If you are doing so many times, it may be worth

[Tutor] Through a glass, darkly: the datetime module

2012-10-05 Thread Richard D. Moores
I thought it would be useful to have a script that would tell me what the date n days from today would be. The docs () seem to get me almost there. I can compute the number of days between 2 dates, and the number of days between a d

Re: [Tutor] getattr works sometimes

2012-10-05 Thread Tino Dai
On Tue, Oct 2, 2012 at 8:39 PM, Steven D'Aprano wrote: > On 03/10/12 04:20, Tino Dai wrote: > >> and the get_class class works sometime for finding modules within a certain directory. If the get_class doesn't work, it throws an AttributeError. >>> >>> I don't really understand what

Re: [Tutor] Through a glass, darkly: the datetime module

2012-10-05 Thread Mark Lawrence
On 05/10/2012 14:47, Richard D. Moores wrote: I thought it would be useful to have a script that would tell me what the date n days from today would be. The docs () seem to get me almost there. I can compute the number of days bet

Re: [Tutor] Through a glass, darkly: the datetime module

2012-10-05 Thread Walter Prins
Hi Richard On 5 October 2012 14:47, Richard D. Moores wrote: > I thought it would be useful to have a script that would tell me what > the date n days from today would be. The docs > () > seem to get me almost there. I can compute

Re: [Tutor] Through a glass, darkly: the datetime module

2012-10-05 Thread Oscar Benjamin
On 5 October 2012 14:47, Richard D. Moores wrote: > I thought it would be useful to have a script that would tell me what > the date n days from today would be. The docs > () > seem to get me almost there. I can compute the number

Re: [Tutor] Through a glass, darkly: the datetime module

2012-10-05 Thread Albert-Jan Roskam
- Original Message - > From: Richard D. Moores > To: Tutor List > Cc: > Sent: Friday, October 5, 2012 3:47 PM > Subject: [Tutor] Through a glass, darkly: the datetime module > > I thought it would be useful to have a script that would tell me what > the date n days from today would b

[Tutor] Python Install Program

2012-10-05 Thread eddy van
Hi Were can i download the python install program for free Thank you ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tut

Re: [Tutor] Python Install Program

2012-10-05 Thread Jerry Hill
On Fri, Oct 5, 2012 at 10:39 AM, eddy van wrote: > Were can i download the python install program for free Python installers are here: http://www.python.org/download/ You'll want either version 2.7.3 or 3.3.0, depending on whether you need python 2 or python 3. The actual installer you choose w

Re: [Tutor] Python Install Program

2012-10-05 Thread Walter Prins
Hi, On 5 October 2012 15:39, eddy van wrote: > Hi > > Were can i download the python install program for free If you google "download python" you'll get lots of relevant hits. That said, assuming you're using Windows, I recommend downloading one of the ActiveState Python distributions from here:

Re: [Tutor] rounding up to the nearest multiple of 8

2012-10-05 Thread Albert-Jan Roskam
> This is all fun, but what about the context?  Your original function > took an integer, not a string, and thus wasn't charged with measuring > string length, possibly multiple times.  Even so, each of these tests is > taking around a microsecond.  So are you expecting to do anything with > t