880 Posted Topics

Member Avatar for SoulMazer

Dos it give you any error message? They code is working fine here. Test with this ico,to see if your ico file is the problem. [url]http://www.iconspedia.com/icon/snowman.html[/url] Klikk on Download.ico.file Can put in exception handling,it will give an TclError if ico-file not found. [CODE]from Tkinter import * root = Tk() root.minsize(290, …

Member Avatar for SoulMazer
0
24K
Member Avatar for mahela007

If you make a script that do what you want, and then use py2exe. It should be possible to to it like this. [CODE][autorun] open = Your_py2exe_file.exe action = Run my program icon = your.ico[/CODE] Save as [ICODE]autorun.inf [/ICODE]in your root usb drive. You also have tool like PStart that …

Member Avatar for mahela007
0
12K
Member Avatar for flatree

Not the best example of list comprehension. Vegaseat pointet out the problem. More basic off list comprehension. [CODE]>>> l = [0 for i in range(10)] >>> #So what will l print? >>> l [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] >>> #So to understand this we can …

Member Avatar for snippsat
0
82
Member Avatar for mehdi0016

You can do that with most gui toolkit. Wxpython is the most populare on this forum. Look at sticky at top for example off gui toolkit for python. [url]http://zetcode.com/wxpython/menustoolbars/[/url]

Member Avatar for mehdi0016
0
104
Member Avatar for vlady

Use code tag now we can not see if your indentation is correct. You dont have [ICODE]strip()[/ICODE]in your script. [CODE]>>> a = 'test \n' >>> len(a) 11 >>> #Without whitespace and new line >>> b = a.strip() >>> b 'test' >>> len(b) 4 >>> [/CODE] So you read in file(for …

Member Avatar for vlady
0
4K
Member Avatar for eva yang

If you look at this post,i give some example. [url]http://www.daniweb.com/forums/thread245633.html[/url]

Member Avatar for eva yang
0
98
Member Avatar for mahela007

A coulpe of class that show __str__ and __repr__ methods. [CODE]import datetime class Time(object): def __init__(self,date): self.date = date def __str__(self): """Return a pleasant representation.""" return 'Return a human-readable string: %s' % (self.date) t = Time(datetime.date.today()) print t #The __str__ method of a class is called whenever Python needs a …

Member Avatar for snippsat
0
1K
Member Avatar for eva yang

It`s better that you make a simple class and post that code. Then ask what you dont understand. If you dont now how to make a class at all,read some tutorials or seek google.

Member Avatar for vegaseat
0
132
Member Avatar for punter999

You have to understand the basic of wxpython. Then you use only the part of code that you need. Examlpe. [CODE]import wx class MyFrame(wx.Frame): '''info abot class | Doc string''' def __init__(self, parent, mytitle, mysize): wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize) #---| Window color |---# self.SetBackgroundColour('light blue') #---| Panel for frame …

Member Avatar for vegaseat
0
99
Member Avatar for pyguy420

See if this help you. [CODE]def colourPicker(): print "pick four different colours from; red, green, blue, yellow, orange, pink, brown" colourList = ["red", "green", "blue", "yellow", "orange", "pink", "brown"] chosenColours = [] count = 0 while True: colourPicked = raw_input("pick a colour: ") if colourPicked in colourList: chosenColours.append(colourPicked) if len(chosenColours) …

Member Avatar for woooee
0
114
Member Avatar for ffs82defxp

Dont use [ICODE]set[/ICODE] as variable [CODE]>>> set <class 'set'> >>> print (set.__doc__) set(iterable) --> set object Build an unordered collection of unique elements. >>> [/CODE] As you see it`s a python build in. [CODE]#python 3.x def range_display(integer): my_set = [] for num in range(0, integer): my_set.append(num) #Dont make a variable …

Member Avatar for snippsat
0
93
Member Avatar for Indran

[QUOTE]Anyone have experience highlighting these issues to the right channel?[/QUOTE] [email]wxpython-users@googlegroups.com[/email] [url]http://groups.google.com/group/wxpython-users[/url]

Member Avatar for snippsat
0
327
Member Avatar for JuvenileMango

You have made a function that dont get passed(and argument) and it dont return anything as your description say. First the easy way with a build in(sum) [CODE]def sum_lst(my_list): return sum(my_list) num = [1,2,3] print sum_lst(num) #6 [/CODE] Here function is passes a list(num) and return the sum. And i …

Member Avatar for JuvenileMango
0
92
Member Avatar for mruane

Sure you gone have big problems. Global variables is a really bad thing,and you have used it a lot. [CODE]def la(): clear() global cash, dealers, hp, gang def foo_sell(): global cash, dealers[/CODE] Now cash,dealer is in global namespace. [CODE]global cash #this is global namespace so no need to use global …

Member Avatar for mruane
0
147
Member Avatar for jwxie

Change the class little,and show some way to handle data. [CODE]import csv class Reader(object): def __init__(self): self.names = [] self.idigit = [] self.fileReader_list = [] self.fileReader = csv.reader(open("survey_result.csv", "rb")) self.fileReader_list.extend(self.fileReader) def my_sort(self): for column in self.fileReader_list: self.names.append(column[0]) self.idigit.append(column[1]) x = Reader() x.my_sort() print 'Name | Number' print x.names print x.idigit …

Member Avatar for snippsat
0
154
Member Avatar for ffs82defxp

What Is an Exception? Python uses exception objects. When it encounters an error, it raises an exception. If such an exception object is not handled (or caught), the program terminates with a so-called traceback (an error message) [CODE]>>> b Traceback (most recent call last): File "<pyshell#8>", line 1, in <module> …

Member Avatar for vegaseat
0
332
Member Avatar for lrh9

[QUOTE]This will not work for nested lists. Example[/QUOTE] No problem,kidding this one was not so easy. Search and think,did find a soultion. [CODE]def unshared_copy(inList): if isinstance(inList, list): return list( map(unshared_copy, inList) ) return inList inlist = [1, 2, [3, 4, 5]] copy_list = unshared_copy(inlist) print inlist print copy_list print print …

Member Avatar for lrh9
0
190
Member Avatar for ffs82defxp

A little messy this. Import <moudule> always first not inside code. You call main() 3 times,call main() one time. if comp_choice != [ICODE]userchoice:[/ICODE] type error. And the big mistake vegaseat pointet out. [QUOTE]It won't work![/QUOTE] Yes that`s for sure true. The logic could be better,user only win if 3-3 4-4.... …

Member Avatar for ffs82defxp
0
113
Member Avatar for python.noob

[QUOTE] I'm really surprised and disappointed to see that no body has replied even after two days of posting the question... Does daniweb forum slowly losing it's fervour and it's uniqueness???[/QUOTE] Maybe because this is a jobb for goolge. [url]http://diotavelli.net/PyQtWiki[/url] And on this site. [url]http://www.daniweb.com/forums/thread191210.html[/url]

Member Avatar for vegaseat
0
161
Member Avatar for Kippstah

Have make a better menu system. Put all comment in doc string. Look at exception handling for your function. Try type a letter. [CODE]def getPints(pints): '''The getPints(pints) function:''' counter = 0 while counter < 7: pints[counter] = input ("Enter pints collected: ") counter = counter + 1 return pints def …

Member Avatar for Kippstah
0
1K
Member Avatar for lewashby

3 days ago you post almost the same question,then i did breake it down. Did you ever read that? And this work correctly. [url]http://www.daniweb.com/forums/thread244170.html[/url]

Member Avatar for snippsat
0
123
Member Avatar for fummy

What are you doing fummy,can you not read? 2 times har Murtan ask you to put your code in code tags. So that indentations is correct. Is that so hard? [url]http://www.daniweb.com/forums/announcement114-3.html[/url]

Member Avatar for Murtan
0
187
Member Avatar for Nazere

> Most people will not want to download .zip files, it is better if you copy and paste your code between the CODE-tags. The zip is just the Homework Assignment. Not a line off code. I you dont try and show some effort now one will or should help you …

Member Avatar for snippsat
0
71
Member Avatar for lewashby

Here i try to break the first class to make it clearer. [QUOTE]Is it the __str__ method using the rank & suit attributes from the __init__ constructor?[/QUOTE] Yes __str__ use rank and suite from __init__. Return a human-readable string. [CODE]class Card(object): """ A playing card. """ RANKS = ["A", "2", …

Member Avatar for snippsat
0
398
Member Avatar for mahela007

Tkinter is the build in gui(Graphical user interface) of python. There are many other good gui toolkit like wxpython - PyQt -PyGTK. [QUOTE]Tkinter is just a way of translating Tk commands into python. (please correct me if I'm wrong).[/QUOTE] No Tkinter or any other gui toolkit is to display our …

Member Avatar for vegaseat
0
1K
Member Avatar for lewashby

[CODE]class Critter(object): """A virtual pet""" def __init__(self, name, hunger = 0, boredom = 0): self.name = name self.hunger = hunger self.boredom = boredom crit = Critter('killer') print crit.name ''' killer ''' #Let look at what the class store print crit.__dict__ ''' {'name': 'killer', 'boredom': 0, 'hunger': 0} ''' #We only …

Member Avatar for masterofpuppets
0
125
Member Avatar for Dokino

[QUOTE]why does it look odd?[/QUOTE] Two classes with 1 attributt(variable) in each,is not a normal OO design. Your program work,but for me this is not a good way to code. Some problem. Menu should come first so user now what this is about. You have no exception handling,so if you …

Member Avatar for Dokino
0
130
Member Avatar for AutoPython

[QUOTE]Yeah, IDEs like notepad++ lack the auto-indent feature[/QUOTE] Try pyscripter has a lot off useful feature and off course auto-indent. [url]http://code.google.com/p/pyscripter/[/url]

Member Avatar for Gribouillis
0
174
Member Avatar for smohrchi

Free books. [url]http://www.swaroopch.com/notes/Python[/url] [url]http://www.diveintopython.org/[/url] [url]http://diveintopython3.org/[/url] [url]http://homepage.mac.com/s_lott/books/python.html[/url] [url]http://www.greenteapress.com/thinkpython/[/url] Good books. [url]http://www.amazon.com/Beginning-Python-Novice-Professional-Second/dp/1590599829/ref=sr_1_51?ie=UTF8&s=books&qid=1259660036&sr=1-51[/url] [url]http://www.amazon.com/Programming-Python-Mark-Lutz/dp/0596009259/ref=sr_1_4?ie=UTF8&s=books&qid=1259660403&sr=1-4[/url]

Member Avatar for jaux
0
92
Member Avatar for katharnakh

Animals is always fun to make with oop design in mind. Here you se __call___ used like this cow('gras') This fill the the empty list(stomach) [CODE]class Animal(object): def __init__(self, name, legs): self.name = name self.legs = legs self.stomach = [] def __call__(self,food): self.stomach.append(food) def poop(self): if len(self.stomach) > 0: return …

Member Avatar for snippsat
0
17K
Member Avatar for vnproduktionz

I have are hard time understand why instructors use outdatet module like graphics. It has to be much better to learn student basic Tkinter(graphical user interface) or another GUI toolkit. That is useful othert than education purpose. And getting help with graphics is hard,because very few has the graphics module.

Member Avatar for vegaseat
0
94
Member Avatar for ffs82defxp

[QUOTE]can i get a simpler example like with 3 functions and a simple task/concept [/QUOTE] The example is simple and you shoul try to understand it. Break it down and ask question. [CODE]def get_data(): """get the data from the user, from a file, or hard coded""" mydata = [1, 2, …

Member Avatar for vegaseat
0
381
Member Avatar for jaison2

[QUOTE]thx for the help but what does this operation do?"global"?[/QUOTE] Global should not be used at all,it`s no good at all. Learn to code without it. Here one way to do what you want. [CODE]import random def main(max_guess): num = random.randrange(1, 100) tries = 0 guess = "" while guess …

Member Avatar for snippsat
0
208
Member Avatar for Musafir

You should not speend much time on outdate mouduls like graphics.py. Think it was written in 2005 by John M. Zelle as and easy intro to graphics for beginner. The only way to do this is to learn a gui toolkit like Tkinter-wxpython-pyqt. I like wxpython and use that to …

Member Avatar for vegaseat
-3
282
Member Avatar for persianprez

Dictionary values are accessed by their key. To allow for high speed key searches, the keys are in a hash order. So a dictionary sorted alphabetically by it's keys would make no sense and would defeat the whole dictionary idea. Here are some way doh. [CODE]>>> d = { "a":4, …

Member Avatar for persianprez
0
251
Member Avatar for ffs82defxp

[QUOTE]1 more question. How do I start the default web browser to a specific URL in python?[/QUOTE] [CODE]>>> import webbrowser >>> dir(webbrowser) ['BackgroundBrowser', 'BaseBrowser', 'Elinks', 'Error', 'Galeon', 'GenericBrowser', 'Grail', 'Konqueror', 'Mozilla', 'Netscape', 'Opera', 'UnixBrowser', 'WindowsDefault', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_browsers', '_iscommand', '_isexecutable', '_synthesize', '_tryorder', 'browser', 'get', 'iexplore', 'main', …

Member Avatar for vegaseat
0
131
Member Avatar for Judgment

Have you tryed som yourself,and mayby post some code. Can take a little about this but next time dont expext to get help if you dont but some effort in to this. [CODE]>>> lst = ['bunnies', 'apples', 'animals', 'fruit', 'amsterdam'] >>> dir(lst) ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', …

Member Avatar for snippsat
-2
115
Member Avatar for ffs82defxp

[QUOTE]The reason why I need GOTO is because the user is going to finish calculating their equations rather quickly and the program will need to loop back into it's original state (the menu screen).[/QUOTE] There is no goto int python and thank god for that. In python you use loop/ …

Member Avatar for snippsat
0
121
Member Avatar for python user

As Mathhax0r take upp your code is really not god at all it`s a big mess. I think helping you now is difficult because of your code design. Never use global variabels like this, or at all. The are ugly an as code grow the will give a lot of …

Member Avatar for python user
0
215
Member Avatar for gibson8720

There are several problems. if number == '1' : #use [B]'1'[/B]because input in python 3 return a string. Then you come to this meny. [CODE] print ('1. Operating expense') print ('2. Payroll expense') print ('3. Charity Support') print ('4. Cancel') number = input ('Enter the Expense you want to add.')[/CODE] …

Member Avatar for snippsat
0
86
Member Avatar for Aiban

Tkinter has change import name in python 3. Put this first then tkinter import correct for python 2.x and 3.x [CODE]try: # for Python2 import Tkinter as tk except ImportError: # for Python3 import tkinter as tk[/CODE]

Member Avatar for Aiban
0
141
Member Avatar for gangster88

[CODE]import random def rockPaperScissors(): #choice = raw_input("please enter your choice: ") #I take away this to make a point computerIndex = random.randint(0,2) if computerIndex == 1: computer = "rock" print computer #test print elif computerIndex == 2: computer = "scissors" print computer #test print else: computer = "paper" print computer …

Member Avatar for sentinel123
0
239
Member Avatar for lewashby

New style class python 2.2--> you should use [CODE]class(object):[/CODE] Old style pre python 2.2 [CODE]class:[/CODE] So object is a build in,let`s test it. [CODE]IDLE 2.6.2 >>> object <type 'object'> >>> [/CODE] For more deeper explanation. [url]http://www.cafepy.com/article/python_types_and_objects/python_types_and_objects.html[/url]

Member Avatar for mn_kthompson
0
131
Member Avatar for lewashby

Newer. [url]http://rgruet.free.fr/PQR25/PQR2.5.html[/url] [url]http://rgruet.free.fr/PQR26/PQR2.6.html[/url]

Member Avatar for python user
0
187
Member Avatar for Musafir

[QUOTE]I just want the output to be 50, I try changing the the code but t doesn't work [/QUOTE] Vegaseat has pretty much given you the answer. You dont say that code dos not work and nothing more. Then is not possibly to help you,post your code and then you …

Member Avatar for snippsat
0
119
Member Avatar for The Champ

[QUOTE]What I was expecting was that L = [ 0, 2, 1 ][/QUOTE] If you what this result is better to iterate over the list and append the result to a new list. [CODE] L = [ 0 , 2, 1 , -1 , -1 , -1, -1 ] new_list …

Member Avatar for snippsat
0
128
Member Avatar for sentinel123

Dont use global variables. Any name (variable) defined inside a function is local to that function,and should always stay that way. If you need access to a function's local variables outside that function use argument and return variables out off function. No are pollutioning the global namespace and you get …

Member Avatar for sentinel123
0
316
Member Avatar for jwxie

You know that this code is for python 3.x? For python 2.x [CODE]n = input('Enter an interger >= 0: ') fact = 1 for i in range(2,n+1): fact = fact*i print n, 'factorial is', fact print 'The factorial off %d is %d' % (n, fact) #Or like this is better[/CODE] …

Member Avatar for vegaseat
0
82
Member Avatar for lewashby

Here is class example have i tryed to explain som basic thing about the making of a class and how thing work. [CODE]class SimpleClass(object): ''' Doc string info about class * SimpleClass inherits the most basic container class object (just a place holder) * this is the newer class writing …

Member Avatar for vegaseat
0
89
Member Avatar for MRWIGGLES

You can do it like this. [CODE]def getValidNum(min, max): print ('Enter a value between %d and %d | 0 to quit' % (min, max)) while True: try: num = input('>') if int(num) in range(int(min), int(max)): print (num) #test print #return num elif num == '0': exit() else: print('Only values between …

Member Avatar for pythopian
0
106

The End.