MCPcopy Create free account
hub / github.com/ScottfreeLLC/AlphaPy / valid_name

Function valid_name

alphapy/utilities.py:234–257  ·  view source on GitHub ↗

r"""Determine whether or not the given string is a valid alphanumeric string. Parameters ---------- name : str An alphanumeric identifier. Returns ------- result : bool ``True`` if the name is valid, else ``False``. Examples -------- >>> va

(name)

Source from the content-addressed store, hash-verified

232#
233
234def valid_name(name):
235 r"""Determine whether or not the given string is a valid
236 alphanumeric string.
237
238 Parameters
239 ----------
240 name : str
241 An alphanumeric identifier.
242
243 Returns
244 -------
245 result : bool
246 ``True`` if the name is valid, else ``False``.
247
248 Examples
249 --------
250
251 >>> valid_name('alpha') # True
252 >>> valid_name('!alpha') # False
253
254 """
255 identifier = re.compile(r"^[^\d\W]\w*\Z", re.UNICODE)
256 result = re.match(identifier, name)
257 return result is not None

Callers 3

__new__Method · 0.90
allvarsFunction · 0.90
vwalkFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected