<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Thanks Alan Gauld for your help. After taking a little break and coming back it all seemed to make sense...i understand why there is gonna be some really weird outputs to the interchanging of the player1.py files...that really could get interesting LOL...I seemed to have got the program running good<BR> <BR>now i have only a few pretty simple questions, If you have the GetBet in the player1.py file you have to pass in the total value right?...that is the only way to get the total into the function? the professor told us straight out that he doesnt really know what he is doing...he wanted us to put in (currentBet, previousBet, and win/lose). I think it only makes sense if you put in the total value in as prevousBet. also he wanted us to pass in (player_hand, dealer_hand) in as parameters for the HitStand function...why would we want to total the hand more than once if we already have the total value? wouldn't we want to just pass in those values instead of the hand itself?<br> <BR>Im starting to think im not really learning anything from this class...if anything its just confusing me and teaching me the wrong way to go about things<BR> <BR>thanks again for your help :)<BR><div><div id="SkyDrivePlaceholder"></div>> To: tutor@python.org<br>> From: alan.gauld@btinternet.com<br>> Date: Wed, 24 Oct 2012 01:23:30 +0100<br>> Subject: Re: [Tutor] blackJack problem<br>> <br>> On 24/10/12 01:00, Matthew D wrote:<br>> <br>> >  > > I thought by having a value outside<br>> >  > > of the functions made the value global.<br>> >  ><br>> > ok...is there an easier way to write this? the reason i was calling that<br>> > global value the same as the currentBet is because i need to add that<br>> > value to 5...<br>> <br>> You need to read about global variables and namespaces in Python.<br>> <br>> But using a global name as a parameter name will not make the function <br>> use the global name as the first parameter, in fact the opposite will <br>> happen in that the parameter will hide the global value.<br>> <br>> If you want to pass the global value into your function then call it <br>> with the global name as the first argument. If you want to change the <br>> global value from your function then you need to declare the name global <br>> inside your function:<br>> <br>> ##########<br>> readMe = 42   # global var we will read<br>> changeMe=666  # global valuer we will change<br>> <br>> def foo(param1):<br>>      print param1<br>>      print readMe    # accesses the global value<br>> <br>> def bar():<br>>     global changeMe   # use global value rather than local<br>>     print 'old: ', changeMe<br>>     changeMe = 99<br>>     print 'new: ', changeMe<br>> <br>> print readMe, changeMe   # print original values<br>> <br>> foo(readMe)  #prints 42 twice, once as param1, once as global value<br>> <br>> bar()   # prints old and new values<br>> <br>> print readMe, changeMe    # print after values<br>> <br>> ##################<br>> <br>> > l...still cant get even a slight idea as of what should work<br>> <br>> Try the above and variations. If you are still stuck ask here for more <br>> detail.<br>> <br>> You can also try reading the "Whats in a Name?" topic of my tutorial for <br>> a different explanation.<br>> <br>> >  > > peoples "player1.py" files on my game.<br>> >  ><br>> >  > Interesting concept. And if the other peoples files are calling your<br>> >  > functions with values in those parameters you will just ignore them I<br>> >  > presume? Hmmm, that should produce some interesting results...<br>> > it should work in theory correct?<br>> <br>> No, in theory users will get unpredictable results since other people <br>> will assume that the values they pass into your functions will influence <br>> the result. They will not expect you to ignore them and apply some <br>> totally arbitrary values of your own. The theory is that the parameters <br>> in a function control the behaviour, not act as simply placeholders for <br>> random data. If your teacher wants the function to have certain <br>> parameters I suspect he wants you to use them in your function!<br>> <br>> -- <br>> Alan G<br>> Author of the Learn to Program web site<br>> http://www.alan-g.me.uk/<br>> <br>> _______________________________________________<br>> Tutor maillist  -  Tutor@python.org<br>> To unsubscribe or change subscription options:<br>> http://mail.python.org/mailman/listinfo/tutor<br></div>                                         </div></body>
</html>