Looping through the gmail dot trick

Joshua Gilman joshuagilman at gmail.com
Sun Jan 20 17:38:06 CET 2008

So I have a very interesting task ahead of me and it is to loop through an
email using the 'gmail dot trick'. Essentially this trick puts periods
throughout your email to make it look different. Even though it has periods
gmail will replace them all and send it to that email.

So blah at gmail.com is the same as bl.ah at gmail.com.

My task is this: Loop through an email and create as many combinations of
periods as possible. So all the combinations for blah would be:


I'm still rather new to python so this is turning out to be rather tricky.
My current code is as follows:

for d in range(1, len(email)):
>     for i in range(1, len(email)):
>         y = i
>         temail = email
>         for x in range(d):
>             if email[y] == '.': break
>             temail = temail.replace(email[y], '.' + email[y])
>             if not y > len(email) - 2: y += 1
>         print temail

It's not looking too bad except for some reason it's making emails like
bl..ah which is invalid. So can anyone help me out with getting this to
work? Thanks.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080120/b54465d6/attachment.html>

More information about the Python-list mailing list