Re: Too much code - slicing

2010-09-27 Thread Antoon Pardon
On Thu, Sep 23, 2010 at 12:23:22AM +, Steven D'Aprano wrote: > On Tue, 21 Sep 2010 16:17:48 +0200, Antoon Pardon wrote: > > > On Tue, Sep 21, 2010 at 12:07:07AM +, Steven D'Aprano wrote: > >> On Mon, 20 Sep 2010 19:28:49 +0200, Antoon Pardon wrote: > >> > >> > Not necessarily. Some of us

Re: Too much code - slicing

2010-09-24 Thread Steven D'Aprano
On Thu, 23 Sep 2010 11:42:25 -0400, Andreas Waldenburger wrote: > On Wed, 22 Sep 2010 20:45:55 -0500 John Bokma > wrote: > >> What surprises me is that this is still discussed. It's like argueing >> about significant whitespace. :-) > > Which is evil! Iagreethatsignioficantwhitespaceisevil.Py

Re: Too much code - slicing

2010-09-23 Thread Seebs
On 2010-09-23, Andreas Waldenburger wrote: > On 23 Sep 2010 03:54:52 GMT Seebs wrote: >> I don't generally like constructs where important structural >> information comes late in the construct. [snip] > I think that is precisely the reason that the elements of the list come > *first* in the list

Re: Too much code - slicing

2010-09-23 Thread Andreas Waldenburger
On Wed, 22 Sep 2010 20:45:55 -0500 John Bokma wrote: > What surprises me is that this is still discussed. It's like argueing > about significant whitespace. :-) Which is evil! /W -- INVALID? DE! -- http://mail.python.org/mailman/listinfo/python-list

Re: Too much code - slicing

2010-09-23 Thread Andreas Waldenburger
On 23 Sep 2010 00:33:28 GMT Steven D'Aprano wrote: > On Tue, 21 Sep 2010 12:26:29 -0400, Andreas Waldenburger wrote: > > > On Sat, 18 Sep 2010 19:09:33 -0700 (PDT) Carl Banks > > wrote: > > > >> On Sep 17, 1:01 pm, Andreas Waldenburger > >> wrote: > >> > On Thu, 16 Sep 2010 16:20:33 -0400 AK

Re: Too much code - slicing

2010-09-23 Thread Andreas Waldenburger
On 23 Sep 2010 03:54:52 GMT Seebs wrote: > On 2010-09-23, Steven D'Aprano > wrote: > [snip] > > I don't see anyone bitching about: > > > for x in seq: > > if x: > > f(x) > > > vs > > > [f(x) for x in seq if x] > > In my case, that's because I only ran into that syntax about an h

Re: Too much code - slicing

2010-09-22 Thread Seebs
On 2010-09-23, John Bokma wrote: > Seebs writes: >> I dunno. I like the "next if /^$/" idiom, > I don't (as a Perl programmer), I prefer: Huh, those are actually nicer. I didn't know that was possible; it wouldn't have occurred to me to try to put "next" (which I think of as a statement) into

Re: Too much code - slicing

2010-09-22 Thread John Bokma
Seebs writes: > I dunno. I like the "next if /^$/" idiom, I don't (as a Perl programmer), I prefer: $line =~ /^$/ and next; Or: $line ne '' or next; which I read as: line must not be empty -- John Bokma j3b Blog: http://johnbo

Re: Too much code - slicing

2010-09-22 Thread Seebs
On 2010-09-23, Steven D'Aprano wrote: > On Thu, 23 Sep 2010 01:49:44 +, Seebs wrote: >> But I do think it's unfair to dismiss it as purely a matter of baby duck >> syndrome. Consistency in ordering of corresponding idioms seems a >> reasonable goal. > I don't see anyone bitching about: > fo

Re: Too much code - slicing

2010-09-22 Thread Steven D'Aprano
On Thu, 23 Sep 2010 01:49:44 +, Seebs wrote: > But I do think it's unfair to dismiss it as purely a matter of baby duck > syndrome. Consistency in ordering of corresponding idioms seems a > reasonable goal. I don't see anyone bitching about: for x in seq: if x: f(x) vs [f(x)

Re: Too much code - slicing

2010-09-22 Thread Seebs
On 2010-09-23, Steven D'Aprano wrote: > Yes, it certainly is. Describing it as "an ugly format" is also a matter > of taste -- taste which in my opinion simply isn't justified by anything > other than familiarity. It may not be convincing to other people, but the logical inversion strikes me as

Re: Too much code - slicing

2010-09-22 Thread John Bokma
Steven D'Aprano writes: For completeness sake: code = side == 'l' ? dir[int(num):] : dir[:-1*int(num)] > code = if side == 'l' then dir[int(num):] else dir[:-1*int(num)] > code = side == 'l' if dir[int(num):] else dir[:-1*int(num)] > code = dir[int(num):] if side == 'l' else dir[:-1*int(num)]

Re: Too much code - slicing

2010-09-22 Thread Steven D'Aprano
On Tue, 21 Sep 2010 12:26:29 -0400, Andreas Waldenburger wrote: > On Sat, 18 Sep 2010 19:09:33 -0700 (PDT) Carl Banks > wrote: > >> On Sep 17, 1:01 pm, Andreas Waldenburger >> wrote: >> > On Thu, 16 Sep 2010 16:20:33 -0400 AK wrote: >> > >> > > I also like this construct that works, I think, s

Re: Too much code - slicing

2010-09-22 Thread Steven D'Aprano
On Tue, 21 Sep 2010 16:17:48 +0200, Antoon Pardon wrote: > On Tue, Sep 21, 2010 at 12:07:07AM +, Steven D'Aprano wrote: >> On Mon, 20 Sep 2010 19:28:49 +0200, Antoon Pardon wrote: >> >> > Not necessarily. Some of us have the impression that Guido >> > deliberatly chose an ugly format for the

Re: Too much code - slicing

2010-09-22 Thread Steven D'Aprano
On Tue, 21 Sep 2010 08:17:00 +, Duncan Booth wrote: > I guess you have worked hard to forget the and-or hack. It was actually: > > condition and true-clause or false-clause > > so its not quite the same pattern. So I did. Oops. Thanks for the correction. -- Steven -- http://mail.pyt

Re: Too much code - slicing

2010-09-21 Thread Andreas Waldenburger
On Sat, 18 Sep 2010 19:09:33 -0700 (PDT) Carl Banks wrote: > On Sep 17, 1:01 pm, Andreas Waldenburger > wrote: > > On Thu, 16 Sep 2010 16:20:33 -0400 AK wrote: > > > > > I also like this construct that works, I think, since 2.6: > > > > > code = dir[int(num):] if side == 'l' else dir[:-1*int(nu

Re: Too much code - slicing

2010-09-21 Thread Antoon Pardon
On Tue, Sep 21, 2010 at 12:07:07AM +, Steven D'Aprano wrote: > On Mon, 20 Sep 2010 19:28:49 +0200, Antoon Pardon wrote: > > > Not necessarily. Some of us have the impression that Guido deliberatly > > chose an ugly format for the ternary operator. > > If he did, then he must have changed his

Re: Too much code - slicing

2010-09-21 Thread Duncan Booth
Steven D'Aprano wrote: > That's sheer and unadulterated nonsense. The fact is that Guido changed > his mind about ternary if after discovering that the work-around > > true-clause and condition or false-clause > > is buggy -- it gives the wrong answer if true-clause happens to be a > false va

Re: Syntax highlighting [was Re: Too much code - slicing]

2010-09-21 Thread rantingrick
On Sep 20, 1:29 am, Steven D'Aprano wrote: > To my eyes, the feature of syntax highlighting that alone makes it > worthwhile, its killer feature, is that I can set comments and docstrings > to grey. When I'm scanning code, being able to slide my eyes over greyed- > out comments and docstrings and

Re: Too much code - slicing

2010-09-20 Thread Lie Ryan
On 09/19/10 17:31, Seebs wrote: > Basically, think of what happens as I read each symbol: > > x = x + 1 if condition else x - 1 > > Up through the '1', I have a perfectly ordinary assignment of a value. > The, suddenly, it retroactively turns out that I have misunderstood > everything

Re: Too much code - slicing

2010-09-20 Thread John Bokma
Terry Reedy writes: >> On 09/19/2010 10:32 PM, John Bokma wrote: > >>> the spoiler. Do you fast forward movies as well? > > I sometimes watch movies (or parts thereof) on 1.5x, especially if it > has a lot of 'filler' scenes. But only when my wife is not watching, > as she hates it. Heh, my ques

Re: Too much code - slicing

2010-09-20 Thread Seebs
On 2010-09-21, Steven D'Aprano wrote: > On Mon, 20 Sep 2010 19:28:49 +0200, Antoon Pardon wrote: >> Not necessarily. Some of us have the impression that Guido deliberatly >> chose an ugly format for the ternary operator. > If he did, then he must have changed his mind, because there is nothing >

Re: Too much code - slicing

2010-09-20 Thread Gregory Ewing
AK wrote: One definite advantage would be that if, say, it takes you 70 pages of a given novel to figure out whether you like it enough to continue, If there was that much doubt, I would give up long before reaching the 70 page mark, regardless of reading speed. If I'm not hooked by the first

Re: Too much code - slicing

2010-09-20 Thread Steven D'Aprano
On Mon, 20 Sep 2010 19:28:49 +0200, Antoon Pardon wrote: > Not necessarily. Some of us have the impression that Guido deliberatly > chose an ugly format for the ternary operator. If he did, then he must have changed his mind, because there is nothing ugly about the ternary operator we ended up w

Re: Too much code - slicing

2010-09-20 Thread Mark Lawrence
On 20/09/2010 18:28, Antoon Pardon wrote: On Sun, Sep 19, 2010 at 11:30:32PM +, Seebs wrote: On 2010-09-19, MRAB wrote: On 19/09/2010 22:32, Seebs wrote: On 2010-09-19, AK wrote: Because that's what 'if' and 'else' mean. My point is, I don't want the order of the clauses in if/else

Re: Too much code - slicing

2010-09-20 Thread Ian Kelly
On Mon, Sep 20, 2010 at 11:28 AM, Antoon Pardon < antoon.par...@rece.vub.ac.be> wrote: > > Not necessarily. Some of us have the impression that Guido deliberatly > chose an ugly format for the ternary operator. Guido has alwasys been > against a ternary operator but the requests kept coming. So ev

Re: Too much code - slicing

2010-09-20 Thread Seebs
On 2010-09-20, Antoon Pardon wrote: > Not necessarily. Some of us have the impression that Guido deliberatly > chose an ugly format for the ternary operator. Guido has alwasys been > against a ternary operator but the requests kept coming. So eventually > he introduced one. But the impression is t

Re: Too much code - slicing

2010-09-20 Thread Terry Reedy
On 09/19/2010 10:32 PM, John Bokma wrote: the spoiler. Do you fast forward movies as well? I sometimes watch movies (or parts thereof) on 1.5x, especially if it has a lot of 'filler' scenes. But only when my wife is not watching, as she hates it. -- Terry Jan Reedy -- http://mail.pytho

Re: Too much code - slicing

2010-09-20 Thread Antoon Pardon
On Sun, Sep 19, 2010 at 11:30:32PM +, Seebs wrote: > On 2010-09-19, MRAB wrote: > > On 19/09/2010 22:32, Seebs wrote: > >> On 2010-09-19, AK wrote: > >>> Because that's what 'if' and 'else' mean. > > >> My point is, I don't want the order of the clauses in if/else to change. > >> If it is so

Re: Too much code - slicing

2010-09-20 Thread John Bokma
Seebs writes: > On 2010-09-20, John Bokma wrote: >> I didn't mean that there are spoilers in the first 70 pages, just that >> to me the excercise would spoil the book, so, I wouldn't do it. I >> consider a book like a meal, I wouldn't gobble down food, regurgitate >> it, and eat it again at a sl

Re: [OT] Syntax highlighting [was Re: Too much code - slicing]

2010-09-20 Thread Seebs
On 2010-09-20, Steven D'Aprano wrote: > On Sun, 19 Sep 2010 07:36:11 +, Seebs wrote: >> No, but the syntax should be invisible. When I read English, I don't >> have to think about nouns and verbs and such unless something is very >> badly written. > That's almost certainly because you've bee

Re: [OT] Speed-reading [was Re: Too much code - slicing]

2010-09-20 Thread Seebs
On 2010-09-20, Steven D'Aprano wrote: > I don't know about how other people speed-read, but I can assure you that > when my wife speed-reads, she's not just scanning a few words and > interpolating between them. She can give you a detailed summary of what > *actually* happened, not just a good

[OT] Syntax highlighting [was Re: Too much code - slicing]

2010-09-19 Thread Steven D'Aprano
On Sun, 19 Sep 2010 07:36:11 +, Seebs wrote: > On 2010-09-19, Steven D'Aprano > wrote: >> I'm not entirely sure I agree with you here... you can't ignore syntax >> in order to understand the meaning of code. > > No, but the syntax should be invisible. When I read English, I don't > have to

[OT] Speed-reading [was Re: Too much code - slicing]

2010-09-19 Thread Steven D'Aprano
On Sun, 19 Sep 2010 10:29:10 -0400, AK wrote: > On 09/18/2010 11:28 PM, Steven D'Aprano wrote: [...] >> My wife can read scarily fast. It's very something to watch her reading >> pages as fast as she can turn them, and a few years ago she read the >> entire Harry Potter series (to date) in one aft

Re: Too much code - slicing

2010-09-19 Thread Seebs
On 2010-09-20, John Bokma wrote: > I didn't mean that there are spoilers in the first 70 pages, just that > to me the excercise would spoil the book, so, I wouldn't do it. I > consider a book like a meal, I wouldn't gobble down food, regurgitate > it, and eat it again at a slower pace. Books, movi

Re: Too much code - slicing

2010-09-19 Thread John Bokma
AK writes: > On 09/19/2010 10:32 PM, John Bokma wrote: >> AK writes: >> >>> On 09/19/2010 07:18 PM, Gregory Ewing wrote: AK wrote: > Afaik the idea is that you can read a novel at the speed of half a page > a second or so and understand it to the same extent as people who'd rea

Re: Too much code - slicing

2010-09-19 Thread AK
On 09/19/2010 10:32 PM, John Bokma wrote: AK writes: On 09/19/2010 07:18 PM, Gregory Ewing wrote: AK wrote: Afaik the idea is that you can read a novel at the speed of half a page a second or so and understand it to the same extent as people who'd read at a normal rate. I've never underst

Re: Too much code - slicing

2010-09-19 Thread Steven D'Aprano
On Mon, 20 Sep 2010 11:18:57 +1200, Gregory Ewing wrote: > AK wrote: > >> Afaik the idea is that you can read a novel at the speed of half a page >> a second or so and understand it to the same extent as people who'd >> read at a normal rate. > > I've never understood why anyone would *want* to

Re: Too much code - slicing

2010-09-19 Thread Seebs
On 2010-09-20, John Bokma wrote: > Heh, to me speed reading those 70 pages in a very short while, > concluding that it's a good book, and start over again would be quite > the spoiler. I rarely encounter substantive spoilers in the first 70 pages or so of a book. That said, I'm pretty much immun

Re: Too much code - slicing

2010-09-19 Thread John Bokma
AK writes: > On 09/19/2010 07:18 PM, Gregory Ewing wrote: >> AK wrote: >> >>> Afaik the idea is that you can read a novel at the speed of half a page >>> a second or so and understand it to the same extent as people who'd read >>> at a normal rate. >> >> I've never understood why anyone would *wa

Re: Too much code - slicing

2010-09-19 Thread Seebs
On 2010-09-20, alex23 wrote: > AK wrote: >> When I was reading The book of the new sun, though, I could stop and >> read a single sentence a few times over and reflect on it for a minute. > Totally understandable, Wolfe is a far, far greater writer than > Rowling :) Certainly true. On the othe

Re: Too much code - slicing

2010-09-19 Thread AK
On 09/19/2010 07:18 PM, Gregory Ewing wrote: AK wrote: Afaik the idea is that you can read a novel at the speed of half a page a second or so and understand it to the same extent as people who'd read at a normal rate. I've never understood why anyone would *want* to read a novel that fast, th

Re: Too much code - slicing

2010-09-19 Thread alex23
AK wrote: > When I was reading The book of the new sun, though, I could stop and > read a single sentence a few times over and reflect on it for a minute. Totally understandable, Wolfe is a far, far greater writer than Rowling :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Too much code - slicing

2010-09-19 Thread Seebs
On 2010-09-19, Gregory Ewing wrote: > AK wrote: >> Afaik the idea is that you can read a novel at the speed of half a page >> a second or so and understand it to the same extent as people who'd read >> at a normal rate. > I've never understood why anyone would *want* to read a > novel that fast,

Re: Too much code - slicing

2010-09-19 Thread Seebs
On 2010-09-19, MRAB wrote: > On 19/09/2010 22:32, Seebs wrote: >> On 2010-09-19, AK wrote: >>> Because that's what 'if' and 'else' mean. >> My point is, I don't want the order of the clauses in if/else to change. >> If it is sometimes "ifelse", then >> it should *ALWAYS WITHOUT EXCEPTION* be

Re: Too much code - slicing

2010-09-19 Thread Gregory Ewing
AK wrote: Afaik the idea is that you can read a novel at the speed of half a page a second or so and understand it to the same extent as people who'd read at a normal rate. I've never understood why anyone would *want* to read a novel that fast, though. For me at least, reading a novel is some

Re: Too much code - slicing

2010-09-19 Thread MRAB
On 19/09/2010 22:32, Seebs wrote: On 2010-09-19, AK wrote: Because that's what 'if' and 'else' mean. My point is, I don't want the order of the clauses in if/else to change. If it is sometimes "ifelse", then it should *ALWAYS WITHOUT EXCEPTION* be condition first, then true clause, then f

Re: Too much code - slicing

2010-09-19 Thread Seebs
On 2010-09-19, AK wrote: > Because that's what 'if' and 'else' mean. My point is, I don't want the order of the clauses in if/else to change. If it is sometimes "if else ", then it should *ALWAYS WITHOUT EXCEPTION* be condition first, then true clause, then false clause. If it's sometimes "if

Re: Too much code - slicing

2010-09-19 Thread AK
On 09/19/2010 02:21 PM, Seebs wrote: On 2010-09-19, AK wrote: On 09/19/2010 03:31 AM, Seebs wrote: Just like: if condition: foo else: bar The condition is the primary, the clauses are secondary to it. To me, the problem with C ternary is, why is tr

Re: Too much code - slicing

2010-09-19 Thread Seebs
On 2010-09-19, AK wrote: > On 09/19/2010 03:31 AM, Seebs wrote: >> Just like: >> if condition: >> foo >> else: >> bar >> The condition is the primary, the clauses are secondary to it. > To me, the problem with C ternary is, why is true condition first and > false seco

Re: Too much code - slicing

2010-09-19 Thread AK
On 09/19/2010 03:36 AM, Seebs wrote: On 2010-09-19, Steven D'Aprano wrote: I'm not entirely sure I agree with you here... you can't ignore syntax in order to understand the meaning of code. No, but the syntax should be invisible. When I read English, I don't have to think about nouns and ver

Re: Too much code - slicing

2010-09-19 Thread AK
On 09/19/2010 03:31 AM, Seebs wrote: On 2010-09-19, Steven D'Aprano wrote: Define "unbalanced". I'm not sure that's the word I'd use. I'm not even sure what it would mean here. Putting aside the over-use of punctuation, The C syntax feels unbalanced to me. You have: condition IF true-cl

Re: Too much code - slicing

2010-09-19 Thread AK
On 09/18/2010 11:28 PM, Steven D'Aprano wrote: On Sat, 18 Sep 2010 21:58:58 -0400, AK wrote: I don't understand this. So far as I know, the phrase "speed reading" refers to various methods of reading much faster than most people read, and is real but not exceptionally interesting. Afaik the

Re: Too much code - slicing

2010-09-19 Thread Seebs
On 2010-09-19, Steven D'Aprano wrote: > I'm not entirely sure I agree with you here... you can't ignore syntax in > order to understand the meaning of code. No, but the syntax should be invisible. When I read English, I don't have to think about nouns and verbs and such unless something is very

Re: Too much code - slicing

2010-09-19 Thread Seebs
On 2010-09-19, Steven D'Aprano wrote: > Define "unbalanced". I'm not sure that's the word I'd use. I'm not even sure what it would mean here. > Putting aside the over-use of punctuation, The C syntax feels unbalanced > to me. You have: > condition IF true-clause ELSE false-clause > so both c

Re: Too much code - slicing

2010-09-18 Thread Steven D'Aprano
On Sun, 19 Sep 2010 00:35:14 +, Seebs wrote: > On 2010-09-19, AK wrote: >> Funny that you should say that, because I thought quite a few times >> that it would be really awesome if some texts in English had syntax >> highlighting. Obviously, not Brothers Karamazov, but something like a >> tut

Re: Too much code - slicing

2010-09-18 Thread Steven D'Aprano
On Sat, 18 Sep 2010 21:58:58 -0400, AK wrote: >> I don't understand this. So far as I know, the phrase "speed reading" >> refers to various methods of reading much faster than most people read, >> and is real but not exceptionally interesting. > > Afaik the idea is that you can read a novel at t

Re: Too much code - slicing

2010-09-18 Thread Steven D'Aprano
On Sat, 18 Sep 2010 19:09:33 -0700, Carl Banks wrote: > Apart from occasions like this and throwaway one-liners I use regular > if-then statements. If Python had added the C-like a ? b : c, then I'd > use it a lot more, since that version is not inherently unbalanced. Define "unbalanced". Putti

Re: Too much code - slicing

2010-09-18 Thread AK
On 09/18/2010 10:12 PM, Seebs wrote: On 2010-09-19, AK wrote: On 09/18/2010 08:35 PM, Seebs wrote: News flash: Not all people think the same way. Film at 11. :) I've tried to use syntax coloring editors, and I've always found that they end up making me slower and less accurate at reading

Re: Too much code - slicing

2010-09-18 Thread Seebs
On 2010-09-19, AK wrote: > On 09/18/2010 08:35 PM, Seebs wrote: >> That wouldn't be *syntax* highlighting, that'd be *semantic* highlighting. > In case of programming, the effect is similar. I have not found that to be the case. It's been exactly the same as syntax highlighting in English would

Re: Too much code - slicing

2010-09-18 Thread Carl Banks
On Sep 17, 1:01 pm, Andreas Waldenburger wrote: > On Thu, 16 Sep 2010 16:20:33 -0400 AK wrote: > > > I also like this construct that works, I think, since 2.6: > > > code = dir[int(num):] if side == 'l' else dir[:-1*int(num)] > > I wonder when this construct will finally start to look good. I do

Re: Too much code - slicing

2010-09-18 Thread AK
On 09/18/2010 09:08 PM, Dennis Lee Bieber wrote: On Sat, 18 Sep 2010 20:00:32 -0400, AK declaimed the following in gmane.comp.python.general: Funny that you should say that, because I thought quite a few times that it would be really awesome if some texts in English had syntax highlighting. O

Re: Too much code - slicing

2010-09-18 Thread AK
On 09/18/2010 08:35 PM, Seebs wrote: On 2010-09-19, AK wrote: Funny that you should say that, because I thought quite a few times that it would be really awesome if some texts in English had syntax highlighting. Obviously, not Brothers Karamazov, but something like a tutorial, or a manual, or a

Re: Too much code - slicing

2010-09-18 Thread Seebs
On 2010-09-19, AK wrote: > Funny that you should say that, because I thought quite a few times that > it would be really awesome if some texts in English had syntax > highlighting. Obviously, not Brothers Karamazov, but something like a > tutorial, or a manual, or an online article. If key words w

Re: Too much code - slicing

2010-09-18 Thread AK
On 09/18/2010 07:38 PM, Seebs wrote: On 2010-09-18, AK wrote: On 09/18/2010 06:56 PM, Seebs wrote: Basically, I can handle do x if y pretty well, but do x if y else z always breaks my parser. So in English, I might say "I'll go to the store if I have time", but I'd rarely us

Re: Too much code - slicing

2010-09-18 Thread Seebs
On 2010-09-18, AK wrote: > On 09/18/2010 06:56 PM, Seebs wrote: >> Basically, I can handle >> do x if y >> pretty well, but >> do x if y else z >> always breaks my parser. >> So in English, I might say "I'll go to the store if I have time", but >> I'd rarely use "I'll go to the store if

Re: Too much code - slicing

2010-09-18 Thread AK
On 09/18/2010 06:56 PM, Seebs wrote: On 2010-09-18, Steven D'Aprano wrote: On Fri, 17 Sep 2010 16:01:54 -0400, Andreas Waldenburger wrote: On Thu, 16 Sep 2010 16:20:33 -0400 AK wrote: I also like this construct that works, I think, since 2.6: code = dir[int(num):] if side == 'l' else dir[

Re: Too much code - slicing

2010-09-18 Thread Seebs
On 2010-09-18, Steven D'Aprano wrote: > On Fri, 17 Sep 2010 16:01:54 -0400, Andreas Waldenburger wrote: >> On Thu, 16 Sep 2010 16:20:33 -0400 AK wrote: >>> I also like this construct that works, I think, since 2.6: >>> code = dir[int(num):] if side == 'l' else dir[:-1*int(num)] >> I wonder when

Re: Too much code - slicing

2010-09-17 Thread Steven D'Aprano
On Fri, 17 Sep 2010 16:01:54 -0400, Andreas Waldenburger wrote: > On Thu, 16 Sep 2010 16:20:33 -0400 AK wrote: > >> I also like this construct that works, I think, since 2.6: >> >> code = dir[int(num):] if side == 'l' else dir[:-1*int(num)] >> > I wonder when this construct will finally start

Re: Too much code - slicing

2010-09-17 Thread Bas
On Sep 17, 10:01 pm, Andreas Waldenburger wrote: > On Thu, 16 Sep 2010 16:20:33 -0400 AK wrote: > > > I also like this construct that works, I think, since 2.6: > > > code = dir[int(num):] if side == 'l' else dir[:-1*int(num)] > > I wonder when this construct will finally start to look good. Us

Re: Too much code - slicing

2010-09-17 Thread Andreas Waldenburger
On Thu, 16 Sep 2010 16:20:33 -0400 AK wrote: > I also like this construct that works, I think, since 2.6: > > code = dir[int(num):] if side == 'l' else dir[:-1*int(num)] > I wonder when this construct will finally start to look good. /W -- INVALID? DE! -- http://mail.python.org/mailman/li

Re: Too much code - slicing

2010-09-16 Thread DataSmash
On Sep 16, 2:47 pm, Benjamin Kaplan wrote: > On Thu, Sep 16, 2010 at 3:35 PM, DataSmash wrote: > > I need to create a simple utility to remove characters from either the > > right or left side of directories. > > This works, but there has to be a better way.  I tried to use a > > variable inside

Re: Too much code - slicing

2010-09-16 Thread AK
On 09/16/2010 03:47 PM, Benjamin Kaplan wrote: On Thu, Sep 16, 2010 at 3:35 PM, DataSmash wrote: I need to create a simple utility to remove characters from either the right or left side of directories. This works, but there has to be a better way. I tried to use a variable inside the brackets

Re: Too much code - slicing

2010-09-16 Thread Benjamin Kaplan
On Thu, Sep 16, 2010 at 3:35 PM, DataSmash wrote: > I need to create a simple utility to remove characters from either the > right or left side of directories. > This works, but there has to be a better way.  I tried to use a > variable inside the brackets but I can't get > that to work.  Can anyo

Too much code - slicing

2010-09-16 Thread DataSmash
I need to create a simple utility to remove characters from either the right or left side of directories. This works, but there has to be a better way. I tried to use a variable inside the brackets but I can't get that to work. Can anyone think of a way to do this with less code? Thanks! import