14,952 Topics

Member Avatar for
Member Avatar for txwooley

In the book "How to Think Like A Computer Scientist" on the website openbookproject.net the tutorial leads you to draw a house with a pre-written script. It then instructs you to: # Wrap the house code in a function named draw_house(). # Run the script now. Do you see a …

Member Avatar for shasta90
0
587
Member Avatar for HiHe

According to the Python 2.7 manual this construction of the with statement should work: [code]text = "aim low and reach it" fname = "test7.txt" with open(fname, 'w') as foutp, open(fname, 'r') as finp: # write text to file foutp.write(text) # read text from file mytext = finp.read() print("to file --> …

Member Avatar for vegaseat
1
169
Member Avatar for Zeruba

Hello, I am currently trying to learn programming and am using Python to start with. I am currently practicing programming with classes and have placed the following code into a python file called complex.py: [CODE]class Complex def __init__(self, realpart, imagpart): self.r = realpart self.i = imagpart[/CODE] and placed the following …

Member Avatar for vegaseat
0
132
Member Avatar for chrisvj11

I have 2 images, one is supposed to be on top of the other. This works fine until one of the "movement" keys are hit (a,s,d,w) [CODE]import sqlite3 as sqlite import wx username=None class MainWindow(): def drawmap(self): self.map4_31="C:/python27/game/4_31.gif" self.map1=wx.Image(self.map4_31,wx.BITMAP_TYPE_GIF).ConvertToBitmap() height=self.map1.GetHeight() width=self.map1.GetWidth() self.map1.map4_31 = wx.StaticBitmap(frame, -1, self.map1, (270, 170), (width,height)) def …

0
109
Member Avatar for blackrusader

Basically, it is an open source software creation application that revolves around databases (similar to Microsoft Visual studio in some aspects but with python as the language). The user will be able to create forms with a drag and drop GUI builder, create an SQLite database and add functionality to …

Member Avatar for blackrusader
2
322
Member Avatar for ineedhelpasap

So, I'm trying to assign some SQL to a variable which will later be executed in the code. I also want to include a varible inside the SQL. I am only allowed to code over 80 characters and then I have been told to use a black slash, now this …

Member Avatar for ineedhelpasap
0
140
Member Avatar for mekhoo

[code] def main(): decimal=int(input('pleas enter a binary sequence: ')) number=binaryConvert(decimal) print("Contert to decimal: ", number) def binaryConvert(decimal): if decimal == 0 : return '0' elif decimal==1: return '1' number='' while decimal == '1' and decimal == '0' : number=str(decimal%2)+ number number=number main() [/code] but i did work well with me …

Member Avatar for vegaseat
0
118
Member Avatar for ineedhelpasap

Anyone ever used the PIL (Python Image Library)? If you have, is there anyway to convert a single pixel at a time in a bmp file? I'm trying to invert a black and white image to white and black. So: [code=python] import PIL image = Image open(filename) pixels = list(image.getdata()) …

Member Avatar for vegaseat
0
147
Member Avatar for mekhoo

(question3.py) Write a word jumble game. In a word jumble the letters in a proper word are randomly mixed up and the user has to guess what the word is. The list of words to be jumbled can be found on D2L - jumble.txt. Here is one possible way to …

Member Avatar for TrustyTony
0
278
Member Avatar for battlex2010

Hello everyone, I managed to recieve the contents of my email from gmail using the poplib module. But I am nor able to save these emails. How can I save the contents of email including images etc in most preferably in a html file?? Regards BattleX

0
94
Member Avatar for ineedhelpasap

Hi, I'm trying to convert a textfile which is set out like this: 1[Tab]Hello 2[Tab]Test into a Python dictionary how would I be able to do it? Thanks

Member Avatar for ineedhelpasap
0
86
Member Avatar for srw0801

Hello, so I've been working on a simple Tic Tac Toe game using TKinter graphics GUI. However i keep getting this error, and i'm not sure why. Any help would be greatly appreciated. Heres the code [CODE] import graphics import random def constructBoard(): win=graphics.GraphWin("Tic Tac Toe",500,500) win.setCoords(0.0,0.0,3.0,3.0) line1=graphics.Line(graphics.Point(1,0), graphics.Point(1,3)).draw(win) line2=graphics.Line(graphics.Point(2,0), …

Member Avatar for woooee
0
307
Member Avatar for flebber

I want to compare a list of files with extension .rtf in my directory with a list of files at a given url and download the files at the url not found in my directory. This is where I am at but cannot figure how to filter a list based …

Member Avatar for TrustyTony
0
320
Member Avatar for TrustyTony

This I did also after 'spying' discussions in other forum. Of course you would use sieve prime generation for bigger numbers, but I proved other simple way for a change. Slightly more advanced primes list generator would use primes % 6 in (1,5) property: [CODE]def primes(n): """ primitive non-sieve prime …

Member Avatar for TrustyTony
0
670
Member Avatar for Thropian

I'm working on a script in python,tkinter that draws a triangle and moves it around the screen. unfortunately I can't get the arrow to move. I've tried using canvas.move() but that wants an x and a y not the set of 3 coordinates I have to make it a triangle. …

Member Avatar for Thropian
0
2K
Member Avatar for meter1060

I need help. I am very illiterate in Python and the like and I have a chunk of code that checks to see if a page updates and then posts it onto a forum. I need to alter it (hopefully) to check to see if an RRS feed is updated …

Member Avatar for meter1060
0
213
Member Avatar for ndowens

[code]def cDownload(): print("Enter package name ") sName=input print("Enter download location ") sLocation=input command = "wget http://aur.archlinux.org/packages/" + sName + "/" + sName + ".tar.gz -O" + sLocation + "/" + sName + ".tar.gz" os.system(command) [/code] I get TypeError: Can't convert 'builtin_function_or_method' object to str implicitly

Member Avatar for ndowens
0
304
Member Avatar for ret801

ok someone please explain popen to me it runs subproccesses does this mean it can run programs from within my program? any help would be appreciated , there is not an easily spottable place that explains this. Thanks

Member Avatar for hondros
0
227
Member Avatar for happymadman

It seems like dataRecived is not "firing" but I cannot work out why. Any ideas? Thanks [CODE] # Basic Chat Server # Imports from twisted.internet import protocol, reactor import pickle import string PORT = 6661 connections = [] class User(protocol.Protocol): def connectionMade(self): self.transport.write("Welcome") def dataRecieved(self, data): print data def connectionLost(self, …

0
53
Member Avatar for Behseini

Hi, Gribouillis, helped me to understand how to invoke a function by btn click event handler, at my last post.Now I am trying to understand how I can handle an selected item event from a list box? lets say I have a list box like below and I want to …

Member Avatar for Lardmeister
0
9K
Member Avatar for nethero

Hi there, I'm kind of new to python and I'm trying to extract a protein sequence from this webpage... [url]http://www.ncbi.nlm.nih.gov/protein/BAH23558.1[/url] When I use urllib.urlopen the html it gets does not contain the sequence data. When I open this page in firefox and use firebug to look at the page I …

Member Avatar for nethero
0
243
Member Avatar for weblover

Hello all, i was working on an R script that will read a huge text file and make some calculation inside it, but i figured out that it will need long time to do the job , so i'm trying to convert it into python. is there any way to …

Member Avatar for TrustyTony
0
178
Member Avatar for [V]

I have a string that looks like: IiiiiiiiiiiHHHHHHHHHHHHHHHHHHHHHHHHHooooooooooooooooHHHHHHHHHHHHHHHHHHHHiiiiiiiiiiiiiiiiiiHHHHHHHHHHHHHHHHHHHHHHHHHooooooooooooooooHHHHHHHHHHHHHHHHHHHHHHHHHiiiiiiiiiiiiHHHHHHHHHHHHHHHHHHHHoooooooooooooooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOooooHHHHHHHHHHHHHHHHHHHHHHHHHiiiiiiiiiiiiiiiiiiHHHHHHHHHHHHHHHHHHHHooooooooooooooooooooooHHHHHHHHHHHHHHHHHHHHHHHHHiiiiiiiiiiiiHHHHHHHHHHHHHHHHHHHHHHHHHooooooooooooooooooooooHHHHHHHHHHHHHHHHHHHHi I want to to capture all the segments that have H's in them and return their respective start & stop string positions. [CODE] tms = re.compile("H+") print tms.findall(string) [/CODE] This will find all the Hs but I cant get the string positions …

Member Avatar for Lardmeister
0
206
Member Avatar for Simplicity.

I've tried to make the code below to solve one of the Euler equation for the Gas Dynamics. I understand my code is not perfect, that is why I'm getting an error which I don't understand. The error message is: " File "eulersys.py", line 50, in <module> u_data = Evolve_in_One_Timestep(u_data) …

Member Avatar for Simplicity.
0
440
Member Avatar for gork000

So, I found a snipped of code that did what I was looking for but I tried adding upon it to fit my need a little more. What I am trying to do is input an integer and return an 8 bit binary string to a list. My first problem …

Member Avatar for gork000
0
205
Member Avatar for adam291086

I am trying to delete a cookie by reseting it but it wont delete. What am i doing wrong [CODE]#!/usr/bin/python import cgi import Cookie import os def cookie_expiry_date(numdays): from datetime import date, timedelta new = date.today() + timedelta(days = numdays) return new.strftime("%a, %d-%b-%Y 23:59:59 GMT") print 'Set-Cookie: UserID=0; expires= '+cookie_expiry_date(-100); …

Member Avatar for ret801
0
233
Member Avatar for vishal.patil

I am looking for step by step details of how to deploy django websites in apache2 server with one example. I am using ubuntu operating system Please give some link or give the details.

Member Avatar for Pupo
0
116
Member Avatar for Krstevski

Hello friends, I want to write simple script to download youtube videos, but I have problem... I use One-liner for this, the file is downloaded but it's empty (0 bytes). Can someone help me about my problem ? Here is my code: [CODE=python] # Author: Abhinay Omkar # Title: One-liner …

Member Avatar for Pupo
0
182
Member Avatar for R3ap3R

I believe the Python thread is the most appropriate place to post a Django question :P Hi there guys and girls! I am currently busy (and learning) Django. It really is a solid platform to work on compared to PHP. Ok let me get to the point :P I am …

Member Avatar for Pupo
0
131
Member Avatar for spixy

I don't know if you could fix this code.. but there is something wrong with it or with me.. i don't know which.. here is the code for the .py script [CODE]import string import sys # input if len(sys.argv) < 2: print "Not enough arguments, quitting." quit() if len(sys.argv) > …

Member Avatar for TrustyTony
0
126

The End.