Python Microproject 1
Python Microproject 1
Python Programming
Sub-code : 4311601
Micro project
Name of student : Patel Meet J.
Branch : IT
Division : 11
Temp-Id : IT-22-019
Enrollment Number : 226400316131
Topic : List out new features of python 3.9 version and compare with older two
different versions.
When Python 2.7 was still supported, a lot of functionality in Python 3 was kept for backward
compatibility with Python 2.7. With the end of Python 2 support, these backward compatibility
layers have been removed, or will be removed soon. Most of them emitted a deprecation
writing warning for several years. For example, using collections mapping instead of
collection.abc.mapping emits a deprecation writing since Python 3.3, released in 2012.
Test your application with the -w default command-line option to see deprecation writing and
pending deprecation Waring or even with -w error to treat them as errors. Warnings Filter can
be used to ignore warnings from third-party code.
Python 3.9 is the last version providing those Python 2 backward compatibility layers, to give
more time to Python projects maintainers to organize the removal of the Python 2 support and
add support for Python 3.9.
Aliases to Abstract Base Classes in the collection module, like collections mapping alias to
collections, are kept for one last release for backward compatibility. They will be removed
from Python 3.10.
More generally, try to run your tests in the Python Development Mode which helps to prepare
your code to make it compatible with the next Python version.
Note: a number of pre-existing deprecations were removed in this version of Python as well.
Consult the Removed section.
New Parser
Python 3.9 uses a new parser, based on PEG instead of LL(1). The new parser’s performance
is roughly comparable to that of the old parser, but the PEG formalism is more flexible than
LL(1) when it comes to designing new language features. We’ll start using this flexibility in
Python 3.10 and later.
The ast module uses the new parser and produces the same AST as the old parser.
In Python 3.10, the old parser will be deleted and so will all functionality that depends on it
(primarily the parser module, which has long been deprecated). In Python 3.9 only, you can
switch back to the LL(1) parser using a command line switch (-x old parser) or an
environment variable (PYTHONOLDPARSER=1).
See PEP 617 for more details. (Contributed by Guido van Rossum, Pablo Galindo and
Lysandros Nikolaou in bpo-40334.)
New Modules
zoneinfo
The zininfo module brings support for the IANA time zone database to the standard library. It
adds zoneinfo.zoneinfo, a concrete datetime.tzinfo implementation backed by the system’s
time zone data.
Example:
See also
PEP 615-Support for the IANA Time Zone Database in the Standard Library
PEP written and implemented by Paul Ganssle
Improved modules
• pathlib
Added pathlib.Path.readlink() which acts similarly to os.readlink(). (Contributed by Girts Folkmanis
in bpo-30618)
• pdb
On Windows now Pdb supports ~/.pdbrc. (Contributed by Tim Hopper and Dan Lidral-Porter in bpo-
20523.)
• poplib
POP3 and POP3_SSL now raise a ValueError if the given timeout for their constructor is zero to
prevent the creation of a non-blocking socket. (Contributed by Dong-hee Na in bpo-39259.)
• print
pprint can now pretty-print types.SimpleNamespace. (Contributed by Carl Bordum Hansen in bpo-
37376.)
• pydoc
The documentation string is now shown not only for class, function, method etc, but for any object that
has its own __doc__ attribute. (Contributed by Serhiy Storchaka in bpo-40257.)
• random
Added a new random.Random.randbytes method: generate random bytes. (Contributed by Victor
Stinner in bpo-40286.)
• signal
Exposed the Linux-specific signal.pidfd_send_signal() for sending to signals to a process using a file
descriptor instead of a pid. (bpo-38712)
• smtplib
SMTP and SMTP_SSL now raise a ValueError if the given timeout for their constructor is zero to
prevent the creation of a non-blocking socket. (Contributed by Dong-hee Na in bpo-39259.)
LMTP constructor now has an optional timeout parameter. (Contributed by Dong-hee Na in bpo-39329.
Python 3.9
Support for the IANA Time Zone Database
Python 3.9 supports and has added a module named zoneinfo that lets you access and use the entire
Internet Assigned Numbers Authority (IANA) time zone database. By default, zoneinfo will use the
system’s time zone data if available.
Sample Code :
>>> print(datetime(2021, 7, 2, 12, 0).astimezone())
2020-07-2 12:00:00-05:00
>>> print(datetime(2021, 7, 2, 12, 0).astimezone()
... .strftime("%Y-%m-%d %H:%M:%S %Z"))
2020-07-2 12:00:00 EST
>>> print(datetime(2021, 7, 2, 12, 0).astimezone(timezone.utc))
2020-07-2 17:00:00+00:00
Removed
The erroneous version at unittest.mock.__version__ has been removed.
nntplib.NNTP: xpath() and xgtitle() methods have been removed. These methods are deprecated since
Python 3.3. Generally, these extensions are not supported or not enabled by NNTP server
administrators. For xgtitle(), please
use nntplib.NNTP.descriptions() or nntplib.NNTP.description() instead. (Contributed by Dong-hee Na
in bpo-39366.)
array.array: tostring() and fromstring() methods have been removed. They were aliases
to tobytes() and frombytes(), deprecated since Python 3.2. (Contributed by Victor Stinner in bpo-
38916.)
New Features
PEP 573: Added PyType_FromModuleAndSpec() to associate a module with a
class; PyType_GetModule() and PyType_GetModuleState() to retrieve the module and its state;
and PyCMethod and METH_METHOD to allow a method to access the class it was defined in.
(Contributed by Marcel Plch and Petr Viktorin in bpo-38787.)
Added PyFrame_GetCode() function: get a frame code. Added PyFrame_GetBack() function: get the
frame next outer frame. (Contributed by Victor Stinner in bpo-40421.)
Added PyFrame_GetLineNumber() to the limited C API. (Contributed by Victor Stinner in bpo-
40421.)