15,181 Topics

Member Avatar for
Member Avatar for gunbuster363

Hi, I have a dictionary storing many things... I would like to delete entries which have key of len < 3. But after I do the del statement, there are still lots of entries with len < 3, what happens? [CODE]for w in fdict.keys()[:]: if w.strip() in banset or len(w.strip()) …

Member Avatar for gunbuster363
0
81
Member Avatar for kunal_00731
Member Avatar for pjistaz

Please help I'm having trouble getting my program to return any answer other than "You Lose!". Where is my mistake? Thanks in advance for any help. [code] print "Let's Play Rock, Paper, Scissors!!" print "Rock beats scissors, paper beats rock, and scissors beats rock and paper! Have fun!" import random …

Member Avatar for SgtMe
0
98
Member Avatar for jjrrmm

hi guys can anyone explain to me this code. i dont really get this. thanks a lot. def readFile(name = ""): try: assert (name != "") , "The file name is not given!!" except AssertionError: print "file name is not given" else: try: f = open(name, 'r') except: print 'File …

Member Avatar for SgtMe
-2
96
Member Avatar for rhoit

How to fill array with any no like using zeros and ones. i'm new to python and i can't find the answer....

Member Avatar for rhoit
0
89
Member Avatar for the_mia_team

Write a python function to convert a numeric input argument to a string output based on the following rules: >=10: A, 9:B, 8:C, 7:D, 6:E, <=5: F I came up with this, but it does not work at all table = {'A': 10, 'B': 9, 'C': 8, 'D': 7, 'E': …

Member Avatar for the_mia_team
0
123
Member Avatar for kishoreinme

hello there Iam using python 2.5.4 pyserial 2.4 pywin32-214 on windows 7 i hav a small test script written to query a serial device (arduino) and get back reply appropriately ////file: test.py import serial print 'hi' ser=serial.Serial(port='\\.\COM2', baudrate=9600) ser.close() ser.open() ser.write('1') ser.readline() ser.readline() ser.close() the device waits for '1' through …

Member Avatar for Tech B
0
118
Member Avatar for the_mia_team

Write a Python program that creates a dictionary of son-father pairs-you can make the pairs with fictional names for fun. Your program should populate this dictionary with the son-father pairs you made up. Your program should present the user a menu with two options. The following is an example: Father …

Member Avatar for snippsat
0
259
Member Avatar for Ronnicus

test = 4 #start of def def change(): test = 5 #end change() print test Why doesn't it print 5? Can anyone explain this to me? Btw, test = 5 is indented, the forum won't let me indent for some reason

Member Avatar for bumsfeld
0
84
Member Avatar for meisterluv

Hi everyone I was wondering if I could get some help on environment variables. I am executing a cgi file from a C file with execv(). The cgi is able to generate the html template correctly. However I am unable to grab the "REQUEST_METHOD" since it always returns NULL. Can …

0
57
Member Avatar for ragavh

i need to create a program that translates an english phrase to a spanish phrase. i have a text file with english words and their spanish meaning. i am unsure how to start this as i am quite new to phyton. ignore the grammar, i want to translate the phrase …

Member Avatar for jcao219
0
167
Member Avatar for yesha27

here I have code in python and now I want to transfer it in Java. import logging import urllib import re from waveapi import events from waveapi import model from waveapi import robot from waveapi import document from django.utils import simplejson from google.appengine.api import urlfetch def OnDocChanged(properties, context): #Get Contents …

Member Avatar for jcao219
0
183
Member Avatar for froggy1

I would like to find and replace a string in a file. I know how to do this, but I can only do it for all instances. Is there a way to do it for just the first instance of the string in the file? import fileinput for line in …

Member Avatar for froggy1
0
148
Member Avatar for fur8ar

[code] Traceback (most recent call last): File "C:/Python31/sample.py", line 10, in <module> calendar.prcal(year) AttributeError: 'module' object has no attribute 'prcal' [/code] Hello, I just started learning Python with this fantastic site. Unfortunatly I get this when i try to execute the following code [code] import calendar print( "Show a given …

Member Avatar for fur8ar
0
100
Member Avatar for andy_long

hello, I have faced a problem that is almost as same as the problem below: ((((If I try to define a timer in an ogl.BitmapShape, like this: class T6963_device (ogl.BitmapShape): def __init__(self): ogl.BitmapShapeinit__ (self) self.t1 = wx.Timer (self) I get this error Traceback (most recent call last): File "D:\data_to_test\smtest2.py", line …

Member Avatar for ihatehippies
0
181
Member Avatar for G_S

Hi everybody, I'm trying to install python 3 from source in my new Mandriva 2010. I have read a lot of posts in this website, but none of the instructions has worked for me. The code compiles and all, but it doesn't install tkinter. I know that tcl/tk are installed …

Member Avatar for G_S
0
237
Member Avatar for Escom

Hello, i would like to make program in python which reads the lines from an input file, which looks like this: Bob 10 20 30 John 15 15 Kate 20 and the program sums the numbers for each person and writes into an output file which should look like this: …

Member Avatar for dilbert_here00
0
169
Member Avatar for Krstevski

Hello friends, I have created simple rss reader class, but the class contains many loops and didn't work correctly and if anyone wants to help me with code, example, tutorial etc... I would be very grateful. The code of the class you can see on the following link: [url]http://pastebin.com/F7zQdhAW[/url] Thanks...

0
66
Member Avatar for Robbert

Hi I need some help with sizers. I just can not get my head around it and i cant find much on the net about what i am trying to achieve. I am not even sure if i need a grid sizer or two box sizers. This is what i …

Member Avatar for Robbert
0
86
Member Avatar for JonKho

Dear all, My window layout looks like this.. [img]http://i41.tinypic.com/hu27ax.jpg[/img] First, the dialog box that consists of listbox would appear to ask for user input. After the user input has been given, It will display in the next windows.. I have been trying to intergate the two coding together. However I …

Member Avatar for JonKho
0
221
Member Avatar for shusshoku

I'm using python for a project and was curious if anyone knew whether it was possible to open up jpg files in a GraphWin window. Also, the image software I'm using with it is PIL, if that helps.

Member Avatar for bumsfeld
0
72
Member Avatar for pubudugokarella

I'm new to here.so i posted it on the code thread pls go through it and help me [url]http://www.daniweb.com/code/snippet271890.html[/url]

0
79
Member Avatar for bumsfeld

[code]#Blast workbench using biopython from Bio.Blast import NCBIWWW ##result_handle = NCBIWWW.qblast("blastn", "nr", "8332116") fasta_string = "AATTCAGTGGCAAAAAAAAAACTCAAATTTTAGGGAAGGCCCTAATATTATCAAATAATTAGAGGGGGGG" result_handle = NCBIWWW.qblast("blastn", "nt", fasta_string) save_file = open("my_blast.xml", "w") save_file.write(result_handle.read()) save_file.close() result_handle.close() result_handle = open("my_blast.xml") from Bio.Blast import NCBIXML for record in NCBIXML.parse(open("my_blast.xml")) : #We want to ignore any queries with no search results: …

0
323
Member Avatar for ultimatebuster

Is python web programming anything like php? Is there simple examples like submitting a form to perform a calculator functions etc?

Member Avatar for snippsat
0
115
Member Avatar for pyprog

I want to remove all the 1's from the sublists so l becomes [[2], [2], [2]] but have trouble keeping track of indices. Can someone help out? [CODE]l = [[1, 2, 1],[1, 1, 2],[2, 1, 1]] i = 0 for element in l: while i < len(element): if element[i] == …

Member Avatar for vegaseat
0
140
Member Avatar for Axel_Carvalho

Hello. I need some help. I have a function [icode]my_function(a, b, c, d)[/icode] which takes string parameters and output them in different combinations. It works well in IDLE, but I would like to output the result into a file. Such code [code=python]file = open("out_file.txt", 'w') file.write(my_function(a, b, c, d)) [/code] …

Member Avatar for Axel_Carvalho
0
129
Member Avatar for pubudugokarella

I'm a bio informatics student who is leaning programming.With the help of this site and other blogs I made this one so far.I need to create a interface which give a text box to enter sequence and a start button and a window that display results.I went through Wx tutorials …

-3
34
Member Avatar for jozz3

Just a quick one- I'm writing code that asks the user for a filename and checks that it exists. If it does it has to print the file's contents, if not print a message. [CODE]import os fileName = raw_input("Enter the name of the file: ") if os.path.exists(fileName) == True: fileName.read() …

Member Avatar for Gribouillis
0
138
Member Avatar for dunwitch

I'm trying to get a SQLite3 DB to populate a wx.ListCrtl. I can get it to print to stdout/stderr without any problem. I just can't seem to figure out how to display the data in the DataWindow/DataList? I'm still learning programing/python so any advice would be appreciated. After two days …

Member Avatar for Stefano Mtangoo
0
824
Member Avatar for soUPERMan

I have this code: [CODE]class Member: def __init__(self, name, typeOM, fee, yearJoin): self.name = name self.typeOM = typeOM self.fee = float(fee) self.yearJoin = yearJoin # Reader Methods def getName(self): return self.name def getTypeOM(self): return self.typeOM def getFee(self): return self.fee def getYearJoin(self): return self.yearJoin def getMemberTypeString(self): if self.typeOM == 'P' or …

Member Avatar for soUPERMan
0
113

The End.