コード例 #1
0
###############################################################################
# Copyright (c) 2005, 2007 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#

###############################################################################

import _utils
# number operations
a1 = 1
_utils.out("a1", a1)
a2 = 2
_utils.out("a2", a2)

b1 = a1 + a2
_utils.out("b1", b1)
b2 = a1 * a2
_utils.out("b2", b2)
b3 = a1 / a2
_utils.out("b3", b3)
b4 = a1**a2
_utils.out("b4", b4)
b5 = a1 // a2
_utils.out("b5", b5)
b6 = a1 >> a2
_utils.out("b6", b6)
b7 = a1 << a2
_utils.out("b7", b7)
コード例 #2
0
###############################################################################
# Copyright (c) 2005, 2007 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#

###############################################################################

import _utils
# number operations
a1 = 1					; _utils.out( "a1", a1 )
a2 = 2					; _utils.out( "a2", a2 )

b1 = a1 + a2				; _utils.out( "b1", b1 )
b2 = a1 * a2				; _utils.out( "b2", b2 )
b3 = a1 / a2				; _utils.out( "b3", b3 )
b4 = a1 ** a2				; _utils.out( "b4", b4 )
b5 = a1 // a2				; _utils.out( "b5", b5 )
b6 = a1 >> a2				; _utils.out( "b6", b6 )
b7 = a1 << a2				; _utils.out( "b7", b7 )
b8 = a1 ^ a2				; _utils.out( "b8", b8 )

# string operations

s1 = "A%s"				; _utils.out( "s1", s1 )
s2 = "B"				; _utils.out( "s2", s1 )
su1= u"A"				; _utils.out( "su1", su1 )

sb1 = s1 + s2				; _utils.out( "sb1", sb1 )
コード例 #3
0
###############################################################################
# Copyright (c) 2005, 2007 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#

###############################################################################

import _utils
from _simple import *

i1 = a
_utils.out("i1", i1)
i2 = b
_utils.out("i2", i2)
i3 = c
_utils.out("i3", i3)
i4 = d
_utils.out("i4", i4)
i5 = e
_utils.out("i5", i5)


class A:
    from _simple import a, b, e


i5a = A()
_utils.out("i5a", i5a)
コード例 #4
0
###############################################################################
# Copyright (c) 2005, 2007 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#

###############################################################################

import _utils
import pkg.pkg2.module

# will import pkg.__init__.py
# will import pkg.pkg2.__init__.py
# will import pkg.pkg2.module

i1 = pkg.pkg2.module.module_val ;_utils.out( "i1", i1 )
i2 = pkg.pkg2.b			;_utils.out( "i2", i2 )
i3 = pkg.a			;_utils.out( "i3", i3 )
コード例 #5
0
###############################################################################
# Copyright (c) 2005, 2007 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#

###############################################################################

import _utils


class A:
    def q(self):
        self.t = 20

    def f(self):
        return self.t


a = A()
_utils.out("a", a)
a.q()
c = a.f()
_utils.out("c", c)
コード例 #6
0
###############################################################################
# Copyright (c) 2005, 2007 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#

###############################################################################

import _utils

class A:
    def q(self):
	self.t = 20
    def f( self ):
	return self.t
a = A()		;_utils.out( "a", a )
a.q()
c = a.f()	;_utils.out( "c", c )
コード例 #7
0
###############################################################################
# Copyright (c) 2005, 2007 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#

###############################################################################

import _utils

from pkg.class0 import *


class test1_0(test1):
    def __init__(self):
        test1.__init__(self)
        self.test1_0_a0 = self.test1_a0


val_test1_0_class = test1_0()
ta0 = val_test1_0_class.test1_0_a0
_utils.out("ta0", ta0)
コード例 #8
0
###############################################################################
# Copyright (c) 2005, 2007 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#

###############################################################################

import _utils

from pkg.class0 import *
class test1_0(test1):
    def __init__( self ):
	test1.__init__( self )
	self.test1_0_a0 = self.test1_a0
val_test1_0_class = test1_0( )
ta0 = val_test1_0_class.test1_0_a0			; _utils.out( "ta0", ta0 )
コード例 #9
0
###############################################################################
# Copyright (c) 2005, 2007 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#

###############################################################################

import _utils
class A:
	def a1(self):
		return 1
	def a2(self):
		return "S"
a = A()

c1 = a.a1()		; _utils.out( "c1", c1 )
c2 = a.a2()		; _utils.out( "c2", c2 )
コード例 #10
0

def a2():
    return "A"


def a3():
    return [50]


def a4():
    return (1)


_a1 = a1()
_utils.out("_a1", _a1)
_a2 = a2()
_utils.out("_a2", _a2)
_a3 = a3()
_utils.out("_a3", _a3)
_a4 = a4()
_utils.out("_a4", _a4)

# complex


def c1():
    return a1()


def c2():
コード例 #11
0
###############################################################################
# Copyright (c) 2005, 2007 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#

###############################################################################

import _utils
import _module0
import _simple

im0 = _module0.a
_utils.out("im0", im0)
im1 = _simple.a
_utils.out("im1", im1)
コード例 #12
0
# http://www.eclipse.org/legal/epl-v10.html
#

###############################################################################

import _utils
def a1():
	return 10
def a2():
	return "A"
def a3():
	return [50]
def a4():
	return (1)

_a1 = a1()				;_utils.out( "_a1", _a1 )
_a2 = a2()				;_utils.out( "_a2", _a2 )
_a3 = a3()				;_utils.out( "_a3", _a3 )
_a4 = a4()				;_utils.out( "_a4", _a4 )

# complex

def c1():
	return a1()
def c2():
	return a1() + 2
def c3():
	return a2()
def c4():
	return a3()
def c5():
コード例 #13
0
###############################################################################
# Copyright (c) 2005, 2007 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#

###############################################################################

import _utils
from _simple import *

i1 = a						;_utils.out( "i1", i1 )
i2 = b						;_utils.out( "i2", i2 )
i3 = c						;_utils.out( "i3", i3 )
i4 = d						;_utils.out( "i4", i4 )
i5 = e						;_utils.out( "i5", i5 )

class A:
    from _simple import a,b,e

i5a = A()					;_utils.out( "i5a", i5a )
i6 = A.a					;_utils.out( "i6", i6 )
i7 = A.b					;_utils.out( "i7", i7 )
try:
	i8 = A.c # unknown should be.
except:
	print "i8 unknown"
i9 = A.e					;_utils.out( "i9", i9 )
try:
コード例 #14
0

class D(B):
    s3 = "S3"

    def __init__(self):
        B.__init__(self)
        self.d1 = self.b1 + 1
        self.d2 = self.b2 + "D"
        self.d3 = self.b3
        self.d4 = self.b4 + ("D")
        self.d5 = self.b5 + ["D"]


a = A()
_utils.out("a", a)
b = B()
_utils.out("b", b)
d = D()
_utils.out("d", d)

# A tests
c1 = a.s1
_utils.out("c1", c1)
c2 = a.a1
_utils.out("c2", c2)
c3 = a.a2
_utils.out("c3", c3)
c4 = a.a3
_utils.out("c4", c4)
c5 = a.a4
コード例 #15
0
###############################################################################
# Copyright (c) 2005, 2007 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#

###############################################################################

import _utils
class A:
    def __init__( self ):
	pass
    def c(self):
	pass
class B( A ):
    def __init__( self ):
	A.__init__( self )
	pass
class D( B ):
    def __init__( self ):
	B.__init__( self )
	pass

a = A() 				; _utils.out( "a", a )
b = B()					; _utils.out( "b", b )
d = D()					; _utils.out( "d", d )
コード例 #16
0
	A.__init__( self )
	self.b1 = self.a1 + 1
	self.b2 = self.a2 + "B"
	self.b3 = self.a3
	self.b4 = self.a4 + ("B")
	self.b5 = self.a5 + ["B"]
class D( B ):
    s3 = "S3"
    def __init__( self ):
	B.__init__( self )
	self.d1 = self.b1 + 1
	self.d2 = self.b2 + "D"
	self.d3 = self.b3
	self.d4 = self.b4 + ("D")
	self.d5 = self.b5 + ["D"]
a = A()					; _utils.out( "a", a )
b = B()					; _utils.out( "b", b )
d = D()					; _utils.out( "d", d )

# A tests
c1 = a.s1				; _utils.out( "c1", c1 )
c2 = a.a1				; _utils.out( "c2", c2 )
c3 = a.a2				; _utils.out( "c3", c3 )
c4 = a.a3				; _utils.out( "c4", c4 )
c5 = a.a4				; _utils.out( "c5", c5 )
c6 = a.a5				; _utils.out( "c6", c6 )

# B Tests
e1 = b.s2				; _utils.out( "e1", e1 )
e2 = b.s1				; _utils.out( "e2", e2 )
e3 = b.b1				; _utils.out( "e3", e3 )