Re: [Python-3000] iostack and Oh Oh

2006-12-07 Thread Tim Hochberg
Talin wrote: > Phillip J. Eby wrote: >> At 09:59 AM 12/5/2006 -0600, Guido van Rossum wrote: >>> My point is that an interface can *document* (at least in English) a >>> "contract" about the invariants between operations. While I'm not into >>> enforcing or verifying such contracts, I'm very intere

Re: [Python-3000] Abilities / Interfaces and security

2006-11-27 Thread Tim Hochberg
Jim Jewett wrote: > On 11/22/06, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > >> While this is more verbose than sticking an 'if' into the original >> sendmail(), note that it can also be added by a third party, via: > >> overload smtpblib.SMTP.sendmail( >> self, from_addr, to_addrs:

Re: [Python-3000] Fwd: Conventions for annotation consumers (was: Re: Draft pre-PEP: function annotations)

2006-08-15 Thread Tim Hochberg
Collin Winter wrote: > On 8/15/06, Calvin Spealman <[EMAIL PROTECTED]> wrote: >> On 8/15/06, Collin Winter <[EMAIL PROTECTED]> wrote: >>> 1) Static analysis tools (pychecker, optimising compilers, etc) must >>> be able to use the annotations >> As in any example given so far, the annotations would

Re: [Python-3000] stdlib reorganization

2006-05-31 Thread Tim Hochberg
The more examples I see of the 'py' and 'site' top level namespaces, the less I like them. Let's dispose of 'site' first; it's been common to show examples like: from gui import wx However, wx currently, and presumably for the forseeable future, lives in site packages, so we'd actually h

Re: [Python-3000] Automatically invoking str() in str.join()

2006-04-27 Thread Tim Hochberg
Barry Warsaw wrote: > On Thu, 2006-04-27 at 10:08 -0700, Aahz wrote: >> -0 >> >> >>While I hate the way it looks, I never have gotten mixed up about the >>order of arguments since switching to ''.join(l). Me too on all counts including the -0. > > > Which is why > > EMPTYSTRING = '' > > ..

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-13 Thread Tim Hochberg
Let me update my original thought experiment in a way that (I think) preserves the current behaviour while also requiring strict dominance. Let's imagine for a second that we have two new types at the top of the hierarchy. I'll call them Ultimate and Penultimate. So the inheritance tree goes l

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-12 Thread Tim Hochberg
Here's a little thought experiment: What would happen if 'a+b' was just syntactic sugar for 'operator.add(a,b)', where operator.add was a generic function, instead of the current magic dance involving __add__ and __radd__. Neglecting the fact that it would break all Python co

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-12 Thread Tim Hochberg
This is just a little update on my rewrite of pprint. I've continued to clean up and optimize this. If anyone wants to look at it, I've updated the code here: http://members.cox.net/~tim.hochberg/pprint2.py [The changes are probably not signifigant enough to justify another posting of t

Re: [Python-3000] Adaptation and type declarations

2006-04-10 Thread Tim Hochberg
Guido van Rossum wrote: > On 4/10/06, Jim Jewett <[EMAIL PROTECTED]> wrote: > >>On 4/10/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: >> >>>A completely separate issue is what kind of objects Seq, Index and >>>Text would be; but that's a discussion we have separate from the >>>syntactic discussi

Re: [Python-3000] Adaptation and type declarations

2006-04-10 Thread Tim Hochberg
Guido van Rossum wrote: > On 4/10/06, Jim Jewett <[EMAIL PROTECTED]> wrote: > >>Every so often Guido talks about adding optional typing to python. >> >>Adaptation may offer the cleanest way to do this. >> >> >>Turning >> >>def fn(a, b, c="default"): ... >> >>into any of >> >>def fn(Seq a,

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-09 Thread Tim Hochberg
Guido van Rossum wrote: > On 4/9/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > >>Rather than having you scroll all through this long message/file, I'll instead >>place all the examples up here at the top. Assuming that you save this as >>pprint2.py, you should

Re: [Python-3000] Sane transitive adaptation

2006-04-09 Thread Tim Hochberg
Guido van Rossum wrote: > On 4/8/06, Talin <[EMAIL PROTECTED]> wrote: > >>You know, on the one hand, I've been reading this thread, and I'm >>excited about the possibility of generic functions (dynamic dispatch, >>duckaplex-typing, whatever you want to call it), but at the same time >>I kind of wo

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-09 Thread Tim Hochberg
"""This is my attempt to rewrite pprint.py to be based on protocols. Or overloading or specialization or whatever they end up being called ;-). My first attempt only touched about 20 lines of the original pprint and probably had 90% of the usability gain that this one does, but for some reason I

Re: [Python-3000] Adaption & generic functions [was Generic functions]

2006-04-07 Thread Tim Hochberg
Walter Dörwald wrote: >Guido van Rossum wrote: > > > >>On 4/5/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> >> >>>But might closes off one route we could take if we're adapting to >>>something that must provide more than one function/method (i.e. an >>>interface) and we'd like to have the

Re: [Python-3000] Sane transitive adaptation

2006-04-06 Thread Tim Hochberg
Nick Coghlan wrote: > One issue with generic functions and adaptation as currently being discussed > (and something Tim mentioned a while back), it that it is very focused on > dispatching based solely on obj.__class__.__mro__. > > That's all well and good, but (to use an example of Tim's), supp

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-06 Thread Tim Hochberg
Walter Dörwald wrote: > Guido van Rossum wrote: > > >>On 4/5/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> >>>The problem with this is that it looks in the base protocol only if the >>>the class can't be found in the registry of the subprotocol. This mean >>>that an adapter from the subprotoco

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-05 Thread Tim Hochberg
Guido van Rossum wrote: [TAHs simple pprint customization example snipped] >> >>Nice! >> >>I expect that with another dozen lines of code I could make custom >>pretty printers possible, although the way the customization happens >>might be a little kludgy. I'll look into it. > > > Neat indeed.

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-05 Thread Tim Hochberg
Walter Dörwald wrote: > Guido van Rossum wrote: > >> On 4/5/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> >>> Guido van Rossum wrote: >>> >>>> On 4/5/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: >>>> >>>>>

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-05 Thread Tim Hochberg
Guido van Rossum wrote: >On 4/5/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > > >>Walter Dörwald wrote: >> >> >>>What's still missing IMHO is a way for an adapter to defer to the next >>>adapter in the chain, i.e. something like: &g

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-05 Thread Tim Hochberg
Walter Dörwald wrote: > Guido van Rossum wrote: > >> Fascinating ideas in this thread! >> >> I spent some time blogging about this on artima: >> http://www.artima.com/weblogs/viewpost.jsp?thread=155123 >> >> I have to write my slides for a talk about Py3K later today, but I'll >> be back. In the m

Re: [Python-3000] String formating operations in python 3k

2006-04-05 Thread Tim Hochberg
Ian Bicking wrote: > Alex Martelli wrote: > >>As for the % operator, I never liked it -- either a builtin function, >>or even better a method of string objects, is going to be much more >>readable (and my preference would be to have it take optional >>positional arguments, corresponding to {

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-05 Thread Tim Hochberg
Nick Coghlan wrote: > Tim Hochberg wrote: > >>I like this version. The naming seems an improvement and the >>default_adapter seems like a worthy addition. I do keep wondering if >>there's some reason for a user of Protocol to call candidate_keys >>directly or

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-05 Thread Tim Hochberg
Nick Coghlan wrote: > Tim Hochberg wrote: > >>So after all of that, I think my conclusion is that I wouldn't refactor >>this at all, at least not yet. I'd add support for multiple registration >>and possibly spell adapt as __call__, otherwise I'd leave it

Re: [Python-3000] Adaptation vs. Generic Functions

2006-04-05 Thread Tim Hochberg
Guido van Rossum wrote: > #!/usr/bin/python2.4 > > """An example of generic functions vs. adaptation. > > After some face-to-face discussions with Alex I'm presenting here two > extremely simplified implementations of second-generation adaptation > and generic functions, in order to contrast and

Re: [Python-3000] Adaption & generic functions [was Generic functions]

2006-04-04 Thread Tim Hochberg
Guido van Rossum wrote: >On 4/4/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > >(Could you not change the subject each time? Or if you do, could you >assume the reader hasn't necessarily read your previous posts? For >gmail users like me, each subject change start

Re: [Python-3000] Adaption & generic functions [was Generic functions]

2006-04-04 Thread Tim Hochberg
Considering generic function in combination adaption led to one more small change in the Protocol implementation that I'm playing with, and all of the sudden I'm left with something that I could actually use. What I realized was that you could factor out the part that potentially has a lot of

Re: [Python-3000] Generic functions

2006-04-04 Thread Tim Hochberg
Phillip J. Eby wrote: > At 11:03 PM 4/3/2006, Ian Bicking wrote: > >>Guido van Rossum wrote: >> >>>On 4/3/06, Ian Bicking <[EMAIL PROTECTED]> wrote: >>> As an alternative to adaptation, I'd like to propose generic functions. I think they play much the same role, except they are much simp

Re: [Python-3000] Adaptation [was:Re: Iterators for dict keys, values, and items == annoying :)]

2006-04-03 Thread Tim Hochberg
Greg Ewing wrote: > Nick Coghlan wrote: > > >>In this case, it makes far more sense to me to move the adapter >>registration out to the individual protocols. > > > That would alleviate some of my concerns as well. This > seems more Pythonic: Namespaces are one honking... etc. > > >>In a glor

Re: [Python-3000] Adaptation: T->P vs P->P

2006-04-03 Thread Tim Hochberg
Michael Chermside wrote: >Tim Hochberg writes: > > >>In this thread, Alex has been advocating adaption where types are >>adapted to protocols: T->P adaption for short. By contrast, my two >>sample implementations have involved Protocol->Protocol adaptio

Re: [Python-3000] Adaptation: T->P vs P->P

2006-04-03 Thread Tim Hochberg
Nick Coghlan wrote: [SNIP] > > Tim Hochberg wrote: > >>In this thread, Alex has been advocating adaption where types are >>adapted to protocols: T->P adaption for short. By contrast, my two >>sample implementations have involved Protocol->Protocol adaption

Re: [Python-3000] A few small py3k wishes

2006-04-03 Thread Tim Hochberg
Talin wrote: [...] > For example, the suggestion of testing each member of a module with > "is_module" is fine - except that a newbie programmer's first attempt to > write "is_module" is probably going to be "isinstance( value, module )" > which won't work because the word "module" isn't bound to

Re: [Python-3000] Adaptation

2006-04-03 Thread Tim Hochberg
7;ll include the module docstring below. Regards, -tim """adaption -- the worlds fourth most naive implementation of adaption Based on some post one python-dev-3000 on April 1st, 2006. Alex Martelli's being one of the main ones. Idiocies are all atributable to me (Tim Hochberg)

Re: [Python-3000] Adaptation: T->P vs P->P

2006-04-02 Thread Tim Hochberg
In this thread, Alex has been advocating adaption where types are adapted to protocols: T->P adaption for short. By contrast, my two sample implementations have involved Protocol->Protocol adaption where objects that implement a certain protocol are adapted to another protocol: P->P adaption f

Re: [Python-3000] A few small py3k wishes

2006-04-02 Thread Tim Hochberg
Talin wrote: > Just a few things that have wanted while doing python > programming. Maybe some of these are already doable > or are already on someone's wish list... Some of these are already pretty easy to do. Perhaps you should explain what's inadequate about the current solutions. For example:

Re: [Python-3000] Adaptation [was:Re: Iterators for dict keys, values, and items == annoying :)]

2006-04-01 Thread Tim Hochberg
Alex Martelli wrote: [SNIP a bunch or erudite stuff.] > > > Here is a simple reference implementation of adaptation under all of > these simplifying assumptions: > > _global_registry = {} > > def register_adapter(T, P, A, registry=_global_registry): > registry[T, P] = A > > def adapt(t

Re: [Python-3000] Adaptation [was:Re: Iterators for dict keys, values, and items == annoying :)]

2006-04-01 Thread Tim Hochberg
Benji York wrote: > Aahz wrote: > >>On Fri, Mar 31, 2006, Alex Martelli wrote: >> >> >>>Once in a while, I'm moved to sing this refrain again, but thanks to >>>the ensuing discussion I'm soon reminded that there are many more >>>gratifying activities I could pursue instead -- repeated beating