Deutsch   English   Français   Italiano  
<parseaddr-20250104204008@ram.dialup.fu-berlin.de>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: How to manage accented characters in mail header?
Date: 4 Jan 2025 19:40:34 GMT
Organization: Stefan Ram
Lines: 27
Expires: 1 Jan 2026 11:59:58 GMT
Message-ID: <parseaddr-20250104204008@ram.dialup.fu-berlin.de>
References: <satn4l-6sqh.ln1@q957.zbmc.eu> <decode_header-20250104154914@ram.dialup.fu-berlin.de> <dhdo4l-uvsi.ln1@q957.zbmc.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de l47VGg45bVtZOiKZJjhG5gnGTe1MUEHr7+CWX8XFiQ2t/h
Cancel-Lock: sha1:/FadT/qiy1T8+B8xscnKfzzb3Zg= sha256:rtRK8kNxeiUfu/+TTRk3qqeYshJwsowxnQ/5YNi5kE0=
X-Copyright: (C) Copyright 2025 Stefan Ram. All rights reserved.
	Distribution through any means other than regular usenet
	channels is forbidden. It is forbidden to publish this
	article in the Web, to change URIs of this article into links,
        and to transfer the body without this notice, but quotations
        of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
	services to mirror the article in the web. But the article may
	be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Bytes: 2272

Chris Green <cl@isbd.net> wrote or quoted:
>>print(final_string)# From: Sébastien Crignon <sebastien.crignon@amvs.fr>
>Is there a simple[r] way to extract just the 'real' address between
>the <>, that's all I actually need.  I think it has the be the last
>chunk of the From: doesn't it?

  Besides the deal with the pointy brackets, there's also this
  other setup with round ones, like in

sebastien.crignon@amvs.fr (Sébastien Crignon)

  . The standard library has:

email.utils.parseaddr(address)

Parse address – which should be the value of some
address-containing field such as To or Cc - into its
constituent realname and email address parts. Returns a tuple
of that information, unless the parse fails, in which case a
2-tuple of ('', '') is returned.

  .