-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic implementation for string and path manipulation in python
- Loading branch information
Showing
2 changed files
with
27 additions
and
2 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 |
---|---|---|
@@ -1 +1,13 @@ | ||
# TODO | ||
# creating log messages | ||
|
||
image_index = 11 | ||
num_images = 100 | ||
|
||
# strings can be added together with the '+' operator | ||
print("Analyzing image " + str(image_index) + "/" + str(num_images) + "...") | ||
|
||
# An alternative way to combine strings and variables from your code | ||
# are so called f-strings: in f-strings you can add variables (and some | ||
# code) in between curly braces. Types are automatically coerced to strings. | ||
# The below code achieves the same output. | ||
print(f"Analysing image {image_index}/{num_images}...") |
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 |
---|---|---|
@@ -1 +1,14 @@ | ||
# TODO | ||
# manipulating file paths | ||
|
||
import pathlib | ||
import tempfile | ||
|
||
# Temporary folder is different on different operating systems. | ||
# We use tempfile.gettempdir() from the standard library as it has all that logic. | ||
tmp_folder = pathlib.Path(tempfile.gettempdir()) | ||
file_name = "nuclei.tif" | ||
|
||
# pathlib.Path objects support "syntactic sugar", like using '/' as a | ||
# separator when composing paths. | ||
path = tmp_folder / file_name | ||
print(path) |