You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
generate_password function to allow users to specify the desired complexity, with flags for including/excluding digits and punctuation. This would provide more flexibility for users who may have varying security requirements or restrictions
If we implement these flags, how should the function handle the case where length is smaller than the sum of required character types to avoid ValueError or an infinite loop?
To address @jadayaanaliah26's concern about the length constraint, we could implement a check that calculates the minimum required length based on the provided boolean flags before generating the string. If length is insufficient, we should either raise a custom ValueError with a descriptive message or automatically increase the length to satisfy the complexity requirements. Alternatively, we could default to filling the remaining length with random characters from the enabled categories to avoid the infinite loop entirely.
Activity
damianoecker26 commentedon Sep 18, 2026
=True
,include_punctuation=True`.jadayaanaliah26 commentedon Oct 21, 2026
If we implement these flags, how should the function handle the case where
lengthis smaller than the sum of required character types to avoidValueErroror an infinite loop?keenstack709 commentedon Nov 20, 2026
To address @jadayaanaliah26's concern about the length constraint, we could implement a check that calculates the minimum required length based on the provided boolean flags before generating the string. If
lengthis insufficient, we should either raise a customValueErrorwith a descriptive message or automatically increase the length to satisfy the complexity requirements. Alternatively, we could default to filling the remaining length with random characters from the enabled categories to avoid the infinite loop entirely.