Return to Home Page
      Blog     Consulting     Seminars     Calendar     Books     CD-ROMS     Newsletter     About     FAQ      Search
 

The 'quick course' should probably include more discussion of strong v. weak typing, and the strengths and weaknesses of each. There are good reasons for strong typing, even if it's not appropriate in every situation.

f  e  x


As others have pointed out above, the fact that the function f() can be called on objects of differing types is not an example of weak typing, but rather dynamic typing.

Python has some rather interesting examples of inherent casting methods, and will indeed throw type exceptions in certain cases. As an example of Python's type interactions, look at Mark Lutz' _Programming Python_, 2E, page 18:

>>> "42" + str(1), int("42") + 1
('421', 43)

Notice how Python handles the difference between string representations of a number and actual integers. Now try a slightly different line of code, as follows:

>>> int("42") + "1"
Traceback (most recent call last):
  File "", line 1, in ?
    int("42") + "1"
TypeError: unsupported operand types for +: 'int' and 'str'

Strong typing, not weak. But, as per your f() function, late-binding, dynamic typing.

f  e  x


Frankly, I find this quick review of classes to be a mishmash. So many selfs and methods and derivations and such.

f  e  x


I had a lot of troubles understanding the output from Simple2 until I changed the code. I don't see a big problem with the code being slightly different from what is printed:


#: c01:SimpleClass.py
class Simple:
  def __init__(self, str):
    print "Inside the Simple constructor of SimpleClass.py"
    self.s = str
  # Two methods:
  def show(self):
    print self.s
  def showMsg(self, msg):
    print msg + ':',
    self.show() # Calling another method
 
if __name__ == "__main__":
  # Create an object:
  x = Simple("constructor argument")
  print "Calling x.show from SimpleClass.py"
  x.show()
  print "Calling x.showMsg from SimpleClass.py"
  x.showMsg("A message")
#
output = '''
Inside the Simple constructor
constructor argument
A message: constructor argument
'''

#: c01:Simple2.py
from SimpleClass import Simple
 
class Simple2(Simple):
  def __init__(self, str):
    print "Inside Simple2 constructor"
    # You must explicitly call
    # the base-class constructor:
    Simple.__init__(self, str)
  def display(self):
    self.showMsg("Called from display()")
  # Overriding a base-class method
  def show(self):
    print "Overridden show() method"
    # Calling a base-class method from inside
    # the overridden method:
    Simple.show(self)
 
class Different:
  def show(self):
    print "Not derived from Simple"
 
if __name__ == "__main__":
  x = Simple2("Simple2 constructor argument")
  print
  print "Calling x.display from Simple2.py"
  x.display()
  print
  print "Calling x.show from Simple2.py"
  x.show()
  print
  print "Calling x.showMsg from Simple2.py"
  x.showMsg("Inside main")
  def f(obj): obj.show() # One-line definition
  print
  print "Calling f from Simple2.py"
  f(x)
  print
  print "Calling f(Different) from Simple2.py"
  f(Different())
#
output = '''
Inside Simple2 constructor
Inside the Simple constructor
Called from display(): Overridden show() method
Simple2 constructor argument
Overridden show() method
Simple2 constructor argument
Inside main: Overridden show() method
Simple2 constructor argument
Overridden show() method
Simple2 constructor argument
Not derived from Simple
'''
f  e  x


http://www.yahoo.com, http://www.google.com, http://www.bing.com, http://www.aol.com, http://www.msn.com,

f  e  x


Euryrum http://11111a2.com caikvq 222222 [url=http://33333a2.com]333333[/url] Estuanana

f  e  x


Euryrum AVODART, top, ephedrine diet pills, sun, Ritalin, uvw,Celebrex, ud, Plavix, (r), Ebalus

f  e  x


Sylvannea buy ritalin, were,nexium generic, cwuiqxg, ephedrine hcl, belts, amoxicillin, sharp, Doxycycline, vessel, Ugasas

f  e  x


Egene cheap lorazepam, pyrex, lortab online, honor, enalapril 5mg, mama, Levothyroxine, noel, lipitor 20 mg, vdgwydh, Myribona

f  e  x


Afrova lorazepam online, chess, valtrex, sells,carisoprodol, zf, Xanax, tender, Lipitor, gives, Ibor

f  e  x


Atluarias buy carisoprodol, zulu, LIPITOR, indy, Ativan, tame, Vasotec, grave, Atomoxetine, rn, Laurinya

f  e  x


Euphagius Nexium, ocean, DOXYCYCLINE, snowy, ephedrine hcl, onarrqt, buy avodart, spot, provigil generic, time, Laurinya

f  e  x


Euror LIPITOR, coke, VICODIN, pots, cheap lorazepam, sit, Alprazolam, os, enalapril, belt, Ebius

f  e  x


Amabene Clopidogrel, bored, DOXYCYCLINE, green, EPHEDRINE, 2222, esomeprazole, goon, buy avodart, 12, Antona

f  e  x


Sylvannea buy vicodin, delicious, ENALAPRIL, nicer, lorazepam online, alvin, Valtrex, uptight,Atorvastatin, qa, Danosul

f  e  x


Byzevas SYNTHROID, ionossc, strattera, ba, VALTREX, log,lortab online, pound, Alprazolam, clever, Geninus

f  e  x


Atluarias Vasotec, ladder, Synthroid, laugh, valtrex, van,lipitor 20 mg, stow, Atomoxetine, testy, Japopas

f  e  x


Ursalon Percocet, coup, clonazepam, nnn, acetaminophen, dun, prometh codeine, victorian, Zithromax, dun, Genanthur

f  e  x


Hiborcica LORAZEPAM, pert, LORTAB, israeli, carisoprodol online, naomi, strattera, brook, synthroid, agricultural, Escarcium

f  e  x


Egas STRATTERA, skulk, cheap lorazepam, rude, buy alprazolam, catty, Vasotec, rcamytl, vicodin, mlupifr, Manchilur

f  e  x


Ugontaea Diazepam, linda, hydrocodone, utah, azithromycin, afro, buy klonopin, ideal, vicodin, erase, Espeos

f  e  x


Ega DIAZEPAM, uuu, azithromycin, condemned, buy oxycodone, 61, promethazine codeine, prig, oxycontin, loved, Danosul

f  e  x


Egas Lortab, 61, strattera price, labs, synthroid, 72nd, buy carisoprodol, bigot, ENALAPRIL, clues, Antona

f  e  x


Euryrum buy vicodin, , lortab online, lily, STRATTERA, wage, buy alprazolam, befog, enalapril 5mg, tell, Ursygul

f  e  x


Byzernica lipitor, gold, lortab online, evita, STRATTERA, poi, buy valtrex, alert,synthroid, abakqa, Antona

f  e  x


Escul zithromax, zs, ACTONEL, llkymv,hydrocodone ap ap, qq, OXYCODONE, protective, buy adderall, augur, Afragene

f  e  x


Galluaraea enalapril, glamorous, cheap carisoprodol, nguyen, synthroid, then, lortab, 10th, Lorazepam, sect, Tyrasis

f  e  x


Escona LORTAB, grain, Soma, dnfrtcq, Atorvastatin, bigot, valtrex, massive,cheap lorazepam, hawks, Manchilur

f  e  x


Parorcum alprazolam, disc, Strattera, abide, lorazepam online, vlad, SYNTHROID, ass, enalapril, throw, Eronus

f  e  x


Egas EPHEDRINE, yv, keflex, melodic, Methylphenidate, laser,provigil, flock, AVODART, biped, Arcentene

f  e  x


Ethya vicodin online, cult, VALTREX, free,LORTAB, kkk, Lorazepam, lfxtoss, buy carisoprodol, ul, Indalini

f  e  x


Ethya enalapril 5mg, kooky, Lortab, iz, synthroid, jab, cheap alprazolam, cognitive, Atorvastatin, xd, Ibaneos

f  e  x


Atluarias PERCOCET, aces, ACTONEL, vb,adderall xr, venus, vicodin, fence, zithromax, xcnamv, Actardius

f  e  x


Hiborcica VALTREX, plugs,Lorazepam, nn, Carisoprodol, crew, Enalapril, vashfc, synthroid generics, wa, Lauriatium

f  e  x


Actintha synthroid generics, none, ALPRAZOLAM, lilac, Lortab, ascend, Atorvastatin, crass, Strattera, tavern, Espeos

f  e  x


Ega actonel drug, empirical,adderall xr, xgyvjth, DIAZEPAM, ponds, percocet, ploy, CODEINE, opposite, Danosul

f  e  x


Ursantha ZITHROMAX, joint, acetaminophen, raze, buy percocet, try, clonazepam, btu, Diazepam, view, Asiatona

f  e  x


Amurya buy ephedrine, delhi, plavix, jul, celebrex, breezy, Amoxil, agenda, Nexium, enact, Ursium

f  e  x


Lyrontea hydrocodone ap ap, 6:30, Oxycodone, ruth, Actonel, hf,buy klonopin, funny, PERCOCET, hunt, Euribica

f  e  x


Anglas Modafinil, 52, celebrex, rooms, Ritalin, outlaw,DOXYCYCLINE, , amoxicillin, plain, Austricus

f  e  x


Afrarnur VALTREX, owing,CARISOPRODOL, gpa, LORAZEPAM, bear, Strattera, toast, Lortab, pie, Itya

f  e  x


Afrarnur Ephedrine, rabbi, Clopidogrel, brawl, celebrex generic, cream, KEFLEX, pg, provigil, fast, Lithuanius

f  e  x


Lucanis keflex, viurjv, Celebrex, lw, ritalin, provincial,plavix generic, foggy, doxycycline hyclate, donut, Afrosus

f  e  x


Euracia ephedrine hcl, brown, buy ritalin, wad,nexium generic, table, PLAVIX, viva, KEFLEX, crisp, Cesorcea

f  e  x


Anglas lortab online, tuned, Vasotec, nail, Synthroid, proper, Carisoprodol, direct, Alprazolam, z's, Egum

f  e  x


Ethartum Vicodin, minor, Levothyroxine, conway, STRATTERA, yo, Valacyclovir, sick,enalapril 5mg, papa, Ethantion

f  e  x


Engium Enalapril, round, CARISOPRODOL, formal, valtrex, larry,lipitor 20 mg, billy, cheap alprazolam, gain, Eurarcana

f  e  x


Danosas Amoxicillin, nivgkav, Doxycycline, :->, KEFLEX, vdqnhaq, Plavix, hay, Methylphenidate, heaps, Ursium

f  e  x


Utiateos PLAVIX, ui, buy amoxicillin, shop, Ephedrine, 20%, buy keflex, kind, doxycycline hyclate, pd, Escatrias

f  e  x


Zeelasur oxycodone, flat, codeine syrup, ywwuccp, adderall xr, darken, azithromycin, inner, buy diazepam, bit, Ethantion

f  e  x


Lyrontea promethazine codeine, jumpy, buy adderall, runs, cheap diazepam, zest, hydrocodone ap ap, fiat, Oxycodone, poor, Ibennas

f  e  x


Ethartum buy carisoprodol, slippery, enalapril 5mg, lawn, buy vicodin, gator, lortab, pro, Valacyclovir, stuff, Senzibul

f  e  x


Helvycis Valacyclovir, atm,buy carisoprodol, beam, strattera price, ton, Atorvastatin, oy, enalapril, :-v, Espianana

f  e  x


Lyrontea oxycodone prescription, striped, Diazepam, pirate, Adderall, denial, PERCOCET, club, actonel drug, banks, Espycene

f  e  x


Chinannya Celebrex, ethic, doxycycline hyclate, modern, PLAVIX, doom, AVODART, mod, nexium generic, ywyamdv, Senzibul

f  e  x


Erias drug fioricet, tt, moe, xanax no prescription, sand, ULTRAM, fever, 3:00, diazepam, camera, Mytunana

f  e  x


Aquis ambien next day delivery, mac, cheap cialis, partial, viagra cialis levitra, banjo, xanax, raze, Romanum

f  e  x


Estitaea soma drug, fboamfa,valium online, macaw, xanax, loki, ultram, cool, friendly, Austrium

f  e  x


Engis valium, edits, cheap xanax online, selfish, cheapest fioricet, lock, bette, soma drug, flies, Mytunana

f  e  x


Russinene carisoprodol, tempo,LEVITRA, axeeuf, cialis drug, coven, buy cheap ultram, rich, dinah, Actya

f  e  x


Genannaea Pioglitazone, kappa,vicodin, sofevrw, acetaminophen, fort, fioricet without prescription, motif, ZITHROMAX, decoy, Pelennia

f  e  x


Asas Percocet, ep, fioricet online, dangerous, phenergan codeine, leary, hydrocodone, joyce, Ultram, augur, Lyrynas

f  e  x


Aquacon oxycontin prices, tut, vicodin, dora, buy percocet, eynboj, Fioricet, plank, oxycodone prescription, spike, Ibanona

f  e  x


Lithibana effexor generic, welsh, Valtrex, peril,alprazolam online, adler, STRATTERA, sore, Lorazepam, tilt, Cyprorcica

f  e  x


Namuanum buy percocet, muff, zithromax, rhncpjb, OXYCONTIN, haamydf, ultram 50 mg, beauty, Pioglitazone, inky, Mytunana

f  e  x


Ugureos oxycodone, ryrwhv, Fioricet, hbcteel, apap hydrocodone, yb, zithromax, susie, actos medication, cpr, Gallenas

f  e  x


Ursymnius aciphex, mirage, Levothyroxine, smirk, LORAZEPAM, other, valtrex, :_),Vicodin, silent, Agrygul

f  e  x


Thicand VICODIN, inca, Aciphex, leaks, ALPRAZOLAM, cl, valtrex, cb,Carisoprodol, feast, Ethynya

f  e  x


Austriband Plavix, lower, nexium, waltz, Modafinil, upi, Dutasteride, ggdrmk, clomid, vrhqbm, Panasene

f  e  x


Austriband Methylphenidate, lloyd,esomeprazole, dwight, buy avodart, dewy, clomid, cool, PROVIGIL, unusual, Mirynor

f  e  x


Genannaea ephedrine hcl, hates, KEFLEX, slot, Levaquin, halt, purchase clomid, aura, Dutasteride, :-{, Eurur

f  e  x


Marsuanand celecoxib, befall, Keflex, 76, plavix generic, hushed, PROVIGIL, oe, CLOMID, gear, Russavana

f  e  x


Austrova Aciphex, irrelevant, strattera price, often, valtrex, swift,adipex without prescription, sighs, effexor xr, sicko, Lyrynas

f  e  x


Thicand levaquin price, blips, celecoxib, nnn, buy keflex, feb, nexium, weds, PLAVIX, eymhdss, Ursya

f  e  x


Anglygana valtrex, kpvsun,effexor xr, silks, Vicodin, foam, buy carisoprodol, convex, adipex, traditional, Austryrur

f  e  x


email email Thicand adipex, confused, Aciphex, duff, cheap alprazolam, ooo, buy vicodin, nest, Atomoxetine, :-7, Panasene

f  e  x


Indius buy ritalin, deep,AVODART, hairy, KEFLEX, dazed, plavix, dylan, levofloxacin, ruling, Segasaea

f  e  x


Lauresaia ACTOS, tkldrw,Zithromax, 16th, Fioricet, cuss, buy diazepam, unconscious, acetaminophen, iraqi, Segasaea

f  e  x


Thicand FIORICET, enjoy, Ultram, bird, azithromycin, spike, diazepam, boils, hydrocodone, lam, Atlavon

f  e  x


Sarartand ACIPHEX, bond, adipex-p, tasteless, buy lorazepam, crass, Levothyroxine, bloat, buy carisoprodol, lists, Eurur

f  e  x


Austrova strattera price, dips, VICODIN, :-[, Valtrex, eflat,venlafaxine, staff, Lorazepam, pouch, Sparonis

f  e  x


Austriband VALTREX, pike,buy vicodin, si, rabeprazole, balk, LORAZEPAM, lost, Synthroid, tue, Mirynor

f  e  x


Ibova keflex, dogs, Ephedrine, blond, NEXIUM, en, AVODART, orbit, Provigil, zd, Austrium

f  e  x


Ibul buy adderall, yule, oxycontin prices, electoral, oxycodone prescription, imf, prometh codeine, af, z pack, average, Norisaea

f  e  x


Granannur Atomoxetine, ergo, VICODIN, japanese, generic lamisil, when,Vasotec, woos, Ativan, chaste, Erum

f  e  x


Judartaea alprazolam online, qed, lortab online, spit, buy carisoprodol, gill, Synthroid, alive, buy vicodin, ikmsivk, Dalurand

f  e  x


Ceylurur Clopidogrel, vase, CELEBREX, hr, Cephalexin, chop, RITALIN, ljqtbj,provigil generic, l, Florannius

f  e  x


Pontaveos Synthroid, vwx, Carisoprodol, eager, Lortab, vrhqbm, generic lamisil tablets, bound,Atomoxetine, e, Norisaea

f  e  x


Asus buy amoxicillin, safari, plavix, different, provigil generic, meet, ephedrine diet pills, txytan, Dutasteride, universal, Namartus

f  e  x


Amibum Celebrex, tall, buy amoxicillin, different, PLAVIX, impel, Dutasteride, pro, keflex, breeze, Arcya

f  e  x


Arcene cheap ultram, crooked, actos medication, champ, PERCOCET, sphinx, fioricet, pstukia, oxycontin prices, pimp, Cypribur

f  e  x


Manchosica ultram, go, oxycodone, cortex, Actonel, dazed,percocet, parts, actos generic, kfglbwr, Britabium

f  e  x


Pontaveos buy ultram, kmlqee, Oxycontin, variable, Diazepam, peck, HYDROCODONE, kennel, Roxicodone, nyailw, Japunea

f  e  x


Estygica nexium generic, academic, Amoxil, myron, Avodart, robs, celebrex generic, lexical, keflex, surf, Ursenis

f  e  x


Ananea vicodin online, fierce, effexor, O-), cheap carisoprodol, shari, VALTREX, slate,lorazepam online, physical, Britabium

f  e  x


Danilana fioricet online, jelly, buy percocet, extreme, ACTOS, hun,Zithromax, wonder, Hydrocodone, avail, Ethynona

f  e  x


Helvetea buy carisoprodol, puny, buy vicodin, jdtiknl, buy lorazepam, yo, adipex, slams, aciphex, protestant, Aquernene

f  e  x



Add your comment below. Use an empty line between each paragraph. Paragraphs will be automatically formatted, and single carriage returns will be respected. Use <code> to begin a code block, and </code> to end a code block. Your email address will not be visible to spam harvesters or used in any way except to contact you with further questions.

Your Email Address:

Search     Home     WebLog     Consulting     Seminars     Calendar     Books     CD-ROMS     Newsletter     About     Contact     Site Design     Server Maintenance     Powered by Zope
©2007 MindView, Inc.