On 9/28/20 8:09 AM, Markus Armbruster wrote:
Eric Blake writes:
On 9/25/20 8:52 AM, Markus Armbruster wrote:
This was my best attempt to open the file read/write, creating it if it
doesn't exist.
Plain
f = open(pathname, "r+", encoding='utf-8')
fails instead of creates, and
Eric Blake writes:
> On 9/25/20 8:52 AM, Markus Armbruster wrote:
>
This was my best attempt to open the file read/write, creating it if it
doesn't exist.
Plain
f = open(pathname, "r+", encoding='utf-8')
fails instead of creates, and
On 9/25/20 9:26 AM, Eduardo Habkost wrote:
On Fri, Sep 25, 2020 at 03:15:57PM +0200, Markus Armbruster wrote:
Cleber Rosa writes:
On Wed, Sep 23, 2020 at 02:37:27PM -0400, John Snow wrote:
On 9/23/20 11:26 AM, Eduardo Habkost wrote:
On Tue, Sep 22, 2020 at 05:00:51PM -0400, John Snow wrote:
On 9/25/20 8:52 AM, Markus Armbruster wrote:
This was my best attempt to open the file read/write, creating it if it
doesn't exist.
Plain
f = open(pathname, "r+", encoding='utf-8')
fails instead of creates, and
f = open(pathname, "w+", encoding='utf-8')
truncates.
If you
Daniel P. Berrangé writes:
> On Fri, Sep 25, 2020 at 03:15:57PM +0200, Markus Armbruster wrote:
>> Cleber Rosa writes:
>>
>> > On Wed, Sep 23, 2020 at 02:37:27PM -0400, John Snow wrote:
>> >> On 9/23/20 11:26 AM, Eduardo Habkost wrote:
>> >> > On Tue, Sep 22, 2020 at 05:00:51PM -0400, John Snow
On 9/25/20 8:24 AM, Daniel P. Berrangé wrote:
This code:
fd = os.open(pathname, os.O_RDWR | os.O_CREAT, 0o666)
f = open(fd, 'r+', encoding='utf-8')
This was my best attempt to open the file read/write, creating it if it
doesn't exist.
Plain
f = open(pathname, "r
On Fri, Sep 25, 2020 at 03:15:57PM +0200, Markus Armbruster wrote:
> Cleber Rosa writes:
>
> > On Wed, Sep 23, 2020 at 02:37:27PM -0400, John Snow wrote:
> >> On 9/23/20 11:26 AM, Eduardo Habkost wrote:
> >> > On Tue, Sep 22, 2020 at 05:00:51PM -0400, John Snow wrote:
> >> > > Make the file handl
On Fri, Sep 25, 2020 at 03:15:57PM +0200, Markus Armbruster wrote:
> Cleber Rosa writes:
>
> > On Wed, Sep 23, 2020 at 02:37:27PM -0400, John Snow wrote:
> >> On 9/23/20 11:26 AM, Eduardo Habkost wrote:
> >> > On Tue, Sep 22, 2020 at 05:00:51PM -0400, John Snow wrote:
> >> > > Make the file handl
Cleber Rosa writes:
> On Wed, Sep 23, 2020 at 02:37:27PM -0400, John Snow wrote:
>> On 9/23/20 11:26 AM, Eduardo Habkost wrote:
>> > On Tue, Sep 22, 2020 at 05:00:51PM -0400, John Snow wrote:
>> > > Make the file handling here just a tiny bit more idiomatic.
>> > > (I realize this is heavily subj
On Tue, Sep 22, 2020 at 05:00:51PM -0400, John Snow wrote:
> Make the file handling here just a tiny bit more idiomatic.
> (I realize this is heavily subjective.)
>
> Use exist_ok=True for os.makedirs and remove the exception,
> use fdopen() to wrap the file descriptor in a File-like object,
> and
On Wed, Sep 23, 2020 at 02:37:27PM -0400, John Snow wrote:
> On 9/23/20 11:26 AM, Eduardo Habkost wrote:
> > On Tue, Sep 22, 2020 at 05:00:51PM -0400, John Snow wrote:
> > > Make the file handling here just a tiny bit more idiomatic.
> > > (I realize this is heavily subjective.)
> > >
> > > Use ex
On 9/23/20 11:26 AM, Eduardo Habkost wrote:
On Tue, Sep 22, 2020 at 05:00:51PM -0400, John Snow wrote:
Make the file handling here just a tiny bit more idiomatic.
(I realize this is heavily subjective.)
Use exist_ok=True for os.makedirs and remove the exception,
use fdopen() to wrap the file de
On Tue, Sep 22, 2020 at 05:00:51PM -0400, John Snow wrote:
> Make the file handling here just a tiny bit more idiomatic.
> (I realize this is heavily subjective.)
>
> Use exist_ok=True for os.makedirs and remove the exception,
> use fdopen() to wrap the file descriptor in a File-like object,
> and
Make the file handling here just a tiny bit more idiomatic.
(I realize this is heavily subjective.)
Use exist_ok=True for os.makedirs and remove the exception,
use fdopen() to wrap the file descriptor in a File-like object,
and use a context manager for managing the file pointer.
Signed-off-by: J
14 matches
Mail list logo