Traceback (most recent call last):
  File "C:/Users/James/Desktop/", line 2, in <module>
    class var(tempfile.TemporaryFile):
TypeError: Error when calling the metaclass bases
    function() argument 1 must be code, not str

Why does this happen and how can I fix it?

Recommended Answers

All 2 Replies

Give us some code!

TemporaryFile is not a class. Use aggregation

class Var(object):
    def __init__(self):
        self._file = tempfile.TemporaryFile()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.