Beginner Question

2016-06-01 Thread Marcin Rak
Hi to all I have a beginner question to which I have not found an answer I was able to understand. Could someone explain why the following program: def f(a, L=[]): L.append(a) return L print(f(1)) print(f(2)) print(f(3)) gives us the following result: [1] [1,2] [1,2,3] How can this

Re: Beginner Question

2016-06-02 Thread Marcin Rak
That linked help clear up my confusion...yes you really have to know how things work internally to understand why things happen the way they happen. Thanks again to all -- https://mail.python.org/mailman/listinfo/python-list

the global keyword:

2016-06-11 Thread Marcin Rak
Hi to all. I have the following file named Solver.py: * from Test import some_function, my_print from Test import test_var some_function() my_print() print(test_var) * and I have the following Test.py: **

Re: the global keyword:

2016-06-11 Thread Marcin Rak
On Saturday, 11 June 2016 18:51:11 UTC-5, Random832 wrote: > On Sat, Jun 11, 2016, at 19:44, Marcin Rak wrote: > > So my question is, how the heck is it possible that I get 5 as the last > > value printed? the global test_var (global to Test.py) I set to 44 when I > > ran som

Re: the global keyword:

2016-06-11 Thread Marcin Rak
On Saturday, 11 June 2016 19:09:29 UTC-5, MRAB wrote: > On 2016-06-12 00:50, Random832 wrote: > > On Sat, Jun 11, 2016, at 19:44, Marcin Rak wrote: > >> So my question is, how the heck is it possible that I get 5 as the last > >> value printed? the global test_var (glo

Re: the global keyword:

2016-06-12 Thread Marcin Rak
Much thanks to all for their time, but Ned in particular...I learned something new about Python!! On Saturday, 11 June 2016 22:48:32 UTC-5, Ned Batchelder wrote: > On Saturday, June 11, 2016 at 11:38:33 PM UTC-4, Steven D'Aprano wrote: > > On Sun, 12 Jun 2016 11:26 am, Random832 wrote: > > > >

base64.b64encode(data)

2016-06-12 Thread Marcin Rak
Hi to everyone. Let's say I have some binary data, be it whatever, in the 'data' variable. After calling the following line b64_encoded_data = base64.b64encode(data) my b64_encoded_data variables holds, would you believe it, a string as bytes!. That is, the b64_encoded_data variable is of type