Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3.6 Cython nametuple TypeError #2917

Closed
beruhan opened this issue Apr 10, 2019 · 3 comments
Closed

python3.6 Cython nametuple TypeError #2917

beruhan opened this issue Apr 10, 2019 · 3 comments

Comments

@beruhan
Copy link

beruhan commented Apr 10, 2019

I have a class that inherits from NamedTuple,I have compile it to pyd file on windows use cython,when I import the class and create a object in another py file,It throws error TypeError: new() takes 1 positional argument but 4 were given, the class as follows:

from typing import NamedTuple


class Info(NamedTuple):
    service: str
    damage: str
    privilege: str


info = Info("http", "no", "no")

when I don't compile it to pyd,It can use normally,How to deal with it?

@beruhan beruhan changed the title python3.6 cython nametuple TypeError python3.6 Cython nametuple TypeError Apr 10, 2019
@beruhan
Copy link
Author

beruhan commented Apr 10, 2019

does any one has alternative plan? this usage is heavily used in the project.,and I don't know how to

@scoder
Copy link
Contributor

scoder commented Apr 10, 2019

This is a duplicate of #2552.

@TeamSpen210
Copy link
Contributor

What you can do is to simply not use namedtuple at all. Run this code in regular Python, then print out the Info._source attribute. This is a copy of the equivalent code to define the class - just cythonise that. Get rid of the builtins imports though, Cython can do those better.

@da-woods da-woods mentioned this issue Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants