calling python method name from name

aceminer

What is the difference when calling python methods from names and from class.

Take for example the time API.

import time
time.strptime("some params")

However,

When i tried to create a python file (xyz.py)

xyz.py 
def test():
    print 1 

And i tried the following:

import abc 
abc.test() --- > module has no attribute test

How do i achieve what the time API did

EDIT:

Saved the filename as xyz instead of abc and the error was resolved.

Reut Sharabani

When python searches for a module to import, it first uses sys.modules or the built-in modules:

When a module named spam is imported, the interpreter first searches for a built-in module with that name. If not found ...

Since there is already an abc module you're importing the wrong module.

Change the name of your module.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Calling method of same name from different class

From Java

Call a Python method by name

From Java

Calling a Java method with no name

From

Why this String() method is called without calling it by name

From

Calling a method with Go Reflect by name and with a parameter

From Java

Calling parent method from within a Thread having the same name

From

How to get the name of the calling method?

From

How to get name of calling function/method in PHP?

From

Calling a Method From a String With the Method's Name in Ruby

From Dev

Calling a static method by repeating the object name?

From Dev

Using an extension method without calling class name

From Dev

Dynamically calling method and class name

From Dev

Difference between calling method with self and with class name?

From Dev

Is calling a Future method parameter "by-name" necessary?

From Dev

How to get Class name that is calling my method?

From Dev

get a class name of calling method

From Dev

Python Changing name of method

From Dev

Get name from variable in calling method - creating calling method signature, parameters and values

From Dev

Calling .NET method with optional parameter by name in PowerShell

From Dev

Calling a method with no name

From Dev

(Reflection) Calling A Method With Parameters By Function Name In Swift

From Dev

Get name of the bound method from instance of the bound method object in Python

From Dev

iOS Adding Method name to NSDictionary and calling it afterwards

From Dev

how to identify the method name that calling the particular function?

From Dev

NameError: name 'self' is not defined Python when calling method from within a class

From Dev

Calling a method from base class to class with same name as the method

From Dev

Calling DLL Method - Method Name non correct

From Dev

Python calling a list by name

From Dev

Calling a method in ruby from a method with the same name

Related Related

  1. 1

    Calling method of same name from different class

  2. 2

    Call a Python method by name

  3. 3

    Calling a Java method with no name

  4. 4

    Why this String() method is called without calling it by name

  5. 5

    Calling a method with Go Reflect by name and with a parameter

  6. 6

    Calling parent method from within a Thread having the same name

  7. 7

    How to get the name of the calling method?

  8. 8

    How to get name of calling function/method in PHP?

  9. 9

    Calling a Method From a String With the Method's Name in Ruby

  10. 10

    Calling a static method by repeating the object name?

  11. 11

    Using an extension method without calling class name

  12. 12

    Dynamically calling method and class name

  13. 13

    Difference between calling method with self and with class name?

  14. 14

    Is calling a Future method parameter "by-name" necessary?

  15. 15

    How to get Class name that is calling my method?

  16. 16

    get a class name of calling method

  17. 17

    Python Changing name of method

  18. 18

    Get name from variable in calling method - creating calling method signature, parameters and values

  19. 19

    Calling .NET method with optional parameter by name in PowerShell

  20. 20

    Calling a method with no name

  21. 21

    (Reflection) Calling A Method With Parameters By Function Name In Swift

  22. 22

    Get name of the bound method from instance of the bound method object in Python

  23. 23

    iOS Adding Method name to NSDictionary and calling it afterwards

  24. 24

    how to identify the method name that calling the particular function?

  25. 25

    NameError: name 'self' is not defined Python when calling method from within a class

  26. 26

    Calling a method from base class to class with same name as the method

  27. 27

    Calling DLL Method - Method Name non correct

  28. 28

    Python calling a list by name

  29. 29

    Calling a method in ruby from a method with the same name

HotTag

Archive