Wrapper functions of codes of text file operation that are very commonly seen. By using textfile, readability of our program will be improve!
Install
> pip install textfile
Very basic usage
Create file and write text to it.
>>> import textfile
>>> textfile.write("a.txt", "any string value")
Read text from text file.
>>> import textfile
>>> textfile.read("a.txt")
"any string value"
Use cases
Write string to text file:
textfile.write("somefile.txt", "any string value")
Read entire string from text file:
textfile.read("somefile.txt")
Replace string in text file:
textfile.replace("somefile.txt", "replaced", "replacement")
Append string to text file:
textfile.append("somefile.txt", "text to append")
Insert string to text file:
textfile.insert("somefile.txt", "text to insert", line=10)
Just a implementation of facade pattern
textfile wraps python algorithms that are very commonly used in the purpose of to more simplify basic operations.
This is just a facade pattern.
The side effect of simplify the interface of text file operation, gets less flexibility. Further more, it becomes hard to do speed tuning.
But I think that those are not a matter in almost all situations of our programming.
We should pay more attention to code readability!
I courage you to use textfile as much as possible you can. If you do so, the readability of your code will increase, and will suppress many bugs.
Is this document written in strange English?
Kenjimaru, the author of this document, I am Japanese and am not familiar to English.
If you read this document, and find anything should be fixed, feel free to contact me, and I will appreciate.
Metadata
Release files for textfile 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| textfile-0.1.5.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| textfile-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.2 kB
Release files / textfile-0.1.5.tar.gz
| Download URL | textfile-0.1.5.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
057e70442275426ed76c229a14fc99e62021bb89c030748f59d29edad6475489
|
|
BLAKE2b-256 checksum How to use checksums |
0b965aa5ba5647a018cd44965f601101c3e0771122f3b2f07185411b64e41149
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.11.2 Darwin/22.4.0
|
Release files / textfile-0.1.5-py3-none-any.whl
| Download URL | textfile-0.1.5-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1d111a924cc6e643a75fd317de4ded430e2a095a9ffded7c5def0d78cf48855
|
|
BLAKE2b-256 checksum How to use checksums |
8efc2b79f1c48ebc4015b495fa07ea73fa246f49c90823b35a45e6fd67aabf65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.11.2 Darwin/22.4.0
|