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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing paths to python variables #439

Open
EthanMarx opened this issue Jan 26, 2024 · 1 comment
Open

Passing paths to python variables #439

EthanMarx opened this issue Jan 26, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@EthanMarx
Copy link

馃殌 Feature request

Given this simple parser setup, is it possible to parse values that are paths to python variables that resolve the the requested type?

parser = jsonargparse.ArgumentParser()
parser.add_argument("--float", type=float)
parser.parse_args(["--float", "math.pi"])

Motivation

Pitch

Alternatives

@EthanMarx EthanMarx added the enhancement New feature or request label Jan 26, 2024
@mauvilsa
Copy link
Member

Thank you for the proposal! It is an interesting idea. I need to think about it to see if it could have unexpected consequences. One small comment for now. One thing is that when parsing, an import path resolves to its corresponding value. This might be relatively easy to implement.

A more complex behavior that people could ask for could be that additionally when serializing (dump, save, print_config), the import path is preserved. This would be considerably complex an not be implemented any time soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants