question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VersionInfo should support string output

See original GitHub issue

It may seem weird, but the VersionInfo object lacks the “opposite” thing of parsing a SemVer. I just like to have a str output like “3.0.0” from a VersionInfo - this is not implemented. Wouldn’t it be nice to have something like

def to_str(self):
    return self.format_version(
        self.major, 
        self.minor,
        self.patch,
        self.prerelease,
        self.build
    )

So if you have a VersionInfo object you can print out the original/created string again (for saving in a DB e.g.):

>>> version = VersionInfo(3, 4, 5)
>>> print(version.to_str())
3.4.5

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
kxepalcommented, Jul 9, 2018
0reactions
scls19frcommented, Jul 9, 2018

Related issue https://github.com/k-bx/python-semver/issues/98

2.8.1 version is now available

Read more comments on GitHub >

github_iconTop Results From Across the Web

string interpolation - format string output - Microsoft Learn
To identify a string literal as an interpolated string, prepend it with the $ symbol. You can't have any white space between the...
Read more >
Standard way to embed version into Python package?
I would imagine there's some way to retrieve that data without any extra hardcoding, since minor/major strings are specified in setup.py already. Alternative ......
Read more >
7. Input and Output — Python 3.11.1 documentation
The str.format() method of strings requires more manual effort. You'll still use { and } to mark where a variable will be substituted...
Read more >
A Guide to Formatting with f-strings in Python - CIS Sandbox
f-strings support extensive modifiers that control the final appearance of the output string. Expressions in f-strings can be modified by a format specification ......
Read more >
Declaring Versions and Ranges - Gradle User Manual
Gradle supports different ways of declaring a version string: ... This means that [1.0, 2.0[ will also exclude all versions starting with 2.0...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found