python

PYQT: why label not change ..?

dear all .. i'm newbee on python and pyqt, i try to make small program with pyqt, the program is running, when i press the return key its will show input dialog and if i input 1 on label1 will show "one" and if i press enter egain input dialog will show again and if i input 2 the problem is the label still show "one" not show "two", any ...

Python nested loop with condition

reworked to hopefully make it clearer. my_list = [[1,2],[1,3],[1,3],[1,3]] my_var = 7 My goal is to be able to see if my_var is larger than all of the positions at my_list[0][1] and my_list[1][1] and my_list[2][1] and so on. my_list can vary in length and my_var can also vary so I am thinking a loop is the best bet? *very new to pyt...

Selecting area of the screen with Python

I'm developing a screen shot utility in Python. At the moment it is specifically for Linux. So far I have the ability to take a screen shot of the full desktop, and have it upload to Imgur, then copy the link to clipboard. Now I want to expand into functions such as screen shots of the active window, or of a specific selection. If anyone...

Installed python3, getting command not found error in terminal

I installed python3, I can open idle and it says it is running python3.0.1, but when I enter python3 in the terminal (on OSX) I get an error saying 'command not found'. Entering python gets me the 2.x version that came on the computer. Any advice on how I can access python3 from the terminal? Thanks ...

Python audio library for simultaneous audio creation and playback

I'm working on an audio creation framework. It'll be generating large audio files, say 3 minute long audio files that take about 1 minute to generate. So what I want is a system much like streaming audio from the internet, where I play the sound as I generate it. Pygame's mixer allows me to edit the sound as it's playing. But I cannot fi...

Regex to match 'lol' to 'lolllll' and 'omg' to 'omggg', etc..

Hey there, I love regular expressions, but I'm just not good at them at all. I have a list of some 400 shortened words such as lol, omg, lmao...etc. Whenever someone types one of these shortened words, it is replaced with its English counterpart ([laughter], or something to that effect). Anyway, people are annoying and type these shor...

Create SVG / XML document without ns0 namespace using Python ElementTree

I'm building an SVG document with ElementTree in Python 2.7. Here is the code: from xml.etree import ElementTree as etree root = etree.XML('<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg"&gt;&lt;/svg&gt;') root.append(etree.Element("path")) root[0].set("d", "M1 1 L2 2 Z") print etree.tostring(root, enco...

Blender3d vs 3DS max; which one is better suited for automation in python?

I am getting started with the development of 3d environments for using in panda3d. As I am new to this, I need to choose a modelling software to create basic geometries, etc. Therefore, which one is better suited for automation through python? 3DS Max or Blender3D? I would like to automate generating basic geometries, the export process ...

Python threads and global vars

Say I have the following function in a module called "firstModule.py": def calculate(): # addCount value here should be used from the mainModule a=random.randint(0,5) + addCount Now I have a different module called "secondModule.py": def calculate(): # addCount value here too should be used from the mainModule a=random.rand...

Python - csv file is empty after using csv writer

Hello, Python newbie here. I was trying to troubleshoot an issue with writing a csv file in a larger program and decided to go back to basics to try to find the problem. I ran an exact code example from the Python csv reading and writing documention: import csv spamWriter = csv.writer(open('eggs.csv', 'w'), delimiter=' ', quotecha...

Image library for Python 3

What is python-3 using instead of PIL for manipulating Images? ...

Ordering a django model on many-to-may field. Denormalization required?

I have a system for composing items from parts in certain categories For instance take the following categories: 1: (Location) 2: (Material) And the following parts: Wall (FK=1) Roof (FK=1) Roof (FK=1) Brick (FK=2) Tile (FK=2) Wood (FK=2) To compose these items: Wall.Brick, Roof.Wood, Wall.Wood class Category(models.Model): ...

Simple interpreter to embed and extend inside an C++ Windows application

I need a simple interpreter which will do execution (evaluation) of simple expressions/statements and also call functions from main C++ applications. At the moment I do not need scripting of the application, but it may be useful later. It should also be strait-forward for other team members to pull my application from Source Repository ...

How do I extract certain digits from raw input in Python?

Let's say I ask a users for some random letters and numbers. let's say they gave me 1254jf4h. How would I take the letters jfh and convert them inter a separate variable and then take the numbers 12544 and make them in a separate variable? ...

Why is this python operation returning a tuple?

from datetime import date from datetime import timedelta a = date.today() - timedelta(1) # a above is a tuple and not datetime # Since I am a C programmer, I would expect python to cast back to datetime # but it is casting it to a tuple Can you please tell me why this is happening? and also how I can see that the operation above resul...

Is there a way to move many files quickly in Python?

I have a little script that moves files around in my photo collection, but it runs a bit slow. I think it's because I'm doing one file move at a time. I'm guessing I can speed this up if I do all file moves from one dir to another at the same time. Is there a way to do that? If that's not the reason for my slowness, how else can I spee...

How to do cloud computing with Python and Java? Final Year project.

For my final year project I plan to code a cloud in Python. The client will be written in Java by the other member of my team. The client will have a tabbed interface and it will provide a text editor, a media player, a couple of small Java based games and a maybe a few more services. The server will work like this: 1) Validate the...

using subprocess.popen in python with os.tmp file while passing in optional parameters

Hi, I am writing a python program in linux and in part of it running the pdftotext executable to convert a pdf text. The code I am currently using is given below. pdfData = currentPDF.read() tf = os.tmpfile() tf.write(pdfData) tf.seek(0) out, err = subprocess.Popen(["pdftotext", "-", "-"], stdin = tf, stdout=subprocess.PIPE ).communi...

Django's Model fields are defined on the class level?

Maybe my question is little childish. A django model is typically defined like this: class DummyModel(models.Model): field1 = models.CharField() field2 = models.CharField() As per my understanding, field1 and field2 are defined on the class level instead of instance level. So different instances will share the same field value...

Python - Fastest way to find the average value over entire dict each time it gets modified?

I'm trying to find the fastest/most efficient way to extract the average value from a dict. The task I'm working on requires that it do this thousands of times, so simply iterating over all the values in the dict each time to find the average would be entirely inefficient. Hundreds and hundreds of new key,value pairs get added to the dic...