cpython

Python equivalent of PyErr_Print()

What is the Python API equivalent of PyErr_Print(), from the C interface? I'm assuming a call in either the sys, or traceback modules, but can't find any functions therein that make calls to PyErr_Print(). Addendum I'm after the Python call to get the same functionality as PyErr_PrintEx(), described as: Print a standard traceback to ...

Limiting the features of an embedded python instance

Is there a way to limit the abilities of python scripts running under an embedded interpretor? Specifically I wish to prevent the scripts from doing things like the following: Importing python extension modules (ie .pyd modules), except those specifically allowed by the application. Manipulating processes in any way (ie starting new pr...

what is the the diffrences between a cpython multithreaded program and jython multithreaded program?

dose any body have any code sample? ...

Assign a value equal only to itself

I wish to assign to a variable (a "constant"), a value that will allow that variable to only ever return True in is and == comparisons against itself. I want to avoid assigning an arbitary value such as an int or some other type on the off chance that the value I choose clashes with some other. I'm considering generating an instance of...

How to check contents of a folder using Python

How can you check the contents of a file with python, and then copy a file from the same folder and move it to a new location? I have Python 3.1 but i can just as easily port to 2.6 thank you! ...

How to generate code objects from modules in Python?

I have a .pyc file with no corresponding Python source code. I want to see the disassembly of the module using dis. I can import my module just fine with import dis import foo But to call dis.dis on it, I can't use the module object. I need the corresponding code object which backs foo. How do I create it? It seems that the compile bu...

Can CPython speak with WCF?

I would like to write a CPython app that would consume WCF services that use NetNamedPipeBinding and NetTcpBinding. It is possible? What library enables that? ...

How to write services with CPython?

Does CPython have any library that helps to write binding-independent services? I have found some SOAP libraries for Python, but it misses the flexibility of choosing the binding at runtime. ...

cpython: when PyDict_GetItem is called and when dict_subscript?

I am reading cpython code for python 3k and I have noticed, that __missing__ is called only when dict_subscript is called, but not when PyDict_GetItem is used. What is the difference between those two methods and when each is called? If I pass an PyObject that is a subclass of dict and has __missing__ method, how can I force using it, si...

Why is the destructor called when the CPython garbage collector is disabled?

I'm trying to understand the internals of the CPython garbage collector, specifically when the destructor is called. So far, the behavior is intuitive, but the following case trips me up: Disable the GC. Create an object, then remove a reference to it. The object is destroyed and the __del__ method is called. I thought this would onl...

Can I treat IronPython as a Pythonic replacement to C#?

Hey guys! I do understand that this topic has been covered in some way at StackOverflow but I'm still not able to figure out the exact answer: can I treat IronPython as a Pythonic replacement to C#? I use CPython every day, I love the Zen :) but my current task is a Windows-only application with a complex GUI and some other features wh...

Is a variable swap guaranteed to be atomic in python?

With reference to the following link: http://docs.python.org/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe I wanted to know if the following: (x, y) = (y, x) will be guaranteed atomic in cPython. (x and y are both python variables) ...

Python + PyQt program freezes

I wrote PyQt application. After it's start I close it (GUI), but timer don't stops and Python sometimes freezes. Only thing to unfreeze it - Ctrl-C, after which following message appears: Traceback (most recent call last): File "", line 262, in timerEvent KeyboardInterrupt timer don't stops again, ...

To convert PyBytesObject type to PyUnicodeObject type in python3

How to convert pyunicodeobject type to pybytesobject type? Example: function(PyBytesObject* byteobj){ ....operation.. } PyUnicodeObject* Uniobj; function((PyBytesObject*) Uniobj); got a bus error as a result. ...

Comparable type in extension module

To implement != and == for my CPython extension type, should I implement tp_compare, tp_richcompare or both? Under what circumstances is each of them called? ...

Using SQL Alchemy and pyodbc with IronPython 2.6.1

I'm using IronPython and the clr module to retrieve SQL Server information via SMO. I'd like to retrieve/store this data in a SQL Server database using SQL Alchemy, but am having some trouble loading the pyodbc module. Here's the setup: IronPython 2.6.1 (installed at D:\Program Files\IronPython) CPython 2.6.5 (installed at D:\Python26...

How C# use python program?

If it doesn't use ironpython, how C# use cpython program(py file)? Because there are some bugs that ironpython load cpython code. ...

Using NumPy and Cpython with Jython

I must use a commercial Java library, and would like to do it from Python. Jython is robust and I am fine with it being a few dot releases behind. However, I would like to use NumPy as well, which obviously does not work with Jython. Options like CPype and Java numeric libraries are unappealing. The former is essentially dead. The latter...

How can I pass map<string,string> into py with API?

C/C++ can use python API to load py. But, only simple type is supported. How can I pass map into py to be a dict with API? Or, which methods are better? ...

CPython vs. Jython vs. IronPython for cross-platform GUI development.

I'm thinking of making some kind of experimental IDE for digital hardware design. So I can't decide witch platform to choose. I'm going to have text-editor with syntax highlighting, some vector graphics and lots of tabbed windows. My goals: 1. to make GUI using as less custom components as possible. 2. to make it as cross-platform as p...