MCPcopy Index your code
hub / github.com/RustPython/RustPython / isidentifier

Method isidentifier

crates/vm/src/builtins/str.rs:1355–1361  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

1353
1354 #[pymethod]
1355 pub fn isidentifier(&self) -> bool {
1356 let Some(s) = self.to_str() else { return false };
1357 let mut chars = s.chars();
1358 let is_identifier_start = chars.next().is_some_and(|c| c == '_' || is_xid_start(c));
1359 // a string is not an identifier if it has whitespace or starts with a number
1360 is_identifier_start && chars.all(is_xid_continue)
1361 }
1362
1363 // https://docs.python.org/3/library/stdtypes.html#str.translate
1364 #[pymethod]

Callers 2

builtin_str.pyFile · 0.45
slot_newMethod · 0.45

Calls 4

to_strMethod · 0.80
charsMethod · 0.80
allMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected