Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 20 Online
OpenStudy (anonymous):

I am trying Problem Set 5, but the given code to import a wordlist is not working, I keep getting this error: inFile = open(WORDLIST_FILENAME, 'r', 0) ValueError: can't have unbuffered text I/O

OpenStudy (shriram):

i just googled the error http://mail.python.org/pipermail/python-dev/2008-December/084436.html has some information

OpenStudy (anonymous):

ok it looks like you need to pass in some new arguements, I've looked up python 3 docs (you said via chat you were using python 3, its important for all people answering) http://docs.python.org/py3k/library/functions.html?highlight=open#open try either inFile = open(WORDLIST_FILENAME, 'rb', 0) OR inFile = open(WORDLIST_FILENAME, 'r', 1)

OpenStudy (anonymous):

Thanks the inFile = open(WORDLIST_FILENAME, 'r', 1) works.

OpenStudy (anonymous):

Yeah, for this course it's recommended you use python 2.7 to avoid these issues with the code provided for the class.

OpenStudy (anonymous):

im on ps 5 too and is it just me or does this seem near impossible for a beginner? this one is definitely going to take awhile

OpenStudy (anonymous):

ps5 is not that hard, i found ps6 much more difficult to deal with, ps5 looks like a cake walk compared to ps6, as i was finishing ps6 i had no idea what I'd done. They ask you to go back and change your code a pile of times, creating new functions, new libraries, i had no idea what was pointing to what by the end, and I'm never looking back. it would be much easier to scrap the entire program and rewrite it, its super confusing

OpenStudy (anonymous):

sounds terrible lol, what lecture did you get through before you did that problem? 10?

OpenStudy (anonymous):

btw im starting to figure out ps5, got the first 2 problems done

OpenStudy (anonymous):

yea, ps5 is fairly strait forward, and yea lecture 10, i more or less limit my lectures to my current assignment

OpenStudy (anonymous):

what im not understanding on ps5 is how does the application actually start? I dont see how this is printed to the screen: Loading word list from file... 83667 words loaded. Enter n to deal a new hand, r to replay the last hand, or e to end game: All the code is in functions and im not calling any functions in the shell to start this so where in the code is it telling a function to start automatically?

OpenStudy (anonymous):

You're running a different module that loads in your module to do some tasks.

OpenStudy (anonymous):

yeah i know that but how does it start? where in the code does it say do this function first

OpenStudy (anonymous):

look at the bottom, if __name__ == '__main__': word_list = load_words() play_game(word_list) or something to that effect

OpenStudy (anonymous):

Code is run in order. Typically you will just have an if (like the one above) that will set things up and offload things to another function(s).

OpenStudy (anonymous):

You have to watch the lecture series, and see where that lines up with you problem set, it is not one set per assignment. And then it gets easier.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!