#!/usr/bin/env python
# In this file: a problem with de-serializing an object.
import pickle
class User:
@classmethod
def from_bytes(cls, b: bytes) -> User:
obj = pickle.loads(b)
assert type(obj) == cls, (type(obj), cls)
return obj
< /code>
fällt mit < /p>
fehlTraceback (most recent call last):
File "/tmp/./lqlq.py", line 7, in
class User:
......
return obj
File "/tmp/./lqlq.py", line 9, in User
def from_bytes(cls, b: bytes) -> User:
^^^^
NameError: name 'User' is not defined
< /code>
In C machen Sie eine Vorwärtsdeklaration. Was ist die Alternative in Python?
Wie bezeichne ich die Rückgabeart eines @classMethod ctor in Python? [Duplikat] ⇐ Python
-
- Similar Topics
- Replies
- Views
- Last post
-
-
Wie setze ich die Breite eines
-Tags in CSS ein? [Duplikat]
by Guest » » in HTML - 0 Replies
- 12 Views
-
Last post by Guest
-