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

2020-12-30 Thread Bischoop
On 2020-12-29, jak wrote: > > you could try this way: > > # --- > from dns import resolver as dns > > emails=['john@fakeserver.bah', > 'john@gmail.com'] > > for ue in emails: > try: > mxl = dns.resolve(ue.split('@')[1], 'MX') > except: >

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

2020-12-29 Thread jak
Il 29/12/2020 02:48, Bischoop ha scritto: On 2020-12-28, Mats Wichmann wrote: On 12/28/20 10:46 AM, Marco Sulla wrote: On Mon, 28 Dec 2020 at 17:37, Bischoop wrote: I'd like to check if there's "@" in a string and wondering if any method is better/safer than others. I was told on one

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

2020-12-28 Thread Bischoop
On 2020-12-28, Michael Torrie wrote: > On 12/28/20 10:46 AM, Marco Sulla wrote: >> On Mon, 28 Dec 2020 at 17:37, Bischoop wrote: >>> >>> I'd like to check if there's "@" in a string and wondering if any method >>> is better/safer than others. I was told on one occasion that I should >>> use is

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

2020-12-28 Thread Richard Damon
On 12/28/20 8:02 PM, Chris Angelico wrote: > > Yes, many such regexes exist, and they are *all wrong*. Without > exception. I don't think it's actually possible for a regex to > perfectly match all (syntactically) valid email addresses and nothing > else. > > ChrisA Since Email addresses are

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

2020-12-28 Thread Bischoop
On 2020-12-28, Mats Wichmann wrote: > On 12/28/20 10:46 AM, Marco Sulla wrote: >> On Mon, 28 Dec 2020 at 17:37, Bischoop wrote: >>> >>> I'd like to check if there's "@" in a string and wondering if any method >>> is better/safer than others. I was told on one occasion that I should >>> use is

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

2020-12-28 Thread Avi Gross via Python-list
Thanks, Chris, I am not actually up-to-date on such messaging issues but not shocked at what you wrote. Years ago I recall most messages going out of my workplace looked like machine!machine2!ihnp4!more!evenmore!user with no @ in sight and as you mention, you may want to send to a domain and have

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

2020-12-28 Thread Chris Angelico
On Tue, Dec 29, 2020 at 10:08 AM Avi Gross via Python-list wrote: > > 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

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

2020-12-28 Thread Avi Gross via Python-list
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

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

2020-12-28 Thread Michael Torrie
On 12/28/20 1:27 PM, Richard Damon wrote: > Validating that it meets the SYNTAX of an email address isn't THAT hard, > but there are a number of edge cases to worry about. Yes one would think that, but in my experience half of all web sites get it wrong, insisting that my perfectly valid and

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

2020-12-28 Thread Grant Edwards
On 2020-12-28, Bischoop wrote: > On 2020-12-28, Stefan Ram 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

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

2020-12-28 Thread Richard Damon
On 12/28/20 4:52 PM, Michael Torrie wrote: > On 12/28/20 10:37 AM, Bischoop wrote: >> 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

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

2020-12-28 Thread Chris Angelico
On Tue, Dec 29, 2020 at 8:57 AM dn via Python-list wrote: > After such disparagement it is worth remembering that there are checks > and there are checks! It depends upon the purpose of the check, or the > level-of-detail/accuracy desired! > > When accepting user-data it *is* worth (even

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

2020-12-28 Thread Cameron Simpson
On 28Dec2020 13:08, Mats Wichmann wrote: >On 12/28/20 10:46 AM, Marco Sulla wrote: >>On Mon, 28 Dec 2020 at 17:37, Bischoop wrote: >>>I'd like to check if there's "@" in a string and wondering if any >>>method is better/safer than others. Others have pointed out: '@' in s >Will add that Yes,

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

2020-12-28 Thread dn via Python-list
On 29/12/2020 09:27, Richard Damon wrote: On 12/28/20 3:08 PM, Mats Wichmann wrote: On 12/28/20 10:46 AM, Marco Sulla wrote: On Mon, 28 Dec 2020 at 17:37, Bischoop wrote: ... but probably what you really want is a regular expression. because... Will add that Yes, you should always

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

2020-12-28 Thread Michael Torrie
On 12/28/20 10:46 AM, Marco Sulla wrote: > On Mon, 28 Dec 2020 at 17:37, Bischoop wrote: >> >> I'd like to check if there's "@" in a string and wondering if any method >> is better/safer than others. I was told on one occasion that I should >> use is than ==, so how would be on this example. >>

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

2020-12-28 Thread Michael Torrie
On 12/28/20 10:37 AM, Bischoop wrote: > 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 exam...@mail.com, "example"

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

2020-12-28 Thread Richard Damon
On 12/28/20 3:08 PM, Mats Wichmann wrote: > On 12/28/20 10:46 AM, Marco Sulla wrote: >> On Mon, 28 Dec 2020 at 17:37, Bischoop wrote: >>> >>> I'd like to check if there's "@" in a string and wondering if any >>> method >>> is better/safer than others. I was told on one occasion that I should >>>

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

2020-12-28 Thread Mats Wichmann
On 12/28/20 10:46 AM, Marco Sulla wrote: On Mon, 28 Dec 2020 at 17:37, Bischoop wrote: I'd like to check if there's "@" in a string and wondering if any method is better/safer than others. I was told on one occasion that I should use is than ==, so how would be on this example. s =

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

2020-12-28 Thread Chris Angelico
On Tue, Dec 29, 2020 at 6:18 AM Bischoop wrote: > > On 2020-12-28, Stefan Ram 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

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

2020-12-28 Thread Terry Reedy
On 12/28/2020 11:31 AM, Bischoop wrote: I'd like to check if there's "@" in a string Use the obvious "'@' in string". > and wondering if any method is better/safer than others. Any special purpose method built into the language is likely to be fastest. Safest? What danger are you worried

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

2020-12-28 Thread Bischoop
On 2020-12-28, Stefan Ram 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

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

2020-12-28 Thread MRAB
On 2020-12-28 16:31, Bischoop wrote: I'd like to check if there's "@" in a string and wondering if any method is better/safer than others. I was told on one occasion that I should use is than ==, so how would be on this example. [snip] The shortest and quickest way to check whether "@" is in

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

2020-12-28 Thread Marco Sulla
On Mon, 28 Dec 2020 at 17:37, Bischoop wrote: > > I'd like to check if there's "@" in a string and wondering if any method > is better/safer than others. I was told on one occasion that I should > use is than ==, so how would be on this example. > > s = 't...@mail.is' You could do simply if "@"