Skip to content

Commit ebb1065

Browse files
author
Bob Farrell
committed
PYTHONSTARTUP actually works now.
I didn't have a chance to test the code I put in before committing but I gave it a test run now, it seems to work fine. committer: Bob Farrell <bob@keys.(none)>
1 parent 7910094 commit ebb1065

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎bpython.py‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,6 @@
4444
import ConfigParser
4545
from bpython.formatter import BPythonFormatter
4646

47-
# XXX I don't ever use this feature so I'm hoping someone can
48-
# test it for me; as you can see it is simple enough, taken
49-
# directly from:
50-
# http://docs.python.org/tut/node4.html#startup
51-
# Let me know if it breaks
52-
filename = os.environ.get('PYTHONSTARTUP')
53-
if filename and os.path.isfile(filename):
54-
execfile(filename)
55-
##################################################
56-
5747
class Dummy( object ):
5848
pass
5949
OPTS = Dummy()
@@ -210,6 +200,7 @@ def __init__( self, scr, interp, statusbar=None, idle=None):
210200
self.argspec = None
211201
self.tablen = None
212202
self.s = ''
203+
213204

214205
if not OPTS.argspec:
215206
return
@@ -714,6 +705,15 @@ def repl( self ):
714705
entered for using up/down to go back and forth (which has to be separate
715706
to the evaluation history, which will be truncated when undoing."""
716707

708+
# This was a feature request to have the PYTHONSTARTUP
709+
# file executed on startup - I personally don't use this
710+
# feature so please notify me of any breakage.
711+
filename = os.environ.get('PYTHONSTARTUP')
712+
if filename and os.path.isfile(filename):
713+
for line in open(filename, 'r'):
714+
self.push( line )
715+
self.push( '\n' )
716+
717717
self.iy, self.ix = self.scr.getyx()
718718
more = False
719719
while not self.do_exit:

0 commit comments

Comments
 (0)