2014-01-28 13:45:31 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								USING: accessors arrays assocs calendar continuations destructors fry kernel
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-31 09:59:04 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								math namespaces python python.ffi python.objects sequences strings tools.test ;
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-12 23:01:11 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								IN: python
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-27 15:59:59 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								py-initialize
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: py-test ( result quot -- )
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-27 15:59:59 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    '[ _ with-destructors ] unit-test ; inline
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ t ] [ Py_GetVersion string? ] unit-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								[ "os" ] [ "os" py-import PyModule_GetName ] py-test
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-31 06:18:12 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								[ t ] [
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    "os" py-import "getpid" getattr
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    { } >py call-object py> 0 >
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-31 06:18:12 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								] py-test
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ t ] [ Py_IsInitialized ] py-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								! py-importing
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ { "ImportError" "No module named kolobi" } ] [
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ "kolobi" py-import ] [ [ type>> ] [ message>> ] bi 2array ] recover
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								] py-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-30 09:06:30 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								! setattr
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ 73 ] [
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    "sys" py-import "testit" [ 73 >py setattr ] [ getattr py> ] 2bi
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-30 09:06:30 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								] py-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Tuples
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ 2 ] [ 2 <py-tuple> py-tuple-size ] py-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: py-datepy> ( py-obj -- timestamp )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    { "year" "month" "day" } [ getattr py> ] with map
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    first3 0 0 0 instant <timestamp> ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-30 11:24:58 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								! Lists
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								[ t ] [ V{ 4 8 15 16 23 42 } dup >py py> = ] py-test
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-30 11:24:58 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-27 15:59:59 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								! ! Datetimes
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ t ] [
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ py-datepy> ] "date" py-type-dispatch get set-at
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    "datetime" py-import "date" getattr "today" getattr
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    { } >py call-object py>
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    today instant >>gmt-offset =
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								] py-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Unicode
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ "غثههح" ] [
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    "os.path" py-import "basename" getattr { "غثههح" } >py call-object py>
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								] py-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Instance variables
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ 7 ] [
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    "datetime" py-import "timedelta" getattr
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    { 7 } >py call-object "days" getattr py>
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								] py-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Create a dictonary
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ 0 ] [ <py-dict> py-dict-size ] py-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Dictionary with object keys
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ 1 ] [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    <py-dict> dup 0 >py 33 >py py-dict-set-item py-dict-size
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								] py-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Dictionary with string keys
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ 1 ] [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    <py-dict> [ "foo" 33 >py py-dict-set-item-string ] [ py-dict-size ] bi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								] py-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Get dictionary items
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ 33 ] [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    <py-dict> "tjaba"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ 33 >py  py-dict-set-item-string ]
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ py-dict-get-item-string py> ] 2bi
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								] py-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Nest dicts
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ 0 ] [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    <py-dict> "foo"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ <py-dict> py-dict-set-item-string ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ py-dict-get-item-string ] 2bi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    py-dict-size
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								] py-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Nested tuples
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ 3 ] [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    1 <py-tuple> dup 0 3 <py-tuple> py-tuple-set-item
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    0 py-tuple-get-item py-tuple-size
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								] py-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Round tripping!
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								[ { "foo" { 99 77 } } ] [ { "foo" { 99 77 } } >py py> ] py-test
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ H{ { "foo" "bar" } { 3 4 } } ] [
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    H{ { "foo" "bar" } { 3 4 } } >py py>
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								] py-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Kwargs
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ 2014 10 22 ] [
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    "datetime" py-import "date" getattr
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-31 06:18:12 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { } >py H{ { "year" 2014 } { "month" 10 } { "day" 22 } } >py
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    call-object-full py>
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 17:45:25 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ year>> ] [ month>> ] [ day>> ] tri
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								] py-test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Modules
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-28 06:14:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								[ t ] [
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 12:39:02 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    "os" py-import PyModule_GetDict dup Py_IncRef &Py_DecRef py-dict-size 100 >
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-28 06:14:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								] py-test
							 |