python

Python Fibonacci Generator

I need to make a program that asks for the amount of fibonacci numbers printed and then prints them like 0, 1, 1, 2... but I cant get it to work. My code looks the following: a = int(raw_input('Give amount: ')) def fib(): a, b = 0, 1 while 1: yield a a, b = b, a + b a = fib() a.next() 0 for i in range(a): p...

Beginner in a desperate need of python help.

Beginner programmer here! I need to write a simple phone book application. My program should be able to add names and phone numbers to a database. I should use a dictionary to store the information. If the user's input is empty, my program should stop, otherwise it should keep on asking inputs. Honestly I am lost here. I need help. ...

recursively downloading files from webpage..

http://examples.oreilly.com/9780735615366/ I actually want to be able to have all these files in my disk. as u can see there are many folders each with different type of files. and u cannot download "the-folder" directly...only individual files ~ is there any way to automate process..? I will need regular expressions on urls to arr...

C++\IronPython integration example code?

I'm looking for a simple example code for C++\IronPython integration, i.e. embedding python code inside a C++, or better yet, Visual C++ program. The example code should include: how to share objects between the languages, how to call functions\methods back and forth etc... Also, an explicit setup procedure would help too. (How to incl...

Python vs Flash

Can python be used as a language to develop browser based games? Like we do in flash. If yes then what frameworks are available to get my hands dirty? If no then what are the reasons? ...

When would we need a javascript client template engine?

Recently, I found out that jQuery has an official template engine which was contributed by the Microsoft team. Also I had heard about jTemplate from my friends, but I'm still confused: When & where might I need to use these plugins? How should I choose between the many client side template engines? ...

Is it possible to make a cross browser extension linked to a Python web app backend?

Current Situation I am in the early phases of designing a web app that the user will interact with via a browser extension that will be in the form of a horizontal nav bar. I wanted to use Pylons and Python on this project but am unsure how it fits in. As I understand it a browser extension is "just bundled HTML, CSS, JS and image files...

Shuffle position of elements in a list

Possible Duplicate: Shuffling a list of objects in python IF I have a list: a = ["a", "b", "c", ..., "zzz"] how can I randomly shuffle its elements in order to obtain a list: b = ["c", "zh", ...] without consuming a lot of the system's resources? ...

Subclass/Child class

Hi, I had this class and subclass : class Range: def __init__(self, start, end): self.setStart(start) self.setEnd(end) def getStart(self): return self.start def setStart(self, s): self.start = s def getEnd(self): return self.end def setEnd(self, e): self.end = e def getLength(self): return len(range(sel...

os.path.exists not accepting variable input

Whenever I call os.path.exists(variable) it will return false but if I call os.path.exists('/this/is/my/path') it will return true. import os import sys test = None print("Test directory") test= sys.stdin.readline() test.strip('\n') print(os.path.exists(test)) I know that os.path.exists can return false if there is a permissions erro...

How to serve up dynamic content via django and php on same domain?

I just finished rewriting a significant portion of my web site using python's django, but I also have some legacy code in php that I haven't finished migrating over yet. Is it possible to get these two working on the same domain and if so, how do I go about doing it? I'm running this site on a virtual Ubuntu instance and serving content...

Unable to import pyglet.media.avbin

My traceback is as follows: C:\Romeo\Scripts>python Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> import pyglet.media.avbin Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Romeo\lib\site-pa...

TkInter: how can I pass a numeric value to specify the color ?

hi, how can I assign a numeric value instead of a string to specify the color of my button ? What the exact syntax ? button = tk.Button(itemFrame, text="", bg="red", width=10, command=callback) i.e bg = #FF0000 thanks ...

How to make heapq evaluate the heap off of a specific attribute?

I wish to hold a heap of objects, not just numbers. They will have an integer attribute in them that the heap can sort by. The easiest way to use heaps in python is heapq, but how do I tell it to sort by a specific attribute when using heapq? ...

Left hand side of assignment with infinite generators

Sorry to double my earlier question, but I thought to ask specific data which would solve the problem. I want this result tuple_of_vars = (item for _, item for zip(tuple_of_vars, new_vals_generator)) as this is not possible a, b, c, d = (val for val in infite_generator) actually then I want to do in single line for var in var_list...

Current Status of PEP 8 Rules?

Are all PEP 8 rules still valid? Are there any which are obsolete? Isn't there a more explanatory cheat sheet that this one. ...

difficulties with python assignment

I am new to programing and am having difficulties writing a program dealing with files. The program is to read a file, calculate an employees pay and an updated YTD pay total. After calculations the program will write to a new file. This is what I have so far: empName = "" prevYTD = 0.0 payRate = 0.0 hoursWorked = 0.0 recordCount = 0 ...

Is it possible to use Python to measure response time?

Hi, I'm running some experiments and I need to precisely measure participants' response time to questions. I know there are some commercial software, but I was wondering if I can do this with Python. Does python provides suitable functionality to measure the response time in millisecond unit? Thank you, Joon ...

pySQLite integration to pyGtk treeview.

Hello, Is there some siple way or how to integrate sqlite database into gtk.TreeModel (TreeView)? What I want is to display data from db in treeview and it would be nice when I change something in db to see the change in treeview and the odher way round. Thanks ...

Image analysis in R

Hi R users, I would like to know how I would go about performing image analysis in R. My goal is to convert images into matrices (pixel-wise information), extract/quantify color, estimate the presence of shapes and compare images based on such metrics/patterns. I am aware of relevant packages available in Python (suggestions relevant t...