-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfstring.py
More file actions
37 lines (29 loc) · 889 Bytes
/
Copy pathfstring.py
File metadata and controls
37 lines (29 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 28 15:50:03 2021
@author: Baptiste
"""
from SmartFramework.serialize import serializejson
class fstring(str):
def __new__(cls, content, **dictionnaire):
self = str.__new__(cls, content.format(**dictionnaire))
self._content = content
return self
# def __reduce__(self):
# return fstring,self._content
# def __new__(cls,string,**kargs):
# return self
# return string.format(**kargs)
# string = str(string)
## self._dictionaire = dictionaire
# return ()
# def setDictionnaire(self,dictionnaire):
# self._dictionaire = dictionnaire
# def __str__(self):
# return self.format(self._dictionaire)
a = fstring("{mot} toi", mot=1)
b = str.format("{mot} toi", mot=1)
print(a)
print(b)
print(serializejson.dumps(a))
print(serializejson.dumps(b))