This PEP, previously known asPEP 3000, describes smaller scale changesand new features for which no separate PEP is written yet, all targetedfor Python 3000.
The list of features included in this document is subject to changeand isn’t binding on the Python development community; features may beadded, removed, and modified at any time. The purpose of this list isto focus our language development effort on changes that are steps to3.0, and to encourage people to invent ways to smooth the transition.
This document is not a wish-list that anyone can extend. While thereare two authors of this PEP, we’re just supplying the text; thedecisions for which changes are listed in this document are made byGuido van Rossum, who has chosen them as goals for Python 3.0.
Guido’s pronouncements on things that will not change in Python 3.0are recorded inPEP 3099.
A general goal is to reduce feature duplication by removing old waysof doing things. A general principle of the design will be that oneobvious way of doing something is enough.[1]
exec as a statement is not worth it – make it a function [done]print by a function[14]PEP 3105 [done]softspace attribute of files goes away. [done]exceptE1,E2,E3aserr: if you want the error variable.[3] [done]None becomes a keyword[4]; alsoTrue andFalse [done]... to become a general expression element[16] [done]as becomes a keyword[5] (starting in 2.6 already) [done]list(); as a consequence theloop variable will no longer be exposedPEP 289 [done]== and!= between disparate typeswill raise an exception unless explicitly supported by the type[6] [done]sys.modules (i.e., a value ofNone forA.string means to use the top-levelstring module) will not besupported.func_whatever will be renamed__whatever__[17] [done]__nonzero__ special method will be renamed to__bool__and have to return a bool. The typeobject slot will be calledtp_bool[23] [done]To be removed:
raiseException,"message": useraiseException("message")[12][done]x: userepr(x)[2] [done]<> operator: use!= instead[3] [done]__oct__,__hex__: use__index__ inoct() andhex()instead. [done]__methods__ and__members__ [done]PyImport_ReloadModule ?
dict.keys(),dict.values(),dict.items(), etc.); iter* methods will be removed. [done]string.join() stringify its arguments?[18] [NO]To be removed:
basestring.find() andbasestring.rfind(); usebasestring.index()orbasestring.[r]partition() orbasestring.rindex() in a try/except block???[13] [UNLIKELY]file.xreadlines() method[31] [done]dict.setdefault()?[15] [UNLIKELY]dict.has_key() method; usein operator [done]list.sort() andbuiltin.sorted() methods: eliminatecmpparameter[27] [done]range(),zip(),map(),filter(), etc.) [done]input() and renameraw_input() toinput().If you need the old input(), use eval(input()). [done]trunc(), which would call the__trunc__() method on itsargument; suggested use is for objects like float where calling__int__()has data loss, but an integral representation is still desired?[8] [done]bin() function for a binary representation of integers [done]To be removed:
apply(): usef(*args,**kw) instead[2] [done]buffer(): must die (use a bytes() type instead) (?)[2] [done]callable(): just use isinstance(x, collections.Callable) (?)[2] [done]compile(): put insys (or perhaps in a module of its own)[2]coerce(): no longer needed[2] [done]execfile(),reload(): useexec()[2] [done]intern(): put insys[2],[22] [done]reduce(): put infunctools, a loop is more readable most of thetimes[2],[9] [done]xrange(): userange() instead[1] [See range() above] [done]StandardError: this is a relic from the original exception hierarchy;Exception instead. [done]To be removed:
macfs [to do]new,reconvert,stringold,xmllib,pcre,pypcre,strop [all done]buildtools,mimetools,multifile,rfc822,[to do]mpz,posixfile,regsub,rgbimage,sha,statcache,sv,TERMIOS,timing [done]cfmfile,gopherlib,md5,MimeWriter,mimify [done]cl,sets,xreadlines,rotor,whrandom [done]Para,addpack,cmp,cmpcache,codehack,dircmp,dump,find,fmt,grep,lockfile,newdir,ni,packmail,poly,rand,statcache,tb,tzparse,util,whatsound,whrandom,zmodsys.exitfunc: use atexit module instead[28],[35] [done]sys.exc_type,sys.exc_values,sys.exc_traceback:not thread-safe; usesys.exc_info() or an attributeof the exception[2][11][28] [done]sys.exc_clear: Python 3’s except statements provide the samefunctionality[24]PEP 3110[28] [done]array.read,array.write[30]operator.isCallable :callable() built-in is being removed[29][36] [done]operator.sequenceIncludes : redundant thanks tooperator.contains[29][36] [done]This document has been placed in the public domain.
Source:https://github.com/python/peps/blob/main/peps/pep-3100.rst
Last modified:2025-02-01 08:55:40 GMT