Python-cheatsheetDocumentation

python-cheatsheet Documentation

Release 0.1.0 crazyguitar

Jan 04, 2023

1 What's New In Python 3 2 Cheat Sheet 3 Advanced Cheat Sheet 4 Appendix

CONTENTS

3 21 135 339

i

ii

python-cheatsheet Documentation, Release 0.1.0

Welcome to pysheeet. This project aims at collecting useful Python snippets in order to enhance pythoneers' coding experiences. Please feel free to contribute if you have any awesome ideas for improvements to code snippets, explanations, etc. Any snippets are welcome. If you'd like to contribute, fork pysheeet on GitHub. If there is any question or suggestion, please create an issue on GitHub Issues.

CONTENTS

1

python-cheatsheet Documentation, Release 0.1.0

2

CONTENTS

CHAPTER

ONE

WHAT'S NEW IN PYTHON 3

The official document, What's New In Python, displays all of the most important changes. However, if you're too busy to read the whole changes, this part provides a brief glance of new features in Python 3.

1.1 New in Python3

Table of Contents ? New in Python3 ? print is a function ? String is unicode ? Division Operator ? New dict implementation ? Keyword-Only Arguments ? New Super ? Remove ? BDFL retirement ? Not allow from module import * inside function ? Add nonlocal keyword ? Extended iterable unpacking ? General unpacking ? Function annotations ? Variable annotations ? Core support for typing module and generic types ? Format byte string ? fstring ? Suppressing exception ? Generator delegation ? async and await syntax

3

python-cheatsheet Documentation, Release 0.1.0

? Asynchronous generators ? Asynchronous comprehensions ? Matrix multiplication ? Data Classes ? Built-in breakpoint() ? The walrus operator ? Positional-only parameters ? Dictionary Merge

1.1.1 print is a function

New in Python 3.0

? PEP 3105 - Make print a function

Python 2

>>> print "print is a statement" print is a statement >>> for x in range(3): ... print x, ... 012

Python 3

>>> print("print is a function")

print is a function

>>> print()

>>> for x in range(3):

...

print(x, end=' ')

... else:

... print()

...

012

1.1.2 String is unicode

New in Python 3.0 ? PEP 3138 - String representation in Python 3000 ? PEP 3120 - Using UTF-8 as the default source encoding ? PEP 3131 - Supporting Non-ASCII Identifiers

Python 2

4

Chapter 1. What's New In Python 3

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download