473,322 Members | 1,719 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,322 software developers and data experts.

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.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...

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

However, when I run the same line by line by starting up python it works.
import SAML
subject = SAML.Subject("Jo*****@example.com","EMailAddress")
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.doesnotexist
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'doesnotexist'
>>class os( object ):
.... pass
....
>>os.doesnotexist
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 1153

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

Similar topics

6
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...
1
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...
7
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>...
2
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...
5
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...
0
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...
0
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...
0
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...
0
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....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
1
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.