[Python-3000] A couple of PEP 3101 related questions

Nick Coghlan ncoghlan at gmail.com
Thu Dec 21 10:09:43 CET 2006


Talin wrote:
> 1) What's the process for editing a PEP after it has been reviewed, but 
> before its been accepted?
> 
> I've recently had some requests to make some edits to the PEP. However, 
> I don't want to do these in "stealth mode", like a congressional staffer 
> who inserts changes into a bill right before it's voted on.

A message to the relevant mailing list giving the gist of the changes that 
were made should be enough notification (and don't forget that anyone that 
wants the exact diff can always look it up on svn.python.org).

> 2) What's a good way to prototype a change to a built-in class? Is there 
> a way that you can write a function in Python, and add it as a method to 
> a built-in class?
> 
> Specifically, what I'd like to be able to do is to add a method to the 
> standard string class, and this should affect all strings, even ones 
> created via literal quotes.

As Brett suggested, you can add a method to the builtin class that imports the 
relevant Python module and then calls the function you want to use. You still 
need to write some C code, but not much of it.

main.c uses this trick to bootstrap itself into runpy.run_module() when 
someone uses the '-m' switch, so that should provide a decent model for your 
interim string method implementation.

> Specifically what I'm aiming for is to be able to write unit tests for 
> 3101 without needing to have the C code already in place. That way, 
> whoever volunteers to do the C code can have the unit tests already 
> working before they begin.

Sounds like a good plan.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-3000 mailing list