why does this gives error print "module {0}".format(key) , i hope this is nt the python version problem...

>>> #Python2.x
>>> key = 5
>>> print "module {0}".format(key)
module 5

>>> #Python 3.x
>>> print("module {0}".format(key))
module 5

Edited 3 Years Ago by snippsat

Always post the traceback when you report such errors! If it is a SyntaxError, use print("module {0}".format(key)). Otherwise, the format() method could cause an error in some cases (unicode encoding, or use of a custom class).

Edited 3 Years Ago by Gribouillis

i was tryinng this

    import sys
    for key in sys.modules.keys():
        if "myPackage" in key:
            del sys.modules[key]
            print "Deleting module {0}".format(key)

this gives error

This question has already been answered. Start a new discussion instead.