Esempio n. 1
0
def run():
    dict = {'name': 1, 'Age': 2}
    dict['name'] = dict.get("name", 2) + 10
    print dict["name"]

    a = [1, 2, 3, 4, 5, 6]
    b = [2, 3]
    # if a.__contains__("")

    for d in dict.keys():
        print len(d), "-", d, "-", dict[d]
Esempio n. 2
0
#
# Tests for DELETE_SUBSCR bytecode
#
l = range(5)
print "del l[3]"
del l[3]
print l
assert l[3] == 4

d = {}
for n in range(5):
    d[n] = n
print "del d[3]"
del d[3]
assert 3 not in dict.keys(d)
print "d=", d

#
# Test for DELETE_NAME bytecode
#
del d
assert "d" not in dict.keys(locals())
print "keys(locals)=", dict.keys(locals())


#
# Test the DELETE_GLOBAL bytecode
#
def delglob():
    global l
Esempio n. 3
0
#
# System Test 136
# Create module interface for compound datatypes
#

import dict, list


# Tests for dict
if 1:
    d = {}
    d[0] = "zero"
    d["one"] = 1
    print d
    print dict.keys(d)
    print dict.values(d)

    dict.clear(d)
    print d
    d['new'] = "more"
    print d

    print "d has key 'new' = ", dict.has_key(d, 'new')
    print "d has key 'old' = ", dict.has_key(d, 'old')


# Tests for list
if 1:
    foo = [0]
    list.append(foo, 1)
Esempio n. 4
0
#
# System Test 136
# Create module interface for compound datatypes
#

import dict, list


# Tests for dict
if 1:
    d = {}
    d[0] = "zero"
    d["one"] = 1
    print d
    print dict.keys(d)
    print dict.values(d)

    dict.clear(d)
    print d
    d['new'] = "more"
    print d

    print "d has key 'new' = ", dict.has_key(d, 'new')
    print "d has key 'old' = ", dict.has_key(d, 'old')


# Tests for list
if 1:
    foo = [0]
    list.append(foo, 1)
Esempio n. 5
0
#
# Tests for DELETE_SUBSCR bytecode
#
l = range(5)
print "del l[3]"
del l[3]
print l
assert l[3] == 4


d = {}
for n in range(5):
    d[n] = n
print "del d[3]"
del d[3]
assert 3 not in dict.keys(d)
print "d=", d


#
# Test for DELETE_NAME bytecode
#
del d
assert "d" not in dict.keys(locals())
print "keys(locals)=", dict.keys(locals())


#
# Test the DELETE_GLOBAL bytecode
#
def delglob():
Esempio n. 6
0
print ();
print a;
print len(a);
print a[0],a[-1];
##print a[2:5];  ## slicees are not implemented yet 
##print a[:];  ## slicees are not implemented yet 
for x in a:
	print x,x*x;
print "=== check: dict";
a={"four":4,"five":5,"six":6};
print a;
print a["four"];
print len(a);
print "six" in a;
print "one" in a;
print dict.keys(a);
print "=== check: for loop 10 print and if statement";
for i in range(0,11):
	print i;
	if(i==5):
		print "if-then %-22.20f" % (1.0/i);
	if(i<3):
		print "if-(then)-else %32.32f" % (1.0*i);
	else:
		print "if-then-(else) %-.32f" % (1.0/i);
print "=== check: for loop 100 func-call-loop";
for i in range(0,100):
	j= nulladd(i)+j;
j= nulllib(j);
print j
Esempio n. 7
0
# This file is Copyright 2003, 2006, 2007, 2009 Dean Hall.
#
# This file is part of the Python-on-a-Chip program.
# Python-on-a-Chip is free software: you can redistribute it and/or modify
# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
#
# Python-on-a-Chip is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
# is seen in the file COPYING up one directory from this.

#
# System Test 138
# globals namespace isn't right
#

import dict

print "dict.keys(globals()) = ", dict.keys(globals())

assert "__bi" in dict.keys(globals())