14,946 Topics

Member Avatar for
Member Avatar for Mr Tk

Hi I have a question about a problem I'm having with raw_input function in python. I'm writing a CL program that requires a comment to be entered by the user, however problems arise when someone makes a mistake entering said comment. [CODE=python]comment = raw_input(Enter comment: )[/CODE] User Input: Archie^?ve testing, …

Member Avatar for Mr Tk
0
3K
Member Avatar for knan

I dont know what goes wrong in this piece of code?!! I keep getting the following error. File "<stdin>", line 11 t1.append(list[temp]) ^ SyntaxError: invalid syntax [CODE]tl = [] for inlist in token_list: temp=[] for token in inlist: temp.append((zlib.adler32(token,65521)) tl.append(temp)[/CODE]

Member Avatar for Gribouillis
0
155
Member Avatar for Enders_Game

I have a class with a button, it runs the command automatically when the gui is constructed (which i dont want it to do) but then doesnt work again after. What am I doing wrong? Builtin commands such as endcommand work as they should. relevant excerpts (ignore the indent problem …

0
100
Member Avatar for br0wnm4n

Hello, I have been working on this code but I can't seem to make it work. I want to implement function index() that takes as input the name of a text file (as a string) and a list of words. For every word in the list, the function will print …

Member Avatar for br0wnm4n
0
246
Member Avatar for Shlaa

Okay, I started learning Python last weekend on Saturday with some tutorials and a book. With this being my first programming language my program won't amaze you :P The program I made is a calculator for working out how much turf a person would need given the length and the …

Member Avatar for Shlaa
0
135
Member Avatar for j855

Is it possible to sort a list of numbers from largest to smallest? Like if I had a list of numbers in variable a

Member Avatar for j855
0
67
Member Avatar for danholding

im wanting to sort files by size and pick the top 20 i have managed this with the glob.glob statement but it does not work quickly and does not pick up if a file is modified/ added while the code is running. i have worked out how to do this …

Member Avatar for Gribouillis
0
194
Member Avatar for henryford

Hi I am in a web programming class and have been struggling greatly with this assignment. I am not very familiar with Functions and so forth but I have been truthfully working on this for a few days now. I am at the point where I am stuck. I would …

Member Avatar for richieking
0
149
Member Avatar for suhas.sonavane
Member Avatar for lalit_jain1988

I am new in Python. May any one tell me how to validate XML file in python from DTD and Schema document....

Member Avatar for suhas.sonavane
0
52
Member Avatar for -ordi-

[CODE]f = open("summatest.01.sis", "rt") n = (f.readline()) jada_elemendid = f.readline().strip().split(' ') otstav_summa = f.readline().strip() f.close() # Valjund vfal = file("sum.val", "w") lmargid = [] def otsi(k): if (k < n): print n k = k + 1 lmargid.append("+") if otsi(k): return True lmargid.append("-") print lmargid else: z = jada_elemendid[0] for …

Member Avatar for woooee
0
134
Member Avatar for j855

In python it will give a decimal like 52.2 and I was wondering if there was a way to make it round all decimals up to the next number like 53.

Member Avatar for Shlaa
0
89
Member Avatar for sss33

If I have a list and I already have split the line in the file. I also have figured out the code to average the numbers in the list now I have want to figure out a way to somehow take the average from the list of numbers and give …

Member Avatar for sss33
0
91
Member Avatar for Avner .H.

Hello fellows... Is there something like static function variables in python? I know there are static attributes of a class, but what if i want to use a static variable inside a function? somthing like this (stupid) code in c++ for example: [code]int static_num() { static int x = 0; …

Member Avatar for zaghaghi
0
9K
Member Avatar for newbieha

To maximize the value of the knapsack The output should like this >>>Bags=[mkBag('cooper',30,120),mkBag('silver',20,100),mkBag('gold',10,60)] >>>knapsack(Bags,50) [('gold',1.0),('silver',1.0),mkBag('copper',0.666666666)] [CODE] class Bag(): __slots__ = ('name', 'weight','value', 'ratio') def mkBag(name,weight,value): bag=Bag() bag.name = name bag.weight = weight bag.value = value bag.ratio=value//weight return bag def printbag(bags): print("Name:", bag.name, "Weight:",bag,weight,"Value:", bag.value) def knapsack(bags,maxweight): bags=sorted(bags, key=lambda mkBag: mkBag.ratio) …

Member Avatar for TrustyTony
0
91
Member Avatar for pratz

Hello, We are trying to use Django with couchdb, is this a good idea??? It is going to be a health software, so is it better to use couchdb. Also we are going to use wtforms. Will this make a good combination for a complete software. Any more suggestions will …

0
73
Member Avatar for R2605

Hello, I'm a new python user and I'm trying to create a python program that will run on a targate and communicate with the terminal. The main idea is to run several commend and short programs and analyze the results. for example running those 2 commands: cd /home/user/folder ls | …

Member Avatar for R2605
0
114
Member Avatar for novice20

below is how an snmp get is issued using pysnmp errorIndication,errorStatus,errorIndex,varBinds = cmdgen.CommandGenerator().getCmd( cmdgen.CommunityData('xxxx', 'xxxx', 1), cmdgen.UdpTransportTarget(('192.168.5.157', 161)), (1,3,6,1,4,1,18489,1,2,1,4,5,[B]1[/B],0)) In the OID part, the integer in bold keeps changing from 1 to 38. I need to put the above in a loop, instead of issuing 38 seperate gets. how can …

0
62
Member Avatar for vegaseat

The map() function applies a function to every member of a list. Here a list of numbers 32 to 255 is changed to a list of the corresponding ASCII characters. Then map() is used in a more complex application to combine the two lists to form a dictionary containing number:character …

Member Avatar for Gribouillis
0
431
Member Avatar for knan

I have a list of lists [CODE]x=[['a', 'b', 'c', 'd'], ['e', 'f'], ['g', 'h']][/CODE] I need the following output. [CODE]a-b a-c a-d b-c b-d c-d e-f g-h[/CODE] How can i do this? Can a regular expression be used here??

Member Avatar for Gribouillis
0
149
Member Avatar for sravi.pearl

haiii Do anyone know how to convert array like this ['26','18','20'] into [26 18 20] because i have to plot graph for these value, ['26','18','20] array is not allow me to do that ,i got ['26','18','20'] from database table with data type varchar....problem is i shouldnot change the datatype .... …

Member Avatar for TrustyTony
0
91
Member Avatar for novice20

[B]hi... I have a value, value=4501-E001 I am concerned about only the value before hyphen i.e., 4501 I need to check whether various values begin with 4501, followed by something, n am not concerned about "something" that follows. How can this splitting be done in python?[/B]

Member Avatar for Gribouillis
0
128
Member Avatar for UaBoy

I am making a program for my CS class. Is there a way, in python, to set more than one value to a variable? Am I thinking about this in the wrong way? I need to make a program that asks a bank account holder for their username. If that …

Member Avatar for TrustyTony
0
118
Member Avatar for kumar86

hello guys suppose if want to open a file in Notepad application, it have short cut key(shift+ctrl+o). So to open a file, using the short cut key, i have to write python script. could please give some example. Regards kumar

0
55
Member Avatar for kumar86

hello guys, I am writing automated python script. How can i propagate the result of each script in XL sheet, whether the script is passed or failed. could you please help me For example , my first script is to verify 'open an existing project' and second script to verify …

0
48
Member Avatar for kumar86

hello guys, I have written a script to open notepad and added the text in script, after that i want to save the file in text format. from pywinauto import application from pywinauto import application app=application.Application() app.start_('Notepad.exe') app.Notepad.edit.TypeKeys('hello') app.Notepad.MenuSelect("File->Open") app.Notepad.MenuSelect("File->Save")/*saveas dialog box opened and waiting for the filename*/ Please guide …

Member Avatar for kumar86
0
105
Member Avatar for sravi.pearl

hiiii all, Can anyone please help me regarding this .... i have table with 2 cloumns in a database "details" Name Age john 26 Mary 18 Nancy 20 i want to get only the Age in an array. I tired in this way: db=MySQLdb.connect(user="root",passwd="my",db="mydb") cursor=db.cursor()# prepare a cursor object using …

Member Avatar for sravi.pearl
0
204
Member Avatar for ChaosKnight11

Hi, I want to start preparing for an IT Olympiad for next year for a chance to get a full bursary for college. We can choose between Java, Python, C and C++. Of the lot I'm most comfortable with Python seeing that I at least have a bit of experience …

Member Avatar for woooee
0
181
Member Avatar for suntom

Hello, new coder here :-) I've been working on one of my first scripts, an SMTP script for sending mail with Gmail. It works and all, but I wan't to have an "if" the login to the server failed, it would print and message saying so and return to the …

Member Avatar for richieking
0
1K
Member Avatar for knan

I have a file named test.txt I get the file [CODE]file=open("test.txt","r") obj=file.read() file.close() print obj a=a b=b c=c d=e e=d e=f f=e f=g g=h[/CODE] All I want to do with this obj is that, I've to create a regular expression such that, 1.If the left number matches the right number, …

Member Avatar for TrustyTony
0
200

The End.