Re: [Python-3000] Removing __del__

2006-09-23 Thread Giovanni Bajo
Raymond Hettinger wrote: >> I don't use __del__ much. I use it only in leaf classes, where it >> surely can't be part of loops. In those rare cases, it's very useful >> to me. For instance, I have a small classes which wraps an existing >> handle-based C API exported to Python. Something along the

Re: [Python-3000] Removing __del__

2006-09-23 Thread Giovanni Bajo
Aahz wrote: >> Did you actually read my posts where I have shown some legitimate use >> cases of __del__ which can't be substituted with short and elegant >> enough code? > > The question is whether those use cases are frequent enough -- > especially for less-than-wizard programmers -- to warrant

Re: [Python-3000] Removing __del__

2006-09-23 Thread Giovanni Bajo
Bob Ippolito wrote: > import weakref > > class GarbageDisposal: > def __init__(self): > self.refs = set() > > def __call__(self, object, func, *args, **kw): > def cleanup(ref): > self.refs.remove(ref) > func(*args, **kw) > self.refs.add(wea

Re: [Python-3000] Removing __del__

2006-09-23 Thread Bob Ippolito
On 9/23/06, Giovanni Bajo <[EMAIL PROTECTED]> wrote: > Bob Ippolito wrote: > > > import weakref > > > > class GarbageDisposal: > > def __init__(self): > > self.refs = set() > > > > def __call__(self, object, func, *args, **kw): > > def cleanup(ref): > > self.refs

Re: [Python-3000] Removing __del__

2006-09-23 Thread Giovanni Bajo
Bob Ippolito wrote: >> class Wrapper2: >>def __init__(self, *args): >> self.handle = CAPI.init(*args) >> >>def foo(self): >> CAPI.foo(self.handle) >> >>def restart(self): >> self.handle = CAPI.restart(self.handle) >> >>def close(self): >> CAPI.close(

Re: [Python-3000] How will unicode get used?

2006-09-23 Thread Martin v. Löwis
Adam Olsen schrieb: > Just a minor nit. I doubt we could accept UCS-2, we'd want UTF-16 > instead, with all the variable-width goodness that brings in. Sure we could; we can currently. > Or maybe not so minor. Old versions of windows used UCS-2, new > versions use UTF-16. The former should get

Re: [Python-3000] How will unicode get used?

2006-09-23 Thread Martin v. Löwis
Adam Olsen schrieb: > As far as I can tell, CPython on windows uses UTF-16 with code units. > Perhaps not intentionally, but by default (not throwing an error on > surrogates). It's intentionally; that's what PEP 261 specifies. Regards, Martin ___ Pytho

Re: [Python-3000] How will unicode get used?

2006-09-23 Thread Martin v. Löwis
Giovanni Bajo schrieb: > Is there a design document explaining the rationale of unicode type, the > status quo? There is a document documenting the status quo: the source code. Contributors to this thread (or, for that matter, to this mailing list) should really familiarize themselves with the sou

Re: [Python-3000] How will unicode get used?

2006-09-23 Thread Martin v. Löwis
Gábor Farkas schrieb: > while i understand the constraints, i think it's not a good decision to > leave this to be implementation-dependent. > > the strings seem to me as such a basic functionality, that it's > behaviour should not depend on the platform. > > for example, how is an application

Re: [Python-3000] How will unicode get used?

2006-09-23 Thread Martin v. Löwis
David Hopwood schrieb: >> Assuming my Unicode lingo is right and code point represents a >> letter/character/digraph/whatever, then it will be a code point. Doing one >> of my rare channels of Guido, I *really* doubt he wants to expose the >> technical details of Unicode to the point of having peo

Re: [Python-3000] Removing __var

2006-09-23 Thread Neil Schemenauer
Bob Ippolito <[EMAIL PROTECTED]> wrote: > The point is that legitimate __ usage is supposedly so rare that this > verbosity doesn't matter. If it's verbose, people definitely won't use > it until they need to, where right now people do it all the time cause > it's "private". It's very rare, in my

Re: [Python-3000] Removing __del__

2006-09-23 Thread Marcin 'Qrczak' Kowalczyk
"Giovanni Bajo" <[EMAIL PROTECTED]> writes: > 1) There's a way to destruct the handle BEFORE __del__ is called, > which would require killing the weakref / deregistering the > finalization hook. Weakrefs should have a method which runs their callback and unregisters them. > 2) The objects requir

Re: [Python-3000] Removing __del__

2006-09-23 Thread Bob Ippolito
On 9/23/06, Giovanni Bajo <[EMAIL PROTECTED]> wrote: > Bob Ippolito wrote: > > >> class Wrapper2: > >>def __init__(self, *args): > >> self.handle = CAPI.init(*args) > >> > >>def foo(self): > >> CAPI.foo(self.handle) > >> > >>def restart(self): > >> self.handle =

Re: [Python-3000] How will unicode get used?

2006-09-23 Thread Josiah Carlson
"Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > David Hopwood schrieb: [snip] > > Should we nevertheless try to avoid making the use of Unicode strings > > unnecessarily difficult for people who have minimal knowledge of Unicode? > > Absolutely, but not at the expense of making basic operations on

Re: [Python-3000] How will unicode get used?

2006-09-23 Thread Martin v. Löwis
Josiah Carlson schrieb: > For me, having recently remembered what was in a unicode string, and > verifying it by checking the source, the question in my mind is whether > we want to stick with the same 2-representation implementation (default > encoding and UTF-16 or UCS-4 depending on build), or g

[Python-3000] __close__ method

2006-09-23 Thread Giovanni Bajo
Micheal, many thanks for your interesting mail, which pointed out the outcome of the previous thread. Let me trying to answer some questions of yours about __close__. > But I'm hearing general agreement (at least among those contributing > to this thread) that it might be wise to change the statu

Re: [Python-3000] Removing __del__

2006-09-23 Thread Jim Jewett
On 9/22/06, Bob Ippolito <[EMAIL PROTECTED]> wrote: > I still haven't seen one that can't be done pretty trivially > with a weakref. Perhaps the solution is to make > doing cleanup-by-weakref easier or more obvious? Possibly, but I've tried, and *I* couldn't come up with any way to use them that

Re: [Python-3000] Removing __del__

2006-09-23 Thread Greg Ewing
Giovanni Bajo wrote: > What I am basically against is the need of removing an easy syntax which can > have problematic side effects if you are not adult enough, So what are you saying, that people who aren't adult enough should be given a tool that's nice and easy but leads them to write buggy co