Re: Figuring out why function implementations aren't available



It appears that the issue relates to the use of functools.partial.
For example, this works,

    from libsheetmusic.spreadsheet import scale
    def diatonic_scale(scientific_note):
        return scale('diatonic',scientific_note)
    sheetmusic_functions = { 'diatonic_scale': diatonic_scale }

and this doesn't.

    import functools
    from libsheetmusic.spreadsheet import scale
    sheetmusic_functions = { 'diatonic_scale': functools.partial(scale, 'diatonic') }

Tom

On 18 Apr 12:20, Thomas Levine wrote:
Oops, I attached the wrong file.

On 18 Apr 12:17, Thomas Levine wrote:
A plugin I am writing is behaving strangely, and I am
having trouble figuring out why I'm seeing no error messages.

The spellbook contains plugin.xml (attached) and sheetmusic.py
(below).

    import libsheetmusic.main
    sheetmusic_functions = libsheetmusic.main.functions()

When I put the spellbook in the appropriate place, set PYTHONPATH
to the directory containing libsheetmusic, open Gnumeric, and run
a function from the spellbook,

    =diatonic_scale('D3'))

the cell renders this,

    Function implementation not available.

and I see no error messages. When I switch sheetmusic.py to
the file below,

    import libsheetmusic.main # in case this is creating an error
    sheetmusic_functions = {'diatonic_scale': lambda _: 3}

it works as you'd expect.

Any ideas?

Thanks

Tom

import libsheetmusic.main
sheetmusic_functions = libsheetmusic.main.functions()

_______________________________________________
gnumeric-list mailing list
gnumeric-list gnome org
https://mail.gnome.org/mailman/listinfo/gnumeric-list



_______________________________________________
gnumeric-list mailing list
gnumeric-list gnome org
https://mail.gnome.org/mailman/listinfo/gnumeric-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]