MCPcopy Create free account
hub / github.com/PyMySQL/mysqlclient / numeric_part

Function numeric_part

src/MySQLdb/connections.py:35–48  ·  view source on GitHub ↗

Returns the leading numeric part of a string. >>> numeric_part("20-alpha") 20 >>> numeric_part("foo") >>> numeric_part("16b") 16

(s)

Source from the content-addressed store, hash-verified

33
34
35def numeric_part(s):
36 """Returns the leading numeric part of a string.
37
38 >>> numeric_part("20-alpha")
39 20
40 >>> numeric_part("foo")
41 >>> numeric_part("16b")
42 16
43 """
44
45 m = re_numeric_part.match(s)
46 if m:
47 return int(m.group(1))
48 return None
49
50
51class Connection(_mysql.connection):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…