ATLAS Offline Software
Functions
python.ext.thousands Namespace Reference

Functions

def splitThousands (s, tSep=',', dSep='.')
 

Function Documentation

◆ splitThousands()

def python.ext.thousands.splitThousands (   s,
  tSep = ',',
  dSep = '.' 
)

Definition at line 12 of file thousands.py.

12 def splitThousands(s, tSep=',', dSep='.'):
13  if s is None:
14  return 0
15  from builtins import int
16  if isinstance(s, int) or isinstance(s, float):
17  s = str(s)
18  if s[0] == '-' or s[0] == '+':
19  lhs=s[0]
20  s=s[1:]
21  else:
22  lhs=''
23  if dSep != '' and s.rfind(dSep)>0:
24  rhs=s[s.rfind(dSep)+1:]
25  s=s[:s.rfind(dSep)]
26  if len(s) <= 3: return lhs + s + dSep + rhs
27  return lhs + splitThousands(s[:-3], tSep) + tSep + s[-3:] + dSep + rhs
28  else:
29  if len(s) <= 3: return lhs + s
30  return lhs + splitThousands(s[:-3], tSep) + tSep + s[-3:]
python.ext.thousands.splitThousands
def splitThousands(s, tSep=',', dSep='.')
Definition: thousands.py:12
str
Definition: BTagTrackIpAccessor.cxx:11