Skip to content

SoundEffect fx parameter, fx attribute, and None #130

Closed
@microbit-carlos

Description

@microbit-carlos

SoundEffect.FX_NONE is 0:

>>> SoundEffect.FX_NONE
0

SoundEffect(fx=SoundEffect.FX_NONE).fx returns None:

>>> str(SoundEffect(fx=SoundEffect.FX_NONE).fx)
'None'

But the fx parameter cannot be set to None:

>>> SoundEffect(fx=None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't convert NoneType to int

But the fx attribute can:

>>> effect = SoundEffect()
>>> effect.fx = 0
>>> str(effect.fx)
'None'
>>> effect.fx = None
>>> str(effect.fx)
'None'

This is the only parameter that can set to "None" and it was originally specified like that to avoid having to create an extra constant and qstring. However, it makes sense to keep the SoundEffect.FX_NONE constant, so maybe we should remove the SoundEffect internal logic that converts 0 to None?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions