'new' module deprecation in python2.6

David Pratt fairwinds.dp at gmail.com
Sat Nov 29 18:36:21 CET 2008


Hi Mike. Many thanks for your reply and thank you for reference.  I  
have code that looks like the following so initially looking at what  
will need to be done as it doesn't appear new will survive. So first  
need to find way of translating this sort of thing using types. I see  
there is a ClassType for types in Python 2.6 but it does not exist in  
Python 3 so wonder where this is going? Is this an oversight or maybe  
just not ready yet.

import new

class FirstBase(object):
     foo = 'bar'
     biz = 'baz'

class SecondBase(object):
     bla = 'blu'
     buz = 'brr'

attr = {
     'fiz': 'An attribute', 'fuz': 'Another one'}

Test = new.classobj(
     'Test', (FirstBase, SecondBase), attr)

class MyNewClass(Test):
     pass

a = MyNewClass()

print a.foo, a.buz, a.fiz, type(a)





On Nov 29, 2008, at 1:04 PM, Michael Crute wrote:

> On Sat, Nov 29, 2008 at 11:52 AM, David Pratt  
> <fairwinds.dp at gmail.com> wrote:
>> Can someone tell me why 'new' has been deprecated in python 2.6  
>> and provide
>> direction for code that uses new for the future.
>> I find new is invaluable for some forms of automation. I don't see a
>> replacement for python 3 either. Many thanks.
>
> You might want to take a look at PEP 3108[1] which says:
>
> new
>
>     * Just a rebinding of names from the 'types' module.
>     * Can also call type built-in to get most types easily.
>     * Docstring states the module is no longer useful as of revision
> 27241 (2002-06-15).
>
> [1] http://www.python.org/dev/peps/pep-3108/
>
> -mike
>
>
> -- 
> ________________________________
> Michael E. Crute
> http://mike.crute.org
>
> God put me on this earth to accomplish a certain number of things.
> Right now I am so far behind that I will never die. --Bill Watterson




More information about the Python-list mailing list