A
Andreas Lobinger
Aloha,
i'm i little bit confused by the following behaviour...
lobingera@sibyl: cat flip.py
import random
paras = { 'flength' : 22,
'cset' : 'abcdefghijkl' }
rstate = 1
def f():
random.seed(rstate)
s = list()
for i in range(paras['flength']):
s.append(random.choice(paras['cset']))
return "".join(s)
def g():
random.seed(rstate)
s = list()
for i in range(paras['flength']):
s.append(random.choice(paras['cset']))
rstate = random.getseed()
return "".join(s)
I try to save the state of the random module locally in flip.
I also have other parameters (paras) in the module.
lobingera@sibyl: python
Python 2.2.2 (#3, Apr 10 2003, 17:06:52)
[GCC 2.95.2 19991024 (release)] on sunos5
Type "help", "copyright", "credits" or "license" for more information.Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "flip.py", line 17, in g
random.seed(rstate)
UnboundLocalError: local variable 'rstate' referenced before assignmentSomehow 'rstate' is readable in f, but not in g, but paras is?
Wishing a happy day
LOBI
i'm i little bit confused by the following behaviour...
lobingera@sibyl: cat flip.py
import random
paras = { 'flength' : 22,
'cset' : 'abcdefghijkl' }
rstate = 1
def f():
random.seed(rstate)
s = list()
for i in range(paras['flength']):
s.append(random.choice(paras['cset']))
return "".join(s)
def g():
random.seed(rstate)
s = list()
for i in range(paras['flength']):
s.append(random.choice(paras['cset']))
rstate = random.getseed()
return "".join(s)
I try to save the state of the random module locally in flip.
I also have other parameters (paras) in the module.
lobingera@sibyl: python
Python 2.2.2 (#3, Apr 10 2003, 17:06:52)
[GCC 2.95.2 19991024 (release)] on sunos5
Type "help", "copyright", "credits" or "license" for more information.Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "flip.py", line 17, in g
random.seed(rstate)
UnboundLocalError: local variable 'rstate' referenced before assignmentSomehow 'rstate' is readable in f, but not in g, but paras is?
Wishing a happy day
LOBI