diff options
author | Chris Liechti <cliechti@gmx.net> | 2017-07-20 23:46:34 +0200 |
---|---|---|
committer | Chris Liechti <cliechti@gmx.net> | 2017-07-20 23:46:34 +0200 |
commit | fd70a55aa51664fcde5aee498c0e8a00297df2f6 (patch) | |
tree | 7e488408ef47bba15dbc33d32bc5482a89c0c8ad /documentation/pyserial_api.rst | |
parent | 8b0eaf27250febf94d154729105d4c83cdb2e4c5 (diff) | |
download | pyserial-git-fd70a55aa51664fcde5aee498c0e8a00297df2f6.tar.gz |
docs: changed __enter__ to open automatically
document the changes from #240
Diffstat (limited to 'documentation/pyserial_api.rst')
-rw-r--r-- | documentation/pyserial_api.rst | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/documentation/pyserial_api.rst b/documentation/pyserial_api.rst index d17d744..a3b0ebb 100644 --- a/documentation/pyserial_api.rst +++ b/documentation/pyserial_api.rst @@ -515,13 +515,18 @@ Native ports >>> with serial.serial_for_url(port) as s: ... s.write(b'hello') - Here no port argument is given, so it is not opened automatically: + The port is opened automatically: - >>> with serial.Serial() as s: - ... s.port = ... - ... s.open() + >>> port = serial.Serial() + >>> port.port = '...' + >>> with port as s: ... s.write(b'hello') + Which also means that ``with`` statements can be used repeatedly, + each time opening and closing the port. + + .. versionchanged:: 3.4 the port is automatically opened + .. method:: __exit__(exc_type, exc_val, exc_tb) @@ -618,7 +623,7 @@ Native ports .. method:: isOpen() - .. deprecated:: 3.0 see :attr:`is_open` + .. deprecated:: 3.0 see :attr:`is_open` .. attribute:: writeTimeout |