Save variables in every iteration of for loop and load them later










0















I want to save the variables m, n, r, X, Y (see code below) in one file e.g file_1 and
repeat for every iteration with a new file name prefarably with
the iteration number e.g., file_2.



In MATLAB I could simply do save(['data_',int2str(i),'.mat'],'variable1', 'variable2' ) so that data(1) will contain m, n, r, X, Y; data(2) will contain m, n, r, X, Y with their new values, and so on



How do I do same in Python?



Test = 5
for i in range(Tests):
r = 5
m = 500
n = 500
X=np.random.rand(m,n)
Y=np.random.rand(m,n)









share|improve this question



















  • 1





    You can save the variables to a file using the pickle library

    – G. Anderson
    Nov 13 '18 at 20:57















0















I want to save the variables m, n, r, X, Y (see code below) in one file e.g file_1 and
repeat for every iteration with a new file name prefarably with
the iteration number e.g., file_2.



In MATLAB I could simply do save(['data_',int2str(i),'.mat'],'variable1', 'variable2' ) so that data(1) will contain m, n, r, X, Y; data(2) will contain m, n, r, X, Y with their new values, and so on



How do I do same in Python?



Test = 5
for i in range(Tests):
r = 5
m = 500
n = 500
X=np.random.rand(m,n)
Y=np.random.rand(m,n)









share|improve this question



















  • 1





    You can save the variables to a file using the pickle library

    – G. Anderson
    Nov 13 '18 at 20:57













0












0








0








I want to save the variables m, n, r, X, Y (see code below) in one file e.g file_1 and
repeat for every iteration with a new file name prefarably with
the iteration number e.g., file_2.



In MATLAB I could simply do save(['data_',int2str(i),'.mat'],'variable1', 'variable2' ) so that data(1) will contain m, n, r, X, Y; data(2) will contain m, n, r, X, Y with their new values, and so on



How do I do same in Python?



Test = 5
for i in range(Tests):
r = 5
m = 500
n = 500
X=np.random.rand(m,n)
Y=np.random.rand(m,n)









share|improve this question
















I want to save the variables m, n, r, X, Y (see code below) in one file e.g file_1 and
repeat for every iteration with a new file name prefarably with
the iteration number e.g., file_2.



In MATLAB I could simply do save(['data_',int2str(i),'.mat'],'variable1', 'variable2' ) so that data(1) will contain m, n, r, X, Y; data(2) will contain m, n, r, X, Y with their new values, and so on



How do I do same in Python?



Test = 5
for i in range(Tests):
r = 5
m = 500
n = 500
X=np.random.rand(m,n)
Y=np.random.rand(m,n)






python loops save load






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 21:42









Cris Luengo

21k52249




21k52249










asked Nov 13 '18 at 20:54









Farouk YahayaFarouk Yahaya

113




113







  • 1





    You can save the variables to a file using the pickle library

    – G. Anderson
    Nov 13 '18 at 20:57












  • 1





    You can save the variables to a file using the pickle library

    – G. Anderson
    Nov 13 '18 at 20:57







1




1





You can save the variables to a file using the pickle library

– G. Anderson
Nov 13 '18 at 20:57





You can save the variables to a file using the pickle library

– G. Anderson
Nov 13 '18 at 20:57












3 Answers
3






active

oldest

votes


















2














The pickle library is the way to go here.



import pickle
Tests = 5
data =
for i in range(Tests):
data['r'] = 5
data['m'] = 500
data['n'] = 500
data['X'] = np.random.rand(data['m'],data['n'])
data['Y'] = np.random.rand(data['m'],data['n'])
with open('data.pickle'.format(i), 'wb') as f:
pickle.dump(data, f)


This allows you to access your dictionary of data later. For example,



with open('data0.pickle', 'rb') as f:
data = pickle.load(f)
r = data['r']
m = data['m']


and so on.






share|improve this answer

























  • How assuming my loop was till 40. can i use a loop to load all 40?

    – Farouk Yahaya
    Nov 13 '18 at 21:16











  • You can always move the code that loads the pickled data into a for loop, allowing you to load all 40. Just change the name of the file within the for loop, like the above code does in saving the data.

    – jwil
    Nov 13 '18 at 21:17












  • Thanks a lot Jwil

    – Farouk Yahaya
    Nov 13 '18 at 21:27











  • Feel free to accept the answer if it worked for you so more people don't spend time typing their solutions. @Farouk Yahaya

    – jwil
    Nov 13 '18 at 21:28












  • I tried to implemt it. it underlines the word data. and says "Unresolved reference 'data' less... (Ctrl+F1) Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items."

    – Farouk Yahaya
    Nov 13 '18 at 21:38


















0














Here is how you can do the same in python.



import numpy as np
Test = 2
for i in range(Test):
r = 5
m = 500
n = 500
X=np.random.rand(m,n)
Y=np.random.rand(m,n)
file_name = 'test_'+str(i)
open(file_name,'w').write(str(r) + str(m) + str(n) + str(X) + str(Y))





share|improve this answer























  • why will you cast them to str. they are real values. X and Y are matrix. Im new to python btw.

    – Farouk Yahaya
    Nov 13 '18 at 21:13











  • If you don't cast it, it will throw error - TypeError: write() argument must be str, not numpy.ndarray

    – Sanchit Kumar
    Nov 13 '18 at 21:19











  • So can u please tell me how to load it. and if i do load it, will i get them back in their original format? i.e scalars and matrices and not as strings?

    – Farouk Yahaya
    Nov 13 '18 at 21:22











  • If you want to preserve the properties of the object such as the data type and all, then prefer using pickle() to save the data and it as an object.

    – Sanchit Kumar
    Nov 13 '18 at 21:25











  • Thanks a lot Sanchit

    – Farouk Yahaya
    Nov 13 '18 at 21:28


















0














If you would like to do it without using any libraries here's my solution:



import numpy as np
Test = 5
for i in range(Test):
r = 5
m = 500
n = 500
X=np.random.rand(m,n)
Y=np.random.rand(m,n)

file = open('file_'.format(i+1), 'w')
file.write('r = ;m = ;n = ;X = ;Y = '.format(r, m, n, X, Y))
file.close()


Loading saved variables



exec(open('file_1', 'r').read())





share|improve this answer























  • this looks simple for small range. my loop will go from 1 to 40. when loading exucuting them one by one can be annoyning.

    – Farouk Yahaya
    Nov 13 '18 at 21:15










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53289354%2fsave-variables-in-every-iteration-of-for-loop-and-load-them-later%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














The pickle library is the way to go here.



import pickle
Tests = 5
data =
for i in range(Tests):
data['r'] = 5
data['m'] = 500
data['n'] = 500
data['X'] = np.random.rand(data['m'],data['n'])
data['Y'] = np.random.rand(data['m'],data['n'])
with open('data.pickle'.format(i), 'wb') as f:
pickle.dump(data, f)


This allows you to access your dictionary of data later. For example,



with open('data0.pickle', 'rb') as f:
data = pickle.load(f)
r = data['r']
m = data['m']


and so on.






share|improve this answer

























  • How assuming my loop was till 40. can i use a loop to load all 40?

    – Farouk Yahaya
    Nov 13 '18 at 21:16











  • You can always move the code that loads the pickled data into a for loop, allowing you to load all 40. Just change the name of the file within the for loop, like the above code does in saving the data.

    – jwil
    Nov 13 '18 at 21:17












  • Thanks a lot Jwil

    – Farouk Yahaya
    Nov 13 '18 at 21:27











  • Feel free to accept the answer if it worked for you so more people don't spend time typing their solutions. @Farouk Yahaya

    – jwil
    Nov 13 '18 at 21:28












  • I tried to implemt it. it underlines the word data. and says "Unresolved reference 'data' less... (Ctrl+F1) Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items."

    – Farouk Yahaya
    Nov 13 '18 at 21:38















2














The pickle library is the way to go here.



import pickle
Tests = 5
data =
for i in range(Tests):
data['r'] = 5
data['m'] = 500
data['n'] = 500
data['X'] = np.random.rand(data['m'],data['n'])
data['Y'] = np.random.rand(data['m'],data['n'])
with open('data.pickle'.format(i), 'wb') as f:
pickle.dump(data, f)


This allows you to access your dictionary of data later. For example,



with open('data0.pickle', 'rb') as f:
data = pickle.load(f)
r = data['r']
m = data['m']


and so on.






share|improve this answer

























  • How assuming my loop was till 40. can i use a loop to load all 40?

    – Farouk Yahaya
    Nov 13 '18 at 21:16











  • You can always move the code that loads the pickled data into a for loop, allowing you to load all 40. Just change the name of the file within the for loop, like the above code does in saving the data.

    – jwil
    Nov 13 '18 at 21:17












  • Thanks a lot Jwil

    – Farouk Yahaya
    Nov 13 '18 at 21:27











  • Feel free to accept the answer if it worked for you so more people don't spend time typing their solutions. @Farouk Yahaya

    – jwil
    Nov 13 '18 at 21:28












  • I tried to implemt it. it underlines the word data. and says "Unresolved reference 'data' less... (Ctrl+F1) Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items."

    – Farouk Yahaya
    Nov 13 '18 at 21:38













2












2








2







The pickle library is the way to go here.



import pickle
Tests = 5
data =
for i in range(Tests):
data['r'] = 5
data['m'] = 500
data['n'] = 500
data['X'] = np.random.rand(data['m'],data['n'])
data['Y'] = np.random.rand(data['m'],data['n'])
with open('data.pickle'.format(i), 'wb') as f:
pickle.dump(data, f)


This allows you to access your dictionary of data later. For example,



with open('data0.pickle', 'rb') as f:
data = pickle.load(f)
r = data['r']
m = data['m']


and so on.






share|improve this answer















The pickle library is the way to go here.



import pickle
Tests = 5
data =
for i in range(Tests):
data['r'] = 5
data['m'] = 500
data['n'] = 500
data['X'] = np.random.rand(data['m'],data['n'])
data['Y'] = np.random.rand(data['m'],data['n'])
with open('data.pickle'.format(i), 'wb') as f:
pickle.dump(data, f)


This allows you to access your dictionary of data later. For example,



with open('data0.pickle', 'rb') as f:
data = pickle.load(f)
r = data['r']
m = data['m']


and so on.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 13 '18 at 21:48

























answered Nov 13 '18 at 21:05









jwiljwil

1799




1799












  • How assuming my loop was till 40. can i use a loop to load all 40?

    – Farouk Yahaya
    Nov 13 '18 at 21:16











  • You can always move the code that loads the pickled data into a for loop, allowing you to load all 40. Just change the name of the file within the for loop, like the above code does in saving the data.

    – jwil
    Nov 13 '18 at 21:17












  • Thanks a lot Jwil

    – Farouk Yahaya
    Nov 13 '18 at 21:27











  • Feel free to accept the answer if it worked for you so more people don't spend time typing their solutions. @Farouk Yahaya

    – jwil
    Nov 13 '18 at 21:28












  • I tried to implemt it. it underlines the word data. and says "Unresolved reference 'data' less... (Ctrl+F1) Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items."

    – Farouk Yahaya
    Nov 13 '18 at 21:38

















  • How assuming my loop was till 40. can i use a loop to load all 40?

    – Farouk Yahaya
    Nov 13 '18 at 21:16











  • You can always move the code that loads the pickled data into a for loop, allowing you to load all 40. Just change the name of the file within the for loop, like the above code does in saving the data.

    – jwil
    Nov 13 '18 at 21:17












  • Thanks a lot Jwil

    – Farouk Yahaya
    Nov 13 '18 at 21:27











  • Feel free to accept the answer if it worked for you so more people don't spend time typing their solutions. @Farouk Yahaya

    – jwil
    Nov 13 '18 at 21:28












  • I tried to implemt it. it underlines the word data. and says "Unresolved reference 'data' less... (Ctrl+F1) Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items."

    – Farouk Yahaya
    Nov 13 '18 at 21:38
















How assuming my loop was till 40. can i use a loop to load all 40?

– Farouk Yahaya
Nov 13 '18 at 21:16





How assuming my loop was till 40. can i use a loop to load all 40?

– Farouk Yahaya
Nov 13 '18 at 21:16













You can always move the code that loads the pickled data into a for loop, allowing you to load all 40. Just change the name of the file within the for loop, like the above code does in saving the data.

– jwil
Nov 13 '18 at 21:17






You can always move the code that loads the pickled data into a for loop, allowing you to load all 40. Just change the name of the file within the for loop, like the above code does in saving the data.

– jwil
Nov 13 '18 at 21:17














Thanks a lot Jwil

– Farouk Yahaya
Nov 13 '18 at 21:27





Thanks a lot Jwil

– Farouk Yahaya
Nov 13 '18 at 21:27













Feel free to accept the answer if it worked for you so more people don't spend time typing their solutions. @Farouk Yahaya

– jwil
Nov 13 '18 at 21:28






Feel free to accept the answer if it worked for you so more people don't spend time typing their solutions. @Farouk Yahaya

– jwil
Nov 13 '18 at 21:28














I tried to implemt it. it underlines the word data. and says "Unresolved reference 'data' less... (Ctrl+F1) Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items."

– Farouk Yahaya
Nov 13 '18 at 21:38





I tried to implemt it. it underlines the word data. and says "Unresolved reference 'data' less... (Ctrl+F1) Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items."

– Farouk Yahaya
Nov 13 '18 at 21:38













0














Here is how you can do the same in python.



import numpy as np
Test = 2
for i in range(Test):
r = 5
m = 500
n = 500
X=np.random.rand(m,n)
Y=np.random.rand(m,n)
file_name = 'test_'+str(i)
open(file_name,'w').write(str(r) + str(m) + str(n) + str(X) + str(Y))





share|improve this answer























  • why will you cast them to str. they are real values. X and Y are matrix. Im new to python btw.

    – Farouk Yahaya
    Nov 13 '18 at 21:13











  • If you don't cast it, it will throw error - TypeError: write() argument must be str, not numpy.ndarray

    – Sanchit Kumar
    Nov 13 '18 at 21:19











  • So can u please tell me how to load it. and if i do load it, will i get them back in their original format? i.e scalars and matrices and not as strings?

    – Farouk Yahaya
    Nov 13 '18 at 21:22











  • If you want to preserve the properties of the object such as the data type and all, then prefer using pickle() to save the data and it as an object.

    – Sanchit Kumar
    Nov 13 '18 at 21:25











  • Thanks a lot Sanchit

    – Farouk Yahaya
    Nov 13 '18 at 21:28















0














Here is how you can do the same in python.



import numpy as np
Test = 2
for i in range(Test):
r = 5
m = 500
n = 500
X=np.random.rand(m,n)
Y=np.random.rand(m,n)
file_name = 'test_'+str(i)
open(file_name,'w').write(str(r) + str(m) + str(n) + str(X) + str(Y))





share|improve this answer























  • why will you cast them to str. they are real values. X and Y are matrix. Im new to python btw.

    – Farouk Yahaya
    Nov 13 '18 at 21:13











  • If you don't cast it, it will throw error - TypeError: write() argument must be str, not numpy.ndarray

    – Sanchit Kumar
    Nov 13 '18 at 21:19











  • So can u please tell me how to load it. and if i do load it, will i get them back in their original format? i.e scalars and matrices and not as strings?

    – Farouk Yahaya
    Nov 13 '18 at 21:22











  • If you want to preserve the properties of the object such as the data type and all, then prefer using pickle() to save the data and it as an object.

    – Sanchit Kumar
    Nov 13 '18 at 21:25











  • Thanks a lot Sanchit

    – Farouk Yahaya
    Nov 13 '18 at 21:28













0












0








0







Here is how you can do the same in python.



import numpy as np
Test = 2
for i in range(Test):
r = 5
m = 500
n = 500
X=np.random.rand(m,n)
Y=np.random.rand(m,n)
file_name = 'test_'+str(i)
open(file_name,'w').write(str(r) + str(m) + str(n) + str(X) + str(Y))





share|improve this answer













Here is how you can do the same in python.



import numpy as np
Test = 2
for i in range(Test):
r = 5
m = 500
n = 500
X=np.random.rand(m,n)
Y=np.random.rand(m,n)
file_name = 'test_'+str(i)
open(file_name,'w').write(str(r) + str(m) + str(n) + str(X) + str(Y))






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 21:02









Sanchit KumarSanchit Kumar

36319




36319












  • why will you cast them to str. they are real values. X and Y are matrix. Im new to python btw.

    – Farouk Yahaya
    Nov 13 '18 at 21:13











  • If you don't cast it, it will throw error - TypeError: write() argument must be str, not numpy.ndarray

    – Sanchit Kumar
    Nov 13 '18 at 21:19











  • So can u please tell me how to load it. and if i do load it, will i get them back in their original format? i.e scalars and matrices and not as strings?

    – Farouk Yahaya
    Nov 13 '18 at 21:22











  • If you want to preserve the properties of the object such as the data type and all, then prefer using pickle() to save the data and it as an object.

    – Sanchit Kumar
    Nov 13 '18 at 21:25











  • Thanks a lot Sanchit

    – Farouk Yahaya
    Nov 13 '18 at 21:28

















  • why will you cast them to str. they are real values. X and Y are matrix. Im new to python btw.

    – Farouk Yahaya
    Nov 13 '18 at 21:13











  • If you don't cast it, it will throw error - TypeError: write() argument must be str, not numpy.ndarray

    – Sanchit Kumar
    Nov 13 '18 at 21:19











  • So can u please tell me how to load it. and if i do load it, will i get them back in their original format? i.e scalars and matrices and not as strings?

    – Farouk Yahaya
    Nov 13 '18 at 21:22











  • If you want to preserve the properties of the object such as the data type and all, then prefer using pickle() to save the data and it as an object.

    – Sanchit Kumar
    Nov 13 '18 at 21:25











  • Thanks a lot Sanchit

    – Farouk Yahaya
    Nov 13 '18 at 21:28
















why will you cast them to str. they are real values. X and Y are matrix. Im new to python btw.

– Farouk Yahaya
Nov 13 '18 at 21:13





why will you cast them to str. they are real values. X and Y are matrix. Im new to python btw.

– Farouk Yahaya
Nov 13 '18 at 21:13













If you don't cast it, it will throw error - TypeError: write() argument must be str, not numpy.ndarray

– Sanchit Kumar
Nov 13 '18 at 21:19





If you don't cast it, it will throw error - TypeError: write() argument must be str, not numpy.ndarray

– Sanchit Kumar
Nov 13 '18 at 21:19













So can u please tell me how to load it. and if i do load it, will i get them back in their original format? i.e scalars and matrices and not as strings?

– Farouk Yahaya
Nov 13 '18 at 21:22





So can u please tell me how to load it. and if i do load it, will i get them back in their original format? i.e scalars and matrices and not as strings?

– Farouk Yahaya
Nov 13 '18 at 21:22













If you want to preserve the properties of the object such as the data type and all, then prefer using pickle() to save the data and it as an object.

– Sanchit Kumar
Nov 13 '18 at 21:25





If you want to preserve the properties of the object such as the data type and all, then prefer using pickle() to save the data and it as an object.

– Sanchit Kumar
Nov 13 '18 at 21:25













Thanks a lot Sanchit

– Farouk Yahaya
Nov 13 '18 at 21:28





Thanks a lot Sanchit

– Farouk Yahaya
Nov 13 '18 at 21:28











0














If you would like to do it without using any libraries here's my solution:



import numpy as np
Test = 5
for i in range(Test):
r = 5
m = 500
n = 500
X=np.random.rand(m,n)
Y=np.random.rand(m,n)

file = open('file_'.format(i+1), 'w')
file.write('r = ;m = ;n = ;X = ;Y = '.format(r, m, n, X, Y))
file.close()


Loading saved variables



exec(open('file_1', 'r').read())





share|improve this answer























  • this looks simple for small range. my loop will go from 1 to 40. when loading exucuting them one by one can be annoyning.

    – Farouk Yahaya
    Nov 13 '18 at 21:15















0














If you would like to do it without using any libraries here's my solution:



import numpy as np
Test = 5
for i in range(Test):
r = 5
m = 500
n = 500
X=np.random.rand(m,n)
Y=np.random.rand(m,n)

file = open('file_'.format(i+1), 'w')
file.write('r = ;m = ;n = ;X = ;Y = '.format(r, m, n, X, Y))
file.close()


Loading saved variables



exec(open('file_1', 'r').read())





share|improve this answer























  • this looks simple for small range. my loop will go from 1 to 40. when loading exucuting them one by one can be annoyning.

    – Farouk Yahaya
    Nov 13 '18 at 21:15













0












0








0







If you would like to do it without using any libraries here's my solution:



import numpy as np
Test = 5
for i in range(Test):
r = 5
m = 500
n = 500
X=np.random.rand(m,n)
Y=np.random.rand(m,n)

file = open('file_'.format(i+1), 'w')
file.write('r = ;m = ;n = ;X = ;Y = '.format(r, m, n, X, Y))
file.close()


Loading saved variables



exec(open('file_1', 'r').read())





share|improve this answer













If you would like to do it without using any libraries here's my solution:



import numpy as np
Test = 5
for i in range(Test):
r = 5
m = 500
n = 500
X=np.random.rand(m,n)
Y=np.random.rand(m,n)

file = open('file_'.format(i+1), 'w')
file.write('r = ;m = ;n = ;X = ;Y = '.format(r, m, n, X, Y))
file.close()


Loading saved variables



exec(open('file_1', 'r').read())






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 21:03









Filip MłynarskiFilip Młynarski

1,7711413




1,7711413












  • this looks simple for small range. my loop will go from 1 to 40. when loading exucuting them one by one can be annoyning.

    – Farouk Yahaya
    Nov 13 '18 at 21:15

















  • this looks simple for small range. my loop will go from 1 to 40. when loading exucuting them one by one can be annoyning.

    – Farouk Yahaya
    Nov 13 '18 at 21:15
















this looks simple for small range. my loop will go from 1 to 40. when loading exucuting them one by one can be annoyning.

– Farouk Yahaya
Nov 13 '18 at 21:15





this looks simple for small range. my loop will go from 1 to 40. when loading exucuting them one by one can be annoyning.

– Farouk Yahaya
Nov 13 '18 at 21:15

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53289354%2fsave-variables-in-every-iteration-of-for-loop-and-load-them-later%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo