On Sat, Mar 2, 2013 at 12:52 AM, Dave Angel wrote:
> The assumption Chris made is that the characters XYC do *not* appear
> anywhere else in each string. if they do, then you need to write a spec as
> to what criteria you can count on for the data.
>
Right. I should have mentioned that. Let's ho
On 03/01/2013 02:08 AM, idy wrote:
On Friday, March 1, 2013 12:23:41 PM UTC+5:30, Chris Angelico wrote:
You want to break the line immediately before the 'XYC'? That's quite
easy; the line break is a character like any other, and can be used in
a replace() call:
formatted_error = Error.
On Friday, March 1, 2013 12:23:41 PM UTC+5:30, Chris Angelico wrote:
> On Fri, Mar 1, 2013 at 5:49 PM, idy wrote:
>
> > Error =
> > 'XYC.12345455LOcation/user/data/MYGLE-INGXYC.23344566LOcation/user/data/INGE-FTYXYC.22334566LOcation/user/data/GETN-YUNXYC.12345455LOcation/user/data/MYGLE-INGXYC.1
On Fri, Mar 1, 2013 at 5:49 PM, idy wrote:
> Error =
> 'XYC.12345455LOcation/user/data/MYGLE-INGXYC.23344566LOcation/user/data/INGE-FTYXYC.22334566LOcation/user/data/GETN-YUNXYC.12345455LOcation/user/data/MYGLE-INGXYC.111LOcation/user/data/INGE-FTYXYC.333LOcation/user/data/GETN-YUN'
>
> I
I have a text string of this format
Error =
'XYC.12345455LOcation/user/data/MYGLE-INGXYC.23344566LOcation/user/data/INGE-FTYXYC.22334566LOcation/user/data/GETN-YUNXYC.12345455LOcation/user/data/MYGLE-INGXYC.111LOcation/user/data/INGE-FTYXYC.333LOcation/user/data/GETN-YUN'
I need to writ
On Wed, 26 Aug 2009 16:47:33 +1000, Ben Finney
wrote:
> "Nicola Larosa (tekNico)" writes:
>
>> Nicola Larosa wrote:
>> > Here's my take:
>> >
>> > excessblk = Block(total - P.BASE, srccol,
>> > carry_button_suppress=True
>> > ) if total > P.BASE else None
>>
>> Oops, it got shortened
"Nicola Larosa (tekNico)" writes:
> Nicola Larosa wrote:
> > Here's my take:
> >
> > excessblk = Block(total - P.BASE, srccol,
> > carry_button_suppress=True
> > ) if total > P.BASE else None
>
> Oops, it got shortened out: line longer than 72 chars, acceptable in
> code, but not in e
Nicola Larosa wrote:
> Here's my take:
>
> excessblk = Block(total - P.BASE, srccol,
> carry_button_suppress=True
> ) if total > P.BASE else None
Oops, it got shortened out: line longer than 72 chars, acceptable in
code, but not in email. I'll try again.
If the first line is too long,
John Posner wrote:
> Is there any consensus on how to format a conditional expression
> that is too long for one line?
Here's my take:
excessblk = Block(total - P.BASE, srccol,
carry_button_suppress=True
) if total > P.BASE else None
--
Nicola Larosa - http://www.tekNico.net/
Nobody
In article <87ocqchl2k@benfinney.id.au>,
Ben Finney wrote:
>"Diez B. Roggisch" writes:
>>
>> excessblk = None
>> if total > P.BASE:
>> excessblk = ...
>>
>> You don't lose any vertical space,
>
>I don't see vertical space as such a scarce resource; we don't have an
>imminent newline shor
Diez wrote:
No. I love them. But not if they are so large that they stretch over several
lines (or to many columns).
foo = bar if cond else baz
is more than fine for me. But
foo = I_need_to_do_something_really_complicated_here() if cond else baz
isn't, because one doesn't grasp as easily in
Richard Brodie a écrit :
"John Posner" wrote in message
news:mailman.26.1250604346.2854.python-l...@python.org...
if total > P.BASE:
excessblk = Block(total - P.BASE, srccol, carry_button_suppress=True)
else:
excessblk = None
I wonder if it is appropriate to replace the None sen
> BTW, from the (admittedly few) responses to my original post, it seems
> there's some sentiment that "conditional expressions" are a non-Pythonic
> misfeature. Interesting ...
No. I love them. But not if they are so large that they stretch over several
lines (or to many columns).
foo = bar if
On Aug 18, 1:25 pm, John Posner wrote:
> BTW, from the (admittedly few) responses to my original
> post, it seems there's some sentiment that "conditional
> expressions" are a non-Pythonic misfeature. Interesting ...
Well, it's not like Guido was especially eager to add it in the first
place.
I
John Posner writes:
> > excessblk = None
> > if total > P.BASE:
> > excessblk = ...
> >
[…]
> But doesn't it violate the DRY principle? The token "excessblk"
> appears twice instead of once.
No, the DRY principle http://c2.com/cgi/wiki?DontRepeatYourself>
doesn't speak against assigning two
"Diez B. Roggisch" writes:
> excessblk = None
> if total > P.BASE:
> excessblk = ...
>
> You don't lose any vertical space,
I don't see vertical space as such a scarce resource; we don't have an
imminent newline shortage, to my knowledge. I value it far lower than,
say, local readability.
>
John Posner writes:
> Is there any consensus on how to format a conditional expression that
> is too long for one line? How about this:
>
> excessblk = (Block(total - P.BASE, srccol, carry_button_suppress=True)
> if total > P.BASE else
> None)
>
> The above format sep
18-08-2009 Steven D'Aprano wrote:
On Tue, 18 Aug 2009 10:04:36 -0400, John Posner wrote:
[snip]
How about this:
excessblk = (Block(total - P.BASE, srccol, carry_button_suppress=True)
if total > P.BASE else
None)
If you insist on using the conditional expres
John Posner wrote:
BTW, from the (admittedly few) responses to my original post, it seems
there's some sentiment that "conditional expressions" are a non-Pythonic
misfeature. Interesting ...
-John
I didn't read it that way. One of the (to me) core points of Pythonic
is readability. A
I wonder if it is appropriate to replace the None sentinel with one that is an
instance
of Block() e.g.
size = total - P.BASE
excessblk = Block(size, srccol, carry_button_suppress=True, empty_block=(size
<= 0) )
In this particular case, Richard, I don't think so. The Block class is
an a
John Posner wrote:
My choice would be
excessblk = None
if total > P.BASE:
excessblk = ...
Diez and Jean-Michel,
Ha! Your suggestion above was my *original* coding. It looks like I'm
evolving backwards!
But doesn't it violate the DRY principle? The token "excessblk"
appears twice ins
"John Posner" wrote in message
news:mailman.26.1250604346.2854.python-l...@python.org...
> if total > P.BASE:
> excessblk = Block(total - P.BASE, srccol, carry_button_suppress=True)
> else:
> excessblk = None
I wonder if it is appropriate to replace the None sentinel with one that
My choice would be
excessblk = None
if total > P.BASE:
excessblk = ...
Diez and Jean-Michel,
Ha! Your suggestion above was my *original* coding. It looks like I'm
evolving backwards!
But doesn't it violate the DRY principle? The token "excessblk" appears
twice instead of once.
Than
On Tue, 18 Aug 2009 10:04:36 -0400, John Posner wrote:
> While refactoring some code, I ran across an opportunity to use a
> conditional expression. Original:
>
> if total > P.BASE:
> excessblk = Block(total - P.BASE, srccol,
> carry_button_suppress=True)
> else:
> excessblk
Diez B. Roggisch wrote:
John Posner wrote:
While refactoring some code, I ran across an opportunity to use a
conditional expression. Original:
if total > P.BASE:
excessblk = Block(total - P.BASE, srccol,
carry_button_suppress=True)
else:
excessblk = None
Is there any
John Posner wrote:
> While refactoring some code, I ran across an opportunity to use a
> conditional expression. Original:
>
> if total > P.BASE:
> excessblk = Block(total - P.BASE, srccol,
> carry_button_suppress=True)
> else:
> excessblk = None
>
> Is there any consensus
While refactoring some code, I ran across an opportunity to use a
conditional expression. Original:
if total > P.BASE:
excessblk = Block(total - P.BASE, srccol, carry_button_suppress=True)
else:
excessblk = None
Is there any consensus on how to format a conditional expression that i
On Jan 27, 7:15 am, [EMAIL PROTECTED] wrote:
> I apologize for the lack of details in my last post.
There is nothing to apologise for. Unlike some, you gave enough
information, without prompting, to get answers to your questions.
Don't go to the other extreme :-)
> This time
> formatting program
I apologize for the lack of details in my last post. This time
formatting program is a piece of a larger program I am trying to write
to de-clutter GPS transmission. I have a GPS receiver that transmits
its readings via bluetooth. I've been able to use pySerial and store
X number of bytes, then
[EMAIL PROTECTED] wrote:
> Hi all,
>
> I am trying to write a simple program that will accept an integral
> "time" input in the HHMMSS format and output a "HH:MM:SS" form. My
> code is as follows:
>
> import string
>
> def FormatTime(time):
> '''Converts an HHMMSS string
On 1月27日, 上午1时02分, [EMAIL PROTECTED] wrote:
> Hi all,
>
> I am trying to write a simple program that will accept an integral
> "time" input in the HHMMSS format and output a "HH:MM:SS" form. My
> code is as follows:
>
> import string
>
> def FormatTime(time):
> '''Conver
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi all,
>
> I am trying to write a simple program that will accept an integral
> "time" input in the HHMMSS format and output a "HH:MM:SS" form. My
> code is as follows:
>
> import string
>
> def FormatTime(ti
Hi all,
I am trying to write a simple program that will accept an integral
"time" input in the HHMMSS format and output a "HH:MM:SS" form. My
code is as follows:
import string
def FormatTime(time):
'''Converts an HHMMSS string to HH:MM:SS format.'''
timeString = str
On 2007-12-14, Neal Becker <[EMAIL PROTECTED]> wrote:
> I have a list of strings (sys.argv actually). I want to print them as a
> space-delimited string (actually, the same way they went into the command
> line, so I can cut and paste)
>
> So if I run my program like:
> ./my_prog a b c d
>
> I wan
Neal Becker wrote:
> I have a list of strings (sys.argv actually). I want to print them as a
> space-delimited string (actually, the same way they went into the command
> line, so I can cut and paste)
>
> So if I run my program like:
> ./my_prog a b c d
>
> I want it to print:
>
> './my_prog' 'a'
Neal Becker a écrit :
> I have a list of strings (sys.argv actually). I want to print them as a
> space-delimited string (actually, the same way they went into the command
> line, so I can cut and paste)
>
> So if I run my program like:
> ./my_prog a b c d
>
> I want it to print:
>
> './my_prog
I have a list of strings (sys.argv actually). I want to print them as a
space-delimited string (actually, the same way they went into the command
line, so I can cut and paste)
So if I run my program like:
./my_prog a b c d
I want it to print:
'./my_prog' 'a' 'b' 'c' 'd'
Just print sys.argv wil
Dennis Lee Bieber wrote:
> On Wed, 21 Nov 2007 08:36:28 -0800 (PST), mike5160 <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
>
>> Thanks to you for your reply. I am a newbie to Python and appreciate
>> you helping me. Now, I am importing data from an excel sheet and
>> getting
On Nov 21, 11:36 am, mike5160 <[EMAIL PROTECTED]> wrote:
> On Nov 21, 1:22 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Tue, 20 Nov 2007 15:11:38 -0800 (PST), mike5160 <[EMAIL PROTECTED]>
> > declaimed the following in comp.lang.python:
>
> > > Hi all,
>
> > > My input file looks l
On Nov 21, 1:22 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Tue, 20 Nov 2007 15:11:38 -0800 (PST), mike5160 <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
>
>
>
> > Hi all,
>
> > My input file looks like this : ( the data is separated by tabs )
>
> > 11/26/2007 56.366
On Nov 20, 9:13 pm, "Sergio Correia" <[EMAIL PROTECTED]> wrote:
> Hey Mike,
> Welcome to Python!
>
> About your first issue, just change the line
> outfile.write( "'%s'," % (LoL[x][y]))
> With
> outfile.write( "'%s'," % (LoL[x][y][:-1]))
>
> Why? Because when you do the line.split, you are includin
Hey Mike,
Welcome to Python!
About your first issue, just change the line
outfile.write( "'%s'," % (LoL[x][y]))
With
outfile.write( "'%s'," % (LoL[x][y][:-1]))
Why? Because when you do the line.split, you are including the '\n' at
the end, so a new line is created.
Now, what you are doing is not
Hi all,
My input file looks like this : ( the data is separated by tabs )
11/26/2007 56.366 898.90 -10.086 23.11 1212.3
11/26/2007 52.25 897.6 -12.5 12.61.5
11/26/2007 52.25 897.6 -12.5 12.6133.5
The output I'm trying to get is as follows :
( Insert N
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
In the meantime, I have produced this evil hack, that takes advantage of the
difference in pixel widths between the space, and either the fullstop or the
single quote...
It will only work if you have quite a lot of space to waste between columns, an
"Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote:
> "Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
>
> > instead of trying to force the listbox to behave like a multicolumn
> > widget, maybe you could switch to another widget? some alternatives include
> >
> > a Text widget (you have to roll your
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
> instead of trying to force the listbox to behave like a multicolumn
> widget, maybe you could switch to another widget? some alternatives include
>
> a Text widget (you have to roll your own selection logic)
I _really_ don't feel strong enough
Hendrik van Rooyen wrote:
> Is there a way to format this so it will line up with *any* font ?
>
> I would prefer not to give up and use a fixed width font - it looks so
> teletypish...
sounds like contradicting requirements to me.
instead of trying to force the listbox to behave like a multi
I am populating a listbox from a directory that looks like this:
variable_dict = {"funny_long_or_short_variable_name_as_key": (2,45),..
the tuple represents a "card, line" pair.
medf is a font object and a forward reference here.
I write:
for x in variable_dict:
txt = x
while medf.m
Steven D'Aprano wrote:
> I have a sinking feeling I'm missing something really,
> really simple.
>
> I'm looking for a format string similar to '%.3f'
> except that trailing zeroes are not included.
>
> To give some examples:
>
> FloatString
> 1.0 1
> 1.1 1.1
> 12.1234
Paul McGuire wrote:
> Ooops, don't combine the two calls to rstrip().
>
> def format(f, width=3): return ("%.*f" % (width, f)).rstrip(".0")
>
> print format(3.140)
> print format(3.000)
> print format(3.001)
> print format(30.)
> print format(30.000)
hey, I'm doing test-driven develop
"Steven D'Aprano" <[EMAIL PROTECTED]> writes:
> On Thu, 06 Apr 2006 22:16:05 +1000, Ben Finney wrote:
> > "Steven D'Aprano" <[EMAIL PROTECTED]> writes:
1> >> I'm looking for a format string similar to '%.3f' except that
> >> trailing zeroes are not included.
> >
> > Can;t be done, to my knowledge
On Thu, 06 Apr 2006 22:16:05 +1000, Ben Finney wrote:
> "Steven D'Aprano" <[EMAIL PROTECTED]> writes:
>> I'm looking for a format string similar to '%.3f' except that
>> trailing zeroes are not included.
>
> Can;t be done, to my knowledge. You specify a particular precision,
> and the number wil
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Steven D'Aprano wrote:
>
> > Here is a (quick and dirty) reference implementation:
> >
> > def format(f, width=3):
> > fs = '%%.%df' % width
> > s = fs % f
> > return s.rstrip('0').rstrip('.')
> >
> > Is there
Steven D'Aprano wrote:
> Here is a (quick and dirty) reference implementation:
>
> def format(f, width=3):
> fs = '%%.%df' % width
> s = fs % f
> return s.rstrip('0').rstrip('.')
>
> Is there a way of getting the same result with just a
> single string format expression?
not with % it
"Steven D'Aprano" <[EMAIL PROTECTED]> writes:
> I have a sinking feeling I'm missing something really, really
> simple.
"Oh no, everyone in the galaxy gets that, that's perfectly natural
paranoia."
> I'm looking for a format string similar to '%.3f' except that
> trailing zeroes are not included
I have a sinking feeling I'm missing something really,
really simple.
I'm looking for a format string similar to '%.3f'
except that trailing zeroes are not included.
To give some examples:
FloatString
1.0 1
1.1 1.1
12.1234 12.123
12.0001 12
and similar.
He
"Dr. Who" <[EMAIL PROTECTED]> writes:
> This seems clunky and my next step was going to be to define generic
> functions which would generate the surrounding html tags only when
> passed the proper argument. I was wondering if there was a better way
> to do this with a standard Python library. I
Dr. Who wrote:
> I have a tool that outputs data in either html or text output.
>
> Currently I'm writing chucnks like:
>
> if html:
> print ''
> print ''
> print ''
> print 'Differences %s: %s' % (htypestr, lbl1)
> if html:
> ...
I'd create two Formatter classes, one for HTML
I have a tool that outputs data in either html or text output.
Currently I'm writing chucnks like:
if html:
print ''
print ''
print ''
print 'Differences %s: %s' % (htypestr, lbl1)
if html:
...
This seems clunky and my next step was going to be to define generic
functions whi
59 matches
Mail list logo