473,386 Members | 1,815 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,386 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 8143
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 & ); }; };
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.