15,181 Topics
| |
Hi all, I am trying to rewrite the following code, to avoid having to write 60 individual loops,I would really appreciate your help with this. # Long Version - not ideal num = 60 n = [open('n%i.txt' % i, "w") for i in range (num)] for a2s1, a2s0, a1s1, a1s0 … | |
![circuit](/attachments/small/2/circuit.jpg "align-right") Here is a version in Python of program from classic Lisp book (see http://www.daniweb.com/software-development/legacy-languages/code/446235/simple-scheme-functions-for-finding-impedance-for-norvigs-implementation for the details) for calculating impedance of a circuit. (Example circuit with 1MOhm like in the book's code not like in diagram) | |
![Lisp001](/attachments/small/2/Lisp001.jpg "align-left") ![Lisp002](/attachments/small/2/Lisp002.jpg "align-right") I did translation to minimal Scheme implementation of Norvig written in Python (http://www.daniweb.com/software-development/python/threads/359370/norvig-an-even-better-lisp-interpreter-in-python) of the impedance code defined in classic book **Lisp by *Patric Henry Winston* and *Berthold Klaus Paul Horn*** from year 1981 (first computer book I ever bought). Errata: diagram has 10 MOhm when … | |
I need to write a program that implements Newton's method ((guess + x/guess) / (2)). The program should prompt the user for the value to find the squareroot of (x) and the number of times to improve the guess. Starting with a guess value of x/2, your program should loop … | |
I am working on an assignment in college using RUR-PLE as a starting program. I don't know if you know what that is or not, but I was wondering how to use it? I enter in this code: x = input("How many beepers are in this maze?") def place_all(): repeat(put_beeper,totalBeepers) … | |
This PySide (PyQT) code sample shows you how to apply a StyleSheet to a GroupBox containing a number of RadioButtons. | |
A little fun drawing with the Python module turtle. Well commented to help the beginner. | |
I mainly need help with creating the 3 by 4 matrix (part 3 of the assignment) as i am confused as how i would create it. However this is the entire assignment: 1. Write a function that returns the sum of all the elements in a specified column in a … | |
I am reading the book for web2py. It is running through some python syntax examples. When I ge to this closure example I am not understanding how 'y' gets its value. This is the code. >>> def f(x): def g(y): return x * y return g >>> doubler = f(2) … | |
Hello, I have got [this](http://www.yasinuludag.com/darkorange.stylesheet) a Qt stylesheet, how do I load it to my PyQt module after creating a QString Object. if I do from PyQt4 import QtCore s = QtCore.QString('c:\myProject\darkFantasy.stylesheet') the above code loads the path string rather than the actual stylesheet. So how do I load the … | |
#McListBox Example #Jan.20, 2013 import tkinter as tk import tkinter.font as tkFont import tkinter.ttk as ttk #import re Actors_list = [("Rowan","Atkinson"),("John","Candy"),("Morgan","Freeman"),("James","Garner"),("Cary","Grant"),("Kate","Hudson"), ("Jack","Nicholson"),("William","Powell"),("Arnold","Schwarzenegger"),("Tom","Selleck"),("John","Wayne")] Movies_list = [[("Bean","1997"),("Mr. Bean's Holiday","2007"),("The Lion King","1994"),("Johnny English","2003"),("Johnny English Reborn","2011"),("Keeping Mum","2005"),("The Black Adder","1982-1983")], [("Dr. Zonk and the Zunkins","1974"),("Tunnel Vision","1976"),("SCTV","1976-1979"),("1941","1979")], [("The Pawnbroker","1964"),("Blade","1973"),("The Electric Company","1971-1977"),("Attica","1980"), ("Brubaker","1980"),("Street Smart","1980"),("Driving Miss Daisy","1989"),("Glory","1989"),("Unforgiven","1992"), ("Outbreak","1995"),("Se7en","1995"),("Amistad","1997"),("The … | |
Im new to python and im runnung xubuntu! I was wondering if there is a site that does tutorials for Python in xubuntu?? | |
Hi everybody, is there anyone with experience with opencv for python? I was wondering if there is a way to allocate some memory on demand, since when I try processing images (usually bigger than 800x800 pixels) I get a "OpenCV Error: Insufficient memory (unable to allocate 59500564 bytes)" message. (bytes … | |
Hi guys, I have a code that intercepts calls to methods via __getattr__. Something like: def __getattr__(self, attr, *fcnargs, **fcnkwargs): out=getattr(self._df, attr)(*fcnargs, **fcnkwargs) etc... My goal is when a user calls a method, if it is not a method of self, the program attempts to run it on one of … | |
I'm fairly new to python. I've been using a modified verson of McListBox from a posting by vegaseat to get 2 treeviews going. It's been working well until I've been trying to be able to click on one to select what will be shown in the second. Anybody have an … | |
I'm trying to create a little text module for pygame. I've got everything up and running but I can't seem to get list.pop() to work. Whenever a person presses a key I put the chr() version of it into a list, then I iterate over that list to print out … | |
Nevermind, fixed it, I was being stupid. | |
Hey Guys i have a list like ['10015, John, Smith, 2, 3.01', '10334, Jane, Roberts, 4, 3.81' , '10208, Patrick, Green, 1, 3.95'] i need to split this list and create a list of this form 10015 John Smith 2 3.01 10334 Jane Roberts 4 3.81 any ideas how to … | |
hello im a hobbyist who is somewhat new to c++ with lots of experience in python. in python i was able to use dictionaries that could be accessed by keys and values with no limits on data types that can be stored but now im trying to port a simple … | |
# "toNumbers(strList) is a list of things,each of which represents a number.Modifies each entry in the list by converting it to a number." # Here is my code and it won't work,please help,thank you! import string def toNumbers(strList): nums = [] for i in strList: nums = nums.append(int(i)) return nums … | |
If you draw shapes that are closely spaced and shifted, you can create interesting interference patterns, so called moire patterns. Here is an example using the Python module PyGame to do the drawing. | |
Hi, I want to perform a search with Python in this site: [url]http://www.draftexpress.com/search.php[/url] I want to search for a player who's first name is "james". The problem: The page with the result's url is: [url]http://www.draftexpress.com/search.php#results[/url] Obviously, when opening this page directly, I don't get the page with the results for … | |
hello everyone i created a python file DailyExpensessave.py when i need to import this in another python program i was getting this error > Traceback (most recent call last): > File "C:\Python32\DailyExpensessave", line 1, in <module> > from DailyExpenses import * > ImportError: No module named DailyExpenses Both the python … | |
Dear friends, is there a way to execute a dos command in a frame inside a wx.window GUI (and not in the usual external window)? Thanks | |
This small code example shows you how to approach the beginning concept of an very simple "IDE" for Python. | |
having a little trouble trying to convert this pseudo code into python, could any help receiveFile () { lastblock := 0 newblock := 0 ; repeat repeat event := getFrameFromUDP(m) ; case event of data : newblock := getBlockNoFromFrame(m) ; transmitAckOverUDP(newblock) | timeout: transmitAckOverUDP(lastblock) esac until newblock==lastblock+1 ; lastblock = … | |
I have implemented a toolbar that has several QPushButtons inside QVBoxLayout, however I have implemented it in `toolbar_UI.py` from PySide import QtCore,QtGui class ToolBarUI(QtGui.QWidget): def __init__(self,*args,**kwargs): super(ToolBarUI,self).__init__(*args,**kwargs) self.floatingToolBar() def sizeHint(self): return QtCore.QSize(65,45) def buttons(self): self.emlSel = QtGui.QAction("Email Selected", self) self.emlScn = QtGui.QAction("Email this Scene", self) self.emlBufr = QtGui.QAction("Email Current Frame … | |
If you want a window with a menubar, toolbar, statusbar, dock and central widgets, you can use the PySide GUI toolkit's QMainWindow. To use the more traditional box and grid layouts, you simply add a QWidget instance as the central widget. Here is an example. | |
Hi all, I want to combine multiple files those are kept in a directory. Before getting the big file, I want to edit first and then combine them. For example, I have two files such as file1 and file2 in a directory, say TEST file1 contains 1 C 8.95377612903e-07 2 … | |
Here is code, which you can play with before installing and using the [superior blist package from pypi](http://pypi.python.org/pypi/blist/). I did it as therapy after doing programming test answer using zillion of setters and getters. Motivation is basically to show why you should use properties after you need them and attribute … |
The End.