I have python class file.
import re
regex = {
'a1': re.compile('(\d+)'),
}
# or A1_REGEX = re.compile('(\d+)')
class A1():
def toview(self, mystring):
data = regex['a1'].search(mystring)
if data:
......
OR
import re
class A1():
a1 = re.compile('(\d+)')
def toView(self, mystring):
data = a1.search(mystring)
if data:
.......
Please anyone tell, which one is better and more accurate. ? Which one is python standard coding/PEP8 standard ? In this case, is there any time consumptions or memory usage for regex usage can be considered ? Please add your opinions or comments to this. Thanks for your valuable comments .!