-2

I have a line of code from Python forbidden fruit module:

__all__ = 'curse', 'curses', 'reverse'

I know what strings are and I know what arrays and tuples are. What kind of variable is this? How can we use this and for what?

quamrana
  • 37,849
  • 12
  • 53
  • 71
  • 7
    It's a tuple. Tuples are defined by commas, not parentheses. – Martijn Pieters Jan 11 '18 at 18:16
  • possible dup : https://stackoverflow.com/questions/44834/can-someone-explain-all-in-python – IMCoins Jan 11 '18 at 18:16
  • @IMCoins: No, that's about the special variable `__all__`, and says nothing about the syntax used here. – Martijn Pieters Jan 11 '18 at 18:17
  • 3
    Terminology nitpick: while Python does have arrays, they are rarely used compared to the far more common built-in data type, `list`. If you're reading a tutorial that calls `[1,2,3]` an array, find a new tutorial. – Kevin Jan 11 '18 at 18:17
  • @MartijnPieters I understand, but he could have selected ANY variable, and he chose this specific one. That sounds more than a coincidence to me. Like : He wanted to know what `__all__` was, since he already said "I know what a tuple is". :) his question might be poorly formulated, but I believe I got it right -- EDIT : Correct me if I'm wrong though. – IMCoins Jan 11 '18 at 18:19
  • @IMCoins: the question is indeed very unclear in that respect. I was going by the question title: *one variable but different values?*. – Martijn Pieters Jan 11 '18 at 18:25
  • hi - op here, my question was based on syntax. I didn't know a tuple could be created without the parenthesis. I only used the __all__ variable because thats how I found it in the module and I thought it may have been important. I learned what its for from that link too though. thanks everyone for their help. – Shoaib Khan Jan 11 '18 at 18:28

1 Answers1

3

It's a tuple. If you want to find out the type of something, use the type function - e.g.

type(__all__)
Finlay McWalter
  • 1,222
  • 1
  • 10
  • 12