15,190 Topics
![]() | |
A Python code example to find an approximate value for x in f(x) = 0 using Newton's method. | |
Explore Python's sqlite3 database module, create, write and read a database file. | |
This snippet shows you how to create a list of class instances. The class itself cannot be pickled, but the list of instances can. To use the pickled data file in another program, you have to recode the class in that program. | |
My code has a couple of "multiple assigments" and somehow I think there should be a nicer way to do this in Python. This is how it currently looks like: # sum price fields paf = paf + float(pa) pbf = pbf + float(pb) pcf = pcf + float(pc) pdf … | |
Jython is a version of Python that can use the extensive Java library. Jython uses Python syntax and avoids the rather ugly syntax (at least for Pythonions) of Java. Here we apply it to bring up an image from a file. | |
Why does the function *def human_move(board, human)* need to receive board *and* human? won't it work the same if it just receives board? *def human_move(board)* # global constants X = "X" O = "O" EMPTY = " " TIE = "TIE" NUM_SQUARES = 9 def display_instruct(): """ Display game instructions. … | |
I was experimenting with special methods, so I tried to create my own `__new__` method , well just as expected it got called when the object was instantiated but the window that should show up didnt show even when i used super to retain the original `__new__ `functionality. from PySide.QtCore … | |
At first, I have "C:/test02.txt" too good positive a film for stunt scheduling i think objective My codes with open('C:/test01.txt') as words: ws = words.read().splitlines() with open('C:/test02.txt') as file_modify4: for x in file_modify4: sx = map(str.strip, x.split("\t")) ssx = sx[0].split(" ") ## list for w in ssx: if w in … | |
why their is a difference between os.getenv('PATH') and sys.path ? | |
I have a web app in python but I'd like to protect it with site minder authentication. Thanks. | |
Hi Guys, Please be gentle with me as im a complete n00b. My favorite language is actually Java which im learning at Uni at the moment. However to throw a spanner in the works they have switched us over to Python, as well as learning Java. My mind has been … | |
When I try to save a pylab plot (either from the GUI or with `pylab.savefig`), I get the error at the bottom. A minimal script that demonstrates the problem is: import pylab pylab.savefig("foo.png") A Google search for `IndexError: Unexpected SeqBase<T> length` did produce some results, none of them hinting how … | |
I've created this script that logs in to Windows Live (http://login.live.com/) but I can't tell if it works, can anyone elaborate? import requests import sys EMAIL = 'email goes here' PASSWORD = 'pass goes here' URL = 'https://login.live.com/' def main(): # Start a session so we can have persistant cookies … | |
import requests import sys EMAIL = 'YOUR EMAIL GOES HERE' PASSWORD = 'YOUR PASSWORD GOES HERE' URL = 'https://login.live.com/' def main(): # Start a session so we can have persistant cookies session = requests.Session() # This is the form data that the page sends when logging in login_data = { … | |
 I'm new to pygame and currently I'm working on creating a memory game where the computer displays boxes at random positions for like a second and then the user has to click on where he/she thinks those boxes are. It's kind of like this: [Click Here](http://www.lumosity.com/brain-games/memory-games/memory-matrix) However right … | |
I am in the process of learning python, but I have a problem some one gave me last week that I wouldn't mind solving before I get to where I actually learn about it. I think python is the best choice. I need to generate a txt file by inserting … | |
I have finished the code, but I can not for the life of me figure out why I am not getting any output. Any help would most appreciated. #!/usr/bin/python import apsw import random class NonRepeatingRandom(object): def __init__(self, maxvalue): self.maxvalue = maxvalue self.used = set() def next(self): if len(self.used) >= self.maxvalue: … | |
This example program of using the multiprocessing is crashing my i7 4 core windows7 64 bit computer (32 bit enthought Python 2.7), but is running fine in virtual machine Ubuntu with 4 cores assigned. Can anyone run it in their commputer in Windows7. My system memory (8 GB) is totally … | |
Hello All, I am trying to access files which are on a shared network file system, but not sure which python API I should be using. Description: For example the IP address of the file system is 10.10.10.1 1. From windows if i want to access this server i simply … | |
Santa just brought me a fancy notebook computer and I want to know if anyone has some experiemce with accessing that little camera with Python code? | |
anytime i add a directory in a .pth file of my c:\python30\Lib\site-packages folder on windows and i try to import from the listed directory in my .pth files, i get an import error that the module does not exist and after importing sys on the windows command line interface and … | |
Hi guys, I am working on a text based adventure game in Python and I am constantly getting this error: **There's an error in your program: return outside function(g.py, line 179** Here is the code http://www.mediafire.com/?4ga0weu4ifc6s1u | |
Hi, I'm trying to make a slider, but for some reason all the numbers of the slider get in left corner of the frame, all at the same position(instead of the 1;left,the position of the slider;middle and 100; right). Also see added File Here is my code: import wx class … | |
![]() | Hello, I am a new to python. I need to solve 5 exercises. Any help would be very much appreciated!! thank you! 1.Write a program dotplot.py That takes as input a fasta file with two sequences A scoring matrix and sliding window, such as: dotplot.py fasta.in score.mat 11 and prints … |
Dear Friends, I have a sequence of two values as the following: 00001.doc d:\pathtofile\image50.jpg 00002.doc d:\pathtofile\image38.jpg 00003.doc d:\pathtofile\image40.jpg ... I would like to add the values to a list, sort the list by second value and rename the first value accordingly. For example, the following steps: Step 1 '00002.doc', 'd:\pathtofile\image38.jpg' … | |
What is the best way to use a dictionary within a class. Do I have to assign the dict within the class ? Thanks | |
Hello Everyone! I am a beginner user of Python without IT background (I am interested in IT developing my knowledge step by step). So far I did simple scripts in Python and I encountered a problem. I was looking on Google, however I didn't find the satisfactory answers which would … | |
I have a question on how to slice a dataframe. Below is a row in my dataframe. I just want to get the list under column C. I saw that I could use df.get_value(), but I'm not sure what to put for index. Is this the right way to return … | |
I need help figuring out how to fix my code. Every time I run the code its traceback is to this part of it. My code is Unbound Local Error for 'result'. Please see code below: def Level1(self): sql = "SELECT easyhint, gps, qrcode FROM gamedb WHERE quad = 1 … | |
Traceback (most recent call last): File "C:/python files/USACO/crazy/crazy.py", line 87, in <module> grid.plot(x,y,"F") File "C:/python files/USACO/crazy\grid.py", line 63, in plot self.g[(x,y)] = replace TypeError: unhashable type: 'list' You see, I'm hashing a string with the key bing a tuple. This is using my own 2d grid data structure. |
The End.