You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+59-26Lines changed: 59 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,10 +34,64 @@ Simple usage:
34
34
35
35
```python
36
36
foo =123
37
-
print(nameof(foo)) # Output: 'foo'
37
+
nameof(foo) # Output: 'foo'
38
38
```
39
39
40
-
It supports string interpolation, so it's easier to reference variable names when logging,
40
+
### Additional Parameters
41
+
42
+
The `nameof` function supports two optional parameters for formatting the output:
43
+
44
+
-`wrap_in_chars`: Wraps the variable name with the specified string at the start and end.
45
+
-`replace_with_whitespace`: Removes all occurrences of the specified character(s) from the variable name and replaces them with a whitespace. Accepts a string or a list of strings.
46
+
47
+
These are especially useful if you are logging to markdown format (printing messages as Markdown), to format variable names as code or to remove underscores for readability.
48
+
49
+
50
+
```python
51
+
some_param =1
52
+
53
+
# Combine both: wrap in backticks and remove underscores
0 commit comments