Re: [Python-Dev] str.dedent

2005-11-14 Thread Gareth McCaughan
On Sunday 2005-11-13 17:43, Marc-Andre Lemburg wrote: [Noam Raphael:] > > The idea is to add a method called "dedent" to strings. It would do > > exactly what the current textwrap.indent function does. [Marc-Andre:] > You are missing a point here: string methods were introduced > to make switchi

Re: [Python-Dev] a quit that actually quits

2006-01-03 Thread Gareth McCaughan
> class _Quitter(str): > def __call__(self): raise SystemExit > quit = _Quitter('The quit command. Type "quit()" to exit') > exit = _Quitter('The exit command. Type "exit()" to exit') I think you meant class _Quitter(str): def __call__(self): raise SystemExit

Re: [Python-Dev] str with base

2006-01-17 Thread Gareth McCaughan
On Tuesday 2006-01-17 15:19, [EMAIL PROTECTED] wrote: > Alex> Identically the same situation as for int: the base argument is > Alex> only accepted if the first argument is a str (not a float, etc). > Alex> Just the same way, the base argument to str will only be accepted > Alex> i

Re: [Python-Dev] str with base

2006-01-19 Thread Gareth McCaughan
ernatively, a name like "to_base" that clarifies the intent and is less likely to clash with variable names might be an improvement. Or there's always %b, whether that ends up standing for "binary" or "base". Or %b f

Re: [Python-Dev] str with base

2006-01-19 Thread Gareth McCaughan
On Thursday 2006-01-19 11:15, Thomas Wouters wrote: > On Thu, Jan 19, 2006 at 10:23:30AM +0000, Gareth McCaughan wrote: ... > > Introducing a new builtin with a name that's a common, short > > English word is a bit disagreeable. > > While I don't particularly mind

Re: [Python-Dev] / as path join operator (was: Re: The path module PEP)

2006-01-30 Thread Gareth McCaughan
Steven Bethard wrote: > My only fear with the / operator is that we'll end up with the same > problems we have for using % in string formatting -- the order of > operations might not be what users expect. Since join is conceptually > an addition-like operator, I would expect: > > Path('home'

Re: [Python-Dev] Proposal: defaultdict

2006-03-01 Thread Gareth McCaughan
> >> d.get(key, [], True).append(value) > > > > hmm. are you sure you didn't just reinvent setdefault ? > > I'm reasonably sure I copied it on purpose, only with a name that isn't 100% > misleading as to what it does ;) Heh. From the original Usenet posting that suggested the capability that

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-19 Thread Gareth McCaughan
On Friday 2006-03-17 05:04, Alex Martelli wrote: > Hmmm, if we allowed '( as )' for generic expr's we'd make > a lot of people pining for 'assignment as an expression' very happy, > wouldn't we...? I hope not. It looks a lot more like a binding construct than an assigning one. But what about

Re: [Python-Dev] PySet API

2006-03-28 Thread Gareth McCaughan
say) emptying a set using PyObject_CallMethod is O(1) doesn't mean it's insignificant. For many applications the size of your sets is O(1) too. (Often with quite a small implicit constant, too.) -- Gareth McCaughan ___ Python-Dev mail

Re: [Python-Dev] PySet API

2006-03-29 Thread Gareth McCaughan
Terry Reedy wrote: [me:] > >> For what it's worth[1], I think Raymond is absolutely on crack here. [Greg Ewing:] > > +1 on a good concrete set API from me, too. [Terry:] > For what it's worth, I think Gareth's crack at Raymond is childish and out > of place here. Er, it wasn't a crack at Raymo

Re: [Python-Dev] 2.4 news reaches interesting places

2004-12-09 Thread Gareth McCaughan
On Wednesday 2004-12-08 22:39, Phillip J. Eby wrote: [Guido:] >> One thing that bugs me: the article says 3 or 4 times that Python is >> slow, each time with a refutation ("but it's so flexible", "but it's >> fast enough") but still, they sure seem to harp on the point. This is >> a PR issue that

Re: [Python-Dev] comprehension abbreviation (was: Adding any() and all())

2005-03-14 Thread Gareth McCaughan
> - Before anybody asks, I really do think the reason this is requested > at all is really just to save typing; there isn't the "avoid double > evaluation" argument that helped acceptance for assignment operators > (+= etc.), and I find redability is actually improved with 'for'. I'd like it, and

Re: [Python-Dev] comprehension abbreviation (was: Adding any() and all())

2005-03-14 Thread Gareth McCaughan
On Monday 2005-03-14 12:09, Alex Martelli wrote: > > On Mar 14, 2005, at 10:57, Gareth McCaughan wrote: > > > of way as it's distracting in C or C++ seeing > > > > Thing thing = new Thing(); > > > > with the type name appearing thre

Re: [Python-Dev] comprehension abbreviation (was: Adding any() and all())

2005-03-14 Thread Gareth McCaughan
On Monday 2005-03-14 12:42, Eric Nieuwland wrote: > Gareth McCaughan wrote: > > > I'd like it, and my reason isn't "just to save typing". > > There are two reasons. > > > > 1 Some bit of my brain is convinced that [x in stuff if condition] >

Re: [Python-Dev] Rationale for sum()'s design?

2005-03-15 Thread Gareth McCaughan
On Tuesday 2005-03-15 01:57, Guido van Rossum wrote: > I think the conclusion should be that sum() is sufficiently > constrained by backwards compatibility to make "fixing" it impossible > before 3.0. But in 3.0 I'd like to fix it so that the 2nd argument is > only used for empty lists. Why's that

Re: [Python-Dev] Python 2.4 won the "Jolt productivity award" last night

2005-03-17 Thread Gareth McCaughan
On Thursday 2005-03-17 15:42, Guido van Rossum wrote: > Python 2.4 won the "Jolt productivity award" last night. That's the > runner-up award; in our category, languages and development tools, the > Jolt (the category winner) went to Eclipse 3.0; the other runners-up > were IntelliJ and RealBasic

Re: [Python-Dev] AST manipulation and source code generation

2005-06-02 Thread Gareth McCaughan
> ?!ng: Well, i should refine that a bit to say that the Lisp macro system > is a little more specific. Whereas AST transformations in Python > are open-ended (you could generate any result you want), the key > interesting property of Lisp macros is that they are constrained > to be "safe", in the

Re: [Python-Dev] Is PEP 237 final -- Unifying Long Integers and Integers

2005-06-22 Thread Gareth McCaughan
[GvR:] > > Huh? C unsigned ints don't flag overflow either -- they perform > > perfect arithmetic mod 2**32. [Keith Dart:] > I was talking about signed ints. Sorry about the confusion. Other > scripting languages (e.g. perl) do not error on overflow. C signed ints also don't flag overflow, nor do

Re: [Python-Dev] Is PEP 237 final -- Unifying Long Int egers and Integers

2005-06-22 Thread Gareth McCaughan
On Wednesday 2005-06-22 13:32, Nick Coghlan wrote: > Gareth McCaughan wrote: > > [Keith Dart:] > >>By "normal" integer I mean the mathematical definition. > > > > Then you aren't (to me) making sense. You were distinguishing > > this from a u

Re: [Python-Dev] while:

2005-07-21 Thread Gareth McCaughan
On Thursday 2005-07-21 01:22, Martin Blais wrote: > The Rule of Least Surprise says to me that "while:" would do the least > unexpected thing. There are only two possibilities: the test is > implicitly false, in which case "while:" would make no sense (i.e. the > block would be ignored). Therefo

Re: [Python-Dev] [Python-checkins] python/dist/src/Modules _hashopenssl.c, NONE, 2.1 sha256module.c, NONE, 2.1 sha512module.c, NONE, 2.1 md5module.c, 2.35, 2.36 shamodule.c, 2.22, 2.23

2005-08-23 Thread Gareth McCaughan
> Here's an excerpt from the check-in note for sha512module.c: > > > RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],0,0x428a2f98d728ae22ULL); > RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],1,0x7137449123ef65cdULL); > RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],2,0xb5c0fbcfec4d3b2fULL); > RND(S[5],S[

Re: [Python-Dev] [Python-checkins] python/dist/src/Modules_hashopenssl.c, NONE, 2.1 sha256module.c, NONE, 2.1 sha512module.c, NONE, 2.1 md5module.c, 2.35, 2.36 shamodule.c, 2.22, 2.23

2005-08-23 Thread Gareth McCaughan
On Tuesday 2005-08-23 16:51, Fredrik Lundh wrote: > Gareth McCaughan wrote: > > > It's valid C99, meaning "this is an unsigned long long". > > since when does Python require C99 compilers? > > It doesn't, of course, and I hope it won'

Re: [Python-Dev] Remove str.find in 3.0?

2005-08-31 Thread Gareth McCaughan
> Just to put my spoke in the wheel, I find the difference in the > ordering of return values for partition() and rpartition() confusing: > > head, sep, remainder = partition(s) > remainder, sep, head = rpartition(s) > > My first expectation for rpartition() was that it would return exactly > the

Re: [Python-Dev] Remove str.find in 3.0?

2005-08-31 Thread Gareth McCaughan
I wrote: [Andrew Durdin:] > > IOW, I expected "www.python.org".partition("python") to return exactly > > the same as "www.python.org".rpartition("python") > > Yow. Me too, and indeed I've been skimming this thread without > it ever occurring to me that it would be otherwise. And, on re-skimming

Re: [Python-Dev] Revising RE docs

2005-09-02 Thread Gareth McCaughan
On Thursday 2005-09-01 18:09, Guido van Rossum wrote: > They *are* cached and there is no cost to using the functions instead > of the methods unless you have so many regexps in your program that > the cache is cleared (the limit is 100). Sure there is; the cost of looking them up in the cache.

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-02 Thread Gareth McCaughan
> We scientists still use these for debugging. We never 'move on' very far > from the tutorial. The salient feature about print statements is that > they live to be put in and commented out 10 minutes later, without some > import being required or other enabling object being around. > > Easy th

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-02 Thread Gareth McCaughan
> > 3. It's convenient for debugging, interactive use, simple scripts, > >and various other things. > >Interactive use is its own mode and works differently to the base > language. To print the value of something, just type an expression. Doesn't do the same thing. >The problem with

Re: [Python-Dev] Revising RE docs

2005-09-05 Thread Gareth McCaughan
Guido wrote: > > > They *are* cached and there is no cost to using the functions instead > > > of the methods unless you have so many regexps in your program that > > > the cache is cleared (the limit is 100). > > > > Sure there is; the cost of looking them up in the cache. ... > > So in this (hi

Re: [Python-Dev] string formatting options and removing basestring.__mod__ (WAS: Replacement for print in Python 3.0)

2005-09-05 Thread Gareth McCaughan
> If people know of other languages that have a different approach to > string formatting, it might be useful to see them. Common Lisp has something broadly C-like but bigger and hairier. It includes powerful-but-confusing looping and conditional features, letting you say things like (format

Re: [Python-Dev] string formatting options and removing basestring.__mod__ (WAS: Replacement for print in Python 3.0)

2005-09-05 Thread Gareth McCaughan
I wrote: > C++'s << operator represents another way to do formatted > output. I regard it as an object lesson in bad design. ... and should add: Of course it's usually seen as being about output more than about formatting, but in fact if you want to do what Python does with "%", C with "sprintf"

Re: [Python-Dev] string formatting and i18n

2005-09-05 Thread Gareth McCaughan
On Monday 2005-09-05 17:07, Antoine Pitrou wrote: > Le lundi 05 septembre 2005 à 16:52 +0100, Gareth McCaughan a écrit : > > ... and should add: Of course it's usually seen as being about > > output more than about formatting, but in fact if you want > > to do what Py

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Gareth McCaughan
> > On 9/6/05, Barry Warsaw <[EMAIL PROTECTED]> wrote: > > > printf('$1 forgot to frobnicate the $2!\n', username, file.name, > > >to=sys.stderr) ... > For me, the problem with that proposal is not the precise format syntax, > but the fact that formatting is tied to a specific function whic

Re: [Python-Dev] list splicing

2005-09-19 Thread Gareth McCaughan
On Monday 2005-09-19 06:38, Josiah Carlson wrote: > > > [ 'x', *a, 'y'] > > > > > > as syntactic sugar for > > > > > > [ 'x' ] + a + [ 'y' ]. > > > > > > Notes: > > > - This is a common operation > > > > is it? > > Not in the code that I read/use. While "not all 3 line functions should

Re: [Python-Dev] "and" and "or" operators in Py3.0

2005-09-20 Thread Gareth McCaughan
On Tuesday 2005-09-20 11:40, Raymond Hettinger wrote: > > > 2) When going back and forth between languages, it is easy to forget > > > that only Python returns something other than a boolean. > > > > As others point out, this isn't true. > > In C, C++, C#, Java, and JavaScript, what do you get wh

Re: [Python-Dev] Adding a conditional expression in Py3.0

2005-09-21 Thread Gareth McCaughan
> I think I'd prefer (if then else ) i.e. no > colons. None of the other expression forms (list comprehensions and > generator expressions) involving statement keywords use colons. FWLIW, this was my (strong) preference back at the time of the original discussion. -- g __

Re: [Python-Dev] Visibility scope for "for/while/if" statements

2005-09-22 Thread Gareth McCaughan
Alexander Myodov wrote: > Thus, your example falls to case 1: "i" variable is newly declared for > this loop. Well, we don't reuse old value of i to start the iteration > from a particular place, like below? > > i = 5 > for i in [3,4,5,6,7]: > print i, > > More general, the variables could b

Re: [Python-Dev] Adding a conditional expression in Py3.0

2005-09-23 Thread Gareth McCaughan
> The reason I like "a if b else c" is because it has the > most natural word order. In English, >My dog is happy if he has a bone, else sad. > sounds much more natural than >My dog is, if he has a bone, happy, else sad. Neither sounds very natural to me; conditional expressions don't occu

Re: [Python-Dev] Visibility scope for "for/while/if" statements

2005-09-23 Thread Gareth McCaughan
On Thursday 2005-09-22 20:00, Josiah Carlson wrote: [Alexander Myodov:] > > But for the "performance-oriented/human-friendliness" factor, Python > > is anyway not a rival to C and similar lowlevellers. C has > > pseudo-namespaces, though. > > C does not have pseudo-namespaces or variable encapsul

Re: [Python-Dev] Adding a conditional expression in Py3.0

2005-09-26 Thread Gareth McCaughan
On Saturday 2005-09-24 04:21, Terry Reedy wrote: > Never wrote a single line, and may have not read one (in DDJ? Byte?) for > 15-20 years. How do *you* read such C? Cond 'Qmark' ? I seldom have to read C code aloud, and the ?: operator is rare-ish; but I would suggest reading a?b:c as "a c

Re: [Python-Dev] Pre-PEP: Allow Empty Subscript List Without Parentheses

2006-06-16 Thread Gareth McCaughan
1. None of the above is intended to constitute argument for or against Noam's proposed change to Python. Python isn't primarily a language for mathematicians, and so much the better for Python. -- Gareth McCaughan (unashamed pure mathematician, at least by training and temperament)

Re: [Python-Dev] 2.5 and beyond

2006-07-11 Thread Gareth McCaughan
> I can say it stronger. Any resemblance between Python and Scheme or > Lisp is purely a coincidence. Neither language is in Python's > ancestry, at least not explicitly; I'd never used or tried to learn > Scheme when I started Python (still haven't) and my Lisp experience > was limited to copying

Re: [Python-Dev] [slighly OT] Native speakers and hurting brains

2006-07-11 Thread Gareth McCaughan
(Attention conservation notice: the following is concerned almost entirely with exegesis of an old python-dev thread. Those interested in improving Python and not in history and exegesis should probably ignore it.) On Tuesday 2006-07-11 13:43, Boris Borcic wrote: > >> I believe that in this case

Re: [Python-Dev] PEP: Adding data-type objects to Python

2006-10-31 Thread Gareth McCaughan
> > It might be better not to consider "bit" to be a > > type at all, and come up with another way of indicating > > that the size is in bits. Perhaps > > > > 'i4' # 4-byte signed int > > 'i4b' # 4-bit signed int > > 'u4' # 4-byte unsigned int > > 'u4b' # 4-bit unsigned int >

Re: [Python-Dev] Floor division

2007-01-23 Thread Gareth McCaughan
On Tuesday 23 January 2007 07:01, Tim Peters wrote: > complex_new() ends with: > > cr.real -= ci.imag; > cr.imag += ci.real; > > and I have no idea what that thinks it's doing. Surely this isn't intended?!: > >>> complex(complex(1.0, 2.0), complex(10.0, 20.0)) > > (-19+12j) > > WTF?

Re: [Python-Dev] Floor division

2007-01-24 Thread Gareth McCaughan
airs with two numbers and have actual mathematical rules. Gosh, and there I was thinking that complex numbers were magic pairs where you just make stuff up at random. Silly me. -- Gareth McCaughan PhD in pure mathematics, University of Cambridge ___ Pytho

Re: [Python-Dev] Floor division

2007-01-24 Thread Gareth McCaughan
On Wednesday 24 January 2007 10:20, Alexey Borzenkov wrote: > > > I think that's the right thing to do, because that is mathematically > > > correct. j is just an imaginary number with a property that j*j = -1. > > > So > > > > > > (a+bj) + (c+dj)j = (a-d) + (b+c)j. > > > > Yes, thanks, I know wha