Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

I do not fear computers. I fear the lack of them. -- Isaac Asimov


devel / comp.lang.python / Re: How to get get_body() to work? (about email)

SubjectAuthor
* How to get get_body() to work? (about email)Peng Yu
+* Re: How to get get_body() to work? (about email)Stefan Ram
|`* Re: How to get get_body() to work? (about email)Jon Ribbens
| `* Re: How to get get_body() to work? (about email)Stefan Ram
|  `* Re: How to get get_body() to work? (about email)Jon Ribbens
|   `* Re: How to get get_body() to work? (about email)Greg Ewing
|    `- Re: How to get get_body() to work? (about email)Jon Ribbens
+- Re: How to get get_body() to work? (about email)Stefan Ram
`- Re: How to get get_body() to work? (about email)Stefan Ram

1
How to get get_body() to work? (about email)

<mailman.2379.1679243097.20444.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=26926&group=comp.lang.python#26926

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: pengyu.ut@gmail.com (Peng Yu)
Newsgroups: comp.lang.python
Subject: How to get get_body() to work? (about email)
Date: Sat, 18 Mar 2023 21:49:45 -0500
Lines: 22
Message-ID: <mailman.2379.1679243097.20444.python-list@python.org>
References: <CABrM6wkTfQXye9TtbE=8X4_po1CXMv_4kkmg_BQ=0VqzKWHOug@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de 5mnD4fgOBGPlqXhlRqlaagdsVjsU295N3mlZCWGvqMXw==
Return-Path: <pengyu.ut@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=QInWpHE7;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'traceback': 0.04; '(most':
0.05; 'last):': 0.05; 'methods,': 0.09; 'received:209.85.219':
0.09; "'import": 0.16; 'accessed': 0.16; 'found.': 0.16;
'from:addr:pengyu.ut': 0.16; 'from:name:peng yu': 0.16; 'peng':
0.16; 'python3': 0.16; 'subject:() ': 0.16; 'says': 0.17; 'to:addr
:python-list': 0.20; 'subject:How': 0.23; 'object': 0.26; 'code,':
0.31; '"",': 0.32; 'to:name:python': 0.32; 'message-
id:@mail.gmail.com': 0.32; 'but': 0.32; 'received:google.com':
0.34; 'following': 0.35; 'from:addr:gmail.com': 0.35;
'received:209.85': 0.37; 'file': 0.38; 'received:209': 0.39;
'try': 0.40; 'true': 0.63; 'subject:get': 0.70; 'attribute': 0.84;
'messages,': 0.84; 'method,': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112; t=1679194197;
h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
:date:message-id:reply-to;
bh=dxFmLcN2BhmW/KuiXK+VDAVrkSLbXQRWkp32+yHOwKY=;
b=QInWpHE7yRwGdVrJjJosAk26NFmS8pRMU+4Rrh62dkqpzQF58qS3VP9LLQuS6y62qP
e+HdoyEDBg6lcPLCZkTdj4a2hsFKOGnkETojNAV5oNnPNMEySeuHw7Vad0yYJ/Kf0BKN
HpX2v2vkCJDnqDWu1qiNJov0OXPmCcZ/Ep3rgImoDgM5pzAHikd+XcKwGxwJsBa1xb6n
tvu5ODf038Ym4eDxwgUE6xOcFh+sb7n4oZ7AFyZwA37FrrxoCVP/ZX2dZa5+bIb3D32J
JpLUb/Z8BnE+QEgaUF2tFEBtTZ0As2KeoPr7ovis/QWBnj+zLTxsVawrq95Hyb73pV2A
VlJA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112; t=1679194197;
h=to:subject:message-id:date:from:mime-version:x-gm-message-state
:from:to:cc:subject:date:message-id:reply-to;
bh=dxFmLcN2BhmW/KuiXK+VDAVrkSLbXQRWkp32+yHOwKY=;
b=ZHMtW2raAwVyQXC1H9Gmdz91Es2g8GvQs6OwT0PXihZoXYeEhxSUrFNq6nr0GinERy
FMegzEiOvMNbJ1+7Oq2j9C889lYB5ORVI62tsPtoWBq7djWjkrsZEFu6csZW2+7vADh4
7kcUqHZzHIr7ga6u3mrMkoz42T41mBNYUEc/mLLlmaUYc6iMq6xCE+j8YBHnzUErEvPL
taTioIl8Arp9YepVkn86G3cXIZIRCc4I7tJeHA2C95rY8YHU0I91d5M0DcLhcwzltKr5
UhumgHGewe8TcJnS8I/SxSfzwjILFle2bg0+XMqQGn4zSQZZt/+LkXVaXOw58+xMOvH8
j3cw==
X-Gm-Message-State: AO0yUKXs+bFoRU/7NyutpYBQNyXMerh65a7L/LqUGKY5JgvF20vjXyAu
fKLpM2a53lJm3wC+TBmUWy0LunoqtHO/zqfwwUyeIErejqM=
X-Google-Smtp-Source: AK7set8gjck8WHHYE/IRsQLiYLDjDSOJsqVVsXrB2I9CoxN95Hm7TSScCj29uMy9mRPa6FyzFPAfzdWqnC0SqiSKG6I=
X-Received: by 2002:a05:6902:1886:b0:b69:bf76:2243 with SMTP id
cj6-20020a056902188600b00b69bf762243mr1049776ybb.3.1679194197244; Sat, 18 Mar
2023 19:49:57 -0700 (PDT)
X-Mailman-Approved-At: Sun, 19 Mar 2023 12:24:57 -0400
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
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: <https://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>
X-Mailman-Original-Message-ID: <CABrM6wkTfQXye9TtbE=8X4_po1CXMv_4kkmg_BQ=0VqzKWHOug@mail.gmail.com>
 by: Peng Yu - Sun, 19 Mar 2023 02:49 UTC

Hi,

https://docs.python.org/3/library/email.parser.html

It says "For MIME messages, the root object will return True from its
is_multipart() method, and the subparts can be accessed via the
payload manipulation methods, such as get_body(), iter_parts(), and
walk()."

But when I try the following code, get_body() is not found. How to get
get_body() to work?

$ python3 -c 'import email, sys; msg =
email.message_from_string(sys.stdin.read()); print(msg.get_body())'
<<< some_text
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'Message' object has no attribute 'get_body'

--
Regards,
Peng

Re: How to get get_body() to work? (about email)

<body-20230319174636@ram.dialup.fu-berlin.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=26928&group=comp.lang.python#26928

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!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 get get_body() to work? (about email)
Date: 19 Mar 2023 16:53:25 GMT
Organization: Stefan Ram
Lines: 33
Expires: 1 Apr 2024 11:59:58 GMT
Message-ID: <body-20230319174636@ram.dialup.fu-berlin.de>
References: <mailman.2379.1679243097.20444.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de AhwJlBCyM8hZ++y8weFT9wzbBzcsQoyaE09vRs28VqrVUz
X-Copyright: (C) Copyright 2023 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
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Sun, 19 Mar 2023 16:53 UTC

Peng Yu <pengyu.ut@gmail.com> writes:
>But when I try the following code, get_body() is not found. How to get
>get_body() to work?

Did you know that this post of mine here was posted to
Usenet with a Python script I wrote?

That Python script has a function to show the body of
a post before posting. The post is contained in a file,
so it reads the post from that file.

I copy it here, maybe it can help some people to see
how I do this.

# Python 3.5

import email

...

def showbody( file ): # lightly edited for posting on 2023-03-19
output = ''
msg = email.message_from_binary_file\
( file, policy=email.policy.default )
for part in msg.walk():
if part.get_content_maintype() == 'multipart':
continue
charset = part.get_content_charset()
if charset is not None:
output += part.get_content() + '\n'
print( '\n' + global_output )

Re: How to get get_body() to work? (about email)

<body-20230319175501@ram.dialup.fu-berlin.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=26929&group=comp.lang.python#26929

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!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 get get_body() to work? (about email)
Supersedes: <body-20230319174636@ram.dialup.fu-berlin.de>
Date: 19 Mar 2023 16:55:23 GMT
Organization: Stefan Ram
Lines: 37
Expires: 1 Apr 2024 11:59:58 GMT
Message-ID: <body-20230319175501@ram.dialup.fu-berlin.de>
References: <mailman.2379.1679243097.20444.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de rhkA9wnEQ1jOP4EFvZiQHQ8+2giYcFsjLfZryBtI67v8HS
X-Copyright: (C) Copyright 2023 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
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Sun, 19 Mar 2023 16:55 UTC

Supersedes: <body-20230319174636@ram.dialup.fu-berlin.de>
[Added "import email.policy"]

Peng Yu <pengyu.ut@gmail.com> writes:
>But when I try the following code, get_body() is not found. How to get
>get_body() to work?

Did you know that this post of mine here was posted to
Usenet with a Python script I wrote?

That Python script has a function to show the body of
a post before posting. The post is contained in a file,
so it reads the post from that file.

I copy it here, maybe it can help some people to see
how I do this.

# Python 3.5

import email
import email.policy

...

def showbody( file ): # lightly edited for posting on 2023-03-19
output = ''
msg = email.message_from_binary_file\
( file, policy=email.policy.default )
for part in msg.walk():
if part.get_content_maintype() == 'multipart':
continue
charset = part.get_content_charset()
if charset is not None:
output += part.get_content() + '\n'
print( '\n' + global_output )

Re: How to get get_body() to work? (about email)

<body-20230319180835@ram.dialup.fu-berlin.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=26930&group=comp.lang.python#26930

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!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 get get_body() to work? (about email)
Supersedes: <body-20230319175501@ram.dialup.fu-berlin.de>
Date: 19 Mar 2023 17:09:35 GMT
Organization: Stefan Ram
Lines: 40
Expires: 1 Apr 2024 11:59:58 GMT
Message-ID: <body-20230319180835@ram.dialup.fu-berlin.de>
References: <mailman.2379.1679243097.20444.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de ZsQYoW2Chaa0jxULXnRhwwLXE1dDLiK29kIiEiIQPUmMPI
X-Copyright: (C) Copyright 2023 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
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Sun, 19 Mar 2023 17:09 UTC

Supersedes: <body-20230319174636@ram.dialup.fu-berlin.de>
[Added "import email.policy"]

Supersedes: <body-20230319175501@ram.dialup.fu-berlin.de>
[changed "global_output" into "output"]

Peng Yu <pengyu.ut@gmail.com> writes:
>But when I try the following code, get_body() is not found. How to get
>get_body() to work?

Did you know that this post of mine here was posted to
Usenet with a Python script I wrote?

That Python script has a function to show the body of
a post before posting. The post is contained in a file,
so it reads the post from that file.

I copy it here, maybe it can help some people to see
how I do this.

# Python 3.5

import email
import email.policy

...

def showbody( file ): # lightly edited for posting on 2023-03-19
output = ''
msg = email.message_from_binary_file\
( file, policy=email.policy.default )
for part in msg.walk():
if part.get_content_maintype() == 'multipart':
continue
charset = part.get_content_charset()
if charset is not None:
output += part.get_content() + '\n'
print( '\n' + output )

Re: How to get get_body() to work? (about email)

<slrnu1eh2o.9qu1.jon+usenet@raven.unequivocal.eu>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=26931&group=comp.lang.python#26931

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: jon+usenet@unequivocal.eu (Jon Ribbens)
Newsgroups: comp.lang.python
Subject: Re: How to get get_body() to work? (about email)
Date: Sun, 19 Mar 2023 17:20:24 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <slrnu1eh2o.9qu1.jon+usenet@raven.unequivocal.eu>
References: <mailman.2379.1679243097.20444.python-list@python.org>
<body-20230319174636@ram.dialup.fu-berlin.de>
Injection-Date: Sun, 19 Mar 2023 17:20:24 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="26c9c208fb216ace83f9443297838363";
logging-data="3255752"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18piO0loIdi+361/t2Jhmuh8DkSb7GBTM0="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:HS1js1HecVfzu2dmKEb9/zJs950=
 by: Jon Ribbens - Sun, 19 Mar 2023 17:20 UTC

On 2023-03-19, Stefan Ram <ram@zedat.fu-berlin.de> wrote:
> Peng Yu <pengyu.ut@gmail.com> writes:
>>But when I try the following code, get_body() is not found. How to get
>>get_body() to work?
>
> Did you know that this post of mine here was posted to
> Usenet with a Python script I wrote?
>
> That Python script has a function to show the body of
> a post before posting. The post is contained in a file,
> so it reads the post from that file.
>
> I copy it here, maybe it can help some people to see
> how I do this.
>
> # Python 3.5
>
> import email
>
> ...
>
> def showbody( file ): # lightly edited for posting on 2023-03-19
> output = ''
> msg = email.message_from_binary_file\
> ( file, policy=email.policy.default )

I wouldn't generally be pedantic about code style, but that's giving me
painful convulsions. Backslashes for line continuations are generally
considered a bad idea (as they mean that any whitespace after the
backslash, which is often invisible, becomes significant). And not
indenting the continuation line(s) is pretty shocking. Writing it as
below is objectively better:

msg = email.message_from_binary_file(
file, policy=email.policy.default )

(Also, I too find it annoying to have to avoid, but calling a local
variable 'file' is somewhat suspect since it shadows the builtin.)

Re: How to get get_body() to work? (about email)

<file-20230319183003@ram.dialup.fu-berlin.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=26932&group=comp.lang.python#26932

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!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 get get_body() to work? (about email)
Date: 19 Mar 2023 17:30:51 GMT
Organization: Stefan Ram
Lines: 21
Expires: 1 Apr 2024 11:59:58 GMT
Message-ID: <file-20230319183003@ram.dialup.fu-berlin.de>
References: <mailman.2379.1679243097.20444.python-list@python.org> <body-20230319174636@ram.dialup.fu-berlin.de> <slrnu1eh2o.9qu1.jon+usenet@raven.unequivocal.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 9VN4ZuOA75JugW6vpo4a/w5pqtPDUwRTF4JjnToAG3lmGq
X-Copyright: (C) Copyright 2023 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
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Sun, 19 Mar 2023 17:30 UTC

Jon Ribbens <jon+usenet@unequivocal.eu> writes:
>(Also, I too find it annoying to have to avoid, but calling a local
>variable 'file' is somewhat suspect since it shadows the builtin.)

Thanks for your remarks, but I'm not aware
of such a predefined name "file"!

main.py

# Python 3.9

print( file )

sys.stderr

Traceback (most recent call last):
File "main.py", line 1, in <module>
print( file )
NameError: name 'file' is not defined

Re: How to get get_body() to work? (about email)

<slrnu1ejrp.9qu1.jon+usenet@raven.unequivocal.eu>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=26934&group=comp.lang.python#26934

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: jon+usenet@unequivocal.eu (Jon Ribbens)
Newsgroups: comp.lang.python
Subject: Re: How to get get_body() to work? (about email)
Date: Sun, 19 Mar 2023 18:07:53 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <slrnu1ejrp.9qu1.jon+usenet@raven.unequivocal.eu>
References: <mailman.2379.1679243097.20444.python-list@python.org>
<body-20230319174636@ram.dialup.fu-berlin.de>
<slrnu1eh2o.9qu1.jon+usenet@raven.unequivocal.eu>
<file-20230319183003@ram.dialup.fu-berlin.de>
Injection-Date: Sun, 19 Mar 2023 18:07:53 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="26c9c208fb216ace83f9443297838363";
logging-data="3272502"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX190iS/7qdp48wuAZBkozwyRSRTIpIfHUk8="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:wiYaxfGD1EQ2ZdufyP2ZLEvXVOw=
 by: Jon Ribbens - Sun, 19 Mar 2023 18:07 UTC

On 2023-03-19, Stefan Ram <ram@zedat.fu-berlin.de> wrote:
> Jon Ribbens <jon+usenet@unequivocal.eu> writes:
>>(Also, I too find it annoying to have to avoid, but calling a local
>>variable 'file' is somewhat suspect since it shadows the builtin.)
>
> Thanks for your remarks, but I'm not aware
> of such a predefined name "file"!

Ah, apparently it got removed in Python 3, which is a bit odd as the
last I heard it was added in Python 2.2 in order to achieve consistency
with other types.

Re: How to get get_body() to work? (about email)

<k7peteFn9jjU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=26935&group=comp.lang.python#26935

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: greg.ewing@canterbury.ac.nz (Greg Ewing)
Newsgroups: comp.lang.python
Subject: Re: How to get get_body() to work? (about email)
Date: Mon, 20 Mar 2023 10:59:03 +1300
Lines: 22
Message-ID: <k7peteFn9jjU1@mid.individual.net>
References: <mailman.2379.1679243097.20444.python-list@python.org>
<body-20230319174636@ram.dialup.fu-berlin.de>
<slrnu1eh2o.9qu1.jon+usenet@raven.unequivocal.eu>
<file-20230319183003@ram.dialup.fu-berlin.de>
<slrnu1ejrp.9qu1.jon+usenet@raven.unequivocal.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net lf/Pjgch3ZpXtBY8OfjPWAj2c/HxcLq4oOxay2VmRD1x1YeLgL
Cancel-Lock: sha1:mDA7hgmhMRKx83R9F4qNWtfrMaY=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:91.0)
Gecko/20100101 Thunderbird/91.3.2
Content-Language: en-US
In-Reply-To: <slrnu1ejrp.9qu1.jon+usenet@raven.unequivocal.eu>
 by: Greg Ewing - Sun, 19 Mar 2023 21:59 UTC

On 20/03/23 7:07 am, Jon Ribbens wrote:
> Ah, apparently it got removed in Python 3, which is a bit odd as the
> last I heard it was added in Python 2.2 in order to achieve consistency
> with other types.

As far as I remember, the file type came into existence
with type/class unification, and "open" became an alias
for the file type, so you could use open() and file()
interchangeably.

With the Unicode revolution in Python 3, file handling got
a lot more complicated. Rather than a single file type,
there are now a bunch of classes that handle low-level I/O,
encoding/decoding, etc, and open() is a function again
that builds the appropriate combination of underlying
objects.

--
Greg

Re: How to get get_body() to work? (about email)

<slrnu1gl4l.9qu1.jon+usenet@raven.unequivocal.eu>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=26937&group=comp.lang.python#26937

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: jon+usenet@unequivocal.eu (Jon Ribbens)
Newsgroups: comp.lang.python
Subject: Re: How to get get_body() to work? (about email)
Date: Mon, 20 Mar 2023 12:41:57 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <slrnu1gl4l.9qu1.jon+usenet@raven.unequivocal.eu>
References: <mailman.2379.1679243097.20444.python-list@python.org>
<body-20230319174636@ram.dialup.fu-berlin.de>
<slrnu1eh2o.9qu1.jon+usenet@raven.unequivocal.eu>
<file-20230319183003@ram.dialup.fu-berlin.de>
<slrnu1ejrp.9qu1.jon+usenet@raven.unequivocal.eu>
<k7peteFn9jjU1@mid.individual.net>
Injection-Date: Mon, 20 Mar 2023 12:41:57 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="4c209b41848f9efbae40716ee75a71f9";
logging-data="3715741"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+aj2qQwRHE7QodVE9Fhhn26EN/UEKY0/c="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:6yZmb5jk4Ft4HrVOnbb2IMicELY=
 by: Jon Ribbens - Mon, 20 Mar 2023 12:41 UTC

On 2023-03-19, Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
> On 20/03/23 7:07 am, Jon Ribbens wrote:
>> Ah, apparently it got removed in Python 3, which is a bit odd as the
>> last I heard it was added in Python 2.2 in order to achieve consistency
>> with other types.
>
> As far as I remember, the file type came into existence
> with type/class unification, and "open" became an alias
> for the file type, so you could use open() and file()
> interchangeably.
>
> With the Unicode revolution in Python 3, file handling got
> a lot more complicated. Rather than a single file type,
> there are now a bunch of classes that handle low-level I/O,
> encoding/decoding, etc, and open() is a function again
> that builds the appropriate combination of underlying
> objects.

This is true, however there does exist a base class which, according to
the documentation, underlies all of the different IO classes - IOBase -
so it might have been neater to make 'file' be an alias for that.


devel / comp.lang.python / Re: How to get get_body() to work? (about email)

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor