Bulding python module using C

Discussion in 'Python' started by Andrew Degtiariov, Sep 24, 2004.

  1. 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="",
    license="unknown",
    url="http://www.python.org/",
    ext_modules = [ Extension( "noddy3", ["noddy3.c"],
    libraries = [ ],
    ) ] )
    --- End of test.py ---

    --
    Andrew Degtiariov
    DA-RIPE
     
    Andrew Degtiariov, Sep 24, 2004
    #1
    1. Advertising

  2. Andrew Degtiariov wrote:

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


    You are trying to set an attribute on the type instead of an *instance*
    of the type.

    > n = noddy3.Noddy


    n = noddy3.Noddy()
    --
    Michael Hoffman
     
    Michael Hoffman, Sep 24, 2004
    #2
    1. Advertising

  3. On Fri, Sep 24, 2004 at 03:01:08PM +0100, Michael Hoffman wrote:
    > >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?

    >
    > You are trying to set an attribute on the type instead of an *instance*
    > of the type.
    >
    > >n = noddy3.Noddy

    >
    > n = noddy3.Noddy()

    Yes, you right. It is stupid for my self, sorry :-(

    --
    Andrew Degtiariov
    DA-RIPE
     
    Andrew Degtiariov, Sep 24, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maric Michaud
    Replies:
    0
    Views:
    7,194
    Maric Michaud
    Jun 24, 2006
  2. hobel
    Replies:
    0
    Views:
    280
    hobel
    Sep 22, 2006
  3. Roedy Green

    Encapsulating HashMap bulding

    Roedy Green, May 10, 2010, in forum: Java
    Replies:
    15
    Views:
    540
  4. Doug Livesey

    Advice on bulding a web service

    Doug Livesey, Aug 24, 2007, in forum: Ruby
    Replies:
    4
    Views:
    104
    Doug Livesey
    Aug 28, 2007
  5. Nick Brown
    Replies:
    3
    Views:
    93
    elise huard
    Nov 6, 2010
Loading...

Share This Page