[vorbis-dev] Question about Python bindings

Grzegorz Adam Hankiewicz gradha at terra.es
Fri Mar 1 07:53:16 PST 2002



On Wed, Feb 27, 2002 at 06:37:07PM -0500, Andrew Chatham wrote:
> Actually, there's a copy of vcedit.c in vorbis-python, now that they're both
> under the LGPL. The README in vorbis-python explains how to use it. Comments
> are basically in a weird dictionary-like thing, which is kind of confusing in
> that all the values are lists, but that's the way it needs to be.
> 
> Or maybe you're talking about something else and I'm just sleepy.

I meant about functionality. However I find it ugly to work like described
by the README, because v['mykey'] = 'myval' simply breaks the way things
work logically. I expect it to be an assignment, not an addition to the
list. And there should be a single obvious way...

In my custom version things are done this way:

>>> tags, None = pyvorbiscomment.read_file_tags("test.ogg")
>>> print tags
{'TITLE': ['Why do I feel so sad'], 'ARTIST': ['Alicia Keys'], 'TRACKNUMBER': ['14'], 'ALBUM': ['Songs in A minor']}
>>> tags["ARTIST"].append("Some other musician")
>>> print tags
{'TITLE': ['Why do I feel so sad'], 'ARTIST': ['Alicia Keys', 'Some other musician'], 'TRACKNUMBER': ['14'], 'ALBUM': ['Songs in A minor']}
>>> tags["ARTIST"] = ["mus1", "mus2", "mus3"]
>>> print tags
{'TITLE': ['Why do I feel so sad'], 'ARTIST': ['mus1', 'mus2', 'mus3'], 'TRACKNUMBER': ['14'], 'ALBUM': ['Songs in A minor']}
>>> pyvorbiscomment.write_file_tags(file, tags)

I see this is more simple, and deletes the redundancy of mykey for each
repeated key. It's also easier to extract all the values of a given key
and loop through them printing to screen or something like that.

write_file_tags would need to assert the type of the objects of the
dictionary, and it could coerce gracefully single non-list items to list
with a single item if the user forgot the brackets, aborting the operation
if the user has something else than strings, keys are non 7-bit strings,
the file is not writtable, etc.


-- 
 Grzegorz Adam Hankiewicz   gradha at terra.es   http://gradha.infierno.org/

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.




More information about the Vorbis-dev mailing list