Package tp :: Package client :: Package pyscheme :: Module symbol
[show private | hide private]
[frames | no frames]

Module tp.client.pyscheme.symbol

A simple "symbol" class for Python.  Symbols are like strings,
except that symbols should only be comparable to other symbols.  This
module is designed so that one should be able to do a "from symbol
import *" on this.

To create a new Symbol, use the Symbol() function, like this:

    hello = Symbol("hello")

All symbols are interned so that comparison using 'is' will work.  For
example,

    Symbol("hello") is Symbol("h" + "ello")

should work.

By default, all symbols are case insensitive, but if the module
variable CASE_SENSITIVE is set to a true value, symbols will become
case sensitive.

Also, we use the UserString to make sure that symbols are of a
different "class" than Strings.  isSymbol() depends on this
representation, so be careful about changing it.

Classes
__Symbol Support class for symbols.

Function Summary
  isSymbol(x)
Returns True if x is already a symbol.
  Symbol(s)
Generates a new Symbol that we guarantee can be compared in constant time to any other symbol.
  makeUniqueTemporary(_counter)
Constructs a symbol that does not collide with any other symbol.

Variable Summary
__Symbol __empty_symbol = ''
WeakValueDictionary __interned_symbols = <WeakValueDictionary at -1214362580...
str __license__ = 'MIT License'
int CASE_SENSITIVE = 0                                                                     
__Symbol false = '#f'
__Symbol true = '#t'

Function Details

isSymbol(x)

Returns True if x is already a symbol.

Symbol(s)

Generates a new Symbol that we guarantee can be compared in
constant time to any other symbol.

makeUniqueTemporary(_counter=[0])

Constructs a symbol that does not collide with any other
symbol.  I'll use this to help with the macro-expansion.

NOTE/FIXME: we do this by making an "illegal" symbol which starts
with a number and contains a space.  The parser module doesn't
allow such symbols to exist... although it's possible to subvert this
by calling STRING->SYMBOL.  So this mechanism is not perfect.

Variable Details

__empty_symbol

Type:
__Symbol
Value:
''                                                                     

__interned_symbols

Type:
WeakValueDictionary
Value:
<WeakValueDictionary at -1214362580>                                   

__license__

Type:
str
Value:
'MIT License'                                                          

CASE_SENSITIVE

Type:
int
Value:
0                                                                     

false

Type:
__Symbol
Value:
'#f'                                                                   

true

Type:
__Symbol
Value:
'#t'                                                                   

Generated by Epydoc 2.1 on Fri Jan 1 08:00:27 2010 http://epydoc.sf.net