Re: Django strange behaviour

2014-11-09 Thread Scot Hacker
On Saturday, November 8, 2014 9:07:04 AM UTC-8, monoBOT monoBOT wrote: > > Lists are inmutable > Lists are absolutely mutable in Python - hence the availability of `result.append()`. Perhaps you're thinking of tuples, which are not mutable and have no methods for alteration. ./s >>

Re: Django strange behaviour

2014-11-08 Thread Rafał Pitoń
This happens because "result" is class level attribute, not instance one, and its expected behaviour in Python. To made result instance attribute, define it in your __init__: class Demo(): def __init__(self): self.result = [] def do_something(self): self.result.append(1

Re: Django strange behaviour

2014-11-08 Thread Aliane Abdelouahab
here is what is gives in the console: class Demo(): result = [] def do_something(self): self.result.append(1) self.result.append(2) self.result.append(3) return self.result demo = Demo() result = demo.do_something() result [1, 2, 3] demo = Demo()

Re: Django strange behaviour

2014-11-08 Thread Aliane Abdelouahab
you are calling the function twice, appending every element, and then appending the whole list! Le samedi 8 novembre 2014 18:07:04 UTC+1, monoBOT monoBOT a écrit : > > Lists are inmutable You are modifiying the same list everytime you > invoque that view > El 07/11/2014 10:08, "termopro" >

Re: Django strange behaviour

2014-11-08 Thread monoBOT
Lists are inmutable You are modifiying the same list everytime you invoque that view El 07/11/2014 10:08, "termopro" escribió: > I have a view in Django which calls external library/class. The problem is > that for some reason Django keeps caching results coming from previous > calls of that

Re: Django strange behaviour

2014-11-07 Thread Erik Cederstrand
> Den 07/11/2014 kl. 10.08 skrev termopro : > > I have a view in Django which calls external library/class. The problem is > that for some reason Django keeps caching results coming from previous calls > of that class. This is expected Python behaviour - see https://docs.python.org/3/tutoria