Bulding python module using C

Andrew Degtiariov ad at astral-on.net
Fri Sep 24 15:44:08 CEST 2004

After some unhappy tries to write own module I attempt to compile
noddy3.c from Python-Docs-2.3.4.
I build noddy3.so using setup.py (showing bellow) and compilation process 
pass witout any warning. Bu while i try run test (test.py) it failed with:
<attribute 'first' of 'noddy3.Noddy' objects>
Traceback (most recent call last):
  File "test.py", line 6, in ?
    n.first = 'test'
TypeError: can't set attributes of built-in/extension type 'noddy3.Noddy'

Where was i wrong?

--- Begin of test.py ---
import sys
import noddy3

n = noddy3.Noddy
print n.first
n.first = 'test'
print n.first
--- End of test.py ---

--- Begin setup.py ---
#! /usr/bin/env python

import sys

from distutils.core import setup, Extension

setup( name="noddy3",
       author="Primer from python documentation",
       author_email="XX at python.org",
       ext_modules = [ Extension( "noddy3", ["noddy3.c"],
                                  libraries = [ ],
                                 ) ] )
--- End of test.py ---

Andrew Degtiariov 

More information about the Python-list mailing list