Le 15/06/2014 05:15, Steve Dower a écrit : > So is exec(tokenize.open(file).read()) the actual replacement for > execfile()? Not too bad, but still not obvious (or widely promoted - I'd > never heard of it). > Another way is to open the file in binary, then exec() checks itself if an encoding is defined in the file. This is what is used in spyder: exec(open(file, 'rb').read()) Here is the discussion for reference: https://bitbucket.org/spyder-ide/spyderlib/pull-request/3/execution-on-current-spyder-interpreter/diff This behavior is not indicated in the documentation but is somehow confirmed on stackoverflow: http://stackoverflow.com/questions/6357361/alternative-to-execfile-in-python-3-2/6357418?noredirect=1#comment30467918_6357418 --- Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce que la protection avast! Antivirus est active. http://www.avast.com
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4