Eric Blake <ebl...@redhat.com> writes: > On 04/29/2015 07:06 AM, Eric Blake wrote: >> Previous commits demonstrated that the generator overlooked various >> bad naming situations: >> - types, commands, and events need a valid name >> - enum members must be valid names, when combined with prefix >> - union and alternate branches cannot be marked optional >> > >> regex, this patch just uses a broader combination that allows both >> upstream and downstream names, as well as a small hack that >> realizes that any enum name is merely a suffix to an already valid >> name prefix (that is, any enum name is valid if prepending _ fits >> the normal rules). >> > >> + # Enum members can start with a digit, because the generated C >> + # code always prefixes it with the enum name >> + if enum_member: >> + membername = "_%s" %membername >> + if not valid_name.match(membername): >> + raise QAPIExprError(expr_info, > > Python question: Would it be any simpler to write: > > membername = '_' + membername > > and if so, do I need to squash anything in?
I find + easier to read here, even when compare to a correctly spaced "_%s" % membername. I think we have enough squash candidates to justify a quick v8. I'd prefer that, as I I haven't checked v7 anyway :)