1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
|
{
"metadata": {
"name": "ch10"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Chapter 10 : Inheritance and Polymorphism: Blackjack"
]
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"example 10.1 page no: 334"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"'''\n",
"//Simple Boss\n",
"//Demonstrates inheritance\n",
"'''\n",
"\n",
"class Enemy:\n",
" def __init__(self):\n",
" self.m_Damage = 10\n",
"\n",
" def Attack(self):\n",
" print \"An enemy attacks and inflicts \" , self.m_Damage , \" damage points!\";\n",
" \n",
" def __del__(self):\n",
" print \"In Enemy destructor, deleting m_pDamage.\\n\";\n",
"\n",
"class Boss(Enemy):\n",
" def __init__(self):\n",
" Enemy.__init__(self)\n",
" self.m_DamageMultiplier = 3\n",
"\n",
" def SpecialAttack(self):\n",
" print \"A boss attacks and inflicts \" , (self.m_DamageMultiplier * self.m_Damage),\n",
" print \" damage points!\";\n",
"\n",
"print \"Creating an enemy.\\n\";\n",
"enemy1 = Enemy()\n",
"enemy1.Attack();\n",
"print \"\\nCreating a boss.\\n\";\n",
"boss1 = Boss()\n",
"boss1.Attack();\n",
"boss1.SpecialAttack();"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Creating an enemy.\n",
"\n",
"An enemy attacks and inflicts 10 damage points!\n",
"\n",
"Creating a boss.\n",
"\n",
"An enemy attacks and inflicts 10 damage points!\n",
"A boss attacks and inflicts 30 damage points!\n"
]
}
],
"prompt_number": 1
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"example 10.2 page no : 338"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"'''\n",
"//Simple Boss 2.0\n",
"//Demonstrates access control under inheritance\n",
"'''\n",
"\n",
"\n",
"class Enemy:\n",
" def __init__(self):\n",
" self.m_Damage = 10\n",
"\n",
" def Attack(self):\n",
" print \"Attack inflicts \" , self.m_Damage , \" damage points!\";\n",
"\n",
"class Boss(Enemy):\n",
" def __init__(self):\n",
" Enemy.__init__(self)\n",
" self.m_DamageMultiplier = 3\n",
"\n",
" def SpecialAttack(self):\n",
" print \"Special Attack inflicts \" , (self.m_DamageMultiplier * self.m_Damage),\n",
" print \" damage points!\";\n",
"\n",
"print \"Creating an enemy.\\n\";\n",
"enemy1 = Enemy()\n",
"enemy1.Attack();\n",
"print \"\\nCreating a boss.\\n\";\n",
"boss1 = Boss()\n",
"boss1.Attack();\n",
"boss1.SpecialAttack();"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Creating an enemy.\n",
"\n",
"Attack inflicts 10 damage points!\n",
"\n",
"Creating a boss.\n",
"\n",
"Attack inflicts 10 damage points!\n",
"Special Attack inflicts 30 damage points!\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"example 10.3 page no : 343"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"'''\n",
"//Overriding Boss\n",
"//Demonstrates calling and overriding base member functions\n",
"'''\n",
"class Enemy:\n",
" def __init__(self,d=10):\n",
" self.m_Damage = d\n",
"\n",
" def Attack(self):\n",
" print \"Attack inflicts \" , self.m_Damage , \" damage points!\";\n",
"\n",
" def Taunt(self):\n",
" print \"The enemy says he will fight you.\";\n",
" __Attack = Attack \n",
"\n",
"\n",
"class Boss(Enemy):\n",
" def __init__(self,d=30):\n",
" Enemy.__init__(self)\n",
" self.m_DamageMultiplier = d\n",
"\n",
" def SpecialAttack(self):\n",
" print \"Special Attack inflicts \" , (self.m_DamageMultiplier * self.m_Damage),\n",
" print \" damage points!\";\n",
"\n",
" def Taunt(self): #override base class member function\n",
" print \"The boss says he will end your pitiful existence.\"\n",
"\n",
" def Attack(self): #override base class member function\n",
" #call base class member function\n",
" Enemy.Attack(self)\n",
" print \" And laughs heartily at you.\\n\";\n",
"\n",
"\n",
"print \"Enemy object :\";\n",
"enemy1 = Enemy()\n",
"enemy1.Taunt()\n",
"enemy1.Attack();\n",
"print \"\\n boss object.\\n\";\n",
"boss1 = Boss()\n",
"boss1.Taunt()\n",
"boss1.Attack();\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Enemy object :\n",
"The enemy says he will fight you.\n",
"Attack inflicts 10 damage points!\n",
"\n",
" boss object.\n",
"\n",
"The boss says he will end your pitiful existence.\n",
"Attack inflicts 10 damage points!\n",
" And laughs heartily at you.\n",
"\n"
]
}
],
"prompt_number": 3
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"example 10.4 page no : 341,348"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"'''\n",
"//Polymorphic Bad Guy\n",
"//Demonstrates calling member functions dynamically\n",
"'''\n",
"\n",
"class Enemy:\n",
" def __init__(self,d=10):\n",
" self.m_Damage = d\n",
"\n",
" def Attack(self):\n",
" print \"Attack inflicts \" , self.m_Damage , \" damage points!\";\n",
"\n",
" def __del__(self):\n",
" print \"In Enemy destructor, deleting m_pDamage.\";\n",
" \n",
"class Boss(Enemy):\n",
" def __init__(self,d=30):\n",
" Enemy.__init__(self)\n",
" self.m_DamageMultiplier = d\n",
"\n",
" def SpecialAttack(self):\n",
" print \"Special Attack inflicts \" , (self.m_DamageMultiplier * self.m_Damage),\n",
" print \" damage points!\";\n",
"\n",
" def Taunt(self): #override base class member function\n",
" print \"The boss says he will end your pitiful existence.\"\n",
"\n",
" def Attack(self): #override base class member function\n",
" #call base class member function\n",
" Enemy.Attack(self)\n",
" print \" And laughs heartily at you.\\n\";\n",
"\n",
" def __del__(self):\n",
" Enemy.__del__(self)\n",
" print \"In Boss destructor, deleting m_pMultiplier.\";\n",
" self.m_pMultiplier = 0;\n",
"\n",
"print \"Calling Attack() on Boss object through pointer to Enemy:\"\n",
"pBadGuy = Boss();\n",
"pBadGuy.Attack();\n",
"print \"\\nDeleting pointer to Enemy:\\n\";\n",
"pBadGuy = 0;"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Calling Attack() on Boss object through pointer to Enemy:\n",
"Attack inflicts 10 damage points!\n",
" And laughs heartily at you.\n",
"\n",
"\n",
"Deleting pointer to Enemy:\n",
"\n",
"In Enemy destructor, deleting m_pDamage.\n",
"In Boss destructor, deleting m_pMultiplier.\n"
]
}
],
"prompt_number": 4
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"example 10.5 page no : 353"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"'''\n",
"//Abstract Creature\n",
"//Demonstrates abstract classes\n",
"'''\n",
"class Creature :\n",
" def __init__(self,h=100):\n",
" self.m_Health = h\n",
" \n",
" def Greet(self): # pure virtual member function\n",
" pass\n",
"\n",
" def DisplayHealth(self):\n",
" print \"Health: \" , self.m_Health\n",
"\n",
"\n",
"class Orc(Creature):\n",
" def __init__(self,h=120):\n",
" Creature.__init__(self,h)\n",
"\n",
" def Greet(self):\n",
" print \"The orc grunts hello.\\n\";\n",
"\n",
"pCreature = Orc();\n",
"pCreature.Greet();\n",
"pCreature.DisplayHealth();"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"The orc grunts hello.\n",
"\n",
"Health: 120\n"
]
}
],
"prompt_number": 5
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"example 10.6, page no : 361-379"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"'''\n",
"defining game class.\n",
"Note : this would give error as we have not initialized player class here.\n",
"'''\n",
"\n",
"ACE = 1\n",
"TWO = 2\n",
"THREE = 3\n",
"FOUR = 4\n",
"FIVE = 5\n",
"SIX = 6\n",
"SEVEN = 7\n",
"EIGHT = 8\n",
"NINE = 9\n",
"TEN = 10\n",
"JACK = 11\n",
"QUEEN = 12\n",
"KING = 13\n",
"\n",
"CLUBS = 0\n",
"DIAMONDS = 1\n",
"HEARTS = 2\n",
"SPADES = 3\n",
"\n",
" \n",
"class Card:\n",
" def __init__(self,r = ACE,s = SPADES,ifu = True): #returns the value of a card, 1 - 11\n",
" self.m_Rank = r\n",
" self.m_Suit = s\n",
" self.m_IsFaceUp =ifu\n",
"\n",
" def GetValue(self):\n",
" #if a cards is face down, its value is 0\n",
" value = 0;\n",
" if (m_IsFaceUp):\n",
" #value is number showing on card\n",
" value = m_Rank;\n",
" #value is 10 for face cards\n",
" if (value > 10):\n",
" value = 10;\n",
" return value;\n",
"\n",
" def Flip(self):\n",
" self.m_IsFaceUp = not (m_IsFaceUp);\n",
"\n",
"class Hand:\n",
" def __init__(self):\n",
" self.m_Cards = []\n",
"\n",
" def __del__(self):\n",
" self.Clear() \n",
"\n",
" def Add(self,pCard):\n",
" self.m_Cards.append(pCard);\n",
"\n",
" def Clear(self):\n",
" #iterate through vector, freeing all memory on the heap\n",
" self.m_Cards = []\n",
"\n",
" def GetTotal(self):\n",
" #if no cards in hand, return 0\n",
" if (self.m_Cards.empty()):\n",
" return 0;\n",
" #if a first card has value of 0, then card is face down; return 0\n",
" if (m_Cards[0].GetValue() == 0):\n",
" return 0;\n",
" #add up card values, treat each ace as 1\n",
" total = 0;\n",
" for i in self.m_Cards:\n",
" total += i.GetValue()\n",
" #determine if hand contains an ace\n",
" containsAce = False;\n",
" for i in self.m_Cards:\n",
" if i.GetValue() == Card.ACE:\n",
" containsAce = True;\n",
"\n",
" #if hand contains ace and total is low enough, treat ace as 11\n",
" if (containsAce and total <= 11):\n",
" #add only 10 since we've already added 1 for the ace\n",
" total += 10;\n",
" return total;\n",
"\n",
"\n",
"class GenericPlayer(Hand):\n",
" def __init__(self,name):\n",
" self.m_Name = name\n",
"\n",
" def __del__(self):\n",
" pass\n",
"\n",
" def IsBusted(self):\n",
" return (self.GetTotal() > 21);\n",
"\n",
" def Bust(self):\n",
" print self.m_Name , \" busts.\";\n",
"\n",
"class Player(GenericPlayer):\n",
" def _init_(self,name):\n",
" GenericPlayer.__init__(self,name)\n",
" \n",
" def _del_(self):\n",
" pass\n",
"\n",
" def IsHitting(self):\n",
" print self.m_Name , \", do you want a hit? (Y/N): \",\n",
" response = raw_input()\n",
" return (response == 'y' or response == 'Y');\n",
"\n",
" def Win(self):\n",
" print self.m_Name , \" wins.\";\n",
"\n",
" def Lose(self):\n",
" print self.m_Name , \" loses.\";\n",
"\n",
" def Push(self):\n",
" print self.m_Name , \" pushes.\";\n",
"\n",
"class House(GenericPlayer):\n",
" def __init__(self,name):\n",
" GenericPlayer.__init__(self,name)\n",
"\n",
" def __del__(self):\n",
" pass\n",
"\n",
" def IsHitting(self):\n",
" return (self.GetTotal() <= 16)\n",
"\n",
" def FlipFirstCard(self):\n",
" if (not self.m_Cards):\n",
" m_Cards[0].Flip();\n",
" else:\n",
" print \"No card to flip!\";\n",
" \n",
"class Deck(Hand):\n",
" def __init__(self):\n",
" self.m_Cards = []\n",
" self.Populate();\n",
" \n",
" def __del__(self):\n",
" pass\n",
" \n",
" def Populate(self):\n",
" self.Clear();\n",
" #create standard deck\n",
" for s in range(Card.CLUBS,Card.SPADES+1):\n",
" for r in range(Card.ACE,Card.KING+1):\n",
" self.Add(Card(r,s))\n",
"\n",
" def Shuffle(self):\n",
" pass\n",
"\n",
" def Deal(self, aHand):\n",
" if (not m_Cards):\n",
" aHand.Add(self.m_Cards[-1]);\n",
" self.m_Cards.pop();\n",
" else:\n",
" print \"Out of cards. Unable to deal.\";\n",
"\n",
" def AdditionalCards(self,aGenericPlayer):\n",
" print ''\n",
" #continue to deal a card as long as generic player isn't busted and\n",
" #wants another hit\n",
" while ( not (aGenericPlayer.IsBusted()) and aGenericPlayer.IsHitting() ):\n",
" self.Deal(aGenericPlayer);\n",
" print aGenericPlayer\n",
" if (aGenericPlayer.IsBusted()):\n",
" aGenericPlayer.Bust();\n",
" \n",
"\n",
"class Game:\n",
" def __init__(self,names):\n",
" #create a vector of players from a vector of names\n",
" self.pName = []\n",
" for i in names:\n",
" self.pName.append(Player(i))\n",
" self.m_Deck.Populate();\n",
" self.m_Deck.Shuffle();\n",
"\n",
" def __del__(self):\n",
" pass\n",
" \n",
" def Play(self):\n",
" # deal initial 2 cards to everyone\n",
" for i in range(2):\n",
" for pPlayer in self.m_Players:\n",
" self.m_Deck.Deal(*pPlayer);\n",
" self.m_Deck.Deal(m_House);\n",
" #hide house's first card\n",
" self.m_House.FlipFirstCard();\n",
" for pPlayer in self.m_Players:\n",
" print pPlayer \n",
"\n",
" print self.m_House\n",
" #deal additional cards to players\n",
" \n",
" for pPlayer in self.m_Players:\n",
" self.m_Deck.AdditionalCards(pPlayer);\n",
"\n",
" #reveal house's first card\n",
" self.m_House.FlipFirstCard();\n",
" print self.m_House;\n",
" #deal additional cards to house\n",
" self.m_Deck.AdditionalCards(m_House);\n",
" if (self.m_House.IsBusted()):\n",
" #everyone still playing wins\n",
" for pPlayer in self.m_Players:\n",
" if ( not (pPlayer.IsBusted()) ):\n",
" pPlayer.Win();\n",
" else:\n",
" #compare each player still playing to house\n",
" for pPlayer in self.m_Players:\n",
" if ( not (pPlayer.IsBusted()) ):\n",
" if (pPlayer.GetTotal() > self.m_House.GetTotal()):\n",
" pPlayer.Win();\n",
" elif (pPlayer.GetTotal() < self.m_House.GetTotal()):\n",
" pPlayer.Lose();\n",
" else:\n",
" pPlayer.Push();\n",
"\n",
" #remove everyones cards\n",
" for pPlayer in self.m_Players:\n",
" pPlayer.Clear();\n",
"\n",
" self.m_House.Clear();\n",
"\n",
"print \"\\t\\tWelcome to Blackjack!\\n\";\n",
"numPlayers = 0;\n",
"while (numPlayers < 1 or numPlayers > 7):\n",
" print \"How many players? (1 - 7): \";\n",
" numPlayers = int(raw_input())\n",
"\n",
"names = []\n",
"name = ''\n",
"for i in range(numPlayers):\n",
" print \"Enter player name: \";\n",
" name = raw_input()\n",
" names.append(name); \n",
"\n",
"print ''\n",
"#the game loop\n",
"aGame = Game(names);\n",
"again = 'y'\n",
"while (again != 'n' and again != 'N'):\n",
" aGame.Play();\n",
" print \"\\nDo you want to play again? (Y/N): \",\n",
" again = raw_input()\n",
"\n",
"#overloads << operator so Card object can be sent to cout\n",
"def print_(aCard):\n",
" RANKS = [\"0\", \"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\",\"10\", \"J\", \"Q\", \"K\"]\n",
" SUITS = [\"c\", \"d\", \"h\", \"s\"]\n",
" if (aCard.m_IsFaceUp):\n",
" print RANKS[aCard.m_Rank] , SUITS[aCard.m_Suit];\n",
" else:\n",
" print \"XX\";\n",
" \n",
"\n",
"def print__(aGenericPlayer):\n",
" print aGenericPlayer.m_Name\n",
" pCard = []\n",
" if (not aGenericPlayer.m_Cards):\n",
" for pCard in aGenericPlayer.m_Cards:\n",
" print pCard\n",
" \n",
" if (aGenericPlayer.GetTotal() != 0):\n",
" print \"(\" , aGenericPlayer.GetTotal() , \")\";\n",
" else:\n",
" print \"<empty>\";"
],
"language": "python",
"metadata": {},
"outputs": [
{
"ename": "StdinNotImplementedError",
"evalue": "raw_input was called, but this frontend does not support stdin.",
"output_type": "pyerr",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mStdinNotImplementedError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-11-33b9c51ff816>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 63\u001b[0m \u001b[1;32mwhile\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mnumPlayers\u001b[0m \u001b[1;33m<\u001b[0m \u001b[1;36m1\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mnumPlayers\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m7\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 64\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"How many players? (1 - 7): \"\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 65\u001b[1;33m \u001b[0mnumPlayers\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mraw_input\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 66\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 67\u001b[0m \u001b[0mnames\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32m/home/jay/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/zmq/ipkernel.pyc\u001b[0m in \u001b[0;36m<lambda>\u001b[1;34m(prompt)\u001b[0m\n\u001b[0;32m 343\u001b[0m \u001b[0mraw_input\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mlambda\u001b[0m \u001b[0mprompt\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m''\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_raw_input\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mprompt\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mident\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mparent\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 344\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 345\u001b[1;33m \u001b[0mraw_input\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mlambda\u001b[0m \u001b[0mprompt\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m''\u001b[0m \u001b[1;33m:\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_no_raw_input\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 346\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 347\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mpy3compat\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mPY3\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32m/home/jay/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/zmq/ipkernel.pyc\u001b[0m in \u001b[0;36m_no_raw_input\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 686\u001b[0m \"\"\"Raise StdinNotImplentedError if active frontend doesn't support\n\u001b[0;32m 687\u001b[0m stdin.\"\"\"\n\u001b[1;32m--> 688\u001b[1;33m raise StdinNotImplementedError(\"raw_input was called, but this \"\n\u001b[0m\u001b[0;32m 689\u001b[0m \"frontend does not support stdin.\") \n\u001b[0;32m 690\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mStdinNotImplementedError\u001b[0m: raw_input was called, but this frontend does not support stdin."
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\t\tWelcome to Blackjack!\n",
"\n",
"How many players? (1 - 7): \n"
]
}
],
"prompt_number": 11
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
|