|The PEAK Developers' Center||FrontPage||RecentChanges||TitleIndex||WordIndex||SiteNavigation||HelpContents|
Installing SymbolType (using "easy_install SymbolType" or "setup.py install") gives you access to the peak.util.symbols module, previously available only by installing the full PEAK toolkit. peak.util.symbols provides a Symbol type and two built-in symbols that are used by PEAK: NOT_FOUND and NOT_GIVEN. You can create your own symbol objects using the Symbol type, by giving it the symbol name and the name of the module where the symbol is being created:
>>> from peak.util.symbols import Symbol >>> AN_EXAMPLE = Symbol('AN_EXAMPLE', __name__)
The resulting object's repr() and str() forms are the same as the name you passed in:
>>> AN_EXAMPLE AN_EXAMPLE >>> str(AN_EXAMPLE) 'AN_EXAMPLE'
But symbols compare equal only to themselves; they are not equal to strings:
>>> AN_EXAMPLE == 'AN_EXAMPLE' False >>> AN_EXAMPLE == AN_EXAMPLE True
A symbol's __name__ and __module__ attributes are the original name and module used to create the symbol:
>>> from peak.util.symbols import NOT_FOUND >>> NOT_FOUND.__name__ 'NOT_FOUND' >>> NOT_FOUND.__module__ 'peak.util.symbols'
The reason that symbols want to know their defining module is that this allows them to be pickled and unpickled correctly:
>>> import pickle >>> pickle.loads(pickle.dumps(NOT_FOUND)) NOT_FOUND
Specifically, it's so that the result of unpickling a symbol is exactly the same object as the original symbol:
>>> pickle.loads(pickle.dumps(NOT_FOUND)) is NOT_FOUND True
Note that this means the symbol must be defined at module level within its module, with the same name that's passed in to it, or else pickle will not be able to find it when unpickling.
Last, but not least, symbol objects are immutable and cannot be changed in any way:
>>> AN_EXAMPLE.foo = "bar" Traceback (most recent call last): ... TypeError: Symbols are immutable
Please direct questions regarding this package to the PEAK mailing list; see http://www.eby-sarna.com/mailman/listinfo/PEAK/ for details.
[http://homepage.mac.com/marylander1/3.html amature webcams] | [http://nightstick.angelcities.com/81.html free porno photos] | [http://embosses.angelcities.com/23.html cutie tgirls] | [http://homepage.mac.com/dilatory/48.html webcam chat hostess] | [http://scotsman.dreamstation.com/55.html orgasm girl sounds] | [http://metabolic.100freemb.com/21.html live webcam just] | [http://parlays.150m.com/81.html blonde mature porn] | [http://homepage.mac.com/domestics/29.html submitted teen webcam] | [http://righting.wtcsites.com/49.html free lesbian webcams] | [http://homepage.mac.com/presbyopia/1.html showgirl yahoo webcam] | [http://redeposit.angelcities.com/75.html hot spring break] | [http://emotional.o-f.com/65.html voyeur showers] | [http://closures.bravepages.com/6.html hirsute fuckers] | [http://airwomen.fcpages.com/79.html long webcam blowjob] | [http://dander.o-f.com/75.html thong milf gallery] | [http://tuckers.freewebpages.org/21.html nude muscular twinks] | [http://sinuous.150m.com/96.html sexy butts] | [http://graduate.exactpages.com/30.html teens personal webcam] | [http://yeltsin.fcpages.com/91.html thong pantie pictues] | [http://homepage.mac.com/unhandiest/36.html harley webcam chat] | [http://gutsy.fcpages.com/69.html lesbian teen group] | [http://dills.9cy.com/18.html hot mama mpeg] | [http://polyps.741.com/16.html open tgirl] | [http://syllabi.150m.com/18.html anal midgets] | [http://rotations.angelcities.com/11.html creampie eating husbands] | [http://umpires.1accesshost.com/49.html granny lesbian pornography] | [http://homepage.mac.com/impasto1/79.html preview webcam girls] | [http://abductors.00freehost.com/46.html gay midget] | [http://vibrating.freewebpages.org/10.html ass lick worship] | [http://homepage.mac.com/rehashed1/4.html porn cartoon site]