Neal Norwitz schrieb:
> On 8/12/07, Georg Brandl <[EMAIL PROTECTED]> 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
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to