[Python-3000-checkins] r56940 - in python/branches/py3k: Demo/scripts/newslist.py Demo/scripts/pp.py Doc/dist/dist.tex Doc/howto/doanddont.tex Doc/lib/libdoctest.tex Doc/lib/libexcs.tex Doc/lib/libfuncs.tex Doc/lib/libuser.tex Doc/ref/ref4.tex Do

Guido van Rossum guido at python.org
Mon Aug 13 04:50:33 CEST 2007


if you read carefully the io module exports several classes that can
be thought of as ABCs: IOBase, RawIOBase, BufferedIOBase, TextIOBase.
All that's lacking in these is an abstract method or two. My intent is
to add these (if it doesn't cause circularities at boot time).

I'm torn about whether exec() should take a stream. OTOH it's what 2.x
did. OTOH appending .read() isn't so bad (unless it's an interactive
stream, and I'm not sure I care about that use case).

--Guido

On 8/12/07, Georg Brandl <g.brandl at gmx.net> wrote:
> Neal Norwitz schrieb:
> > On 8/12/07, Georg Brandl <g.brandl at gmx.net> wrote:
> >> neal.norwitz schrieb:
> >> > Author: neal.norwitz
> >> > Date: Sun Aug 12 02:43:29 2007
> >> > New Revision: 56940
> >>
> >> > Log:
> >> > Kill execfile(), use exec() instead
> >>
> >> > Modified: python/branches/py3k/Demo/scripts/newslist.py
> >> > =======================================
> >> > --- python/branches/py3k/Demo/scripts/newslist.py     (original)
> >> > +++ python/branches/py3k/Demo/scripts/newslist.py     Sun Aug 12 02:43:29 2007
> >> > @@ -99,7 +99,7 @@
> >> > rcfile = os.path.join(dir, '.newslistrc.py')
> >> > if os.path.exists(rcfile):
> >> > print(rcfile)
> >> > - execfile(rcfile)
> >> > + exec(open(rcfile).read())
> >> > break
> >>
> >> Doesn't exec() support file objects directly?
> >
> > Hmmm, is it supposed to?  Seems like a fine interface and I see that
> > the doc mentions it as well as the error message.  But it doesn't
> > work.
> >
> >>>> exec(open('nn.py'))
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in <module>
> > TypeError: exec() arg 1 must be a string, file, or code object, not
> > TextIOWrapper
>
> The problem seems to be how to recognize a "file" object.  ABCs, anyone?
>
> Georg
>
>
> --
> Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
> Four shall be the number of spaces thou shalt indent, and the number of thy
> indenting shall be four. Eight shalt thou not indent, nor either indent thou
> two, excepting that thou then proceed to four. Tabs are right out.
>
> _______________________________________________
> Python-3000-checkins mailing list
> Python-3000-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-3000-checkins
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000-checkins mailing list