Ask your own question, for FREE!
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW) 13 Online
OpenStudy (anonymous):

anyone try to get the oldmaid code to work? it was given in chaps 15 and 16. to play it says, import cards. but idle doesn't know what that means. anyone know the correct way to call this program to action?

OpenStudy (anonymous):

The python file cards must be in the main folder/source folder.

OpenStudy (anonymous):

Great. do you know where to find this file? i appreciate the help!

OpenStudy (anonymous):

i.e. it should be sourced to .../python33/... instead of the desktop and elsewhere if you're using the IDLE

OpenStudy (anonymous):

OK. so split the 'cards' coding from the oldmaidgame code and then importing cards worked. but now i get CardGame not defined. CardGame is a class in cards. hmmm. any thoughts? much appreciated.

OpenStudy (anonymous):

you might need to call cards.CardGame.

OpenStudy (anonymous):

if you don't want to add that troublesome cards. prefix, just do from cards import * to import all the classes and functions.

OpenStudy (anonymous):

wow, thought that was it. tried both import and cards. and both times got CardGame not defined. but this is CardGame in cards class CardGame: just like in chapter 16. doesn't make sense.

OpenStudy (anonymous):

may i get the link and code? if there is a CardGame class in the cards file, then importing it and calling (cards.Cardgame) should do it.

OpenStudy (anonymous):

sure. how do i post it? github?

OpenStudy (anonymous):

your choice. git hub is fine

OpenStudy (anonymous):

here is the github link https://gist.github.com/4645924 thank you for taking the time.

OpenStudy (anonymous):

no worries :P I'm just interested. python 2.7, i take it?

OpenStudy (anonymous):

yes. in the course the told us to use this version

OpenStudy (anonymous):

you have two OldMaidHands. but this should work. http://dpaste.com/892967/

OpenStudy (anonymous):

I see what you did. makes sense. i'm getting no module named cards. just checked the directory. both files cards and OldMaidGame (yours and mine) are in the python26 directory on the local disc.

OpenStudy (anonymous):

ah. i just changed to do import first and calling the OldMaidGame from OldMaidGame it self

OpenStudy (anonymous):

right. importing * so don't need cards.

OpenStudy (anonymous):

feel like letting this one go. something's not right.

OpenStudy (anonymous):

import * means import everything in cards. though running it gives an almost infinite loop of them exchanging cards....

OpenStudy (anonymous):

I copied your link and tried running it and got the no module named cards note i figured the from cards import * would take in all classes from cards. but it is asking for the cards module. maybe i should put the file cards in the oldmaidgame file before the oldmaidgame class.

OpenStudy (anonymous):

it works fine with mine though....maybe IDLE crashed?

OpenStudy (anonymous):

ok. maybe i'll reboot. this is nuts. appreciate the help very much. thanks.

OpenStudy (anonymous):

lol you're welcome. :)

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!