Hi,

Learning CPython, I've made this simple exercice, a module test which contains an object Test.

The object Test has an attribute name, fixed at instanciation.

So, I try my code with a script:

-------------------------------------------
from test import Test

for n in ("The name", "Foo", "Spam"):
    t = Test(n)
    print("%s --> %s" %(n, t.name))
-------------------------------------------

And the return:

Uhe name --> Uhe name
Goo --> Goo
Tpam --> Tpam

As we can see, the first letter is changed with the next letter in alphabetical order, but not only for the attribute name, also for the reference n.

Same into a console:

(py352_venv) vincent@djoliba:~/CPython/py352_venv/pydcraw$ python
Python 3.5.2 (default, Dec 19 2016, 11:46:33)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from test import Test
>>> for n in ("The name", "Foo", "Spam"):
...     t = Test(n)
...     print("%s --> %s" %(n, t.name))
...
Uhe name --> Uhe name
Goo --> Goo
Tpam --> Tpam


I'm working in a venv.

The testmodule.c is attached.


The setup.py
------------------------------------------------
from distutils.core import setup, Extension
setup(name="test", version="1.0",
      ext_modules=[
         Extension("test", ["testmodule.c"],
                   libraries=[])
         ])
------------------------------------------------


Best,


Vincent

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to