473,245 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,245 software developers and data experts.

determining fully qualified package & class name


Hi List,

I am used to the following with Java:

import some.package.MyClass;
name = MyClass.class.getName();

The value for name will be "some.package.MyClass".

For Python, I find:

from some.package.myclass import MyClass
name = MyClass.__name__

The value for name will be "MyClass"

Is there a comparable way to get the fully qualified name (package, module,
and class name) in Python?

Thanks,
Patrick Smith
--
View this message in context: http://www.nabble.com/determining-fu...html#a13161736
Sent from the Python - python-list mailing list archive at Nabble.com.

Oct 11 '07 #1
2 8114
On Thu, 11 Oct 2007 11:18:33 -0700, patrimith wrote:
I am used to the following with Java:

import some.package.MyClass;
name = MyClass.class.getName();

The value for name will be "some.package.MyClass".

For Python, I find:

from some.package.myclass import MyClass
name = MyClass.__name__

The value for name will be "MyClass"

Is there a comparable way to get the fully qualified name (package, module,
and class name) in Python?
Take a look at the `__module__` attribute of the class.

Ciao,
Marc 'BlackJack' Rintsch
Oct 11 '07 #2
import myPackage

f = myPackage.foo()

print f.__module__ + "." + f.__class__.__name__

That should do it!

Oct 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stefan | last post by:
I'm installing Oracle 9ias Release 2 on Windows 2000 Advanced Server. The installation instructions say to specify a fully qualified host name for the machine. What is the definition of fully...
2
by: Gravy | last post by:
Hi Is there an easy way to decode type names from a config file. For example I have the following element in my config file: <MyElement type = "myassembly, myclass" /> I want to get the...
4
by: Jim Garrison | last post by:
I know how to use the name() function to access the name of the current node. How do I get the 'fully qualified' name, consisting of the path from the root to the current node? I.e. <a> <b>...
1
by: BH | last post by:
Is there a performance difference between importing (keyword "using") a namespace for an entire class file and using the classes from that namespace with the fully qualified name? Particularly...
4
by: Aashish Patil | last post by:
Hello, Is it possible to obtain the fully qualified name of a class in c#. What I am looking for is something analogous to Box.class.getName() that exists in Java. Its possible to get this by...
5
by: fc2 | last post by:
Hi I have a problem with fully qualified names. According to the C# language specification: "Every namespace and type has a fully qualified name, which uniquely identifies the namespace or...
1
by: Erland | last post by:
Hi all, As per my understanding in order to load an assembly using Assembly.Load() you have to provide fully qualified name of the assembly you are trying to load e.g. Assembly...
0
by: Rob Maui | last post by:
I use the following code in an aspx file to read the file name which I am uploading from the client PC onto the server; Dim MyFileName As String Dim MyFileColl As HttpFileCollection =...
2
by: winkerbean | last post by:
Given the following: class A { class B { A::B( A::B const & ); }; };
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.