NameError: name 'execfile' is not defined
Newbie issue: I downloaded http://www.python.org/download/releases/3.0.1/ (windows insaller), opened the interpreter, wrote a print "Hello World" program in helloworld.py, and in the interpreter typed execfile("helloworld.py") Got back NameError: name 'execfile' is not defined (following tutorial in David Beazley's Python Essential Reference). Is execfile not supported in 3? Thanks, - Henrik -- http://mail.python.org/mailman/listinfo/python-list
Invalid syntax with print "Hello World"
obviously total mewbiew: My first program in Python Windows print "Hello World" I select Run/Run Module and get an error: Syntax error, with the closing quote highlighted. Tried with single quotes as well. Same problem. Can someone explain my mistake? Thanks, - Henrik -- http://mail.python.org/mailman/listinfo/python-list
Re: Invalid syntax with print "Hello World"
On Mar 12, 7:45 am, Dotan Cohen wrote: > > Welcome to the list. As a newbie myself, I ran into the Python3 vrs > > 2.6 issue. May I suggest starting with 2.6? There is many more books > > and internet stuff you can learn with in 2.6 - and the examples will > > work. As Garry wrote, once you understand 2.6, 3.0 will not be a > > challenge. > > I do not think that is the best way to go about learning Python. Why > learn an arguably depreciating version when the new version is > available. I agree that there are not many tutorial written for Python > 3 however there are enough to get going: most of the Python 2 > tutorials are redundant. Sticking to Python 3 tutorials will give him > a higher signal-to-noise ratio in the tutorials that he finds. > > -- > Dotan Cohen > > http://what-is-what.comhttp://gibberish.co.il > > א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת > ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه-و-ي > А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я > а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я > ä-ö-ü-ß-Ä-Ö-Ü Thanks everyone! Now that I know what the issue is (2 vs 3), I'll be able to resolve those kinds of issues in the future. Thanks again! - Henrik -- http://mail.python.org/mailman/listinfo/python-list
Re: NameError: name 'execfile' is not defined
On Mar 12, 3:15 am, Gary Herron wrote: > Henrik Bechmann wrote: > > Newbie issue: > > > I downloadedhttp://www.python.org/download/releases/3.0.1/(windows > > insaller), opened the interpreter, wrote a print "Hello World" program > > in helloworld.py, and in the interpreter typed > > > execfile("helloworld.py") > > > Got back > > > NameError: name 'execfile' is not defined > > > (following tutorial in David Beazley's Python Essential Reference). > > > Is execfile not supported in 3? > > That's correct. > > Fromhttp://docs.python.org/dev/3.0/whatsnew/3.0.htmlyou can find this > line: > > Removed execfile(). Instead of execfile(fn) use exec(open(fn).read()). > > Gary Herron > > > Thanks, > > > - Henrik > > -- > >http://mail.python.org/mailman/listinfo/python-list Excellent. Thanks very much! - Henrik -- http://mail.python.org/mailman/listinfo/python-list