python.modules: vocab hierarchy for standard library modules
pre-existing bindings for various python modules can be placed here so that they dont have to be redeclared for everyone using themdb4
parent
87b0205c87
commit
e819e34cec
|
@ -0,0 +1,31 @@
|
||||||
|
USING: python.syntax ;
|
||||||
|
IN: python.modules.__builtin__
|
||||||
|
|
||||||
|
PY-FROM: __builtin__ =>
|
||||||
|
callable ( obj -- ? )
|
||||||
|
dir ( obj -- seq )
|
||||||
|
int ( val -- s )
|
||||||
|
len ( seq -- n )
|
||||||
|
open ( name mode -- file )
|
||||||
|
range ( n -- seq )
|
||||||
|
repr ( obj -- str ) ;
|
||||||
|
|
||||||
|
PY-METHODS: obj =>
|
||||||
|
__name__ ( self -- n )
|
||||||
|
__str__ ( o -- str ) ;
|
||||||
|
|
||||||
|
PY-METHODS: file =>
|
||||||
|
close ( self -- )
|
||||||
|
fileno ( self -- n )
|
||||||
|
tell ( self -- n ) ;
|
||||||
|
|
||||||
|
PY-METHODS: str =>
|
||||||
|
lower ( self -- self' )
|
||||||
|
partition ( self sep -- bef sep aft )
|
||||||
|
startswith ( self str -- ? )
|
||||||
|
title ( self -- self' )
|
||||||
|
zfill ( self n -- str' ) ;
|
||||||
|
|
||||||
|
PY-METHODS: list =>
|
||||||
|
append ( list obj -- )
|
||||||
|
remove ( list obj -- ) ;
|
|
@ -0,0 +1,7 @@
|
||||||
|
USING: python.syntax ;
|
||||||
|
IN: python.modules.argparse
|
||||||
|
|
||||||
|
PY-FROM: argparse => ArgumentParser ( -- self ) ;
|
||||||
|
PY-METHODS: ArgumentParser =>
|
||||||
|
add_argument ( self name ** -- )
|
||||||
|
format_help ( self -- str ) ;
|
|
@ -0,0 +1,4 @@
|
||||||
|
USING: python.syntax ;
|
||||||
|
IN: python.modules.datetime
|
||||||
|
|
||||||
|
PY-FROM: datetime => timedelta ( ** -- timedelta ) ;
|
|
@ -0,0 +1,6 @@
|
||||||
|
USING: python.syntax ;
|
||||||
|
IN: python.modules.os
|
||||||
|
|
||||||
|
PY-FROM: os =>
|
||||||
|
getpid ( -- y )
|
||||||
|
system ( x -- y ) ;
|
|
@ -0,0 +1,6 @@
|
||||||
|
USING: python.syntax ;
|
||||||
|
IN: python.modules.os.path
|
||||||
|
|
||||||
|
PY-FROM: os.path =>
|
||||||
|
basename ( x -- x' )
|
||||||
|
splitext ( x -- base ext ) ;
|
|
@ -0,0 +1,8 @@
|
||||||
|
USING: python.syntax ;
|
||||||
|
IN: python.modules.sys
|
||||||
|
|
||||||
|
PY-FROM: sys =>
|
||||||
|
path ( -- seq )
|
||||||
|
argv ( -- seq )
|
||||||
|
getrefcount ( obj -- n )
|
||||||
|
platform ( -- x ) ;
|
|
@ -0,0 +1,4 @@
|
||||||
|
USING: python.syntax ;
|
||||||
|
IN: python.modules.time
|
||||||
|
|
||||||
|
PY-FROM: time => sleep ( n -- ) ;
|
|
@ -1,12 +1,9 @@
|
||||||
USING: arrays kernel python python.ffi python.syntax sequences ;
|
USING: arrays kernel python python.ffi python.modules.__builtin__ python.syntax
|
||||||
|
sequences ;
|
||||||
IN: python.throwing
|
IN: python.throwing
|
||||||
|
|
||||||
PY-FROM: traceback => format_tb ( tb -- seq ) ;
|
PY-FROM: traceback => format_tb ( tb -- seq ) ;
|
||||||
|
|
||||||
PY-METHODS: obj =>
|
|
||||||
__name__ ( o -- str )
|
|
||||||
__str__ ( o -- str ) ;
|
|
||||||
|
|
||||||
: throw-error ( ptype pvalue ptraceback -- )
|
: throw-error ( ptype pvalue ptraceback -- )
|
||||||
[
|
[
|
||||||
[ $__name__ py> ]
|
[ $__name__ py> ]
|
||||||
|
|
Loading…
Reference in New Issue