- Page 2 and 3:
Table of Contents | Index Core Pyth
- Page 4 and 5:
The Complete Developer's Guide to P
- Page 6 and 7:
Table of Contents | Index Copyright
- Page 8 and 9:
Section 6.2. Strings Section 6.3. S
- Page 10 and 11:
Section 11.5. Formal Arguments Sect
- Page 12 and 13:
Section 19.4. Brief Tour of Other G
- Page 14 and 15:
Copyright Many of the designations
- Page 16 and 17:
Praise for Core Python Programming
- Page 18 and 19:
Prentice Hall Core Series Core J2EE
- Page 20 and 21:
Another set of first edition reader
- Page 22 and 23:
We will continue to update the book
- Page 24 and 25:
Dictionaries are Python's mapping o
- Page 26 and 27:
and you will find it fun! We first
- Page 28 and 29:
Acknowledgments Acknowledgments for
- Page 30 and 31:
Christian Tismer (creator of Stackl
- Page 32 and 33:
Chapter 1. Welcome to Python! Chapt
- Page 34 and 35:
1.2. Origins Work on Python began i
- Page 36 and 37:
which you can build an application,
- Page 38 and 39:
often provides an extended distract
- Page 40 and 41:
Build It Yourself For most other pl
- Page 42 and 43:
Windows/DOS To add Python to your s
- Page 44 and 45:
It is also possible in Unix to auto
- Page 46 and 47:
MacOS X is very Unix-like (based on
- Page 48 and 49:
Figure 1-5. Starting IDLE in Window
- Page 50 and 51:
1.6. Python Documentation Python do
- Page 52 and 53:
orrow features from languages such
- Page 54 and 55:
1.8. Other Implementations The "sta
- Page 56 and 57:
1.9. Exercises 1-1. Python Installa
- Page 58 and 59:
abs(4) 4 >>> abs(-4) 4 We will intr
- Page 60 and 61:
%s means to substitute a string whi
- Page 62 and 63:
It's very tempting for beginners to
- Page 64 and 65:
2.4. Operators The standard mathema
- Page 66 and 67:
2.5. Variables and Assignment Rules
- Page 68 and 69:
All numeric types are covered in Ch
- Page 70 and 71:
2.8. Lists and Tuples Lists and tup
- Page 72 and 73:
2.10. Code Blocks Use Indentation C
- Page 74 and 75:
2.12. while Loop The standard while
- Page 76 and 77:
Using the string format operator al
- Page 78 and 79:
2.14. List Comprehensions These are
- Page 80 and 81:
case you would have to revert back
- Page 82 and 83:
2.17. Functions Like many other lan
- Page 84 and 85:
2.18. Classes Classes are a core pa
- Page 87 and 88:
2.19. Modules A module is a logical
- Page 89 and 90:
2.20. Useful Functions In this chap
- Page 91 and 92:
2-4. User Input with raw_input(). a
- Page 93 and 94:
put in your own as you write your c
- Page 95 and 96:
Chapter 3. Python Basics Chapter To
- Page 97 and 98:
3.1.3. Multiple Statement Groups as
- Page 99 and 100:
3.2. Variable Assignment This secti
- Page 101:
Another way of assigning multiple v
- Page 104 and 105:
[a] access keyword obsoleted as of
- Page 106 and 107:
three PEPs: 7 (Style Guide for C Co
- Page 108 and 109:
3. Module imports Import all the mo
- Page 110 and 111:
Tests in the main body are an easy
- Page 112 and 113:
As responsible programmers, we are
- Page 114 and 115:
● It is explicitly removed from a
- Page 116 and 117:
Lines 13 The Unix startup line is f
- Page 118 and 119:
1 #!/usr/bin/env python 2 3 'readTe
- Page 120 and 121:
3.7. Related Modules/Developer Tool
- Page 122 and 123:
3-10. Exceptions. Replace the call
- Page 124 and 125:
4.1. Python Objects Python uses the
- Page 126 and 127:
4.3. Other Built-in Types ● Type
- Page 128 and 129:
4.4. Internal Types ● Code ● Fr
- Page 130 and 131:
4.5. Standard Type Operators 4.5.1.
- Page 132 and 133:
Example 2: foo1 and foo2 reference
- Page 134 and 135:
4.5.3. Boolean In the above example
- Page 136 and 137:
4.6. Standard Type Built-in Functio
- Page 138 and 139:
str(2e10) '20000000000.0' >>> >>> s
- Page 140 and 141:
>>> type(foo) # assumes foo instant
- Page 142 and 143:
then we do not even need to check b
- Page 144 and 145:
4.7. Type Factory Functions Since P
- Page 146 and 147:
Another way of categorizing the sta
- Page 148:
Sequence types are those whose elem
- Page 151 and 152:
4.10. Exercises 4-1. Python Objects
- Page 153 and 154:
Chapter 5. Numbers Chapter Topics
- Page 155 and 156:
Okay, now that you have a good idea
- Page 157 and 158:
Core Style: Use uppercase "L" with
- Page 159 and 160:
5.3. Double Precision Floating Poin
- Page 161 and 162:
aComplex.real -8.333 >>> aComplex.i
- Page 163 and 164:
Automatic numeric coercion makes li
- Page 165 and 166:
True Division This is where divisio
- Page 167 and 168:
see that the unary operator binds m
- Page 169 and 170:
Bitwise Operator Function ~num (una
- Page 171 and 172:
In addition, because of the unifica
- Page 173 and 174:
divmod(10,2.5) (4.0, 0.0) >>> divmo
- Page 175 and 176:
floor(-1.2) -2.0 round(-1.2) -1.0 -
- Page 178 and 179:
5.7. Other Numeric Types 5.7.1. Boo
- Page 180 and 181:
cannot "be continued." If we were t
- Page 182 and 183:
uniform() Does almost the same thin
- Page 184 and 185: 5.9. Exercises The exercises in thi
- Page 186 and 187: Why do we get 134L and not 1342 in
- Page 188 and 189: Chapter 6. Sequences: Strings, List
- Page 190 and 191: obj not in seq Tests if obj is not
- Page 192 and 193: if not provided, or if None is used
- Page 194 and 195: Extended Slicing with Stride Indice
- Page 196 and 197: above. 6.1.3. Built-in Functions (B
- Page 198 and 199: [a] New in Python 2.3. [b] key argu
- Page 200 and 201: considered a substring. To access s
- Page 202 and 203: 6.3. Strings and Operators 6.3.1. S
- Page 204 and 205: Notice how the omission of both ind
- Page 206 and 207: numeric identifier strings that we
- Page 208 and 209: method (see example below). There i
- Page 210 and 211: 6.4. String-Only Operators 6.4.1. F
- Page 212 and 213: '6c' >>> >>> "%X" % 108 '6C' >>> >>
- Page 214 and 215: >>> print s.substitute(lang='Python
- Page 216 and 217: 6.5. Built-in Functions 6.5.1. Stan
- Page 218 and 219: isinstance() calls to verify type:
- Page 220 and 221: string.isalpha() [a] , [b] [c] Retu
- Page 222 and 223: >>> quest.endswith('color?') True >
- Page 224 and 225: \t 011 9 0x09 HT Horizontal tab \n
- Page 226: string was created when the operati
- Page 229 and 230: convert the numeric value of the by
- Page 231 and 232: Example 6.2. Simple Unicode String
- Page 233: Mistake #2: Using the string module
- Page 237 and 238: [d] Obsoleted in Python 2.5 by hash
- Page 240 and 241: 6.11. Lists Like strings, lists pro
- Page 242 and 243: 6.12. Operators 6.12.1. Standard Ty
- Page 244 and 245: False >>> >>> 'x' in mixup_list[1]
- Page 247 and 248: 6.13. Built-in Functions 6.13.1. St
- Page 249 and 250: max(str_list) 'park' >>> max(num_li
- Page 251 and 252: 6.14. List Type Built-in Methods Li
- Page 253 and 254: in (or not in) first, and then usin
- Page 255 and 256: 6.15. Special Features of Lists 6.1
- Page 257 and 258: Lines 1943 The entire menu-driven a
- Page 259 and 260: A queue is a first-in-first-out (FI
- Page 261 and 262: Enter choice: v You picked: [v] ['B
- Page 263 and 264: Like numbers and strings, tuples ar
- Page 265 and 266: False >>> (2, 4) < (3, -1) True >>>
- Page 267 and 268: Although tuple objects themselves a
- Page 269 and 270: One of the questions in the Python
- Page 271 and 272: 6.20. *Copying Python Objects and S
- Page 273 and 274: [9919616, 11800088] >>> [id(x) for
- Page 275 and 276: isdecimal() • isdigit() • islow
- Page 277 and 278: 6.22. Exercises 6-1. Strings. Are t
- Page 279 and 280: This is the program listing for Exe
- Page 281 and 282: 6-14. *Random Numbers. Design a "ro
- Page 283 and 284: Chapter 7. Mapping and Set Types Ch
- Page 285 and 286:
Python dictionaries are implemented
- Page 287 and 288:
We will introduce all of a dictiona
- Page 289 and 290:
7.2. Mapping Type Operators Diction
- Page 291 and 292:
7.3. Mapping Type Built-in and Fact
- Page 293 and 294:
If we have reached this point, i.e.
- Page 295 and 296:
The hash() BIF is not really meant
- Page 297 and 298:
[d] New in Python 2.2. [e] New in P
- Page 299 and 300:
{}.fromkeys('xyz') {'y': None, 'x':
- Page 301 and 302:
We know that numbers and strings ar
- Page 303 and 304:
This is the familiar code that will
- Page 305 and 306:
!= Is not equal to < Is a (strict)
- Page 307 and 308:
7.7. Set Type Operators 7.7.1. Stan
- Page 309 and 310:
In the above examples, s is a set w
- Page 311 and 312:
7.8. Built-in Functions 7.8.1. Stan
- Page 313 and 314:
s.symmetric_difference_update(t) Up
- Page 315 and 316:
s.symmetric_ difference(t) s ^ t Sy
- Page 317 and 318:
7.12. Exercises 7-1. Dictionary Met
- Page 319 and 320:
7-6. Lists and Dictionaries. Create
- Page 321 and 322:
7-14. User Validation. Alter the pr
- Page 323 and 324:
8.1. if Statement The if statement
- Page 325 and 326:
if balance > 0.00: if balance - amt
- Page 327 and 328:
msgs = {'create': 'create item', 'd
- Page 330 and 331:
8.5. while Statement Python's while
- Page 332 and 333:
8.6. for Statement The other loopin
- Page 334 and 335:
The best of both worlds comes from
- Page 336 and 337:
We saw the shortest syntax earlier
- Page 338 and 339:
8.7. break Statement The break stat
- Page 340 and 341:
8.9. pass Statement One Python stat
- Page 342 and 343:
largest factor of 14 is 7 largest f
- Page 344 and 345:
There is a reversed() built-in func
- Page 346 and 347:
for eachURL in allURLs: if not each
- Page 348 and 349:
This syntax will filter or "capture
- Page 350 and 351:
8.13. Generator Expressions Generat
- Page 352 and 353:
days, the following was acceptable
- Page 354 and 355:
8.14. Related Modules Iterators wer
- Page 356 and 357:
8-3. range(). What argument(s) coul
- Page 358:
8-12. (Integer) Bit Operators. Writ
- Page 361 and 362:
9.1. File Objects File objects can
- Page 363 and 364:
[a] Open for read with universal NE
- Page 365 and 366:
9.3. File Built-in Methods Once ope
- Page 367 and 368:
time, file.xreadlines() was the mos
- Page 369 and 370:
Regardless of your platform, these
- Page 371 and 372:
file.truncate(size=file.tell()) Tru
- Page 373 and 374:
9.5. Standard Files There are gener
- Page 375 and 376:
expensive "calculators." Python has
- Page 377 and 378:
[a] Return current working director
- Page 379 and 380:
This code exercises some of the fun
- Page 381 and 382:
[] *** creating test file... *** up
- Page 383 and 384:
As you can tell from our lengthy di
- Page 385 and 386:
9.9. Persistent Storage Modules In
- Page 387 and 388:
The pickle module allows you to sto
- Page 389 and 390:
The fileinput module iterates over
- Page 391 and 392:
9.11. Exercises 9-1. File Filtering
- Page 393 and 394:
c. object, as well as how to perfor
- Page 395 and 396:
9-19. Generating Files. Create a si
- Page 397 and 398:
Chapter 10. Errors and Exceptions C
- Page 399 and 400:
Eiffel, and Java. The origins of ex
- Page 401 and 402:
IndexError: request for an out-of-r
- Page 403 and 404:
10.3. Detecting and Handling Except
- Page 405 and 406:
1.2345e+069 Unfortunately, float()
- Page 407 and 408:
except Exception1[, reason1]: suite
- Page 409 and 410:
not promote good Python coding styl
- Page 411 and 412:
the exception handler. Although rea
- Page 413 and 414:
eturn retval Upon running our new c
- Page 415 and 416:
These lines represent the general "
- Page 417 and 418:
10.3.10. try-finally Statement An a
- Page 419 and 420:
except (Exception6, Exception7), Ar
- Page 421 and 422:
● tHReading.BoundedSemaphore Sinc
- Page 423 and 424:
10.5. *Exceptions as Strings Prior
- Page 425 and 426:
If the additional parameter to the
- Page 427 and 428:
10.7. Assertions Assertions are dia
- Page 429 and 430:
10.8. Standard Exceptions Table 10.
- Page 431 and 432:
IndexError No such index in sequenc
- Page 433 and 434:
[c] Prior to Python 2.5, KeyboardIn
- Page 435 and 436:
21 return tuple(myargs) 22 23 def f
- Page 437 and 438:
The entire purpose of the updArgs()
- Page 439 and 440:
Lines 108110 We want to execute our
- Page 441 and 442:
10.11. Why Exceptions at All? If th
- Page 443 and 444:
10.13. Related Modules Table 10.3 l
- Page 445 and 446:
10-5. Exceptions. Name the exceptio
- Page 447 and 448:
Chapter 11. Functions and Functiona
- Page 449 and 450:
Also, like most other languages, yo
- Page 451 and 452:
11.2. Calling Functions 11.2.1. Fun
- Page 453 and 454:
Randomly chooses numbers and an ari
- Page 455 and 456:
Lines 16-28 represent the controlli
- Page 457 and 458:
File "", line 3, in foo NameError:
- Page 459 and 460:
Function attributes were added to P
- Page 461 and 462:
func = deco2(deco1(func)) Function
- Page 463 and 464:
14 pass 15 16 foo() 17 sleep(4) 18
- Page 465 and 466:
A more realistic example of passing
- Page 467 and 468:
The syntax for declaring variables
- Page 469:
grabWeb.py script, given in Example
- Page 472 and 473:
print 'formal arg 1:', arg1 print '
- Page 474 and 475:
additional non-keyword arg: 30 addi
- Page 476 and 477:
int('1234') = 1234 int('12.34') = F
- Page 478 and 479:
visualize their lambda equivalents.
- Page 480 and 481:
all of them take a function object
- Page 482 and 483:
$ python oddnogen.py [39, 77, 39, 7
- Page 484 and 485:
We have also discussed how map () c
- Page 486 and 487:
· def mySum(x,y): return x+y · la
- Page 488 and 489:
>>> add1(10) 11 >>> add1(1) 2 >>> m
- Page 490 and 491:
Why bother with so much repetition
- Page 492 and 493:
It is possible to "hide" or overrid
- Page 494 and 495:
If references are made from inside
- Page 496 and 497:
14 print output % ('w', id(w), w) 1
- Page 498 and 499:
21 try: 22 return f(*args, **kargs)
- Page 500 and 501:
File "", line 3, in NameError: y I
- Page 502 and 503:
17 k = 7 18 proc1() 19 print "j ==
- Page 504 and 505:
11.10. Generators Earlier in Chapte
- Page 506 and 507:
generator, but serves as a short fo
- Page 508 and 509:
11.11. Exercises 11-1. Arguments. C
- Page 510 and 511:
11-10. Functional Programming with
- Page 512 and 513:
Chapter 12. Modules Chapter Topics
- Page 514 and 515:
12.2. Modules and Files If modules
- Page 516 and 517:
12.3. Namespaces A namespace is a m
- Page 518 and 519:
ar = 100 print "in __main__, bar is
- Page 520 and 521:
12.4. Importing Modules 12.4.1. The
- Page 522 and 523:
workaround is to assign the module
- Page 524 and 525:
In practice, using from module impo
- Page 526 and 527:
and RuntimeWarning. These are descr
- Page 528 and 529:
12.6. Module Built-in Functions The
- Page 530 and 531:
12.7. Packages A package is a hiera
- Page 532:
The rationale behind this decision
- Page 535 and 536:
The world was pretty clean-cut when
- Page 537 and 538:
The workaround for this problem is
- Page 539 and 540:
12.10. Exercises 12-1. PathSearch v
- Page 541 and 542:
Chapter 13. Object-Oriented Program
- Page 543 and 544:
Classes and Instances Classes and i
- Page 545 and 546:
chapter, these attributes really ar
- Page 547 and 548:
>>> john.name 'John Doe' >>> john.p
- Page 549 and 550:
"AddrBookEntry," "RepairShop," etc.
- Page 551 and 552:
Person would include the Customer,
- Page 553 and 554:
13.3. Classes Recall that a class i
- Page 555 and 556:
13.4. Class Attributes What is an a
- Page 557 and 558:
In keeping with OOP tradition, Pyth
- Page 559 and 560:
eturns a type object when invoked.
- Page 561 and 562:
13.5. Instances Whereas a class is
- Page 563 and 564:
13.5.3. __new__() "Constructor" Met
- Page 565 and 566:
= InstTrack() >>> b.howMany() 2 >>>
- Page 567 and 568:
arguments in Section 11.5.2. One ca
- Page 569 and 570:
dir(c) ['__class__', '__delattr__',
- Page 571 and 572:
1.0 >>> x.conjugate() (1-2j) Attemp
- Page 573 and 574:
But... all of this changes if the c
- Page 575 and 576:
13.7. Binding and Method Invocation
- Page 577 and 578:
13.8. Static Methods and Class Meth
- Page 579 and 580:
13.9. Composition Once a class is d
- Page 581 and 582:
print 'calling parent method' class
- Page 583 and 584:
created an instance of C >>> c.__cl
- Page 585 and 586:
Core Note: Overriding __init__ does
- Page 587 and 588:
class RoundFloat(float): def __new_
- Page 589 and 590:
Simple Attribute Lookup Example The
- Page 591 and 592:
(, , , , , ) *MRO Problems Caused b
- Page 593 and 594:
13.12. Built-in Functions for Class
- Page 595 and 596:
class myClass(object): ... def __in
- Page 597 and 598:
c.foo = 100 >>> c.bar = 'Python' >>
- Page 599 and 600:
Object (Value) Comparison [c] C.__c
- Page 601 and 602:
[f] Test sequence membership; in ke
- Page 603 and 604:
subclass anything (except object of
- Page 605 and 606:
1 #!/usr/bin/env python 2 3 class R
- Page 607 and 608:
mon - tue Traceback (most recent ca
- Page 609 and 610:
The answer is yes, you can, and it
- Page 611 and 612:
14-21). In the last part of next(),
- Page 613 and 614:
17 other.__num, \ 18 self.__string
- Page 615 and 616:
Not calling repr() on self.__string
- Page 617 and 618:
13.14. Privacy Attributes in Python
- Page 619 and 620:
Delegation is a characteristic of w
- Page 621 and 622:
dictionaries fails to find a succes
- Page 623 and 624:
38 39 def __getattr__(self, attr):
- Page 625 and 626:
code is identical to what you would
- Page 627 and 628:
OLD (not as good): BETTER: ● if t
- Page 629 and 630:
The signatures for __get__(), __set
- Page 631 and 632:
class C2(object): ... foo = DevNull
- Page 633 and 634:
Lines 2838 Saving the attribute tak
- Page 635 and 636:
Believe it or not, you have already
- Page 637 and 638:
class PI(object): pi = property(get
- Page 639 and 640:
if it is there, it will use the cla
- Page 641 and 642:
stacklevel=3) We will create three
- Page 643 and 644:
13.17. Related Modules and Document
- Page 645 and 646:
There are plenty of class, and obje
- Page 647 and 648:
Extra credit: Allow the user to opt
- Page 649 and 650:
13-7. Date Class. Provide an interf
- Page 651 and 652:
13-12. Chat Rooms. You have been pr
- Page 653 and 654:
d. e. f. In addition to instantiati
- Page 655 and 656:
14.1. Callable Objects A number of
- Page 657 and 658:
Internally, user-defined functions
- Page 659 and 660:
immediately garbage-collected. The
- Page 661 and 662:
callable(c) # instance is callable
- Page 663 and 664:
14.3. Executable Object Statements
- Page 665 and 666:
1 2 3 4 5 In the final example, we
- Page 667 and 668:
Note that once execution has comple
- Page 669 and 670:
22 print %s 23 %s = %s + %d 24 """
- Page 671 and 672:
3.0 arrrghhh ----------------------
- Page 673 and 674:
Calling sys.exit() causes the Pytho
- Page 675 and 676:
14.4. Executing Other (Python) Prog
- Page 677 and 678:
Earlier in this chapter, we describ
- Page 679 and 680:
14.5. Executing Other (Non-Python)
- Page 681 and 682:
from the interactive interpreter so
- Page 683 and 684:
type, operating system name, etc. A
- Page 685 and 686:
GNU/Linux >>> f = Popen('who', stdo
- Page 687 and 688:
14.7. Terminating Execution Clean e
- Page 689 and 690:
We execute the old exit function af
- Page 691 and 692:
[a] New in Python 2.3.
- Page 693 and 694:
14.10. Exercises 14-1. Callable Obj
- Page 695 and 696:
Part II: Advanced Topics Chapter 15
- Page 697 and 698:
15.1. Introduction/Motivation Manip
- Page 699 and 700:
with which to recognize multiple st
- Page 701 and 702:
\s Match any whitespace character,
- Page 703 and 704:
While the dot is good for allowing
- Page 705 and 706:
Using these shortcuts, we will pres
- Page 707 and 708:
15.3. REs and Python Now that we kn
- Page 709 and 710:
make function calls with the same s
- Page 711 and 712:
The chances are greater that the pa
- Page 713 and 714:
m = re.match('r2d2|c3po', 'c2do') #
- Page 715 and 716:
'ab' >>> m.group(2) # subgroup 2 'b
- Page 717 and 718:
% who wesc console Jun 20 20:33 wes
- Page 719 and 720:
You may have seen the use of raw st
- Page 721 and 722:
Sat May 5 16:36:23 1990::fclihw@alw
- Page 723 and 724:
Both of the above REs are the most
- Page 725 and 726:
patt = '.+?(\d+-\d+-\d+)' >>> re.ma
- Page 727 and 728:
15-13. type(). The type() built-in
- Page 729 and 730:
Chapter 16. Network Programming Cha
- Page 731 and 732:
System (NFS). If you are accessing
- Page 733 and 734:
includes any necessary exchange of
- Page 735 and 736:
other end; otherwise, you get the f
- Page 737 and 738:
16.3. Network Programming in Python
- Page 739 and 740:
networked applications In our multi
- Page 741 and 742:
22 if not data: 23 break 24 tcpCliS
- Page 743 and 744:
The TCP client socket (tcpCliSock)
- Page 745 and 746:
Creates a UDP server that accepts m
- Page 747 and 748:
way as the UDP server. Lines 1222 O
- Page 749 and 750:
[b] Convert IP address string to pa
- Page 751 and 752:
consists of an event handler for th
- Page 753 and 754:
This is a timestamp TCP client that
- Page 755 and 756:
16.5. *Introduction to the Twisted
- Page 757 and 758:
Our familiar timestamp TCP client w
- Page 759:
16.6. Related Modules Table 16.4 li
- Page 762 and 763:
16-7. Half-Duplex Chat. Create a si
- Page 764 and 765:
Chapter 17. Internet Client Program
- Page 766 and 767:
17.2. Transferring Files 17.2.1. Fi
- Page 768 and 769:
So how do we write an FTP client us
- Page 770 and 771:
drwxr-xr-x 3 root wheel 512 May 19
- Page 772 and 773:
allocated rather than depending on
- Page 774 and 775:
17.3. Network News 17.3.1. Usenet a
- Page 776 and 777:
from nntplib import NNTP n = NNTP('
- Page 778 and 779:
Finally, we are going to do blank l
- Page 780 and 781:
75 count += 1 76 lastBlank = False
- Page 782 and 783:
lines making up the article body an
- Page 784 and 785:
In order to send e-mail, your mail
- Page 786 and 787:
[a] SMTP-AUTH only. 17.4.5. Interac
- Page 788 and 789:
interested reader to the aforementi
- Page 790 and 791:
17.4.11. poplib.POP3 Class Methods
- Page 792 and 793:
(s). Line 14 puts everything togeth
- Page 794 and 795:
Module Description ftplib FTP proto
- Page 796 and 797:
NNTP 17-7. Recursion. The ftpmirror
- Page 798 and 799:
17-21. IMAP. Now that you are famil
- Page 800 and 801:
17-30. * Developing New Internet Cl
- Page 802:
18.1. Introduction/Motivation Befor
- Page 805 and 806:
18.3. Python, Threads, and the Glob
- Page 807 and 808:
Let us create two "time loops," one
- Page 809 and 810:
18.4. tHRead Module Let's take a lo
- Page 811 and 812:
We did not have any code that told
- Page 813 and 814:
As hinted in the earlier Core Note,
- Page 815 and 816:
18.5.1. Thread Class Another reason
- Page 817 and 818:
28 29 print 'all DONE at:', ctime()
- Page 819 and 820:
loop 0 done at: Sun Aug 13 18:49:21
- Page 821 and 822:
To generalize our subclass of Threa
- Page 823 and 824:
233 fib finished at: Sun Jun 18 19:
- Page 825 and 826:
18 def writer(queue, loops): 19 for
- Page 827 and 828:
18.6. Related Modules The table bel
- Page 829 and 830:
18-10. Take your solution to the pr
- Page 831 and 832:
19.1. Introduction 19.1.1. What Are
- Page 833 and 834:
19.2. Tkinter and Python Programmin
- Page 835 and 836:
created by the Tk class in Tkinter
- Page 837 and 838:
19.3. Tkinter Examples 19.3.1. Labe
- Page 839 and 840:
This example features both a Label
- Page 841 and 842:
Figure 19-4. Tkinter Label, Button,
- Page 843 and 844:
29 30 MyButton = pto(Button, top) 3
- Page 845 and 846:
13 self.label.pack() 14 15 self.cwd
- Page 847 and 848:
The Unix version of this applicatio
- Page 849 and 850:
number of files exceeds the size of
- Page 851 and 852:
19.4. Brief Tour of Other GUIs We h
- Page 853 and 854:
Our first example uses the Tix modu
- Page 855 and 856:
Our third example uses wxPython (an
- Page 857 and 858:
15 'Animals (in pairs; min: pair, m
- Page 859 and 860:
19.5. Related Modules and Other GUI
- Page 861 and 862:
19.6. Exercises 19-1. Client/Server
- Page 863 and 864:
Chapter 20. Web Programming Chapter
- Page 865 and 866:
and values chained as part of the r
- Page 867 and 868:
20.2. Web Surfing with Python: Crea
- Page 869 and 870:
scheme in case one is not provided
- Page 871 and 872:
If the "POST" request method is des
- Page 873 and 874:
28 ldir = dirname(path) # local dir
- Page 875 and 876:
final = '%s?name=%s&num=%d' % (base
- Page 877 and 878:
This script uses both techniques de
- Page 879 and 880:
20.3. Advanced Web Clients Web brow
- Page 881 and 882:
* http://www.null.com/home/overview
- Page 883 and 884:
Forms input from the client sent to
- Page 885 and 886:
20.5. Building CGI Applications 20.
- Page 887 and 888:
Figure 20-5. Friends form page in I
- Page 889 and 890:
If you are a Web site producer, you
- Page 891 and 892:
55 else: 56 showForm() 57 58 if __n
- Page 893 and 894:
If you look at the location or "Go
- Page 895 and 896:
71 error = 'Please select number of
- Page 897 and 898:
We click on the "Back" button, chec
- Page 899 and 900:
20.6. Using Unicode with CGI In Cha
- Page 901 and 902:
20.7. Advanced CGI We will now take
- Page 903 and 904:
Figure 20-14. Upload and multivalue
- Page 905 and 906:
The data are submitted to the serve
- Page 907 and 908:
When the script detects no form dat
- Page 909 and 910:
55 split(self.cookies['info'], ':')
- Page 911 and 912:
172 self.langs.append(eachLang.valu
- Page 913 and 914:
four-megabyte binary file.
- Page 915 and 916:
Module Description BaseHTTPServer P
- Page 917 and 918:
20.9. Related Modules In Table 20.7
- Page 919 and 920:
inascii En-/decodes data using base
- Page 921 and 922:
20-7. Count how many of each type o
- Page 923 and 924:
20-24. Advanced Web Clients. The cr
- Page 925 and 926:
21.1. Introduction 21.1.1. Persiste
- Page 927 and 928:
Inserting a Row INSERT INTO users V
- Page 929 and 930:
21.2. Python Database Application P
- Page 931 and 932:
Parameter Description user Username
- Page 933 and 934:
The commit() method is irrelevant i
- Page 935 and 936:
Table 21.7. Type Objects and Constr
- Page 937 and 938:
later on in this chapter. Let us no
- Page 939 and 940:
import psycopg >>> cxn = psycopg.co
- Page 941 and 942:
MySQL, but which does a few more th
- Page 943 and 944:
82 uid INTEGER, 83 prid INTEGER) 84
- Page 945 and 946:
The guts of consistent database acc
- Page 947 and 948:
The director of this movie is main(
- Page 949 and 950:
Example 21.2. SQLAlchemy ORM Exampl
- Page 951 and 952:
112 113 if__name__ == '__main__': 1
- Page 953 and 954:
103 print '\n*** Dropping users tab
- Page 955 and 956:
(3 users moved) LOGIN USERID PROJ#
- Page 957 and 958:
Jess 7912 1 Amy 7209 4 Melissa 8602
- Page 959 and 960:
21.4. Related Modules Table 21.8 li
- Page 961 and 962:
21.5. Exercises 21-1. Database API.
- Page 963 and 964:
22.1. Introduction/Motivation 22.1.
- Page 965 and 966:
22.2. Extending Python by Writing E
- Page 967 and 968:
To run our program, we issue the fo
- Page 969 and 970:
Python to C int PyArg_ParseTuple()
- Page 971 and 972:
of the string.) strdup() creates an
- Page 973 and 974:
The next step is to create a setup.
- Page 975 and 976:
Test Function The one last thing we
- Page 977 and 978:
59 if (!PyArg_ParseTuple(args, "s",
- Page 979 and 980:
As with the reference counting macr
- Page 981 and 982:
has the effect of giving a potentia
- Page 983 and 984:
Chapter 23. Miscellaneous Chapter T
- Page 985 and 986:
['YHOO', '30.76', '5/23/2006', '4:0
- Page 987 and 988:
If we run this script, we will get
- Page 989 and 990:
consider for the general audience.
- Page 991 and 992:
On line 13, we use what is known as
- Page 993 and 994:
20 sleep(1) 21 for i in RANGE: 22 r
- Page 995 and 996:
In our example, we just use a (titl
- Page 997 and 998:
olFolderDrafts (16), olFolderSentMa
- Page 999 and 1000:
This script downloads stock quotes
- Page 1001 and 1002:
decimal point, e.g., "34.2" is disp
- Page 1003 and 1004:
write a GUI application using Swing
- Page 1005 and 1006:
Jython is a great development tool
- Page 1007 and 1008:
23-8. Microsoft Outlook and Web Ser
- Page 1009 and 1010:
Java, Python, Jython 23-16. Jython.
- Page 1011 and 1012:
Appendix A. Answers to Selected Exe
- Page 1013 and 1014:
Chapter 2 5. Loops and numbers a. b
- Page 1015 and 1016:
Chapter 3 4. Statements Use; 5. Sta
- Page 1017 and 1018:
Chapter 5 8. Geometry import math d
- Page 1019 and 1020:
Chapter 6 1. Strings find(), rfind(
- Page 1021 and 1022:
7. Inverting dictionaries list1 = o
- Page 1023 and 1024:
Chapter 9 2. File access f = open(r
- Page 1026 and 1027:
Chapter 11 2. Functions def sumtime
- Page 1028 and 1029:
Chapter 13 2. Functions versus meth
- Page 1030 and 1031:
Chapter 15 1. Matching strings bat,
- Page 1032 and 1033:
Chapter 16 3. Sockets TCP 6. Daytim
- Page 1034 and 1035:
Chapter 18 2. Python threads I/O-bo
- Page 1036 and 1037:
Chapter 20 15. CGI errors The Web s
- Page 1038 and 1039:
Chapter 22 1. DB-API The DB-API is
- Page 1040 and 1041:
Appendix B. Reference Tables Python
- Page 1042 and 1043:
Python Standard Operators and Funct
- Page 1044 and 1045:
Numeric Type Operators and Function
- Page 1046 and 1047:
Sequence Type Operators and Functio
- Page 1048 and 1049:
split() • title() • tuple() •
- Page 1050 and 1051:
String Format Operator Directives W
- Page 1052 and 1053:
String Type Built-in Methods The de
- Page 1054 and 1055:
string.title() [b] [c] Returns "tit
- Page 1056 and 1057:
Dictionary Type Built-in Methods In
- Page 1058 and 1059:
Set Types Operators and Functions T
- Page 1060 and 1061:
File Object Methods and Data Attrio
- Page 1062 and 1063:
Python Exceptions Table B.12 lists
- Page 1064 and 1065:
Error [i] UnboundLocalError Access
- Page 1067 and 1068:
Special Methods for Classes Table B
- Page 1069 and 1070:
Numeric Types: base representation
- Page 1071 and 1072:
Python Operator Summary Table B.14
- Page 1073 and 1074:
Appendix 3. About the Author Wesley
- Page 1075 and 1076:
Index [SYMBOL] [A] [B] [C] [D] [E]
- Page 1077 and 1078:
Index [SYMBOL] [A] [B] [C] [D] [E]
- Page 1079 and 1080:
async* module "at-sign" ( @ ) atomi
- Page 1081 and 1082:
uilt-in types 2nd "built-in" names
- Page 1083 and 1084:
uilding applications cgi module coo
- Page 1085 and 1086:
UDP Web 2nd Windows close( ) built-
- Page 1087 and 1088:
cursor (database) cursor objects cu
- Page 1089 and 1090:
function attributes layers in modul
- Page 1091:
distutils package division operator
- Page 1094 and 1095:
equality for sets eric3 errors/erro
- Page 1096 and 1097:
exponentiatial notation output expo
- Page 1098 and 1099:
isatty( ) iterating through 2nd 3rd
- Page 1100 and 1101:
constructs debugging/performance me
- Page 1102 and 1103:
Index [SYMBOL] [A] [B] [C] [D] [E]
- Page 1104 and 1105:
Index [SYMBOL] [A] [B] [C] [D] [E]
- Page 1106 and 1107:
import cycles loading vs. locals( )
- Page 1108 and 1109:
Integrated Development Environments
- Page 1110 and 1111:
Index [SYMBOL] [A] [B] [C] [D] [E]
- Page 1112 and 1113:
Index [SYMBOL] [A] [B] [C] [D] [E]
- Page 1114 and 1115:
loops [See also iterators.] and ite
- Page 1116 and 1117:
epetition 2nd searching vs. 2nd 3rd
- Page 1118 and 1119:
modulefinder modules [See also impo
- Page 1120 and 1121:
Index [SYMBOL] [A] [B] [C] [D] [E]
- Page 1122 and 1123:
complex creating double precision f
- Page 1124 and 1125:
object-oriented language object-ori
- Page 1126 and 1127:
SQLObject 2nd 3rd os module additio
- Page 1128 and 1129:
positional arguments (functions) PO
- Page 1130 and 1131:
Index [SYMBOL] [A] [B] [C] [D] [E]
- Page 1132 and 1133:
any single character ( . ) 2nd ASCI
- Page 1134 and 1135:
Index [SYMBOL] [A] [B] [C] [D] [E]
- Page 1136 and 1137:
elated modules removing set members
- Page 1138 and 1139:
standard files standard input stand
- Page 1140 and 1141:
min( ) no char type for non-NUL/ '0
- Page 1142 and 1143:
Index [SYMBOL] [A] [B] [C] [D] [E]
- Page 1144 and 1145:
truncate( ) built-in method 2nd 3rd
- Page 1146 and 1147:
Index [SYMBOL] [A] [B] [C] [D] [E]
- Page 1149 and 1150:
Index [SYMBOL] [A] [B] [C] [D] [E]
- Page 1151 and 1152:
Web surfing 2nd 3rd while statement
- Page 1153 and 1154:
Index [SYMBOL] [A] [B] [C] [D] [E]
- Page 1155:
Index [SYMBOL] [A] [B] [C] [D] [E]