I've just been bitten yet again by the fact you can't have a weakref
to a bound method! I find myself wanting to do this whenever I have a
registry of callback functions.
Could we in py3k either
1) make weakrefs to bound methods work? A weakref to a bound method
should mean hold the weakref on
Phillip J. Eby wrote:
> That's actually a separate problem from the one Paul and I are
> talking about, one that I'm not even going to *try* to solve. (Being
> as I already have, and failed miserably.) Hell, I'm not sure Windows
> even has a way to *tell* whether your app was launched from the
At 02:18 PM 2/15/2008 +0200, Niki Spahiev wrote:
>Phillip J. Eby wrote:
> > That's actually a separate problem from the one Paul and I are
> > talking about, one that I'm not even going to *try* to solve. (Being
> > as I already have, and failed miserably.) Hell, I'm not sure Windows
> > even has
On 14 Feb, 2008, at 23:21, Martin v. Löwis wrote:
>> The code that guesses the default stdout encoding isn't very good,
>> especially not on OSX. Suggestions are welcome.
>
> Unfortunately, Apple isn't very cooperative here. There is no way
> of determining the encoding of a Terminal.app window,
On Thu, Feb 14, 2008 at 5:02 PM, <[EMAIL PROTECTED]> wrote:
> Guido> You can hack around this for now by doing (before printing
> Guido> anything)
>
> Guido> sys.stdout._encoding = 'utf-8'
>
> Guido> but that ought to be a temporary hack until we've figured out the
> Guido> r
On Fri, Feb 15, 2008 at 2:12 AM, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> I've just been bitten yet again by the fact you can't have a weakref
> to a bound method! I find myself wanting to do this whenever I have a
> registry of callback functions.
>
> Could we in py3k either
>
> 1) make w
On Fri, Feb 15, 2008 at 10:24 AM, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> On Thu, Feb 14, 2008 at 5:02 PM, <[EMAIL PROTECTED]> wrote:
> > Guido> You can hack around this for now by doing (before printing
> > Guido> anything)
> >
> > Guido> sys.stdout._encoding = 'utf-8'
>
On Fri, Feb 15, 2008 at 8:46 AM, Joel Bender <[EMAIL PROTECTED]> wrote:
> How about a BNFish notation? Use brackets around optional parameters.
>
> def test([arg1, [arg2,]] arg3):
> ...
If I understand right, positional only arguments would not be optional
in any way shape or form,
On Thu, Feb 14, 2008 at 4:52 PM, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> Would it be worthwhile to leave reversed(s) and s[::-1] as the two obvious
> ways to do it (ways that work with any Sequence, not just lists)?
I think we should keep it. There's no faster way to reverse a list in plac
At 09:35 AM 2/15/2008 -0800, Guido van Rossum wrote:
>On Fri, Feb 15, 2008 at 2:12 AM, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> > I've just been bitten yet again by the fact you can't have a weakref
> > to a bound method! I find myself wanting to do this whenever I have a
> > registry of cal
Dj Gilcrease wrote:
> On Thu, Feb 14, 2008 at 6:04 PM, Greg Ewing <[EMAIL PROTECTED]> wrote:
>> Guido van Rossum wrote:
>> > Now can you come up with a syntax for positional-only
>> > arguments? So far everybody has failed at that, and there are some use
>> > cases where it's useful too.
>
>
>
Dj Gilcrease schrieb:
> On Fri, Feb 15, 2008 at 8:46 AM, Joel Bender <[EMAIL PROTECTED]> wrote:
>> How about a BNFish notation? Use brackets around optional parameters.
>>
>> def test([arg1, [arg2,]] arg3):
>> ...
>
> If I understand right, positional only arguments would not be op
Dj Gilcrease wrote:
> If I understand right, positional only arguments would not be optional
> in any way shape or form, thats what default arguments are for.
I have been expecting that by providing a default value to an argument
in the definition that you are making it optional, be it keyword o
At 11:41 AM 2/15/2008 -0800, Guido van Rossum wrote:
>On Fri, Feb 15, 2008 at 10:26 AM, Phillip J. Eby
><[EMAIL PROTECTED]> wrote:
> > I've never actually encountered a usecase for keeping a standard
> > weakref to a standard bound method, though. It's pretty useless,
> > because bound methods
On Fri, Feb 15, 2008 at 12:52 PM, Phillip J. Eby <[EMAIL PROTECTED]> wrote:
> At 11:41 AM 2/15/2008 -0800, Guido van Rossum wrote:
> >On Fri, Feb 15, 2008 at 10:26 AM, Phillip J. Eby
> ><[EMAIL PROTECTED]> wrote:
>
> > > I've never actually encountered a usecase for keeping a standard
> > > we
On Fri, Feb 15, 2008 at 9:37 AM, Dj Gilcrease <[EMAIL PROTECTED]> wrote:
> The intent is to make it so (Assuming arg1 and arg2 are positional
> only) you cannot do test(arg3=9, arg1=7, arg2=8), thus you would be
> required to do test(7, 8, 9) {since doing test(7, 8, arg3=9) would
> raise an err
On 15 Feb 2008, at 17:37, Guido van Rossum wrote:
> On Thu, Feb 14, 2008 at 4:52 PM, Raymond Hettinger <[EMAIL PROTECTED]>
> wrote:
>> Would it be worthwhile to leave reversed(s) and s[::-1] as the two
>> obvious ways to do it (ways that work with any Sequence, not just
>> lists)?
>
> I thin
On Fri, Feb 15, 2008 at 10:26 AM, Phillip J. Eby <[EMAIL PROTECTED]> wrote:
> At 09:35 AM 2/15/2008 -0800, Guido van Rossum wrote:
> >On Fri, Feb 15, 2008 at 2:12 AM, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> > > I've just been bitten yet again by the fact you can't have a weakref
> > > to a
Dj Gilcrease wrote:
> Positional only args would be arguments that you cannot specify by
> keyword, so having a positional only arg that has a default value,
> thus making it optional just seems broken to me.
There's no logical problem with optional positional-only
args -- it just means you have t
Adam Olsen wrote:
> That'd rely on prompt deletion for correct behaviour. Why not an
> explicit detach method?
>
> buf = sys.stdout.buffer
> sys.stdout.detach()
> sys.stdout = io.TextIOWrapper(buf, "utf-8")
Or keep an explicit count of the number of unclosed
wrappers that are referencing a buffe
Phillip J. Eby wrote:
> So, Nick's query is (in effect), can we either:
>
> 1. make ref(method) create a "weak method" instead, or
>
> 2. make ref(method) an error instead of useless behavior that gives
> you the illusion of working code
Maybe what we want here is a weakref protocol. So instead
On Fri, Feb 15, 2008 at 4:21 PM, Greg Ewing <[EMAIL PROTECTED]> wrote:
> Adam Olsen wrote:
> > That'd rely on prompt deletion for correct behaviour. Why not an
> > explicit detach method?
> >
> > buf = sys.stdout.buffer
> > sys.stdout.detach()
> > sys.stdout = io.TextIOWrapper(buf, "utf-8")
Phillip J. Eby wrote:
> The part I'm not
> immediately sure of is where to call it *from*, so that you can still
> subclass weakref.ref and not end up in a strange delegation loop.
The function for creating a weak ref would need to be
different from the weakref class itself. One of them
would ha
Guido van Rossum wrote:
> It would be better
> if TextIOWrapper didn't explicitly close() when deleted.
> Maybe __del__() should just flush() instead of close()?
Sounds good to me.
--
Greg
___
Python-3000 mailing list
[email protected]
http://ma
Guido van Rossum wrote:
> But maybe given how rare the use case is, it would be easier to just
> create a custom class in weakref.py that does what Nick requested.
Nick would still forget to use it and get strange bugs
in his code, though!
--
Greg
___
> I think you're on to something. There's an API to access the
> underlying (buffered) binary stream: sys.stdout.buffer. It's possible
> to create a new TextIOWrapper on top of that:
>
> sys.stdout = io.TextIOWrapper(sys.stdout.buffer, "utf-8")
While it might be possible to switch an output strea
In general these things are only safe when done before any I/O happens.
But even so it's only a stop-gap measure; the app shouldn't have to do
this, we should fix the guessing algorithm.
On Fri, Feb 15, 2008 at 5:03 PM, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
> > I think you're on to somethi
Raymond Hettinger wrote:
> I've been exercising the new keyword-only arguments syntax. It is absolutely
> wonderful. I'm amazed at how many long standing problems it solves elegantly.
>
> Thanks Talin!
Well, that made my day :)
-- Talin
___
Python-3
28 matches
Mail list logo