Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54479
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <vlastimil.brom@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.014 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'algorithm': 0.04; 'beginner': 0.05; 'expressions': 0.07; 'skip:" 60': 0.07; 'ugly': 0.07; 'string': 0.09; '"if': 0.09; 'converted': 0.09; 'subject:skip:c 10': 0.09; 'wrote': 0.14; 'posted': 0.15; 'exist.': 0.16; 'inverse': 0.16; 'it".': 0.16; 'letters.': 0.16; 'sense,': 0.16; 'thanks,': 0.17; 'obviously': 0.18; 'unlike': 0.19; 'written,': 0.19; 'written': 0.21; '>>>': 0.22; 'import': 0.22; 'saying': 0.22; 'char': 0.24; 'text,': 0.24; "i've": 0.25; 'skip:" 40': 0.26; 'this:': 0.26; 'skip:" 20': 0.27; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'character': 0.29; 'possibility': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'lines': 0.31; '"",': 0.31; 'spam,': 0.31; 'skip:m 30': 0.32; 'regular': 0.32; 'another': 0.32; 'url:python': 0.33; 'comment': 0.34; 'maybe': 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'url:listinfo': 0.36; 'method': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.38; 'list,': 0.38; 'bad': 0.39; 'generating': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'how': 0.40; 'even': 0.60; 'remove': 0.60; 'john': 0.61; 'simple': 0.61; 'back': 0.62; 'address': 0.63; 'name': 0.63; 'personal': 0.63; 'such': 0.63; 'contact': 0.67; 'skip:r 40': 0.68; 'capital': 0.73; 'obvious': 0.74; 'special': 0.74; '*really*': 0.84; 'detecting': 0.84; 'email addr:hotmail.com,': 0.84; 'etc..': 0.84; 'me).': 0.84; 'received:mail-ob0-x22f.google.com': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=maGPpdtjuH+EF5mhhS6q+xVFbqSvh10JVu+X12oWPec=; b=MWEEdYkDwDTW1N1buX/JOZfzknz5gXv817WqU7aR9gVFuVrlcd3Aqs5Cjfw77yPZrd FCjEhOCq8uVRP0y69it+UWf/hBXUhJpjYozowN+jT7ZDRwVkFQGtOqsXDjO0GuF7ghrj oc1GiUY14e+jVDA46Nx5xSn/pSoT4gMQyVXzyARdRb/udJfW2N+EY6gt3eHG+/QY5d02 SVIlVpzzDPeDepPLGZcKQYqaf8sVIlgaNUHt1Obg/uLTvPfYBM5TOSd/wQmebucowBp7 RfExsIsRGrwJe3O77k/rLo0AEenNn7jCRrMc1HU0/q9KMH2B1GnXInw1u8pOiLlARuvZ LLsg== |
| MIME-Version | 1.0 |
| X-Received | by 10.182.71.82 with SMTP id s18mr6575839obu.9.1379692065673; Fri, 20 Sep 2013 08:47:45 -0700 (PDT) |
| In-Reply-To | <523C6402.7090501@gmail.com> |
| References | <523C6402.7090501@gmail.com> |
| Date | Fri, 20 Sep 2013 17:47:45 +0200 |
| Subject | Re: Antispam measures circumventing |
| From | Vlastimil Brom <vlastimil.brom@gmail.com> |
| To | python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.187.1379692075.18130.python-list@python.org> (permalink) |
| Lines | 64 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1379692075 news.xs4all.nl 16006 [2001:888:2000:d::a6]:34942 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:54479 |
Show key headers only | View raw
2013/9/20 Jugurtha Hadjar <jugurtha.hadjar@gmail.com>: > Hello, > # I posted this on the tutor list, but my message wasn't displayed > I shared some assembly code (microcontrollers) and I had a comment wit my > e-mail address for contact purposes. > Supposing my name is John Doe and the e-mail is john.doe@hotmail.com, my > e-mail was written like this: > REMOVEMEjohn.doSPAMeSPAM@REMOVEMEhotmail.com' > With a note saying to remove the capital letters. > Now, I wrote this : > for character in my_string: > ... if (character == character.upper()) and (character !='@') and > (character != '.'): > ... my_string = my_string.replace(character,'') > And the end result was john.doe@hotmail.com. > Is there a better way to do that ? Without using regular expressions (Looked > *really* ugly and it doesn't really make sense, unlike the few lines I've > written, which are obvious even to a beginner like me). > I obviously don't like SPAM, but I just thought "If I were a spammer, how > would I go about it". > Eventually, some algorithm of detecting the john<dot>doe<at>hotmail<dot>com > must exist. > retrieve the original e-mail address? Maybe a function with no inverse > function ? Generating an image that can't be converted back to text, etc.. > If this is off-topic, you can just answer the "what is a better way to do > that" part. > > Thanks, > -- > ~Jugurtha Hadjar, > -- > https://mail.python.org/mailman/listinfo/python-list Hi, is the regex really that bad for such simple replacement? >>> re.sub(r"[A-Z]", "", "REMOVEMEjohn.doSPAMeSPAM@REMOVEMEhotmail.com") 'john.doe@hotmail.com' Alternatively, you can use a check with the string method isupper(): >>> "".join(char for char in "REMOVEMEjohn.doSPAMeSPAM@REMOVEMEhotmail.com" if not char.isupper()) 'john.doe@hotmail.com' or using a special form of str.translate() >>> "REMOVEMEjohn.doSPAMeSPAM@REMOVEMEhotmail.com".translate(None, "ABCDEFGHIJKLMNOPQRSTUVWXYZ") 'john.doe@hotmail.com' which is the same like: >>> import string >>> "REMOVEMEjohn.doSPAMeSPAM@REMOVEMEhotmail.com".translate(None, string.ascii_uppercase) 'john.doe@hotmail.com' Another possibility would be to utilise ord(...) >>> "".join(char for char in "REMOVEMEjohn.doSPAMeSPAM@REMOVEMEhotmail.com" if ord(char) not in range(65, 91)) 'john.doe@hotmail.com' >>> Well, maybe there are other possibilities, these above are listed roughly in the order of my personal preference. Of course, others may differ... hth, vbr
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Antispam measures circumventing Vlastimil Brom <vlastimil.brom@gmail.com> - 2013-09-20 17:47 +0200
csiph-web