-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34ae5ad
commit 23e3f94
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
id: cwab3v7c5fbe9heqos93k0e | ||
title: Best Practices | ||
desc: '' | ||
updated: 1687284332737 | ||
created: 1687284123125 | ||
--- | ||
|
||
# Linters | ||
|
||
|
||
Linters perform static analysis of source codes and check for symantic discrepancies. | ||
When you lint your code, it’s passed through a basic quality checking tool that provides | ||
instructions on how eliminate basic syntactic inconsistencies. | ||
|
||
|
||
# Formatters | ||
|
||
Formatters are similar tools that tries to restructure your code spacing, line length, | ||
argument positioning etc to ensure that your code looks consistent across different | ||
files or projects. | ||
|
||
|
||
# References | ||
|
||
1. [https://py-vscode.readthedocs.io/en/latest/files/linting.html](https://py-vscode.readthedocs.io/en/latest/files/linting.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
id: vvdgu21ycbtn2zfytwremiy | ||
title: Testing | ||
desc: '' | ||
updated: 1687289774366 | ||
created: 1687289451077 | ||
--- | ||
|
||
|
||
# Create named temporary file | ||
|
||
```python | ||
import tempfile | ||
|
||
def create_temp_file(prefix): | ||
temp_file = tempfile.NamedTemporaryFile(prefix=prefix, delete=False) | ||
temp_file.close() | ||
return temp_file.name | ||
|
||
# Example usage | ||
prefix = "my_prefix" | ||
temp_file_path = create_temp_file(prefix) | ||
print("Temporary file created:", temp_file_path) | ||
``` | ||
|
||
From the above code, note that the file path can be retrived with `temp_file.name`. | ||
|
||
## Access the file directory | ||
|
||
|
||
```python | ||
from pathlib import Path | ||
|
||
temp_file = create_temp_file("my_prefix") | ||
path = Path(temp_file) | ||
print(path.parent) | ||
``` | ||
|
||
|
||
# References | ||
|
||
1. [Source](https://chat.openai.com/share/abe75dba-545e-4e17-83db-b59d60ed8c98) |