Example #1
0
 def isidentifier(string):
     """
     Return whether the given string is a valid Python identifier.
     """
     return string.isidentifier()
Example #2
0
import string

assert string.translate("foobar", {
    ord("o"): "foo",
    ord("b"): 32,
    ord("r"): None
}) == "ffoofoo a"

assert string.isidentifier("_foo13_1")
assert not string.isidentifier("_foo13_1-")
assert not string.isidentifier("1_foo13_1")
Example #3
0
 def isidentifier(string):
     """
     Return whether the given string is a valid Python identifier.
     """
     return string.isidentifier()
Example #4
0
 def isidentifier(string):
     """Check if string can be a variable name."""
     return string.isidentifier()