1 #!/usr/bin/env python 2 3 """ 4 Simple built-in classes and functions. Objects which provide code which shall 5 always be compiled should provide docstrings. 6 7 Copyright (C) 2005, 2006, 2007, 2008, 2009 Paul Boddie <paul@boddie.org.uk> 8 9 This program is free software; you can redistribute it and/or modify it under 10 the terms of the GNU General Public License as published by the Free Software 11 Foundation; either version 3 of the License, or (at your option) any later 12 version. 13 14 This program is distributed in the hope that it will be useful, but WITHOUT 15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 details. 18 19 You should have received a copy of the GNU General Public License along with 20 this program. If not, see <http://www.gnu.org/licenses/>. 21 """ 22 23 class object: 24 def __init__(self): pass 25 def __bool__(self): pass 26 def __iadd__(self, other): pass 27 28 class basestring(object): 29 def __init__(self, x=None): pass 30 def __getitem__(self, index): pass 31 def __getslice__(self, start, end=None): pass 32 def __iadd__(self, other): pass 33 def __add__(self, other): pass 34 def __radd__(self, other): pass 35 def __mul__(self, other): pass 36 def __rmul__(self, other): pass 37 def __mod__(self, other): pass 38 def __rmod__(self, other): pass 39 def __lt__(self, other): pass 40 def __gt__(self, other): pass 41 def __le__(self, other): pass 42 def __ge__(self, other): pass 43 def __eq__(self, other): pass 44 def __ne__(self, other): pass 45 def __len__(self): pass 46 def __str__(self): pass 47 def __bool__(self): pass 48 def join(self, l): pass 49 50 class bool(object): 51 def __bool__(self): pass 52 def __str__(self): pass 53 54 class buffer(object): 55 def __init__(self, size): pass 56 def append(self, s): pass 57 def __str__(self): pass 58 59 class complex(object): 60 def __init__(self, real, imag=None): pass 61 62 class dict(object): 63 def __init__(self, *args): pass 64 def __setitem__(self, key, value): pass 65 def __getitem__(self, key): pass 66 67 class file(object): 68 def write(self, s): pass 69 70 class float(object): 71 def __init__(self, number_or_string=None): pass 72 def __iadd__(self, other): pass 73 def __isub__(self, other): pass 74 def __add__(self, other): pass 75 def __radd__(self, other): pass 76 def __sub__(self, other): pass 77 def __rsub__(self, other): pass 78 def __mul__(self, other): pass 79 def __rmul__(self, other): pass 80 def __div__(self, other): pass 81 def __rdiv__(self, other): pass 82 def __floordiv__(self, other): pass 83 def __rfloordiv__(self, other): pass 84 def __mod__(self, other): pass 85 def __rmod__(self, other): pass 86 def __pow__(self, other): pass 87 def __rpow__(self, other): pass 88 def __lt__(self, other): pass 89 def __gt__(self, other): pass 90 def __le__(self, other): pass 91 def __ge__(self, other): pass 92 def __eq__(self, other): pass 93 def __ne__(self, other): pass 94 def __neg__(self): pass 95 def __pos__(self): pass 96 def __str__(self): pass 97 def __bool__(self): pass 98 99 class frozenset(object): 100 def __init__(self, iterable): pass 101 102 class function(object): 103 pass 104 105 class int(object): 106 def __init__(self, number_or_string=None): pass 107 def __iadd__(self, other): pass 108 def __isub__(self, other): pass 109 def __iand__(self, other): pass 110 def __ior__(self, other): pass 111 def __add__(self, other): pass 112 def __radd__(self, other): pass 113 def __sub__(self, other): pass 114 def __rsub__(self, other): pass 115 def __mul__(self, other): pass 116 def __rmul__(self, other): pass 117 def __div__(self, other): pass 118 def __rdiv__(self, other): pass 119 def __floordiv__(self, other): pass 120 def __rfloordiv__(self, other): pass 121 def __mod__(self, other): pass 122 def __rmod__(self, other): pass 123 def __pow__(self, other): pass 124 def __rpow__(self, other): pass 125 def __and__(self, other): pass 126 def __rand__(self, other): pass 127 def __or__(self, other): pass 128 def __ror__(self, other): pass 129 def __xor__(self, other): pass 130 def __rxor__(self, other): pass 131 def __lt__(self, other): pass 132 def __gt__(self, other): pass 133 def __le__(self, other): pass 134 def __ge__(self, other): pass 135 def __eq__(self, other): pass 136 def __ne__(self, other): pass 137 def __neg__(self): pass 138 def __pos__(self): pass 139 def __str__(self): pass 140 def __bool__(self): pass 141 def __lshift__(self): pass 142 def __rlshift__(self): pass 143 def __rshift__(self): pass 144 def __rrshift__(self): pass 145 146 class list(object): 147 def __init__(self, args=()): pass 148 def __getitem__(self, index): pass 149 def __setitem__(self, index, value): pass 150 def __getslice__(self, start, end=None): pass 151 def __setslice__(self, start, end, slice): pass 152 def append(self, value): pass 153 def __len__(self): pass 154 def __add__(self, other): pass 155 def __iadd__(self, other): pass 156 def __str__(self): pass 157 def __bool__(self): pass 158 159 def __iter__(self): 160 161 "Return an iterator." 162 163 return listiterator(self) 164 165 class listiterator(object): 166 def __init__(self, l): pass 167 def next(self): pass 168 169 class long(object): 170 def __init__(self, number_or_string=None): pass 171 def __iadd__(self, other): pass 172 def __isub__(self, other): pass 173 def __add__(self, other): pass 174 def __radd__(self, other): pass 175 def __sub__(self, other): pass 176 def __rsub__(self, other): pass 177 def __mul__(self, other): pass 178 def __rmul__(self, other): pass 179 def __div__(self, other): pass 180 def __rdiv__(self, other): pass 181 def __floordiv__(self, other): pass 182 def __rfloordiv__(self, other): pass 183 def __and__(self, other): pass 184 def __rand__(self, other): pass 185 def __or__(self, other): pass 186 def __ror__(self, other): pass 187 def __xor__(self, other): pass 188 def __rxor__(self, other): pass 189 def __lt__(self, other): pass 190 def __gt__(self, other): pass 191 def __le__(self, other): pass 192 def __ge__(self, other): pass 193 def __eq__(self, other): pass 194 def __ne__(self, other): pass 195 def __neg__(self): pass 196 def __pos__(self): pass 197 def __str__(self): pass 198 def __bool__(self): pass 199 200 class set(object): 201 def __init__(self, iterable): pass 202 203 class slice(object): 204 def __init__(self, start_or_end, end=None, step=None): pass 205 206 class str(basestring): 207 pass 208 209 class type(object): 210 pass 211 212 class tuple(object): 213 def __init__(self, args): pass 214 def __getitem__(self, index): pass 215 def __getslice__(self, start, end=None): pass 216 def __len__(self): pass 217 def __add__(self, other): pass 218 def __str__(self): pass 219 def __iter__(self): pass 220 def __bool__(self): pass 221 222 class unicode(basestring): 223 pass 224 225 class xrange(object): 226 227 "Implementation of xrange." 228 229 def __init__(self, start_or_end, end=None, step=1): 230 231 "Initialise the xrange with the given 'start_or_end', 'end' and 'step'." 232 233 if end is None: 234 self.start = 0 235 self.end = start_or_end 236 else: 237 self.start = start_or_end 238 self.end = end 239 240 self.step = step 241 self.current = self.start 242 243 def __iter__(self): 244 245 "Return an iterator, currently self." 246 247 return self 248 249 def next(self): 250 251 "Return the next item or raise a StopIteration exception." 252 253 if self.step < 0 and self.current <= self.end or self.step > 0 and self.current >= self.end: 254 raise StopIteration() 255 256 current = self.current 257 self.current += self.step 258 return current 259 260 # Exceptions and warnings. 261 262 class BaseException(object): 263 264 "Implementation of BaseException." 265 266 def __init__(self, *args): 267 self.args = args 268 269 class Exception(BaseException): pass 270 class Warning(object): pass 271 272 class ArithmeticError(Exception): pass 273 class AssertionError(Exception): pass 274 class AttributeError(Exception): pass 275 class DeprecationWarning(Exception): pass 276 class EOFError(Exception): pass 277 class EnvironmentError(Exception): pass 278 class FloatingPointError(Exception): pass 279 class FutureWarning(Warning): pass 280 class GeneratorExit(Exception): pass 281 class ImportError(Exception): pass 282 class ImportWarning(Warning): pass 283 class IndentationError(Exception): pass 284 class IndexError(Exception): pass 285 class IOError(Exception): pass 286 class KeyError(Exception): pass 287 class KeyboardInterrupt(Exception): pass 288 class LookupError(Exception): pass 289 class MemoryError(Exception): pass 290 class NameError(Exception): pass 291 class NotImplementedError(Exception): pass 292 class OSError(Exception): pass 293 class OverflowError(Exception): pass 294 class PendingDeprecationWarning(Warning): pass 295 class ReferenceError(Exception): pass 296 class RuntimeError(Exception): pass 297 class RuntimeWarning(Warning): pass 298 class StandardError(Exception): pass 299 class StopIteration(Exception): "Implementation of StopIteration." 300 class SyntaxError(Exception): pass 301 class SyntaxWarning(Warning): pass 302 class SystemError(Exception): pass 303 class SystemExit(Exception): pass 304 class TabError(Exception): pass 305 class TypeError(Exception): pass 306 class UnboundLocalError(Exception): pass 307 class UnicodeDecodeError(Exception): pass 308 class UnicodeEncodeError(Exception): pass 309 class UnicodeError(Exception): pass 310 class UnicodeTranslateError(Exception): pass 311 class UnicodeWarning(Warning): pass 312 class UserWarning(Warning): pass 313 class ValueError(Exception): pass 314 class ZeroDivisionError(Exception): pass 315 316 # Various types. 317 318 #class ellipsis: pass 319 class NoneType: pass 320 class NotImplementedType: pass 321 322 # General functions. 323 # NOTE: Some of these are actually provided by classes in CPython. 324 # NOTE: We may refuse to support some of these in practice, such as... 325 # NOTE: super, reload. 326 327 def __import__(name, globals=None, locals=None, fromlist=None, level=-1): pass 328 def abs(number): pass 329 def all(iterable): pass 330 def any(iterable): pass 331 def callable(obj): pass 332 def chr(i): pass 333 def classmethod(function): pass 334 def cmp(x, y): pass 335 def compile(source, filename, mode, flags=None, dont_inherit=None): pass 336 def delattr(obj, name): pass 337 def dir(obj=None): pass 338 def divmod(x, y): pass 339 def enumerate(iterable): pass 340 def eval(source, globals=None, locals=None): pass 341 def execfile(filename, globals=None, locals=None): pass 342 def filter(function, sequence): pass 343 def getattr(obj, name, default=None): pass 344 def globals(): pass 345 def hasattr(obj, name): pass 346 def hash(obj): pass 347 def help(*args): pass 348 def hex(number): pass 349 def id(obj): pass 350 def input(prompt=None): pass 351 def isinstance(obj, cls_or_tuple): pass 352 def issubclass(obj, cls_or_tuple): pass 353 def iter(collection_or_callable, sentinel=None): pass 354 355 def len(obj): 356 357 "Implementation of len." 358 359 return obj.__len__() 360 361 def locals(): pass 362 def map(function, *args): pass 363 def max(*args): pass 364 def min(*args): pass 365 def oct(number): pass 366 def open(name, mode=None, buffering=None): pass 367 def ord(c): pass 368 def pow(x, y, z=None): pass 369 def property(fget=None, fset=None, fdel=None, doc=None): pass 370 371 def range(start_or_end, end=None, step=1): 372 373 "Implementation of range." 374 375 l = [] 376 for i in xrange(start_or_end, end, step): 377 l.append(i) 378 return l 379 380 def raw_input(prompt=None): pass 381 def reduce(function, sequence, initial=None): pass 382 def reload(module): pass 383 def repr(obj): pass 384 def reversed(sequence): pass 385 def round(number, ndigits=None): pass 386 def setattr(obj, name, value): pass 387 def sorted(iterable, cmp=None, key=None, reverse=False): pass 388 def staticmethod(function): pass 389 def sum(sequence, start=0): pass 390 def super(*args): pass 391 def unichr(i): pass 392 def vars(obj=None): pass 393 def zip(*args): pass 394 395 # Reference some names to ensure their existence. This should be everything 396 # mentioned in a get_builtin or load_builtin call. Instances from this module 397 # should be predefined constants. 398 399 function 400 AttributeError 401 StopIteration 402 TypeError 403 IndexError 404 405 list 406 tuple 407 #xrange 408 #ellipsis 409 #bool 410 411 # vim: tabstop=4 expandtab shiftwidth=4