-2

how can i directly access a function from a package? where is this function located?

Code for e.g:

import openpyxl as xl

path = 'transaction.xlsx'

wb = xl.load_workbook(path) 

#how can i directly access a function from a package? where is this function located?

sheet = wb['Sheet1']

cell = sheet.cell(1,1)

print(cell)
Saleem Ali
  • 1,363
  • 11
  • 21
  • Im not exactly sure whats your question. If you want to know where your Packages are located to see their code check [this](https://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory). Also please add more formatting to your question like code blocks to increase readability. – Kevin Müller Oct 04 '19 at 12:19
  • Read [openpyxl - tutorial](https://openpyxl.readthedocs.io/en/stable/tutorial.html#) – stovfl Oct 04 '19 at 12:51
  • can i call a function from a package directly ? or as i have learnt you have to access package then file then function. as in this case openpyxl is a package and load_workbook(path) is function. – Biswajit Jena Oct 04 '19 at 18:33

1 Answers1

0

In order to read an XLSX using Openpyxl - follow this clear tutorial

To summarize

from openpyxl import load_workbook

wb = load_workbook('test.xlsx')
print(wb.sheetnames)
Anthony R
  • 2,739
  • 1
  • 12
  • 11
  • openpyxl is a package and load_workbook(path) is function how can we access a function directly ? we supposed to go to package >file>function – Biswajit Jena Oct 04 '19 at 18:37
  • Well, from the openpyxl package, you can choose to select **only** the load_workbook function to use, not the entire package. `how can we access a function directly?` implies that `wb = load_workbook()` isn't direct enough? What do you mean by 'directly' ? – Anthony R Oct 04 '19 at 19:07
  • in a package there are many files . if more than one file contain a function named load_workbook() then what will happen when you call load_workbook() from a package ? – Biswajit Jena Oct 05 '19 at 05:33