Which method to check if string index is queal to character.

Avi Gross avigross at verizon.net
Mon Dec 28 18:01:03 EST 2020


This may be a nit, but can we agree all valid email addresses as used today
have more than an @ symbol?

I see it as requiring at least one character before the @ that come from a
list of allowed characters (perhaps not ASCII) but does not include the
symbol @ again. It is normally followed by some minimal number of characters
and maybe  a period and one of the currently valid domains like .com or .it
but the latter gets tricky as it can look like user at abd.def.att.com or other
long variations where only the final component must be testable in the
program.

The lack of an at-sign suggests it is not an email address. The lack of
anything before or after also seems to disqualify it. You may be able to add
more conditions but as noted, having more than one at-sign may also
disqualify it.

I am sure someone has some complex regular expressions that they think
matches only potentially valid strings but, of course, as noted by Chris, to
really validate that an address works might require sending something and
validating a human replied and that can be quite  task.

-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon.net at python.org> On
Behalf Of Chris Angelico
Sent: Monday, December 28, 2020 2:24 PM
To: Python <python-list at python.org>
Subject: Re: Which method to check if string index is queal to character.

On Tue, Dec 29, 2020 at 6:18 AM Bischoop <Bischoop at vimart.net> wrote:
>
> On 2020-12-28, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> >
> >   "@" in s
> >
>
> That's what I thought.
>
> >>I want check if string is a valid email address.
> >
> >   I suggest to first try and define "valid email address" in English.
> >
> >
>
> A valid email address consists of an email prefix and an email domain, 
> both in acceptable formats. The prefix appears to the left of the @
symbol.
> The domain appears to the right of the @ symbol.
> For example, in the address example at mail.com, "example" is the email 
> prefix, and "mail.com" is the email domain.
>

To see if it's a valid email address, send email to it and get the person to
verify receipt. Beyond that, all you can really check is that it has an at
sign in it (since a local address isn't usually useful in contexts where
you'd want to check).

So the check you are already looking at is sufficient.

ChrisA
--
https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list