Where is the location of the fcntl module of pytho

2019-08-02 21:11发布

问题:

I'm on unix but I can't find the location of the fcntl module. I'm using Jython in my web development, and the existing program that I'm modifying needs that module. Can you give me a way to import it or for my code to be able to use this module? Thanks in advance!

回答1:

fcntl is a built-in module. It's not written in Python, but in C. Unfortunately, it hasn't been ported to Java, and according to this bug report, it's unlikely that it ever will be.

To answer your question: it's in the CPython source, here.

The problem is that fcntl is Unix-specific; your program was not portable from the start. Java is pretty strictly platform-independent, and (as the Jython developers imply in that bug report) some low-level things aren't possible. You can search about the particular functions you need — you'll might a better chance of getting that to work than the whole module – but I'd recommend looking for some way around the problem rather than trying to get fcntl to work in Java.

I hope you can find an alternative solution.