[PYTHON] Notes about with

What are you doing with with syntax

c = PokoClass()
with c as poko:
	poko.hoge()

Is

c = PokoClass()
poko = c.__enter__()
poko.hoge()
c.__exit__()

Synonymous with.

__exit () __ takes four arguments: self, exc_type, exc_value, traceback. None is passed if no exception is raised

Recommended Posts

Notes about with
Notes about pytorch
Notes playing with symbolic links
Auto Encodder notes with Keras
About learning with google colab
Beginner notes about django's setting.py
Think about dropouts with MNIST
Implement blockchain with about 60 lines
Notes on package management with conda
Laplacian eigenmaps with Scikit-learn (personal notes)
Notes on using rstrip with python.
About LangID
About CAGR
Step notes to get started with django
JetBrains_Learning Notes_003
About virtiofs
About python-apt
About sklearn.preprocessing.Imputer
About gunicorn
WEB scraping with Python (for personal notes)
About requirements.txt
About package management with conda and pip
Notes on running M5Stick V with uPyLoader
About permissions
SQLAlchemy notes
[Linux] [C / C ++] Notes about Waf build system
pyenv notes
About Opencv ②
About axis = 0, axis = 1
Miscellaneous notes about the Django REST framework
About Opencv ③
About import
A story about machine learning with Kyasuket
Notes on doing Japanese OCR with Python
SQL notes
Pandas notes
Sphinx notes
django notes
Personal notes and links about machine learning ① (Machine learning)
Gaussian process regression with PyMC3 Personal notes
About numpy
Jupyter_Learning Notes_000
About pip
About Linux
About numpy.newaxis
About endian
About Linux
About import
About Opencv ①
About Linux
About Linux
How about polarity analysis with "order" added?
About Linux ①
About cv2.imread
About _ and __
About wxPython
Django notes
Download PDF with selenium chromedriver (Chrome 57) + (Other notes)
About WARNING when packaging with pyinstaller using pyocr
mod_wsgi talks about putting it in with pip
Play with Lambda layer (python) for about 5 minutes