It is recommended to use DiscId together with the with statement:

# this will load libdiscid
import discid

with discid.DiscId() as disc:
    print("device: %s" % discid.DEFAULT_DEVICE)        # reads from default device
    print("id: %s" %
    print("submission url:\n%s" % disc.submission_url)

This will make sure the internal object is removed afterwards.

If you don’t use with, then you have to use

disc = discid.DiscId()
device = discid.DEFAULT_DEVICE
id =
# disc can't be used anymore

You can use other devices of course: see

When anything goes wrong reading from the device, DiscError is raised.

Table Of Contents

Previous topic

Download and Installation

Next topic

discid API

This Page