python-3.x

Subclass lookup.

(I'm developing in Python 3.1, so if there's some shiny new 3.x feature I should know about for this, please let me know!) I've got a class (we'll just call it "Packet") that serves as the parent for a bunch of child classes representing each of a few dozen packet types in a legacy client-server protocol over which I have no control. (T...

A python compute cluster!

Would it be possible to make a python cluster, by writing a telnet server, then telnet-ing the commands and output back-and-forth? Has anyone got a better idea for a python compute cluster? PS. Preferably for python 3.x, if anyone knows how. ...

Setting value for a node in XML document in Python

I have a XML document "abc.xml": I need to write a function replace(name, newvalue) which can replace the value node with tag 'name' with the new value and write it back to the disk. Is this possible in python? How should I do this? ...

Types that define `__eq__` are unhashable in Python 3.x?

I had a strange bug when porting a feature to the Python 3.1 fork of my program. I narrowed it down to the following hypothesis: In contrast to Python 2.x, in Python 3.x if an object has a .__eq__ method it is automatically unhashable. Is this true? Here's what happens in Python 3.1: >>> class O(object): def __eq__(self, other): ...

Python 3 and PyQt 4 recommendations

Is the combination of Python 3 and PyQt 4 recommended? Are there any alternatives? ...

I need __closure__

I just checked out this very interesting mindmap: http://www.mindmeister.com/10510492/python-underscore And I was wondering what some of the new ones mean, like __code__ and __closure__. I googled around but nothing concrete. Does anyone know? ...

No IDLE for Python 3?

I installed Python 3.1 yesterday on my Windows Vista PC, and was surprised to find that the version of IDLE is 2.6.4, for "Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on win32" I was hoping to use IDLE to investigate some of the new features of Python 3... I guess I'm stuck with the command line... Any...

Swampy.1.1 with Python 3

I am reading the book Think Python by Allen Downey. For chapter 4, one has to use a suite of modules called Swampy. I have downloaded and installed it. The problem is that the modules were written in Python 2 and I have Python 3 (in Windows 7 RC1). When I ran the TurtleWorld module from Swampy, I got error messages about the print and e...

Designing the storage for a very large game world.

I'm starting up game programming again. 10 years ago I was making games in qbasic and I havn't done any game programming since, so I am quite rusty. I have been programming all the time though, I am web developer/DBA/admin now. I have several questions, but I'm going to limit it to one per post. The game I am working on is going to be l...

Uploading to the cheeseshop different versions of a package for different versions of Python

I have an open-source Python project (called GarlicSim), and I maintain 4 different versions of it for Python versions 2.4, 2.5, 2.6 and 3.1. Yes, maybe it's unusual, but I like using as much features as possible. I keep them in 4 different forks of the repository. Now I want to upload my project to the cheeseshop. What's the way to do ...

Tool like 2to3, except for merges

I maintain a fork of my project for Python 3.1. When I initially made the port from 2.6, I used 2to3, but now I constantly have to merge new code from the 2.6 fork into the 3.1 fork. How can I perform the 2to3 operation on these merges automatically? (I use git, if it matters.) ...

What's going on with python 3k ?

Since I'm not strictly python developer please don't flame me just for the question. I'm wondering about Python 3k, that from my point of view, might be some kind of misconception. Or quite in-relevant step forward (I'm taking into account the 2.6 and 3k releases, which was almost one after another). Before the flame will start, I'll ex...

Creating a PyBuffer from a C struct

EDIT: Upon re-reading my original question I realized very quickly that it was very poorly worded, ambiguous, and too confusing to ever get a decent answer. That's what I get for rushing out a question at the end of my lunch break. Hopefully this will be clearer: I am trying to expose a simple C structure to Python (3.x) as a PyBuffer s...

Python: data vs. text?

Guido van Rossum's presentation about Python 3000 mentions several things to make a transition from Python 2 to Python 3 easier eventually. He is specifically talking about text handling since the move to Unicode as the only representation of strings in Python 3 is one of the major changes. As far as text handling goes, one slide (#14) ...

Building executables for Python 3 and PyQt

Hi all. I built a rather simple application in Python 3.1 using PyQt4. Being done, I want the application to be distributed to computers without either of those installed. I almost exclusively care about Windows platforms, so my goal is to have a single executable file and maybe some resource files and .dlls in the end. Having searche...

bytes vs bytearray in Python 2.6 and 3

I'm experimenting with bytes vs bytearray in Python 2.6. I don't understand the reason for some differences. A bytes iterator returns strings: for i in bytes(b"hi"): print(type(i)) Gives: <type 'str'> <type 'str'> But a bytearray iterator returns ints: for i in bytearray(b"hi"): print(type(i)) Gives: <type 'int'> <type...

Python 3 Library for Realtime Midi Communication

Hi, Can anyone suggest a good Python 3 Library for sending / receiving reatime MIDI? ...

Using Python 3.1 with TextMate

TextMate seems to use the built-in Python version I assume (sys.path doesn't work). How do you configure it to use 3.1 instead? I've already installed the 3.1 package and I can use IDLE for interactive sessions, but I need to use TextMate now. Thanks ...

Tornado and Python 3.x

I really like Tornado and I would like to use it with Python 3, though it is written for Python versions 2.5 and 2.6. Unfortunately it seems like the project's source doesn't come with a test suite. If I understand correctly the WSGI part of it wouldn't be that easy to port as it's spec is not ready for Python 3 yet (?), but I am rather...

How to print out encoded Asian characters(gb2312) on command prompt?

Hi all: I am working for a company that uses the Python programming language version 3.1 as a causal work now. And I've encountered this problem: how to print out some encoded Asian characters(Chinese, Japanese, Korean) on command prompt? Done a bit research and tried, but got no luck: import sys import codecs print(sys.getdefaultenco...