Bulding python module using C

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


Hello.
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
sys.exit(0)
--- End of test.py ---

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

import sys

from distutils.core import setup, Extension

setup( name="noddy3",
       version="3",
       author="Primer from python documentation",
       author_email="XX at python.org",
       license="unknown",
       url="http://www.python.org/",
       ext_modules = [ Extension( "noddy3", ["noddy3.c"],
                                  libraries = [ ],
                                 ) ] )
--- End of test.py ---

-- 
Andrew Degtiariov 
DA-RIPE



More information about the Python-list mailing list