Skip to content

Commit

Permalink
Added basic implementation for string and path manipulation in python
Browse files Browse the repository at this point in the history
  • Loading branch information
k-dominik committed May 27, 2024
1 parent 7e33269 commit 846564c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
14 changes: 13 additions & 1 deletion _includes/string_concat/creating_log_messages.py
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}...")
15 changes: 14 additions & 1 deletion _includes/string_concat/manipulating_file_paths.py
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)

0 comments on commit 846564c

Please sign in to comment.