python-3.x

Windows can't find the file on subprocess.call()

I am getting the following error: WindowsError: [Error 2] The system cannot find the file specified My code is: subprocess.call(["<<executable file found in PATH>>"]) Windows 7, 64 bit. Python 3.x latest, stable. Any ideas? Thanks, ...

How to write a Python 2.6+ script that gracefully fails with older Python?

I'm using the new print from Python 3.x and I observed that the following code does not compile due to the end=' '. from __future__ import print_function import sys if sys.hexversion < 0x02060000: raise Exception("py too old") ... print("x",end=" ") # fails to compile with py24 How can I continue using the new syntax but make th...

syntax error in python:

Hello, I'm learning python. It gives syntax error in this script. I'm unable to figure out. import exceptions class FOUND(Exception): pass x = [1,2,3,4,56,73,29,35,12,32,63,12,76,75,89] while True: try: test = int(raw_input('Enter integer to be checked in list:')) count = -1 for y in x: count...

What are good uses for Python3's "Function Annotations"

Function Annotations: PEP-3107 I ran across a snippet of code demonstrating Python3's function annotations. The concept is simple but I can't think of why these were implemented in Python3 or any good uses for them. Perhaps SO can enlighten me? How it works: def foo(a: 'x', b: 5 + 6, c: list) -> max(2, 9): ... function body ... ...

How can you print a string using raw_unicode_escape encoding in python 3?

The following code with fail in Python 3.x with TypeError: must be str, not bytes because now encode() returns bytes and print() expects only str. #!/usr/bin/python from __future__ import print_function str2 = "some unicode text" print(str2.encode('raw_unicode_escape')) How can you print a Unicode string escaped representation using p...

How do I override file.write() under Python 3?

Below works on Python 2.6 but on Python 3.x it doesn't: old_file_write = file.write class file(): def write(self, d): if isinstance(d, types.bytes): self.buffer.write(d) else: old_file_write(d) # ... some code I cannot change or do not want to change f = open("x") f.write("...") f.write(b"....

Is there any linux distribution that comes with python 3?

I would like to know if there is any Linux distribution where you can easily install and use Python 3. This means a distribution that will provide not only Python 3 binaries and updates but also python modules. I know that probably we are not going to see any python 3 as the default python interpretor so soon but at least I would like t...

Deleting already printed in Python

For practice, I'm trying to do some stuff in Python. I've decided to make a simple hangman game - I'm not making a GUI. The game would start with a simple input(). Now, I'd like next line to, beside asking for input, to delete the hidden word. I've tried using \b (backspace character), but it's not working. Something like: word = input(...

How to write python web service server WSDL?

All the stuff I am seeing points me towards writing clients. ...

Converting from utf-16 to utf-8 in Python 3

I'm programming in Python 3 and I'm having a small problem which I can't find any reference to it on the net. As far as I understand the default string in is utf-16, but I must work with utf-8, I can't find the command that will convert from the default one to utf-8. I'd appreciate your help very much. ...

Is there one decent tutorial out there that shows how to provide a web service using Python that is not outdated?

I am having the hardest time finding any resources that decently walk you through in terms of setting up a basic web service that can be accessed. Most of the stuff I am seeing is on the client side. The imports people talk about are all outdated and/or are buggy or rely heavily on established frameworks. I prefer SOAP so can anyone plea...

resize image using tkinter

hello everyone, is it possible to resize an image using tkinter only? ...

how to set the python framework path before building cxfreeze for python3

I m building a python script using a setup.py file. In building process, it links to python framework. I want to change the linking framework path as its linking to the wrong location. How to set the framework path before building the script. Thanks in advance for sparring ur valuable time for this thread. ...

Pylint equivalent for Py3k

Pylint doesn't yet support Py3k, so am looking for an alternative. [note] An immature branch off some VCS would be sufficient enough for me to try out. ...

__bases__ doesn't work! What's next?

The following code doesn't work in Python 3.x, but it used to work with old-style classes: class Extender: def extension(self): print("Some work...") class Base: pass Base.__bases__ += (Extender,) Base().extension() Question is simple: How can I add dynamically (at runtime) a super class to a class in Python 3.x? B...

Python 3.1.2 + Snow Leopard + lxml + XMLSchema

Hi folks, I'd like to use lxml library to validate XML Schemas in Python 3.1.2. Since the Snow Leopard MAC OS comes with the Python 2.6.1 installed, firstly, I downloaded the Python 3.1.2 automated installer at http://www.python.org/ftp/python/3.1.2/python-3.1.2-macosx10.3-2010-03-24.dmg and installed it. Secondly, I downloaded lxml 2...

Can python3.1 scripts be freezed in mac os x using cxfreeze?

I m new to this and i need to freeze python3.1 scripts so that it can be run in other machines which does'nt have python3.1. CXFREEZE is the one which supports python 3.1 as far as i know. But i could not find any thread saying that freeze is successful for python3.x. So can anybody tell me will it be done with cxfreeze or i have to ch...

How to Be Python 3 Ready?

What are the current rules for writing python code that will pass cleanly through 2to3 and what are the practices that seem to be best suited to writing code that will not become mired forever in version 2. I have read from the SciPy/NumPy forums that "100% test coverage" (unit testing) is important for many people, and I am not sure if...

Why is Python 3.1 slower than 2.6 for this code?

Consider the following code (from here, with the number of tests increased): from timeit import Timer def find_invpow(x,n): """Finds the integer component of the n'th root of x, an integer such that y ** n <= x < (y + 1) ** n. """ high = 1 while high ** n < x: high *= 2 low = high/2 while low < high:...

List of products that run with python 3.1

Is there a web site that contains a list of open source products that run under python 3.1 version? Thanks! ...