5
Contributors
6
Replies
73
Views
4 Years
Discussion Span
Last Post by vegaseat
0
>>> #Python2.x
>>> key = 5
>>> print "module {0}".format(key)
module 5

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

Edited by snippsat

0

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 by Gribouillis

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.