))
if set:
self[key] = default
return default
Using Guido's original example:
d.get(key, [], True).append(value)
I don't really think this is a replacement for defaultdict, though.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
Fredrik Lundh wrote:
Nick Coghlan wrote:
Using Guido's original example:
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 ;)
I think
, but requires building the
list of keys).
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
. whether or not default_factory has been set
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing
that this is a moot point. But perhaps I can help to
winnow down the dozens of rejected lambda replacement proposals to just
a few rejected lamda proposals :)
Heh.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
blame Tim's recent checkins for test_logging subsequently
breaking on Solaris though ;)
There still seems to be something a bit temperamental in that test. . .
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
Greg Ewing wrote:
Nick Coghlan wrote:
I wouldn't mind seeing one of the early ideas from PEP 340 being
resurrected some day, such that the signature for the special method
was __next__(self, input) and for the builtin next(iterator,
input=None)
Aren't we getting an argument to next
the way, that should probably be explained in
the PEP somewhere :)
Cheers,
Nick
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
changed it again.
Heh :)
Plus the SVN history and the mailing list archive already provide that record.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
it so that there is a single
method pair (bytes.decode to go from bytes to characters, and text.encode to
go from characters to bytes).
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http
!
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev@python.org
http
@contextmanager.
The solution you propose means that __exit__ methods *can* suppress exceptions
if they want to, but their default behaviour will still do the right thing.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
problem is a nail to be hit with the shiny new hammer ;)
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
abruptly exit.
It also nicely aligns with the way that license() and help() already work at
the interactive prompt.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http
of Python functions - maybe the module should be called
metafunctions or functools to reflect its application domain, rather than
the coincidental fact that its first member happens to be a decorator.
Regards,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
Nick Coghlan wrote:
Georg Brandl wrote:
Hi,
to underlay my proposals with facts, I've written a simple decorator
module containing at the moment only the decorator decorator.
Sorry, I forgot the initial comment which was meant to be Thanks for moving
this proposal forward :)
It's currently
).
Regards,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev@python.org
http
, compiling the actual
subscript operation :)
Bug here: http://www.python.org/sf/1448804
(assigned to myself, since I already wrote a test for it and worked out where
to fix it)
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
Travis E. Oliphant wrote:
Nick Coghlan wrote:
And how...
case Ellipsis_kind:
ADDOP_O(c, LOAD_CONST, Py_Ellipsis, consts)
break;
Just a couple of minor details missing, like, oh, compiling the actual
subscript operation :)
Bug here: http://www.python.org/sf/1448804
Nick Coghlan wrote:
Unfortunately my new test case breaks test_compiler. I didn't notice because
I
didn't use -uall before checking it in :(
If no-one else gets to it, I'll try to sort it out tonight.
OK, as of rev 43025 the compiler module also understands augmented assignment
to tuple
from the latest
SVN version)
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev
Nick Coghlan wrote:
Following Guido's acceptance of the PEP in SVN, PEP 338 has now been checked
in for 2.5. (PEP's 0, 338 and 356 have been updated to reflect this).
And thanks to buildbot, the test code that was broken on Windows has been
fixed, too.
Cheers,
Nick.
--
Nick Coghlan
this a long while back, but I have
no idea what I ended up doing with the code (I think it died along with the
old hard drive in my laptop).
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
*Python*
interface.
Regards,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev
:
PyRun_SimpleString.
Is this bug still present in current python or the 2.4 line ?
I found nothing about it.
Confirmed on SVN trunk.
I don't know enough about the tokenizer to determine if the proposed fix is
the best solution, though.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED
^
SyntaxError: invalid syntax
There's an easy workaround (adding the missing newline), but I think there's
definitely something going wrong in the tokenizer.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
are updated.
If I don't hear any objections, I'll switch SVN (along with PEP 338 and the
docs patch) to the new (non-thread-safe) semantics sometime this weekend.
Regards,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
the clause on the end
(with or without mandatory parentheses) but figured I'd throw this idea out as
an option. I'm not sure whether the parallel with print and print
stream, is a positive or a negative, though. . .
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
the whole lot, then even if the standard library used a common
bulk data format in 2.6, extension modules probably wouldn't be using it until
2.7.
Of course, there's a whole 'nother question of where Jython, IronPython and
PyPy would fit into this. . .
Regards,
Nick.
--
Nick Coghlan | [EMAIL
work on Windows. The combination of -uall and rerunning with -v when a test
fails is really quite effective.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http
show at 0x00AE9B30
Using:function wrapped at 0x00AE9CF0
Annotated?: True
function show at 0x00AE9B30
Decorates:function show at 0x00AE99F0
Using:function wrapped at 0x00AE9CF0
Annotated?: False
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane
. Isn't that
exactly the idiom we're trying to get rid of for SystemExit and
KeyboardInterrupt?
Regards,
Nick.
[1] http://mail.python.org/pipermail/python-dev/2005-August/055173.html
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
iterator has completed, not that the entire stack
of iterators should be shut down.
Regards,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
, and TerminatingException if it isn't.
Regards,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing
isn't worth it.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev
*not* apply to StopIteration - that should stay
under Exception because it should never accidentally leak beyond the code that
is calling the next() method.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
details of what's happening on the p3yk branch.
Regards,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev
.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev@python.org
http
.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org
that philosophy be extended to slicing operations, though?
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev
as a
multi-dimensional array.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev
Guido van Rossum wrote:
On 3/25/06, Nick Coghlan [EMAIL PROTECTED] wrote:
The kind of code I'm talking about would be an *existing* Python 2.4
generator
that happens to do something like:
def gen(tasks):
yield the results of a bunch of task functions
for task in tasks
to
functools.partial, and add a functools.decorator function.
The idea of the latter being that sticking @decorator on the front would be
enough to make a decorator function well-behaved (and future-proof).
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev@python.org
http
Nick Coghlan wrote:
a message to the wrong list
Darn, I'd hoped I'd caught that in time :(
Sorry folks.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http
main function from
within the current program) seems like a recipe for disaster - far better to
use the subprocess module instead (since, strangely enough, application
initialisation code has this tendency to assume it has sole control of the
interpreter).
Cheers,
Nick.
--
Nick Coghlan
memory leaks in real applications.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
, anyway ;)
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev@python.org
():
... print Hi world from %s! % f
...
Py f()
Hi world from function f at 0x00AE90B0!
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
Jim Jewett wrote:
Nick Coghlan wrote:
[ much good, including the @instance decorator ]
P.S. If all you want is somewhere to store mutable
state between invocations, you can always use the
function's own attribute space
def f(): print Hi world from %s! % f
f()
Hi
Greg Ewing wrote:
Nick Coghlan wrote:
Generators are even more special, in that they only require finalisation in
the first place if they're stopped on a yield statement inside a try-finally
block.
I find it rather worrying that there could be a
few rare cases in which my generators
with an enhanced version of PEP 292 style string formatting rather
than the existing mod-style formatting.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
.
But now all *clients* of the Calendar class are forced to deal with the fact
that firstweekday may not be greater than seven.
If you want to accept any input value, why not use a property to force it to
be modulo 7, rather than doing an actual range check?
Cheers,
Nick.
--
Nick Coghlan
that eliminate the current cycle problem?
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev
help.
Status was 1. With -x bad.* it's zero, so it looks like that's the issue.
FWIW, this breaks for me too and the output of:
C:\Python25\python.exe -Wi -m compileall -f C:\Python25\Lib
includes the expected SyntaxErrors from the bad_coding and badsyntax test
modules.
Cheers,
Nick.
--
Nick
the parser, the AST
definition, the AST compiler and the bytecode compiler in order to get the
info to the eval loop.
Given that import statements aren't supposed to be in time critical code, go
for the easy option :)
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
Phillip J. Eby wrote:
At 07:43 AM 4/12/2006 +1000, Nick Coghlan wrote:
Phillip J. Eby wrote:
I propose to create a new API, 'imp.find_loader()' and have it
return a PEP
302-compatible loader object, even for cases that would normally be
handled
via 'imp.load_module()'. In such cases
Phillip J. Eby wrote:
At 08:39 PM 4/12/2006 +1000, Nick Coghlan wrote:
In this particular case, it would be a Python module imp.py that
included the line from _imp import * (where _imp is the current
C-only module with a different name).
I don't think that's going to work, since importing
exception
name, naturally).
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
I wanted that was rather
esoteric and easy enough to deal with by using a custom result checker.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
believe it
will, but I'm not sure).
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
without an appropriate icon for pythonw (the Windows .exe to
start Python GUI applications without displaying a console window). The plain
Plus-Python icon would work in both cases (the normal python executable and
the pythonw variant).
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED
for recommending that context managers should be contexts is
similar to the reason that iterators should be iterables - so that doing the
__context__() call manually will still give you something that can be used in
a with statement.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane
Nick Coghlan wrote:
The second occurrence of context manager is meant to say context:
This PEP proposes that the protocol used by the with statement be
known as the context management protocol, and that objects that
implement that protocol be known as context managers
A.M. Kuchling wrote:
On Wed, Apr 19, 2006 at 11:10:55PM +1000, Nick Coghlan wrote:
When Phillip went through to make the terminology consistent he actually
swapped the meanings of context (which meant 'has a __context__ method'
in the original PEP) and context manager (which meant 'has
Phillip J. Eby wrote:
At 11:41 PM 4/19/2006 +1000, Nick Coghlan wrote:
Given that naming though, I think contextlib.contextmanager should be
renamed
to contextlib.context.
The name is actually correct under this terminology arrangement.
@contextmanager *returns* a context manager
. Having
remembered why we picked context manager over context in the first place,
my preference is strongly for reverting to the original terminology.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
With the -m switch switching to using the runpy module in 2.5, the two private
helper functions exposed by import.c (_PyImport_FindModule
_PyImport_IsScript) aren't needed anymore.
Should I remove them, since they're essentially dead code now?
Cheers,
Nick.
--
Nick Coghlan | [EMAIL
Greg Ewing wrote:
Nick Coghlan wrote:
During implementation, the meanings of context and context manager were
swapped from the meanings in the approved PEP, leading to the current
situation where decimal.Context is actually not, in fact, a context.
That's rather disappointing. I *liked
Phillip J. Eby wrote:
At 10:51 AM 4/21/2006 -0400, A.M. Kuchling wrote:
On Fri, Apr 21, 2006 at 07:31:35PM +1000, Nick Coghlan wrote:
fit the new definition. So we settled on calling them context managers
instead.
...
method. Instead, the new term manageable context (or simply context
. The old name makes even more
sense if Phillip's heuristic scan gets added :)
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
in the
announcement. . .
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev@python.org
http
of the Thread) :)
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev
/k5spk ?
That's beautiful. It even matches the PEP [1] :)
Cheers,
Nick.
[1] http://tinyurl.com/pc5uq
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
Paul Moore wrote:
On 4/22/06, Nick Coghlan [EMAIL PROTECTED] wrote:
Alternatively, I could have a go at clearing it up for next week's alpha2,
and
we can ask Anthony to make an explicit request for review of those docs in
the
announcement. . .
I've just had a *very* quick scan through
Paul Moore wrote:
Presumably, then, my proposal didn't make things clear to you?
As Phillip said, I'm probably way too close to this to be a good judge of how
understandable the terminology is. I just want to make one more attempt before
admitting defeat. . .
Cheers,
Nick.
--
Nick Coghlan
the equivalent of alien (rpm - dpkg
converter), so that given an egg, one can easily get a native installer for
that egg.
Regards,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http
' is potentially confusing, and
I didn't clearly acknowledge the distinction myself until the recent
discussion. Not acknowledging that distinction appears to have been largely
responsible for my manifest failure to document this properly in the PEP. . .
Cheers,
Nick.
--
Nick Coghlan | [EMAIL
Anthony Baxter wrote:
On Sunday 23 April 2006 11:43, Nick Coghlan wrote:
Maybe we need something that's the equivalent of alien (rpm - dpkg
converter), so that given an egg, one can easily get a native
installer for that egg.
An 'eggconvert' that used the existing bdist_foo machinery
in the
release announcement asking folks to go over the relevant documentation so we
have some feedback to work with on whether the updated documentation makes
sense or not.
Regards,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
terminology post-alpha
2.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python
Paul Moore wrote:
On 4/23/06, Nick Coghlan [EMAIL PROTECTED] wrote:
For those not following along at home, I've now updated PEP 343 to clarify my
originally intended meanings for various terms, and to record the fact that
we
don't currently have a consensus on python-dev that those
Nick Coghlan wrote:
For those not following along at home, I've now updated PEP 343 to clarify my
originally intended meanings for various terms, and to record the fact that
we
don't currently have a consensus on python-dev that those are the right
definitions.
As written up in the PEP
to be something other than context object in order to reduce the
current ambiguity.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
):
The actual changes made to the runtime state by the context manager
based on the current state of the context specifier
This removes the ambiguity between context object and runtime context.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
between them, but other cases put
the asynchronous operation inside a loop or a conditional statement which
means that particular trick won't work).
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org
Martin v. Löwis wrote:
Nick Coghlan wrote:
Do we want to add a released context manager to the threading module for
2.5?
I don't think that should be added. I would consider it a dangerous
programming style: if the lock merely doesn't need to be held (i.e.
if it isn't necessary
actually know whether the buildbot
is reporting a real problem or not.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
was context managers rather
than context specifiers).
The changes I made this weekend are designed to give everything its own name,
leaving context free to refer to either the runtime context or a context
specifier or whatever else makes sense in context.
Cheers,
Nick.
--
Nick Coghlan
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman
necessary, but then neither was it necessary to make the iterator
protocol a superset of the iterable protocol.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
- that was a
deliberate design decision taken at the time iterators were introduced. I
merely copied that pre-existing approach for PEP 343.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http
Phillip J. Eby wrote:
At 12:24 PM 4/24/2006 -0700, Aahz wrote:
On Mon, Apr 24, 2006, Phillip J. Eby wrote:
At 04:48 AM 4/25/2006 +1000, Nick Coghlan wrote:
Using two names to describe three different things isn't intuitive for
anybody.
Um, what three things? I only count two:
1. Objects
() method.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev@python.org
, the fact that it's in contextlib provides ample indication that
it's talking about with statement contexts.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
Phillip J. Eby wrote:
At 12:08 AM 4/26/2006 +1000, Nick Coghlan wrote:
Secondly, the documentation now shows an example
of a class with a close() method using contextlib.closing directly as
its own
__context__() method.
Sadly, that would only work if closing() were a function. Classes
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
in for different areas.
I know I'm pretty reluctant to commit anything not directly related to the AST
compiler, PEP 338 or PEP 343.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http
.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman
401 - 500 of 6273 matches
Mail list logo