Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make a path object from a list of strings? #12

Closed
berrondo opened this issue Nov 16, 2012 · 2 comments
Closed

How to make a path object from a list of strings? #12

berrondo opened this issue Nov 16, 2012 · 2 comments

Comments

@berrondo
Copy link

I have this use case:

new_dir = os.path.join( var_a, var_b, var_c )

where each var evaluates to string and so, the first var is not a path object.

to use path.py i need to do this:

new_dir = path('').joinpath( var_a, var_b, var_c )

or:

new_dir = path.joinpath( path(var_a), var_b, var_c )

or:

new_dir = path( var_a ).joinpath( var_b, var_c )

and i have lists too, which is a pain:

path('').joinpath(*List) ?
path.joinpath(path(p) for p in List) ?
path.joinpath(map(path, List)) ?
sum(map(path, List)) ?!
path(path.os.sep.join(List)) ?! :(

what do you think about pass lists to the constructor? or maybe joinpath to be a staticmethod?

@oliverjanik
Copy link

How about:

new_dir = path(os.path.join(var1, var2, var3))

@jaraco
Copy link
Owner

jaraco commented Dec 8, 2012

joinpath as a static method seems like a reasonable idea. It's certainly worth exploring.

I often use:

new_dir = path(var_a) / var_b / var_c

But I don't like it because the syntax is incongruent (var_a is treated differently than var_b, but they fundamentally represent the same concept.

@jaraco jaraco closed this as completed in fc2862a Jan 16, 2013
jaraco pushed a commit that referenced this issue Feb 23, 2020
* Require toml extra for setuptools_scm

setuptools_scm does not know to invoke itself
if it can't read pyproject.toml.  This broke
sdist installs for projects deriving from skeleton:

  $ python -m pip install zipp --no-binary zipp
  Collecting zipp
    [...]
  Successfully installed zipp-0.0.0

Note the version number defaulting to '0.0.0'.
Building locally only works because pep517,
the build tool, depends on toml which it exposes
to the build environment.

* Require setuptools_scm 3.4.1 at a minimum

A bare

  [tool.setuptools_scm]

does not work in 3.4.0.

* fixup! Require toml extra for setuptools_scm

* fixup! Require setuptools_scm 3.4.1 at a minimum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants