python-3.x

Can I reduce the computational complexity of this?

Well, I have this bit of code that is slowing down the program hugely because it is linear complexity but called a lot of times making the program quadratic complexity. If possible I would like to reduce its computational complexity but otherwise I'll just optimize it where I can. So far I have reduced down to: def table(n): a = 1 ...

MySQL-db lib for Python 3.0 ?

So, looking for a mysql-db-lib that is compatible with py3k/py3.0/py3000, any ideas? google turned up nothing. ...

Python 3 porting workflow?

I have a small project I want to try porting to Python 3 - how do I go about this? I have made made the code run without warnings using python2.6 -3 (mostly removing .has_key() calls), but I am not sure of the best way to use the 2to3 tool. Use the 2to3 tool to convert this source code to 3.0 syntax. Do not manually edit the output!...

Finding Integers With A Certain Property - Project Euler Problem 221

I've become very addicted to Project Euler recently and am trying to do this one next! I've started some analysis on it and have reduced the problem down substantially already. Here's my working: A = pqr and 1/A = 1/p + 1/q + 1/r so pqr/A = pq + pr + qr And because of the first equation: pq+pr+qr = 1 Since...

How to download a file over http with authorization in python 3.0, working around bugs?

I have a script that I'd like to continue using, but it looks like I either have to find some workaround for a bug in Python 3, or downgrade back to 2.6, and thus having to downgrade other scripts as well... Hopefully someone here have already managed to find a workaround. The problem is that due to the new changes in Python 3.0 regard...

How to instantiate a class in python

So, I'm trying to learn Python. It seems pretty easy, but evidently, I don't understand how classes are used. The following code gives me an error when I try to use the class. class mystuff: def average(a,b,c): #get the average of three numbers result=a+b+c result=result/3 return...

Tix and Python 3.0

Has anyone seen anything in Tix work under python 3.0? I've tried to work through the examples but when creating anything it states that cnf is unsubscriptable. I also noticed that none of the Dir Select stuff (DirList DirTree) works under 2.6.1. Why doesn't Python either dump Tix or support it? Its got a lot of good stuff to make ea...

Are there any graph/plotting/anything-like-that libraries for Python 3.0?

As per the title. I am trying to create a simple scater plot, but haven't found any Python 3.0 libraries that can do it. Note, this isn't for a website, so the web ones are a bit useless. ...

What is an alternative to execfile in Python 3.0?

It seems they canceled in Python 3.0 all the easy way to quickly load a script file - both execfile() and reload(). Is there an obvious alternative I'm missing? ...

Python 3 development and distribution challenges

Suppose I've developed a general-purpose end user utility written in Python. Previously, I had just one version available which was suitable for Python later than version 2.3 or so. It was sufficient to say, "download Python if you need to, then run this script". There was just one version of the script in source control (I'm using Git) ...

Python 3.0 `wsgiref` server not functioning

Hello, I can't seem to get the wsgiref module to work at all under Python 3.0. It works fine under 2.5 for me, however. Even when I try the example in the docs, it fails. It fails so hard that even if I have a print function above where I do: "from wsgiref.simple_server import make_server", it never gets printed for some reason. It doesn...

Both Python 2 and 3 in Emacs

I have been using Emacs to write Python 2 code. Now I have both Python 2.6 and 3.0 installed on my system, and I need to write Python 3 code as well. Here is how the different versions are set up in /usr/bin: python -> python2.6* python2 -> python2.6* python2.6* python3 -> python3.0* python3.0* Is there any way to set this up so tha...

py2exe for Python 3.0

Hey guys, I am looking for a Python3.0 version of "py2exe". I tried running 2to3 on the source for py2exe but the code remained broken. Any ideas? Thanks a lot. ...

python 3.0, how to make print() output unicode?

I'm working in WinXP 5.1.2600, writing a Python application involving Chinese pinyin, which has involved me in endless Unicode problems. Switching to Python 3.0 has solved many of them. But the print() function for console output is not Unicode-aware for some odd reason. Here's a teeny program. print('sys.stdout encoding is "' + sys.std...

Python: loop over consecutive characters?

In Python (specifically Python 3.0 but I don't think it matters), how do I easily write a loop over a sequence of characters having consecutive character codes? I want to do something like this pseudocode: for Ch from 'a' to 'z' inclusive: # f(Ch) Example: how about a nice "pythonic" version of the following? def Pangram(Str): ...

What happened to types.ClassType in python 3?

I have a script where I do some magic stuff to dynamically load a module, and instantiate the first class found in the module. But I can't use types.ClassType anymore in Python 3. What is the correct way to do this now? ...

Accessing POST Data from WSGI

I can't seem to figure out how to access POST data using WSGI. I tried the example on the wsgi.org website and it didn't work. I'm using Python 3.0 right now. Please don't recommend a WSGI framework as that is not what I'm looking for. I would like to figure out how to get it into a fieldstorage object. ...

Who's Using Python 3.0?

The "what's new" list looks pretty extensive. I've heard that this is considered a radical shift in the language. Any early adopters out there? Would you advise someone dipping their toes into the water to stick with version 2.x? Or dive into 3.0? ...

Python 3.0 urllib.parse error "Type str doesn't support the buffer API"

File "/usr/local/lib/python3.0/cgi.py", line 477, in __init__ self.read_urlencoded() File "/usr/local/lib/python3.0/cgi.py", line 577, in read_urlencoded self.strict_parsing): File "/usr/local/lib/python3.0/urllib/parse.py", line 377, in parse_qsl pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')] TypeError: T...

Python 3.0 smtplib

I have a very simple piece of code that I used in previous versions of Python without issues (version 2.5 and prior). Now with 3.0, the following code give the error on the login line "argument 1 must be string or buffer, not str". import smtplib smtpserver = 'mail.somedomain.com' AUTHREQUIRED = 1 # if you ne...