Skip to main content

Safe open function

Project description

Introduction

How to use

    from safe_open import safe_open

    with safe_open("test.txt", "w") as f:
        f.write("Hello, World!")  # 正常写入
    
    with safe_open("test.txt", "r") as f:
        content = f.read()  # 正常读取

    with safe_open("test.txt", "w") as f: # OSError: file mode error: cannot read in write mode
        content = f.read()  # 异常读取

    with safe_open("test.txt", "r") as f: # OSError: file mode error: cannot write in read mode
        content = f.write()  # 异常写入

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

safe_open-0.2.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

safe_open-0.2-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file safe_open-0.2.tar.gz.

File metadata

  • Download URL: safe_open-0.2.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for safe_open-0.2.tar.gz
Algorithm Hash digest
SHA256 09018e73aa75409bdf877f4a2211056c153fa62b861d876344e41df1b62f54e1
MD5 8fb47eef4b9a489b5f2885994140a78e
BLAKE2b-256 6760941943f636d72e8286087777dde47eafacb4c44d9ab2e7921d5aec0d7884

See more details on using hashes here.

File details

Details for the file safe_open-0.2-py3-none-any.whl.

File metadata

  • Download URL: safe_open-0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for safe_open-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3033f4bc28e6551c03a358eb87d1e217fbc843ec20174a4f66fe8989f01ab1cf
MD5 ed286c9f8fb8d53f92d386d62d9df787
BLAKE2b-256 273b2418f018f18db894cce38413305571c4e97c1e912f885a0cef9f192cbca8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page