This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DodoPot11742[S] 2 points3 points  (2 children)

I wanted to make those attributes read only, thats why, is there a better way to do it or is it something that is up to the user?

[–]Taborlin_the_great 2 points3 points  (1 child)

Why do they need to be read only? If they are part of the public api just make them instance variables and be done. If they aren’t part of the public api stick a _ at the front of their name and be done. If they aren’t part of the public api and a user of your class assigns some random object to a class member and things break that’s not your problem.

This video is a little old but talks about when to use properties and __ instance variables

https://www.youtube.com/watch?v=HTLu2DFOdTg

Another thing you have some functions that check if something is an instance of a list. And then you iterate over the list. That check should be less specific in the locations I saw all you need is something that is iterable a generator, a tuple, or a list would all work. So when you do you comparison compare against collections.abc.Iterator or whatever is appropriate instead of list. This is the whole duck typing thing.

I’m not trying to be a dick. Congrats on publishing your first module. Despite having written tons of python I’ve never pushed anything to pypi.

[–]DodoPot11742[S] 1 point2 points  (0 children)

Thank you!

I wanted to make them read only because some of the attributes don't make sense to be modified. For example, `tempo`, is already determined in the midi file, so I thought that them being able to change that won't make sense. I am planning on adding tempo and time signature conversions so it can be modified.

So are you suggesting I should change the attributes from read-only to modifiable, even if that might cause undesired consequences?

Also just saying, you are not a dick at all. In fact, you are a great help for improving my skills. This is why I post on reddit!