Python Examples

The following are code examples for showing how to use They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: randomsheetmusic   Author: musescore   File:    MIT License 4 votes vote down vote up
def __deepcopy__(self, memo=None):
        Helper method to's deepcopy function.  Call it from there.

        memo=None is the default as specified in

        Problem: if an attribute is defined with an understscore (_priority) but
        is also made available through a property (e.g. priority)  using dir(self)
        results in the copy happening twice. Thus, __dict__.keys() is used.

        >>> from copy import deepcopy
        >>> from music21 import note, duration
        >>> n = note.Note('A')
        >>> n.offset = 1.0 #duration.Duration("quarter")
        >>> n.groups.append("flute")
        >>> n.groups

        >>> idN =
        >>> idN > 10000  # pointer
        >>> b = deepcopy(n)
        >>> b.offset = 2.0 #duration.Duration("half")

        >>> n is b
        >>> !=
        >>> n.accidental = "-"
        >>> n.offset
        >>> b.offset
        >>> n.groups[0] = "bassoon"
        >>> ("flute" in n.groups, "flute" in b.groups)
        (False, True)
        #environLocal.printDebug(['calling Music21Object.__deepcopy__', self])
        new = self._deepcopySubclassable(memo)
        # must do this after copying
        #environLocal.printDebug([self, 'end deepcopy', 'self._activeSite', self._activeSite])
        return new