Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions doc/user/subtelties.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ It can then be instantiated in the axiom and modified during the simulation::
Axiom: Apex(ApexParameters(age=0))
dt = 1
derivation length: 2
production:
Apex(p) :
p.age += dt
produce Node() Apex(p)
Expand All @@ -26,12 +27,12 @@ Creating the lsystem and running it the first time will produce the expected res

>>> l = Lsystem('mycode.lpy')
>>> lstring = l.derive()
>>> print lstring
>>> print(lstring)
Node()Node()Apex(ApexParameters(age=2))

However, a strange behavior occurs when asking for the axiom.::

>>> print l.axiom
>>> print(l.axiom)
Apex(ApexParameters(age=2))

In fact, this behavior is due to the way python manage object. By default, complex objects
Expand All @@ -40,7 +41,7 @@ are not copied but simply shared between variables.::
>>> a = ApexParameters(age=0)
>>> b = a
>>> b.age = 2
>>> print a.age
>>> print(a.age)
2

The variables ``b`` and ``a`` point toward the same object in memory. This one will be destroyed only when no variable
Expand Down
4 changes: 2 additions & 2 deletions src/openalea/lpy/gui/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def open(self,fname):
elif answer == QMessageBox.Discard:
os.remove(bckupname)
os.chdir(os.path.dirname(self.fname))
code = open(readname,'rU').read()
code = open(readname,'r').read()
self.readonly = (not os.access(fname, os.W_OK))
self.textedition = recovery
self.setEdited(recovery)
Expand All @@ -367,7 +367,7 @@ def importtmpfile(self,fname):
self.textedition = True
self.setEdited(True)
try:
lpycode = open(fname,'rU').read()
lpycode = open(fname,'r').read()
self.opencode(lpycode)
self._tmpfname = fname
except:
Expand Down
Loading