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

Conversion of Informations between units #9

Open
gebn opened this issue Sep 16, 2017 · 1 comment
Open

Conversion of Informations between units #9

gebn opened this issue Sep 16, 2017 · 1 comment
Labels

Comments

@gebn
Copy link
Owner

gebn commented Sep 16, 2017

You seem to have managed to avoid providing a way to get an Information object in a particular unit. Intuitively, you expect to be able to do information.bytes or information.gigabytes. Consider implementing __getattr__(). You could implement it as a method that takes a unit constant, but which of these would you prefer to see?

  • int(math.ceil(size.bits / 8e+9))
  • size.to(Information.GIGABYTES)
  • size.gigabytes

Go with the last one. Should you be returning floats or decimals? Bits should always return int.

@gebn gebn added the bug label Sep 16, 2017
@gebn
Copy link
Owner Author

gebn commented Oct 5, 2017

You should override __dir__() to make the properties available via autocomplete.

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

No branches or pull requests

1 participant