Skip to content

Add '.py' extension when not specified when saving, and appending to file when saving #239

@ikanobori

Description

@ikanobori

Personally, I would want bpython to add the '.py' to the filename when I save a file. Adding the following lines in the write2file method in repl.py:

#!python

if not fn.endswith('.py')
    fn += '.py'

works for me, I don't know if that would cause any adverse reactions in other situations.
I've also changed the line:

#!python

f = open(fn, 'w')

in the same method to:

#!python

f = open(fn, 'a')

so that a file is not overwritten when saving to it, it is merely appended to.

These would probably be better suited as options rather than the default behavior, but I think it's useful functionality nonetheless.


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions