[issue36223] Execution sequence for print function

2020-09-15 Thread Ketan Sharma
Change by Ketan Sharma : -- nosy: -iitkgp.ke...@gmail.com ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: ht

[issue36223] Execution sequence for print function

2019-03-10 Thread Ketan Sharma
Ketan Sharma added the comment: Realized this is expected behavior. Slight modification to the existing comments: Resolution happens in usual order for print(a, pola(a), a). 1) a -> is a reference to the array, resolved as is. 2) pola(a) -> changes the values pointed at by the reference a 3)

[issue36223] Execution sequence for print function

2019-03-07 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Agreed with @remi.lapeyre. There is no delayed evaluation in Python and this is not only related to print but it's the general evaluation model in Python. Another example as below since foo(1) is used as an argument it's evaluated first and then th

[issue36223] Execution sequence for print function

2019-03-07 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: print does not execute statements, arguments are first resolved like with any function. Your code is equivalent to: >>> def pola(arr): ... for i, item in enumerate(arr): ... arr[i] = item*item ... >>> a = [1,2,3,4] >>> pola(a) >>> print(a, None,

[issue36223] Execution sequence for print function

2019-03-07 Thread Ketan Sharma
New submission from Ketan Sharma : >>> def pola(arr): ... for i, item in enumerate(arr): ... arr[i] = item*item ... >>> a = [1,2,3,4] >>> print(a,pola(a),a) [1, 4, 9, 16] None [1, 4, 9, 16] I would expect the print statement to execute and print the arguments sequentially from left to ri