I'm working on a music app' in Python and would like to use the fractions module to handle time signatures amongst other things. My problem is that fractions get simplified, i.e.:
>>> from fractions import Fraction
>>> x = Fraction(4, 4)
>>> x
Fraction(1, 1)
However, it is important from a musical point of view that 4/4 stays 4/4 even though it equals 1. Is there any built-in way to avoid that behaviour?
Thanks!
Yes: make a custom class for it.
Musical time signatures are not fractions, so it doesn't make sense to represent them with a math class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With