looping in python for getting table names











up vote
-2
down vote

favorite












tablename1 = GetTbname(1)
tablename2 = GetTbname(2)
tablename3 = GetTbname(3)
.
.
.
.
tablenamen = GetTbname(n)
print(tablename1)
print(tablename2)
print(tablename3)
.
.
.
.
print(tablenamen)


How do I print the above one in looping format so that I can just enter tablename = GetTbname to get the entire table instead of typing entirely manually.










share|improve this question
























  • Use range function for i in range(1, n): ....
    – Rakesh
    Nov 7 at 7:03












  • Put your table names into a list instead of separate variables.
    – Klaus D.
    Nov 7 at 7:09















up vote
-2
down vote

favorite












tablename1 = GetTbname(1)
tablename2 = GetTbname(2)
tablename3 = GetTbname(3)
.
.
.
.
tablenamen = GetTbname(n)
print(tablename1)
print(tablename2)
print(tablename3)
.
.
.
.
print(tablenamen)


How do I print the above one in looping format so that I can just enter tablename = GetTbname to get the entire table instead of typing entirely manually.










share|improve this question
























  • Use range function for i in range(1, n): ....
    – Rakesh
    Nov 7 at 7:03












  • Put your table names into a list instead of separate variables.
    – Klaus D.
    Nov 7 at 7:09













up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











tablename1 = GetTbname(1)
tablename2 = GetTbname(2)
tablename3 = GetTbname(3)
.
.
.
.
tablenamen = GetTbname(n)
print(tablename1)
print(tablename2)
print(tablename3)
.
.
.
.
print(tablenamen)


How do I print the above one in looping format so that I can just enter tablename = GetTbname to get the entire table instead of typing entirely manually.










share|improve this question















tablename1 = GetTbname(1)
tablename2 = GetTbname(2)
tablename3 = GetTbname(3)
.
.
.
.
tablenamen = GetTbname(n)
print(tablename1)
print(tablename2)
print(tablename3)
.
.
.
.
print(tablenamen)


How do I print the above one in looping format so that I can just enter tablename = GetTbname to get the entire table instead of typing entirely manually.







python python-3.x






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 7 at 9:10









Mureinik

174k21123191




174k21123191










asked Nov 7 at 7:01









Yadhu

225




225












  • Use range function for i in range(1, n): ....
    – Rakesh
    Nov 7 at 7:03












  • Put your table names into a list instead of separate variables.
    – Klaus D.
    Nov 7 at 7:09


















  • Use range function for i in range(1, n): ....
    – Rakesh
    Nov 7 at 7:03












  • Put your table names into a list instead of separate variables.
    – Klaus D.
    Nov 7 at 7:09
















Use range function for i in range(1, n): ....
– Rakesh
Nov 7 at 7:03






Use range function for i in range(1, n): ....
– Rakesh
Nov 7 at 7:03














Put your table names into a list instead of separate variables.
– Klaus D.
Nov 7 at 7:09




Put your table names into a list instead of separate variables.
– Klaus D.
Nov 7 at 7:09












2 Answers
2






active

oldest

votes

















up vote
1
down vote













I'd use a loop and store the names in a list:



num_tables = 100 # or any other value
tables =

for i in range(num_tables):
tables.append(GetTbname(i + 1))

for table in tables:
print(table)





share|improve this answer























  • *tables.append(GetTbname(i + 1))
    – Vineeth Sai
    Nov 7 at 7:06








  • 1




    @VineethSai erg, yeah. Stupid typo, thanks for noticing. Edited and fixed.
    – Mureinik
    Nov 7 at 7:06


















up vote
0
down vote













for i in range(n):
print(GetTbname(i))


In the code above, I assumed there is a list and the GetTbname function returns something based on the index from this list. Here n is the length of the list. I started the loop from 0. You can use range(1,n) to start from 1.






share|improve this answer



















  • 1




    Wheres the explanation?
    – U9-Forward
    Nov 7 at 7:15






  • 1




    I assumed there is a list and the GetTbname function returns something based on the index from this list. here 'n' is the length of the list. Here i started the loop from 0. You can use range(1,n) to start from 1.
    – Nishil
    Nov 7 at 7:27












  • Please edit the post and paste it in there
    – U9-Forward
    Nov 7 at 7:28











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',
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%2f53184834%2flooping-in-python-for-getting-table-names%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













I'd use a loop and store the names in a list:



num_tables = 100 # or any other value
tables =

for i in range(num_tables):
tables.append(GetTbname(i + 1))

for table in tables:
print(table)





share|improve this answer























  • *tables.append(GetTbname(i + 1))
    – Vineeth Sai
    Nov 7 at 7:06








  • 1




    @VineethSai erg, yeah. Stupid typo, thanks for noticing. Edited and fixed.
    – Mureinik
    Nov 7 at 7:06















up vote
1
down vote













I'd use a loop and store the names in a list:



num_tables = 100 # or any other value
tables =

for i in range(num_tables):
tables.append(GetTbname(i + 1))

for table in tables:
print(table)





share|improve this answer























  • *tables.append(GetTbname(i + 1))
    – Vineeth Sai
    Nov 7 at 7:06








  • 1




    @VineethSai erg, yeah. Stupid typo, thanks for noticing. Edited and fixed.
    – Mureinik
    Nov 7 at 7:06













up vote
1
down vote










up vote
1
down vote









I'd use a loop and store the names in a list:



num_tables = 100 # or any other value
tables =

for i in range(num_tables):
tables.append(GetTbname(i + 1))

for table in tables:
print(table)





share|improve this answer














I'd use a loop and store the names in a list:



num_tables = 100 # or any other value
tables =

for i in range(num_tables):
tables.append(GetTbname(i + 1))

for table in tables:
print(table)






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 7 at 7:06

























answered Nov 7 at 7:05









Mureinik

174k21123191




174k21123191












  • *tables.append(GetTbname(i + 1))
    – Vineeth Sai
    Nov 7 at 7:06








  • 1




    @VineethSai erg, yeah. Stupid typo, thanks for noticing. Edited and fixed.
    – Mureinik
    Nov 7 at 7:06


















  • *tables.append(GetTbname(i + 1))
    – Vineeth Sai
    Nov 7 at 7:06








  • 1




    @VineethSai erg, yeah. Stupid typo, thanks for noticing. Edited and fixed.
    – Mureinik
    Nov 7 at 7:06
















*tables.append(GetTbname(i + 1))
– Vineeth Sai
Nov 7 at 7:06






*tables.append(GetTbname(i + 1))
– Vineeth Sai
Nov 7 at 7:06






1




1




@VineethSai erg, yeah. Stupid typo, thanks for noticing. Edited and fixed.
– Mureinik
Nov 7 at 7:06




@VineethSai erg, yeah. Stupid typo, thanks for noticing. Edited and fixed.
– Mureinik
Nov 7 at 7:06












up vote
0
down vote













for i in range(n):
print(GetTbname(i))


In the code above, I assumed there is a list and the GetTbname function returns something based on the index from this list. Here n is the length of the list. I started the loop from 0. You can use range(1,n) to start from 1.






share|improve this answer



















  • 1




    Wheres the explanation?
    – U9-Forward
    Nov 7 at 7:15






  • 1




    I assumed there is a list and the GetTbname function returns something based on the index from this list. here 'n' is the length of the list. Here i started the loop from 0. You can use range(1,n) to start from 1.
    – Nishil
    Nov 7 at 7:27












  • Please edit the post and paste it in there
    – U9-Forward
    Nov 7 at 7:28















up vote
0
down vote













for i in range(n):
print(GetTbname(i))


In the code above, I assumed there is a list and the GetTbname function returns something based on the index from this list. Here n is the length of the list. I started the loop from 0. You can use range(1,n) to start from 1.






share|improve this answer



















  • 1




    Wheres the explanation?
    – U9-Forward
    Nov 7 at 7:15






  • 1




    I assumed there is a list and the GetTbname function returns something based on the index from this list. here 'n' is the length of the list. Here i started the loop from 0. You can use range(1,n) to start from 1.
    – Nishil
    Nov 7 at 7:27












  • Please edit the post and paste it in there
    – U9-Forward
    Nov 7 at 7:28













up vote
0
down vote










up vote
0
down vote









for i in range(n):
print(GetTbname(i))


In the code above, I assumed there is a list and the GetTbname function returns something based on the index from this list. Here n is the length of the list. I started the loop from 0. You can use range(1,n) to start from 1.






share|improve this answer














for i in range(n):
print(GetTbname(i))


In the code above, I assumed there is a list and the GetTbname function returns something based on the index from this list. Here n is the length of the list. I started the loop from 0. You can use range(1,n) to start from 1.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 7 at 8:04









SU3

2,49621843




2,49621843










answered Nov 7 at 7:12









Nishil

2238




2238








  • 1




    Wheres the explanation?
    – U9-Forward
    Nov 7 at 7:15






  • 1




    I assumed there is a list and the GetTbname function returns something based on the index from this list. here 'n' is the length of the list. Here i started the loop from 0. You can use range(1,n) to start from 1.
    – Nishil
    Nov 7 at 7:27












  • Please edit the post and paste it in there
    – U9-Forward
    Nov 7 at 7:28














  • 1




    Wheres the explanation?
    – U9-Forward
    Nov 7 at 7:15






  • 1




    I assumed there is a list and the GetTbname function returns something based on the index from this list. here 'n' is the length of the list. Here i started the loop from 0. You can use range(1,n) to start from 1.
    – Nishil
    Nov 7 at 7:27












  • Please edit the post and paste it in there
    – U9-Forward
    Nov 7 at 7:28








1




1




Wheres the explanation?
– U9-Forward
Nov 7 at 7:15




Wheres the explanation?
– U9-Forward
Nov 7 at 7:15




1




1




I assumed there is a list and the GetTbname function returns something based on the index from this list. here 'n' is the length of the list. Here i started the loop from 0. You can use range(1,n) to start from 1.
– Nishil
Nov 7 at 7:27






I assumed there is a list and the GetTbname function returns something based on the index from this list. here 'n' is the length of the list. Here i started the loop from 0. You can use range(1,n) to start from 1.
– Nishil
Nov 7 at 7:27














Please edit the post and paste it in there
– U9-Forward
Nov 7 at 7:28




Please edit the post and paste it in there
– U9-Forward
Nov 7 at 7:28


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53184834%2flooping-in-python-for-getting-table-names%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







這個網誌中的熱門文章

Academy of Television Arts & Sciences

L'Équipe

1995 France bombings