python-3.x

Python3k replacement for IPython?

So, I'm a huge IPython fan, though I'm sure I don't use nearly all the power it has (mainly tab completion and ? for introspection, though I also use %ed a fair amount). However, I want to really start working with Python3k, and as this thread states, I'll need a Snickers to tide me over til IPython is ported. So what are my options fo...

how to convert python/cython unicode string to array of long integers, to do levenshtein edit distance

I have the following Cython code (adapted from the bpbio project) that does Damerau-Levenenshtein edit-distance calculation: #--------------------------------------------------------------------------- cdef extern from "stdlib.h": ctypedef unsigned int size_t size_t strlen(char *s) void *malloc(size_t size) void *calloc(size_t n...

Graphing in Python 3.x

In Python 2.6, I used matplotlib to make some simple graphs. However, it is incompatible with Python 3.1. What are some alternative modules that can accomplish the same thing without being very complex? ...

Good resources for learning pyqt?

Hey I've started learning Python 3 - and now so far that I need some UI to experiment with. I've decided to go with the QT4 IDE (called from the Eric IDE) on Linux. Does anyone know good resources to get started? Books, tutorials, eBooks - basically anything I can get my hands on :-) EDIT: Thank you all for your contributions. Sucks, ...

is there a difference between class(): and class(object): in python 2.6-3.x?

Before py2.6 it's been answered here. http://stackoverflow.com/questions/332255/difference-between-class-foo-and-class-fooobject-in-python But for python2.6+ and python3.x, is the first one wrong? class Foo(): pass vs class Foo(object): pass ...

Python 3 argument (semi)not UTF-8 when passed from Windows batch.cmd

When I invoke a Python 3 script from a Windows batch.cmd, a UTF-8 arg is not passed as "UTF-8", but as a series of bytes, each of which are interpreted by Python as individual UTF-8 chars. How can I convert the Python 3 arg string to its intended UTF-8 state? The calling .cmd and the called .py are shown below. PS. As I mention in a ...

Calling in functions in another function

I created a function to read in a csv file and then write some of the data from the csv file into another file. I had to manipulate some of the data in the original csv file before I write it. I will probably have to do that manipulation a lot during the next couple months so I wrote another function to just do that manipulation, but I ...

Is there any way to create an app for python3 script?

Py2app will create the app for python2. But for python3? Has anyone succeeded in creating an app for python3 script? Any clue would be helpful for my script in creating that. ...

Python: Unicode and ElementTree.parse

Hi, I'm trying to move to Python 2.7 and since Unicode is a Big Deal there, I'd try dealing with them with XML files and texts and parse them using the xml.etree.cElementTree library. But I ran across this error: >>> import xml.etree.cElementTree as ET >>> from io import StringIO >>> source = """\ ... <?xml version="1.0" encoding="UTF-...

Getting ready to convert from Python 2.x to 3.x

As we all know by now (I hope), Python 3 is slowly beginning to replace Python 2.x. Of course it will be many MANY years before most of the existing code is finally ported, but there are things we can do right now in our version 2.x code to make the switch easier. Obviously taking a look at what's new in 3.x will be helpful, but what ar...

How to correct bugs in this Damerau-Levenshtein implementation?

I'm back with another longish question. Having experimented with a number of Python-based Damerau-Levenshtein edit distance implementations, I finally found the one listed below as editdistance_reference(). It seems to deliver correct results and appears to have an efficient implementation. So I set down to convert the code to Cython. o...

Hot swapping python code (duck type functions?)

I've been thinking about this far too long and haven't gotten any idea, maybe some of you can help. I have a folder of python scripts, all of which have the same surrounding body (literally, I generated it from a shell script), but have one chunk that's different than all of them. In other words: Top piece of code (always the same) Mi...

tkinter callback AFTER modify

I have bound a event to a text widget in order to follow all the changes in its text. This event is called before the new character is added to the widget's text. What I need is a event that's called after the new character has been added, or something similar. ...

What technologies exist to create stand alone executables for Python 3?

Other than cx_Freeze, are there any other current maintained tool suites to generate stand alone executables for Python 3k? Are there any other techniques for minimizing preinstallation requirements under Windows? ...

python + Semicolon written to file is written on the next line

Hi everyone, I have this simple python expression: fscript.write (("update %s va set %s = %s where %s = %s;") % (argv[1],argv[2],vl[0],argv[3],vl[1])) And I would expect to receive output like this update some_table va set active_id = 1 where id = 5; update some_table va set active_id = 1 where id = 3; ...more lines... However, i'...

strange Oracle error: "invalid format text"

I'm trying to fetch some data from a column whose DATA_TYPE=NUMBER(1,0) with this piece of code: import cx_Oracle conn = cx_Oracle.connect(usr, pwd, url) cursor = conn.cursor() cursor.execute("SELECT DELETED FROM SERVICEORDER WHERE ORDERID='TEST'") print(cursor.fetchone()[0]) which complains thus: Traceback (most recent call last): ...

Invalid syntax error in simple Python-3 program

from TurtleWorld import * import math bob = Turtle() print(bob) draw_circle(turtle, r): d = r*2 c = d*math.pi degrees = 360/25 length = c // 25 for i in range(25): fd(turtle, length) rt(turtle, degrees) draw_circle(bob, 25) wait_for_user() The problem in on line 7: draw_circle(turtle, r): ...

Some utf8 chars allowed in python source, some not

I've noticed that I can not use all unicode characters in my python source code. While def 价(何): is perfectly allright (albeit nonsensical [probably?]), def N(N₀, t, λ) -> 'N(t)': this isn't allowed (the subscript zero that is). I also can't use some other characters, most of which I recognise as something other than letters (ma...

Web gateway interfaces in Python 3.

I've finally concluded that I can no longer afford to just hope the ongoing Py3k/WSGI disasterissues will be resolved anytime soon, so I need to get ready to move on. Unfortunately, my available options don't seem a whole lot better: While I find a few different Python modules for FastCGI scattered around the web, none of them seem to...

A Python 2.7, 3.0 Question for Pythonistas - Best Practices?

I am learning to program in Python and we have version 2.7 installed at work. Whenever I try to dive deep into Python, I never liked the dea of diving into a deprecated version (2.7). My work is not ready for 3.0 just yet. My question is : I want to write code in 2.7 which can easily be converted to 3.0 using 2to3. Honestly, I want to s...