this post was submitted on 20 Sep 2023
0 points (NaN% liked)

Python

6150 readers
3 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

๐Ÿ“… Events

October 2023

November 2023

PastJuly 2023

August 2023

September 2023

๐Ÿ Python project:
๐Ÿ’“ Python Community:
โœจ Python Ecosystem:
๐ŸŒŒ Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS
 

Constant modules are modules that often contains variables that you want to use in many places without relying on hard coded values. Sometime you store paths (often relatives).

Is it a good thing to use pathlib.Path() object is modules dedicated to constant?

Or is there anything that you should know before choosing to do so?

I would say the same question appears for using re.compile() in constants.

Any advise?

top 2 comments
sorted by: hot top controversial new old
[โ€“] gigachad@feddit.de 0 points 11 months ago* (last edited 11 months ago)

I don't see why not. However I like to have my constants module contain data structures as simple as possible, therefore I would prefer strings (which are also immutable), and create a Path object when I need it. I can see though that you usually won't have the case where you would not want the path to be a Path object.

[โ€“] Fal@yiffit.net -1 points 11 months ago