-1

Please have a look at this snippet:

import xlrd,spss
from xlrd import open_workbook
wb=open_workbook('C:/temp/testbook.xls')
sheetnames=[]
for s in wb.sheets():
   sheetnames.append(s.name)

Why should I write "wb.sheets()" instead of "wb.sheets"? And why is it "s.name" instead of "s.name()"?

I often use empty braces when I'm not supposed to and the other way around. Could anybody tell me what they mean and when I should (not) use them?

RubenGeert
  • 2,902
  • 6
  • 32
  • 50

1 Answers1

3

The () are necessary when the attribute (sheets) is a function you with to call. The () should not be used when the attribute is a value want to use directly rather than make a call on.

Steven Rumbalski
  • 44,786
  • 9
  • 89
  • 119
Josh Heitzman
  • 1,816
  • 1
  • 14
  • 26