Quote:
Originally Posted by chaley
I looked at that code at least 20 times before I saw it. 
I don't understand what re.sub() would fix. The dict comprehension on line 5 ensures that the key starts with the user_cat_prefix so removing len(user_cat_prefix) characters from the key (user_cat) can't do the wrong thing. What am I missing?
|
It will not change much. It only fails better in case the user enters a wrong value for user_cat_prefix (e.g missing one or more letters), it will return the full path of the user category, which makes it more obvious what the user did wrong.