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

2005-03-12 Thread Greg Ewing
names for boolean-valued functions in any context. Including 'true' in their names smacks of the same kind of redundancy as if blarg == True: ... which is widely regarded as a naive-newbie style blunder in any language. +1 on 'any' and 'all

Re: [Python-Dev] code blocks using 'for' loops and generators

2005-03-12 Thread Greg Ewing
altogether for this very different use case. -Brian -- Greg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

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

2005-03-12 Thread Greg Ewing
pes for the meaning of (x from ()). . . How about: (for x in seq if f(x)) It still has the word 'for' in it and avoids mentioning x more times than necessary. Although I can't help feeling that it should be some other word instead, such as (all x in seq i

Re: [Python-Dev] code blocks using 'for' loops and generators

2005-03-13 Thread Greg Ewing
there is a mechanism for passing a code block as a thunk to an arbitrary function, the function is free to loop or not as it sees fit. I'd just prefer the spelling of it didn't force you to make it look like it's looping when it's not. -- Greg Ewing, C

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

2005-03-13 Thread Greg Ewing
think that if an identity is specified, it should be used even if the sequence is non-empty. The reason being that the user might be relying on that to get the semantics he wants. Think of the second argument as "accumulator object" rather than "identity". -- Greg Ewing, C

Re: [Python-Dev] code blocks using 'for' loops and generators

2005-03-13 Thread Greg Ewing
ke that would be better, yes. Maybe even just dt = stopwatch(): a() b() Whatever keyword is used is bound to not sound right for some usages, so it would be best if no keyword were needed at all. -- Greg Ewing, Computer Science Dept, +--+ Universit

Re: [Python-Dev] code blocks using 'for' loops and generators

2005-03-14 Thread Greg Ewing
were implemented by passing a thunk to a function that calls it repeatedly. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc.

Re: [Python-Dev] Exception needed: Not enough arguments to PyArg_ParseTuple

2005-03-14 Thread Greg Ewing
ction to find out how many parameters it has been passed, and most C implementations don't provide any way at all. That's why the calling interface to varargs functions invariably includes some way for the caller to indicate the number of arguments, such as a format string or a terminating NULL.

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

2005-03-14 Thread Greg Ewing
specified explicitly. In that case I would argue in favour of keeping it the way it is, since... currently sum([1,1], 40) equals 42. ...seems quite reasonable to me. Or at least as reasonable as anything else. -- Greg Ewing, Computer Science Dept, +--+ University of

Re: [Python-Dev] comprehension abbreviation

2005-03-14 Thread Greg Ewing
ntity(y) Not that it's false, it just seems like a completely unnecessary layer of mental gymnastics... -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand

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

2005-03-14 Thread Greg Ewing
Eric Nieuwland wrote: Perhaps the second argument should not be optional to emphasise this. After all, there's much more to sum() than numbers. I think practicality beats purity here. Using it on numbers is surely an extremely common case. -- Greg Ewing, Computer Science

Re: [Python-Dev] code blocks using 'for' loops and generators

2005-03-16 Thread Greg Ewing
def g(...): ... Of course if the functions then are allowed to change the surrounding bindings this could be used for resource release issues etc. Yes, rebinding in the surrounding scope is the one thing that style wouldn't give you -- Greg Ewing, Comput

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

2005-03-16 Thread Greg Ewing
nt to "".join(x). Although it might be better to call it str.concat() instead of str.sum(). -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-o

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

2005-03-16 Thread Greg Ewing
ted until the function is called. Not to mention that if the seq is empty, there's no way of knowing what T to instantiate... -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christc

Re: [Python-Dev] RE: code blocks using 'for' loops and generators

2005-03-16 Thread Greg Ewing
scoped. (7) A __leave__ or __exit__ special method really turns into another name for __del__. Not really. A PEP-310-style __exit__ method is explicitly invoked at well-defined times, not left until the object is reclaimed. It doesn't suffer from any of the problems of __del__. -- Greg Ewing, C

Re: [Python-Dev] Draft PEP to make file objects support non-blocking mode.

2005-03-18 Thread Greg Ward
setblocking(True) file (the default, right?) behaves as you described above, warts and all. (So old code that uses fcntl() continues to "work" as before.) But files that have had setblocking(False) called could gain these new semantics that you propose. Greg -- Greg Ward <

Re: [Python-Dev] Draft PEP to make file objects support non-blocking mode.

2005-03-20 Thread Greg Ewing
read, and EOF. This means recording that IOError(EAGAIN) is raised for an empty non-blocking read. Isn't that unix-specific? The file object is supposed to provide a more or less platform-independent interface, I thought. -- Greg Ewing, Computer Science Dept, +

Re: [Python-Dev] docstring before function declaration

2005-03-21 Thread Greg Ewing
lines significant. Currently I can leave some space before/after a docstring without breaking anything. This can help readability, especially for class docstrings. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCo

Re: [Python-Dev] Draft PEP to make file objects support non-blocking mode.

2005-03-21 Thread Greg Ewing
methods which behave more like os.read/os.write, maybe called something like readsome() and writesome(). That would eliminate the need to extract and manipulate the fds, and might make it possible to do some of this stuff in a more platform-independent way. -- Greg Ewing, Computer

Re: [Python-Dev] Draft PEP to make file objects support non-blocking mode.

2005-03-21 Thread Greg Ewing
Donovan Baarda wrote: On Mon, 2005-03-21 at 17:32 +1200, Greg Ewing wrote: I don't agree with that. There's no need to use non-blocking I/O when using select(), and in fact things are less confusing if you don't. Because staller.py outputs and flushes a fragment of data smaller t

Re: [Python-Dev] Patch review: all webbrowser.py related patches up to 2005-03-20

2005-03-21 Thread Greg Ward
to try the other detected browser alternatives. I like it. Short, simple, and obvious. Can you think of a way to unit-test it? I took a brief look at the code, and it wasn't obvious to me. Might require factoring out a lazy initializer, and even then it might not work. And that would cert

python-dev@python.org

2005-03-23 Thread Greg Ward
rently than OSS, so be it.) (But, oh yeah: +1 to Fred's suggestion of making redirection controllable. Something like this: default should be no redirection, programmer should be allowed to specify what to do with stdout/stderr of GUI browsers.) Greg -- Greg Ward <[EMAIL

[Python-Dev] New style classes and operator methods

2005-04-07 Thread Greg Ewing
x4019056c> NewStyleSpam.__add__ <__main__.NewStyleSpam object at 0x4019062c> <__main__.NewStyleSpam object at 0x4019056c> Traceback (most recent call last): File "/home/cosc/staff/research/greg/tmp/foo.py", line 27, in ? print x1 + x2 TypeError: unsupported operand ty

Re: [Python-Dev] Pickling buffer objects.

2005-04-18 Thread Greg Ewing
Travis Oliphant wrote: I'm proposing to pickle the buffer object so that it unpickles as a string. Wouldn't this mean you're only solving half the problem? Unpickling a Numeric array this way would still use an intermediate string. -- Greg Ewing, Comput

Re: [Python-Dev] anonymous blocks

2005-04-20 Thread Greg Ewing
s that from the point of view of the user of withfile, the name 'thefile' magically appears in the namespace without it being obvious where it comes from. (but assignments within the block should still affect its _surrounding_ namespace, it seems to me...). I agree with that much. -- Gre

Re: [Python-Dev] anonymous blocks

2005-04-20 Thread Greg Ewing
There isn't all that much left that people want to do on a regular basis. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned su

Re: [Python-Dev] anonymous blocks

2005-04-20 Thread Greg Ewing
You can't rely on a function's signature alone to tell you much in any case. A distressingly large number of functions found in third-party extension modules have a help() string that just says something like fooble(arg,...) There's really no substitute for a good docstring! -- Gre

Re: [Python-Dev] anonymous blocks

2005-04-20 Thread Greg Ewing
ffect, not to compute a value for consumption by the block function. I don't see a great need for blocks to be able to return values. How do blocks work with control flow statements like "break", "continue", "yield", and "return"? Perhaps "break&qu

Re: [Python-Dev] anonymous blocks

2005-04-21 Thread Greg Ewing
se() return func Usage example: with_file("foo.txt", "w") as f: f.write("My hovercraft is full of parrots.") Does that help? -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZea

Re: [Python-Dev] anonymous blocks

2005-04-21 Thread Greg Ewing
sion of the regular assignment statement. Syntactically, yes, but semantically it's more complicated than just a "simple extension", to my mind. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZea

Re: [Python-Dev] anonymous blocks

2005-04-21 Thread Greg Ewing
t;readme.txt") def _(fileobj): ... (Disclaimer: This post should not be taken as an endorsement of this abuse! I'd still much rather have a proper language feature for it.) -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury,

Re: [Python-Dev] anonymous blocks

2005-04-21 Thread Greg Ewing
to understand what it was doing. We already have "return" and "yield"; this would be a third similar-yet- different thing. If it were considered important enough, it could easily be added later, without disturbing anything. But I think it's best left out of an initial specifi

Re: [Python-Dev] Re: anonymous blocks

2005-04-25 Thread Greg Ewing
x27;m +1 on moving towards __next__, BTW. IMO, that's the WISHBDITFP. :-) -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-own

Re: [Python-Dev] Re: anonymous blocks

2005-04-25 Thread Greg Ewing
tercepting break and continue isn't so bad, since they're already associated with the loop they're in, but return has always been an unconditional get-me-out-of-this-function. I'd feel uncomfortable if this were no longer true. -- Greg Ewing, Computer Science Dept, +-

Re: [Python-Dev] Re: anonymous blocks

2005-04-25 Thread Greg Ewing
and iterators (even though they are) doesn't seem right, because they're being used for a purpose very different from generating and iterating. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealand

Re: [Python-Dev] Re: Caching objects in memory

2005-04-25 Thread Greg Ewing
;help", "copyright", "credits" or "license" for more information. >>> "foo" is "foo" True >>> "foo" is "f" + "oo" False >>> "foo" is intern("f" + "oo") True

Re: [Python-Dev] Re: Re: anonymous blocks

2005-04-25 Thread Greg Ewing
you're defining it by means of a generator, you don't need a class at all -- just make the whole thing a generator function. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a |

Re: [Python-Dev] Re: switch statement

2005-04-25 Thread Greg Ewing
being switched on all the time, and the operator being used for comparison. 2) The first case is syntactically different from subsequent ones, even though semantically all the cases are equivalent. -- Greg Ewing, Computer Science Dept, +--+ University of Cante

Re: [Python-Dev] site enhancements (request for review)

2005-04-25 Thread Greg Ewing
ning the main .py file for .pth files? This would make it easier to have collections of Python programs sharing a common set of modules, without having to either install them system-wide or write hairy sys.path-manipulating code or use platform-dependent symlink or PATH hacks. -- Greg Ewing, Comp

Re: [Python-Dev] defmacro (was: Anonymous blocks)

2005-04-25 Thread Greg Ewing
Jim Jewett wrote: defmacro myresource(filename): with myresource("thefile"): def reader(): ... def writer(): ... def fn(): -1. This is ugly. -- Greg Ewing, Computer Science Dept, +--+ University of

Re: [Python-Dev] defmacro (was: Anonymous blocks)

2005-04-25 Thread Greg Ewing
readable. Or prohibit anything that would permit creating a new dialect. Or something. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidi

Re: [Python-Dev] defmacro (was: Anonymous blocks)

2005-04-25 Thread Greg Ewing
sing syntax is fairly unobtrusive. So in summary, I don't think you necessarily *need* macros to get nice-looking user-defined control structures. It depends on other features of the language. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbu

Re: [Python-Dev] Re: anonymous blocks

2005-04-26 Thread Greg Ewing
l intent has nothing to do with iteration. In other words, this is too low a level of explanation. Greg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/option

Re: [Python-Dev] Re: anonymous blocks

2005-04-26 Thread Greg Ewing
Guido van Rossum wrote: [Greg Ewing] * It seems to me that this same exception-handling mechanism would be just as useful in a regular for-loop, and that, once it becomes possible to put 'yield' in a try-statement, people are going to *expect* it to work in for-loops as well. (You can a

Re: [Python-Dev] atexit missing an unregister method

2005-04-26 Thread Greg Ewing
nt, and register a single atexit() hander to invoke it. I don't think there's any need to mess with the way atexit() currently works. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp,

Re: [Python-Dev] defmacro

2005-04-26 Thread Greg Ewing
only that, in those cases where they *do* feel so compelled, they might not if lambda weren't such a long word. I was just trying to understand why Smalltalkers seem to get on fine without macros, whereas Lispers feel they are needed. I think Smalltalk's lightweight block-passing syntax ha

Re: [Python-Dev] defmacro

2005-04-26 Thread Greg Ewing
could use the normal exec statement to invoke the block whenever needed. There's no need for all that. They're just callable objects. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZeal

Re: [Python-Dev] defmacro (was: Anonymous blocks)

2005-04-26 Thread Greg Ewing
le is loaded, its source code has long since been compiled into code objects. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of US

Re: [Python-Dev] defmacro (was: Anonymous blocks)

2005-04-26 Thread Greg Ewing
le, when you write while expr: ... it gets turned into expr.__while__(thunk) etc. No, I'm not really serious about this -- it was just a wild thought! -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZeal

Re: [Python-Dev] Re: anonymous blocks

2005-04-26 Thread Greg Ewing
statement, for example. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | [EMAIL

Re: [Python-Dev] Re: anonymous blocks vs scope-collapse

2005-04-26 Thread Greg Ewing
l the necessary information about both scopes available. Although it might be better to have some sort of "outer" declaration for rebinding in the enclosing scope, instead of doing it on a whole-function basis. -- Greg Ewing, Computer Science Dept, +--+

Re: [Python-Dev] Re: Caching objects in memory

2005-04-26 Thread Greg Ewing
uido was saying that it's important for them to know that mutable objects are never in danger of being shared, so you should at least tell them that much. Otherwise they may end up worrying unnecessarily that two of their lists might get shared somehow behind their back. -- Greg Ewi

Re: [Python-Dev] site enhancements (request for review)

2005-04-26 Thread Greg Ewing
on Windows running under Virtual PC mounting the source directory from the host system as a file share, and it turns out that reading a unix symlink from the Windows end just returns the contents of the link. Aaarrghh! Braindamage! -- Greg Ewing, Computer Science Dept, +--

Re: [Python-Dev] Re: anonymous blocks

2005-04-27 Thread Greg Ewing
hink Guido was right in the first place, and __error__ really is just a minor variation on __next__ that shouldn't have a separate entry point. Greg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/pyth

Re: [Python-Dev] Re: anonymous blocks

2005-04-27 Thread Greg Ewing
lanation can't be found, I strongly suspect that this doesn't correspond to a cohesive enough concept to be made into a built-in language feature. If you can't give a short, understandable explanation of it, then it's probably a bad idea. Greg ___

[Python-Dev] Anonymous blocks: Thunks or iterators?

2005-04-28 Thread Greg Ewing
oogle and got "PEP 340: Prevention and Care of Athletic Injuries"!] Greg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] Anonymous blocks: Thunks or iterators?

2005-04-28 Thread Greg Ewing
. Cells slow down access somewhat compared to regular local variables. True, but is the difference all that great? It's just one more C-level indirection, isn't it? we'll want variables *assigned to* by the thunk also to be shared with the containing function, Agreed. We'd

Re: [Python-Dev] Integrating PEP 310 with PEP 340

2005-04-28 Thread Greg Ewing
Nick Coghlan wrote: With an appropriate utility block manager I've just thought of another potential name for them: Block Utilization and Management Function (BUMF) :-) -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citiz

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-28 Thread Greg Ewing
Neil Schemenauer wrote: A variation on this with somewhat different semantics swaps the keywords: in EXPR for VAR: BLOCK Looks weird to my eyes. Probably makes perfect sense if you're Dutch, though. :-) -- Greg Ewing, Computer Science

Re: [Python-Dev] Re: anonymous blocks

2005-04-28 Thread Greg Ewing
xplain the meanings of those particular uses, and leave the full general explanation as an advanced topic. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wh

Re: [Python-Dev] Re: anonymous blocks

2005-04-28 Thread Greg Ewing
e of a for-loop. This is going to give people the wrong idea altogether. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA

Re: [Python-Dev] Re: anonymous blocks

2005-04-28 Thread Greg Ewing
tement. struct opening(foo) as f: ... Then we could confuse both C *and* Ruby programmers at the same time! :-) [No, I don't really mean this. I actually prefer "block" to this.] -- Greg Ewing, Computer Science Dept, +--+ Universit

Re: [Python-Dev] PEP 340: Else clause for block statements

2005-05-01 Thread Greg Ewing
7; (i.e. it is not > terminated early due to an exception, a break statement or a return > statement) I've always thought that was a particularly unintuitive use of the word 'else', and I'm not sure I'd like it to be extende

Re: [Python-Dev] 2 words keyword for block

2005-05-03 Thread Greg Ewing
to get lots of finger exercise typing redundant keywords, I'd program in COBOL. :-) -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned s

Re: [Python-Dev] PEP 340 -- loose ends

2005-05-04 Thread Greg Ewing
y! class Frobbing: def __neg__(self): begin_frobbing() try: yield finally: end_frobbing() frobbing = Frobbing() ... -frobbing: do_something() -- Greg Ewing, Computer Science Dept, +--+ University o

Re: [Python-Dev] PEP 340: Only for try/finally?

2005-05-04 Thread Greg Ewing
y out there which take function arguments could *already* be used with a thunk-based block statement, without needing to be re-written at all. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | C

[Python-Dev] PEP 340 -- Clayton's keyword?

2005-05-04 Thread Greg Ewing
g these user-defined statements look even more like the native ones. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand |

Re: [Python-Dev] PEP 340: Breaking out.

2005-05-05 Thread Greg Ewing
rator propagates the Break exception back out, the block statement should break any enclosing loop. If the iterator wants to behave like a loop, it can catch the Break exception and raise StopIteration instead. -- Greg Ewing, Computer Science Dept, +--+ Universi

Re: [Python-Dev] PEP 340: propose to get rid of 'as' keyword

2005-05-05 Thread Greg Ewing
y extends as far as it *doesn't* require anything beyond existing syntax and semantics. If new syntax and tricky new interactions with iterators are needed to support it, it doesn't seem so elegant any more. -- Greg Ewing, Computer Science Dept, +--+ U

Re: [Python-Dev] PEP 340 - Remaining issues - keyword

2005-05-05 Thread Greg Ewing
Nick Coghlan wrote: > Something relatively nonsensical, but usefully mnemonic > (like 'stmt') may be a good way to go. How about 'do'? do opening(filename) as f: ... do locking(obj): ... do carefully(): # :-) ... -- Greg Ew

Re: [Python-Dev] PEP 340: Breaking out.

2005-05-05 Thread Greg Ewing
gt; trying to understand the source code, having break depend > on something defined somewhere completely else seems like > an obstacle to easy understanding. IMHO, of course. > > //Simon > -- Greg Ewing, Computer Science Dept, +--+

Re: [Python-Dev] PEP 340: Breaking out.

2005-05-05 Thread Greg Ewing
o *not* retain existing PEP 340 semantics if uncaught, i.e. break an enclosing loop rather than just terminate the block statement. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurc

Re: [Python-Dev] Pre-PEP: Unifying try-except and try-finally

2005-05-05 Thread Greg Ewing
some people might find it useful for indenting a block of code for cosmetic reasons, although that could easily be seen as an abuse... -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christ

[Python-Dev] PEP 340 - For loop cleanup, and feature separation

2005-05-05 Thread Greg Ewing
give you block iterators implemented by generators. This makes a lot more sense to me than trying to warp the iterator protocol to make it into a block protocol as well. Let's keep the two things orthogonal. -- Greg Ewing, Computer Science Dept, +--+ Univ

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-08 Thread Greg Ewing
an __exit__ method. But if the for-loop can tell whether the iterator needs finalizing or not, why not have it finalize the ones that need it and not finalize the ones that don't? That would be backwards compatible, since old for-loops working on old

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Greg Ewing
know or care whether it requires finalization -- it should Just Work, whatever context it is used in. Greg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Greg Ewing
particular screw, and this isn't a problem. But I don't have a big crowd of people looking over my shoulder while I work, all trying to figure out why I chose one particular screwdriver over another, and decide which would be the best screwdriver to use on

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Greg Ewing
If implemented properly, it could be as simple as testing whether a slot of a type object is populated during processing of the bytecode which causes exit from the loop. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of New

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Greg Ewing
the right statement. For backwards compatibility, the existing for-loop would work for partial iteration of old iterators, but this usage would be deprecated. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Greg Ewing
d" idiom. I'm inclined to agree. Anything more elaborate than breaking from a single place in the immediately enclosing loop tends to be getting into the realm of spaghetti, in my experience. Giving people named loops would be tantamount almost to giving them a go

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Greg Ewing
he's not wrong, and due to the way things are coded, the reference happens to hang around a little longer than strictly needed. If garbage collection were sufficient, we'd be relying on it to close our files in the first place, and this whole thread would never have gotten sta

Re: [Python-Dev] Merging PEP 310 and PEP 340-redux?

2005-05-10 Thread Greg Ewing
Guido van Rossum wrote: > Now it would make more sense to change the syntax to > > with EXPR as VAR: > BLOCK > > and we have Phillip Eby's proposal. Change the 'with' to 'do' and I'd be +1

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-10 Thread Greg Ewing
ecorator What about giving them an __exit__ method if and only if they have a yield inside a try/finally? Old generators won't be doing that, because it's currently illegal. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury,

Re: [Python-Dev] the current behavior of try: ... finally:

2005-05-12 Thread Greg Ewing
n this case? Or do you think return (and break and continue) should be disallowed in a finally? -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | whol

Re: [Python-Dev] Tidier Exceptions

2005-05-12 Thread Greg Ewing
are in some very old library modules. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc

Re: [Python-Dev] Tidier Exceptions

2005-05-12 Thread Greg Ewing
; attribute set to > None if not a chained exception). Instead of an 'args' attribute, I'd suggest that the constructor take keyword arguments and store them in corresponding attributes. Then interested parties could retrieve them by name instead of having to remember their positio

Re: [Python-Dev] Merging PEP 310 and PEP 340-redux?

2005-05-12 Thread Greg Ewing
Guido van Rossum wrote: > - Greg Ewing (I believe) wants 'do' instead of 'with' for the > keyword. I think I like 'with' better, especially combining it with > Benji's proposal. IMO this reads better with 'with' than with 'do':

Re: [Python-Dev] Merging PEP 310 and PEP 340-redux?

2005-05-12 Thread Greg Ewing
line) To anyone with a Lisp or funcional background, that looks like nothing more than a local variable binding. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand

Re: [Python-Dev] Merging PEP 310 and PEP 340-redux?

2005-05-13 Thread Greg Ewing
ing to do with whether a generator is used or not. Keeping them separate seems to be a useful thing in its own right. Greg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.or

Re: [Python-Dev] Merging PEP 310 and PEP 340-redux?

2005-05-13 Thread Greg Ewing
lso I don't see that people will be writing block controllers anywhere near as often as iterators, so writing classes for them isn't going to be a big chore. And people can always use a do-protocol-to-generator adaptor if they really want. Greg _

Re: [Python-Dev] PEP 343 - Abstract Block Redux

2005-05-15 Thread Greg Ewing
u want to do 'with' it, e.g. you have a pathname and you want to open a file. I've already argued against giving file objects __enter__ and __exit__ methods. And I'm -42 on giving them to strings. :-) -- Greg Ewing, Computer Science Dept, +--+

Re: [Python-Dev] PEP 343 - Abstract Block Redux

2005-05-15 Thread Greg Ewing
Guido van Rossum wrote: >>Also, one question: will the "do protocol" be added to built-in "resource" >>types? That is, locks, files, sockets, and so on? > > One person proposed that and it was shot down by Greg Ewing. I think > it's better to requ

Re: [Python-Dev] PEP 343 - Abstract Block Redux

2005-05-15 Thread Greg Ewing
ety of possible errors. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA In

Re: [Python-Dev] PEP 343 - Abstract Block Redux

2005-05-15 Thread Greg Ewing
method *does* return a canvas, with __enter__ and __exit__ methods, and the rule that you have to use the appropriate protocol before you can use it. This would avoid most of the aforementioned problems. So I think I may have just talked myself out of

Re: [Python-Dev] PEP 343 - Abstract Block Redux

2005-05-15 Thread Greg Ewing
e > existing "open" builtin would suffice: > >with open(filename, "rb") as f: >for line in f: >print line I think I'm starting to agree. Currently about +0.6 in favour of 'with' now, especially if this is to be almost

Re: [Python-Dev] PEP 343 - Abstract Block Redux

2005-05-15 Thread Greg Ewing
lity constraints. E.g. it seems we can't make for-loops work the way they should in the face of generator finalisation or we break old code. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a

Re: [Python-Dev] PEP 343 - Abstract Block Redux

2005-05-15 Thread Greg Ewing
blem, the difference would be even smaller. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned

Re: [Python-Dev] PEP 343 - Abstract Block Redux

2005-05-16 Thread Greg Ewing
kwards-compatible change. Greg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] Tidier Exceptions

2005-05-16 Thread Greg Ewing
Aahz wrote: > On Fri, May 13, 2005, Greg Ewing wrote: > >>Instead of an 'args' attribute, I'd suggest that the constructor take >>keyword arguments and store them in corresponding attributes. > > Sounds reasonable, but it should be equally easy to ha

Re: [Python-Dev] PEP 343 - Abstract Block Redux

2005-05-16 Thread Greg Ewing
t an exception if you try to re-use one. I still think it's conceptually cleaner if the object you use to access the resource is created by the __enter__ method rather than being something pre- existing, but I'm willing to concede that PBP here. -- Greg Ewing, Computer Science Dept, +--

<    15   16   17   18   19   20   21   22   23   24   >