Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'expressions': 0.07; 'matches': 0.07; 'string': 0.09; 'friday,': 0.09; 'subject:language': 0.09; 'subject:string': 0.09; 'template': 0.14; 'expressions.': 0.16; 'for,': 0.16; 'lowercase': 0.16; 'mode,': 0.16; 'nightmare.': 0.16; 'subject:generation': 0.16; 'subject:random': 0.16; 'template,': 0.16; 'uppercase': 0.16; 'sat,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'aug': 0.22; 'module,': 0.24; 'fairly': 0.24; 'paul': 0.24; 'equivalent': 0.26; 'pass': 0.26; 'least': 0.26; 'certain': 0.27; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'matching': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'work.': 0.31; 'though.': 0.31; 'regular': 0.32; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'e.g.': 0.38; 'to:addr:python-list': 0.38; 'expect': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'expression': 0.60; 'ian': 0.60; 'august': 0.61; 'more': 0.64; 'case?': 0.84; 'regular,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=8uZM0TBVZar2bH2U+lK7ZUQUuUvrPl4pQMwmkpgLKaU=; b=nDpfjW4yIoeL4P4xh65F4v85eZYLw0D2/YJMkBRqXOWYcHUF7nz+aB/qup6Ma9Cz1r 6q6ggrWSafiY4FRlhc6m2h9wxTJUgzGLlryKYifyAui0IWdhqsxXEe1AZnEi4vEderov jzgOJUKeBV1lWEjqXOFS8SniZ/7cT8Pi+6wcr10OzL+iFZf20/Tt4giL+HGeQ2959iRB ACNqHIeYl6q3+UAO3wFHp7+dOqQIqWTPV8sIJpcMYSQmAbd2NSOYPQKRlH62u5Bd9Ych 2ydHjY7NERky3UcRJWVbAVpNEvXbqz8fcd7PVO8nLVDBwoxPkR6mXC2C05cp37XKbycg zexw== X-Received: by 10.66.235.1 with SMTP id ui1mr29365575pac.28.1407570634307; Sat, 09 Aug 2014 00:50:34 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <58187503-1651-4eca-a131-49f474148f62@googlegroups.com> References: <14d94692-2257-4dfb-a82f-f1674a839233@googlegroups.com> <58187503-1651-4eca-a131-49f474148f62@googlegroups.com> From: Ian Kelly Date: Sat, 9 Aug 2014 01:49:54 -0600 Subject: Re: Template language for random string generation To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407570638 news.xs4all.nl 2842 [2001:888:2000:d::a6]:45995 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75935 On Sat, Aug 9, 2014 at 12:52 AM, Paul Wolf wrote: > On Friday, 8 August 2014 23:03:18 UTC+1, Ian wrote: >> Have you given any thought to adding a validation mode, where the user >> provides a template and a string and wants to know if the string >> matches the template? > > Isn't that what regular expressions are? Or do you have a clarifying use case? > > strgen is provided as the converse of regular expressions. The syntax is not equivalent though. You can't take a strgen template, pass it into the re module, and just expect it to work. Also, I'm not sure how best to go about writing a regular expression for, e.g. "12 or more letters, digits, and punctuation, including at least one each of uppercase letter, lowercase letter, digit, and punctuation". I'm fairly certain that language is regular, but actually matching it with a regular expression would be a nightmare.