Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I need to import function from another file

I know how to import functions from normal files…
but my file name is ‘selection sort’
it contains a space in between
is there a way to import function from these without renaming it

Please help ASAP… My board exams are near.

I tried
import selection sort and import selection_sort… both didn’t work

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I also watched few videos and questions like these but can’t find the solution.

>Solution :

You can use the __import__() function like:

selection_sort = __import__("selection sort")

and then the file selection sort is imported as selection_sort.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading