904 Posted Topics

Member Avatar for HLA91

The two functions num = input("Enter a number: ") and name = raw_input("Enter a name: ") are for the user to enter number or name from the console. Please use code blocks. import string def main(): #data = raw_input("H:\harry.txt") # use data = raw_input("Enter file name: ") # what you …

Member Avatar for bumsfeld
0
182
Member Avatar for mruane

You could save important details of player (player, hitpoints, treasures, weapons etc.) to a file before you exit the game. Now you have to also write your code to accept any saved game as option when you start. Tkinter that comes with Python allows graphics, another one is PIL also …

Member Avatar for bumsfeld
0
114
Member Avatar for theUnNown1

If you have Windoze machine you can use MSvfw32.lib for Dev_Cpp code example see: "An AVI Media Player (Dev-C++)" [url]http://www.daniweb.com/code/snippet95.html[/url]

Member Avatar for bumsfeld
0
88
Member Avatar for dunderhead

One solution to fix problem is to have MakePanel2 inherit MakePanel1, then you only need to create instance of MakePanel1 in MakePanel2. For some odd reason wx.BoxSizer() gets confused with the label location. Look the code over. [code]#!/usr/bin/python import wx import time class MakePanel1(wx.Panel): def __init__(self, Parent, *args, **kwargs): wx.Panel.__init__(self, …

Member Avatar for dunderhead
0
2K
Member Avatar for FireSBurnsmuP

I have used Python and I am learning C++. Programs that are just a few lines of code in Python are nightmares in C++, like splitting sentence into words and loading them into array of strings dynamically.

Member Avatar for vegaseat
0
180
Member Avatar for phuduz

Here are some corrections: [code]// blah blah blah code cout << "Please enter initial balance: "; cin >> acctbalance; // add the do for the while!!! do { cout << "What do you wish to do?" << endl; cout << "D Deposit Money" << endl; cout << "W Withdraw Money" …

Member Avatar for ~s.o.s~
0
102
Member Avatar for JyotiC

I have used pygtk one little and have found these good resources: [QUOTE]Recommended reading for Python+GTK users PyGTK 2.0 Tutorial by John Finlay download from: [url]http://www.pygtk.org/dist/pygtk2-tut.pdf[/url] also: PyGTK FAQ Index at: [url]http://www.async.com.br/faq/pygtk/index.py?req=index[/url][/QUOTE]

Member Avatar for JyotiC
0
295
Member Avatar for mikeallen

Looks like whatever is item in hand[i] is not an integer. I also fail to see how hand[i] can be 1, 2, 3 , 4, ... all at the same time?

Member Avatar for bumsfeld
0
115
Member Avatar for mypranoygarg

Maybe it's something like this: [code]// simple to do with copy and paste #include <iostream> using namespace std; void hour_glass() { cout << "*******" << endl; cout << " ***** " << endl; cout << " *** " << endl; cout << " * " << endl; cout << " …

Member Avatar for bumsfeld
0
87
Member Avatar for bumsfeld

I read in the news that Python in going from version 2.4 to version 2.5 fixed 450 bugs. That seems to be lots of bugs! I used Python a lot and never found a single one of those bugs. What is your experience?

Member Avatar for nytrokiss
0
269
Member Avatar for shermaine

Looks like you have somewhat incomplete code: [code]#include<stdio.h> float x[4] = {1.2,2.4,3.6,4.8}; float f[4] = {0.1,0.2,0.3,0.4}; float xave = 0.0; float ftotal = 0.0; int main() { int i; float weights[4] = {0}; char buf[80]; for(i = 0; i < 4; ++i) { printf("Enter weight #%d", i+1); fgets(buf,sizeof(buf),stdin); weights[i] = …

Member Avatar for vegaseat
0
173
Member Avatar for bumsfeld

I wrote this little code to test a 2 dimensional array. Given the array array[row][col] I can find total_columns, but I am at loss to figure out total_rows. [code]// 2 D array #include <iostream> using namespace std; int main() { int row, col, total_columns; // two dimensional array in the …

Member Avatar for bumsfeld
0
89
Member Avatar for Matt Tacular

Make sure you test this out thoroughly! There are few things that might need to be changed.

Member Avatar for Matt Tacular
0
403
Member Avatar for canerkocamaz

If the lines you want start with number, other than header, here is easy solution: [code]# this would be rawfile.txt str1 = """ NAME:XXXXXXXXXXXX SURNAME:XXXXXXXXXXXX DATE:23.09.2006 A B C D E F G H (column names) 40 250 300 01.01.2006 13:43:21 250 12345678 KENTBANK 31 123 455 02.02.2006 11:22:43 450 …

Member Avatar for vegaseat
0
100
Member Avatar for akadri
Member Avatar for jrcagle
0
131
Member Avatar for chris99

Just for learning purposes: [code]# one alternative to random.sample(range(0,50), 6) import random print "show 6 random unique integers from 1 to 50:" numbers=[] while len(numbers) < 6: ri = random.randint(1,50) if ri not in numbers: numbers.append(ri) print numbers [/code]

Member Avatar for vegaseat
0
133
Member Avatar for chris99

Nice little song! This is how you make things wait for a few seconds: [code]# by Christopher O'Leary # The death of Charlie! import time def print_charlieVerse(): print "Charlie was a pidgeon, a pidgeon, a pidgeon." print "Charlie was a pidgeon, a pidgeon that flew." print "He flew in the …

Member Avatar for Ene Uran
0
117
Member Avatar for chris99

Wonder why you did that: [code]noun1 = noun verb1 = verb adjective1 = adjective moan = sound_disgust [/code] You had perfectly good variable names already.

Member Avatar for chris99
0
165
Member Avatar for chris99

A while ago our friend "a1eio" suggested the Python tutorial at [url]http://bembry.org/technology/python/index.php[/url] I liked that one! Very good for Python starters!

Member Avatar for bumsfeld
0
139
Member Avatar for Matt Tacular

A more foolproof way would be to loop each data entry like this: [code]# let's say your attacking army can be from 1 tp 100 # keeps looping until entry is acceptable aArmy = 0 while aArmy < 1 or aArmy > 100: try: aArmy = input("Enter the size of …

Member Avatar for vegaseat
0
215
Member Avatar for Ene Uran

[QUOTE=Ene Uran]Is there a way to verify an exit, if you click on the exit symbol on a wxPython frame?[/QUOTE] I left a short example in code snippet area: [url]http://www.daniweb.com/code/snippet526.html[/url]

Member Avatar for Ene Uran
0
79
Member Avatar for biganimal

Looks like first thing you need to add is menu loop to add, edit, search data, also exit program should be in loop. Took the liberty to put your code into code tags, added some remarks: [code]import shelve import string UNKNOWN = 0 HOME = 1 WORK = 2 FAX …

Member Avatar for bumsfeld
0
114
Member Avatar for rockzZ25

Usually memory is saved by keeping data in files. In your case, you would have to keep data in memory using module StringIO. That is swimming upstream. You could compress your datafile with methods in module zipfile or better tarfile. That will speed up loading time.

Member Avatar for rockzZ25
0
121
Member Avatar for lostpenan

For image files I would stick with binary file operation, it can handle text too. Here is example: [code]# typical image header str1 = \ """BANDS = 1 BAND_STORAGE_TYPE = BAND_SEQUENTIAL BAND_NAME = "N/A" LINES = 2240 LINE_SAMPLES = 3840 SAMPLE_TYPE = UNSIGNED_INTEGER SAMPLE_BITS = 8 END ~~now starts binary …

Member Avatar for lostpenan
0
2K
Member Avatar for abayden

Which version of wxPython did you install? Here is site that seems to have many difficult install questions/answers for wxPython: [url]http://lists.wxwidgets.org/cgi-bin/ezmlm-cgi/11[/url]

Member Avatar for bumsfeld
0
133
Member Avatar for srired

For learning about Python and XML see this website: [url]http://pyxml.sourceforge.net/topics/howto/xml-howto.html[/url] For GUI package for Python I would use wxPython. It is much more powerful than Tkinter. Python is useful for just about anything you are interested in. Things like scientific calculations, problem solving, working with databases, networking, WEB programming, audiovisual …

Member Avatar for bumsfeld
0
93
Member Avatar for a1eio

"Beautiful Soup" is an HTML/XML parser for Python that can turn even poorly written markup code into a parse tree, so you can extract information. Download the free program and documentation from: [url]http://www.crummy.com/software/BeautifulSoup/[/url]

Member Avatar for metabo_man
0
345
Member Avatar for jimmypk

If you insist writing your own destructor for class Tree, change it to this: [code]class Tree: def __init__(self): self.Root = None def __del__(self): if self.Root != None: del self.Root def LNR(self): ... ... [/code] Note: Destructors are optional thing in Python.

Member Avatar for G-Do
0
140
Member Avatar for Jayzilla

Please show your code. It makes it tough to help without it. Others too can learn from your code and the answers. This would be one way to bind Entry box enter1 to return key: [code]enter1.bind('<Return>', func=my_function) [/code] The data is then in enter1.get() as a string.

Member Avatar for bumsfeld
0
131
Member Avatar for bumsfeld

Why is there a tuple and list in Python. They seemed to perform similar things.

Member Avatar for jrcagle
0
175
Member Avatar for JohnJohnUSA

Go to directory where idle.py is located. On my Windows XP computer this was C:\Python24\Lib\idlelib Now bring up file config-main.def in editor like NotePad. It explains a lot of your questions.

Member Avatar for bumsfeld
0
422
Member Avatar for Ene Uran

A kbyte is 1024 bytes. This would be more correct: [code]fsize = os.path.getsize(fname) print "size = %0.1f kb" % float(fsize/1024.0) [/code]

Member Avatar for bumsfeld
0
671
Member Avatar for msaenz

I assume you want to sum numeric values. Here is slight modification, also removing return statement out of the loop: [code]def three2one(prot): code = {"G" : "6", "A" : "7", "L" : "1", "I" : "4", "R" : "2", "K" : "3", "M" : "5", "C" : "8", "Y" : …

Member Avatar for bumsfeld
0
81
Member Avatar for vince_2x

If you have two lists like list1 = [1, 2, 3] list2 = [1, 2, 3] then list1 == list2 is True, they have equal content but list1 is list2 would give False, they are not the same object.

Member Avatar for bumsfeld
0
159
Member Avatar for Blujacker
Member Avatar for Matt Tacular

Well, I can help with the startButton text: [code]def dieSimulator(): startButton.configure(text="Restart") # rest of your code ....... [/code]

Member Avatar for a1eio
0
2K
Member Avatar for Debbie Webbie

Have you checked into function reload(my_module)? What happened to your indentations?

Member Avatar for Debbie Webbie
0
136
Member Avatar for Taral
Member Avatar for hotteaboi

Give me an example of your list. Also, wouldn't use list as variable name since list() is built-in function, just as len().

Member Avatar for Dani
0
180
Member Avatar for girish_sahani
Member Avatar for Taral
Member Avatar for Blujacker

You have to set widget for name to come up. At the moment I don't quite know how, I don't have my notes along.

Member Avatar for bumsfeld
0
327
Member Avatar for skanker

What operating system do you have? Did you install proper version of wxPython? I have Windows XP and my wx package is in C:\Python24\Lib\site-packages\wx-2.6-msw-unicode\wx\__init__.py Here is a simple sample of wxPython code: [code]import wx class MyFrame(wx.Frame): def __init__(self): # create a frame/window, no parent, default to wxID_ANY wx.Frame.__init__(self, None, wx.ID_ANY, …

Member Avatar for vegaseat
0
147
Member Avatar for girish_sahani
Member Avatar for girish_sahani
0
73
Member Avatar for girish_sahani

I started playing with code from you and came to this conclusion: [code]# want 'abc' to generate a list [['a','bc'],['bc','a'],['c','ab'],['ab','c'],['b','ac'],['ac','b']] def gensubset(colocation): rulesList= [] length = len(colocation) for i in range(0,length): rule1 = [colocation[i:i+1],colocation[i+1:length]] rule2 = [colocation[i+1:length],colocation[i:i+1]] rulesList.append(rule1) rulesList.append(rule2) return rulesList colocation = 'abc' sublist = gensubset(colocation) # not quite …

Member Avatar for girish_sahani
0
211
Member Avatar for ber

Can you give sample of the first ten lines of each file? If the lines match (word and number), then you can read in one line from each file at a time, process and write/append back out.

Member Avatar for vegaseat
0
97
Member Avatar for Confucius

You put program code in a loop and designate one key to break out of loop: [code]while True: # this is an example of your program: print print "My program! Really!" print choice = raw_input("Enter r (repeat) or q (quit): ") if 'q' in choice: break # exits the while …

Member Avatar for Confucius
0
105
Member Avatar for Ene Uran

This is cool, so initially list1[0] is zero to start the count! How can you wrap that into a normal bread and butter function?

Member Avatar for vegaseat
0
149
Member Avatar for girish_sahani

['a': 1,'b': 2] is an invalid construct and gives a syntax error! Do you mean dictionary {'a': 1,'b': 2} ? If you want the same data/info in a tuple you could use (('a', 1),('b', 2)) and later on ... [code]# convert tuple of tuples to dictionary print dict((('a', 1),('b', 2))) …

Member Avatar for girish_sahani
0
250
Member Avatar for girish_sahani

Dictionary keys have to be immutable objects. Lists are mutable objects. Comvert all the lists to tuples.

Member Avatar for bumsfeld
0
86

The End.