473,830 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: Class instantiation fails when passed in a file but work vialine by line interpreter

On Tue, 2008-11-18 at 10:45 -0800, Jeff Tchang wrote:
Odd issue I am having with class instantiation on Python 2.5.2 (Windows).

I have a custom module with a few classes in it. The module is named SAML.py.
There is a copy of it in C:\Python25\Lib \site-packages\SAML.p y.

Basically when I try to run a python file that tries to create an
instance of the class Subject I get this error:
AttributeError: type object 'SAML' has no attribute 'Subject'

In SAML.py I have the class...

class Subject(object) :
...
...
etc

However, when I run the same line by line by starting up python it works.
import SAML
subject = SAML.Subject("J o*****@example. com","EMailAddr ess")
print subject
<SAML.Subject object at 0x00C94770>
>>
I've double checked I am loading the correct module by the usage of the -v flag.
What else should I be checking?

-Jeff
--
http://mail.python.org/mailman/listinfo/python-list
Random related question. If you're writing a SAML implementation have
you found an XML Signature implementation that works reliably from
python? I've had a hell of a time finding something that doesn't
segfault and is interoperable with .NET.

As far as your problem goes, I would guess that somewhere you've got a
class named SAML that's shadowing your module. See the difference in the
error messages:

Python 2.5.2 (r252, Oct 31 2008, 10:47:40)
[GCC 4.1.2 (Gentoo 4.1.2 p1.1)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
>>import os
type( os )
<type 'module'>
>>os.doesnotexi st
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'doesnotexist'
>>class os( object ):
.... pass
....
>>os.doesnotexi st
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'os' has no attribute 'doesnotexist'

--
John Krukoff <jk******@ltgc. com>
Land Title Guarantee Company

Nov 18 '08 #1
0 1174

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

Similar topics

6
3642
by: Ruud de Jong | last post by:
I have the situation where I need to construct the name of a static method, and then retrieve the corresponding function from a class object. I thought I could just use __getattribute__ for this purpose. This works fine if I already have an instantiation of the class, but not when I try this on the class object directly. A bare bones example:
1
2391
by: Andrew James | last post by:
All, I'm having some trouble with understanding python's importing behaviour in my application. I'm using psyco to optimise part of my code, but I'm not sure whether it inherits throughout the rest of my application (read this as for any imported module) if I import in in a 'higher-level' module. For example: A.py ====
7
2482
by: Drew McCormack | last post by:
I have a C++ template class which contains a static variable whose construction registers the class with a map. Something like this: template <typename T> class M { static Registrar<M> registrar; }; The constructor of Registrar does the registering when it is initialized.
2
2288
by: um | last post by:
When the POSIX pthreads library for w32 release 2-2-0 (http://sources.redhat.com/pthreads-win32/) is compiled with VC++6 then it compiles and passes all the benchmark tests in the subdirectory "tests". Also, VC++ 2005 beta 1 compiles the tests fine, but here the following tests fail in execution: # semaphore1.pass \ # condvar2.pass \ # condvar2_1.pass \ # mutex8.pass \
5
2335
by: Slant | last post by:
Here's a question that most will have different answers to. I'm just dying to find a solution that seems halfway automated!! There really are two seperate issues which might be answered by the same answer. Web App: - constants.php begin - define("DB_HOST", "locahost"); .... to include the standard connection info define("DB_NAME", "mydatabase");
0
2841
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass magic, I wrote the following module. It is mainly useful as a light weight tool to help programmers catch mistakes at definition time (e.g., forgetting to implement a method required by the given interface). This is handy when unit tests or...
0
1029
by: Jeff Tchang | last post by:
Odd issue I am having with class instantiation on Python 2.5.2 (Windows). I have a custom module with a few classes in it. The module is named SAML.py. There is a copy of it in C:\Python25\Lib\site-packages\SAML.py. Basically when I try to run a python file that tries to create an instance of the class Subject I get this error: AttributeError: type object 'SAML' has no attribute 'Subject' In SAML.py I have the class...
0
1014
by: Steve Holden | last post by:
Jeff Tchang wrote: Look for assignments to "SAML" in your code, or a class definition of something called SAML. That message should read "module object "SAML' has no attribute 'Subject'". If SAML isn't a module, why not? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/
0
1085
by: Jeff Tchang | last post by:
Random related question. If you're writing a SAML implementation have I guess you could call it a SAML implementation. Really I am writing it so I can get more familiar with the specification. Right now it is far enough along that it generates signed assertions. This is definitely a tangent but since you asked I use PyXMLSec. I wrote a blog post on compiling it for Windows so I wouldn't forget how I did it:...
0
9793
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10777
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10493
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10526
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10206
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7747
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5780
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.