4,305 Posted Topics
Re: `random.randrange(0,100,1)` returns an integer, so x will be an integer as you exit the while loop. Please use code tags to enclose your code. This will preserve your all important block indentations | |
Re: Here is an example how to do this. I had to create your kind of data file first to use it properly ... [code=python]data_str = """\ 1846440556 1846440521 1846440491 1846440505 1846441137 1846441102 1846441080 1846441331 1846441323 1846441315""" # let's create your data file from the string fout = open("MyData1.txt", "w") fout.write(data_str) … | |
Re: Sounds delicious, where can I get one? :) | |
Re: Looks like classic Chomsky generated text! Those things are fun to work with. | |
Re: Maybe a Black Hole after it has eaten a whole Universe gets indigestion and answers with a big belch (bang). | |
Re: You are trying to compare integer [B]number[/B] with string [B]Input[/B]. Also, don't create a new label for the warning each time a guess is made. Create the label once and then change its text. | |
Re: You need to indent the statement block that belongs to the second while loop. Note: You can write a function within a function in Python, but generally it is only used for special cases like closures. | |
Re: There are quite few changes and improvements with Python version 3 from the older version 2. One of them is function input() which has replaced the older raw_input(). The original old version input() that could be used for numeric input is no longer. This is the reason you are getting … | |
Re: Your explanation sounds well reasoned. | |
Re: Well it's also a New Decade! Let's hope you all have a good one! | |
Re: If you want to display the result you have to use a GUI toolkit like PyQt. The PyQt label widget can display html formatted text like this example shows: [url]http://www.daniweb.com/forums/post1093216.html#post1093216[/url] | |
Re: What kind of layout manager are you using? What have you tried so far? | |
Re: It might be a lot simpler to use the Python module enchant, see: [url]http://www.rfk.id.au/software/pyenchant/[/url] | |
Re: I realize that the QT-Designer is tempting to use for a beginner, but the code it spits out is complex and very difficult to troubleshoot. First of all test the module I assume you saved as tcp.py by adding this to the end of the module code ... [code]# test … | |
Re: Could be as simple as using [code=text] " OK " that has the size of "Edit Birdlist" [/code] | |
Re: When the code is that simple, you can get away with a global variable ... [code]import random # this will be a global variable PLAYER_TOTAL = 0 def gameIntro(): print('''This is a dice roll game. Dice are rolled, and you recieve money if you are equal to the total. Are … | |
Re: Did you put the event loop in? This is a code sample of a very basic pygame program ... [code=python]import pygame from pygame.locals import * yellow = (255,255,0) # RGB color tuple # initialize screen pygame.init() screen = pygame.display.set_mode((350, 250)) pygame.display.set_caption('Basic Pygame program') # fill background background = pygame.Surface(screen.get_size()) background … | |
Re: You are reading lines of the text file, not individual words. To get to the individual word study this hint ... line = "Toto je moj prvy pokus otvorit a citat subor." word_list = line.split() for word in word_list: print word Note: Please use code tags with your code to … | |
Re: Would be nice to know what your GUI toolkit is. | |
Re: Considering all the other stuff we are made to believe since childhood, this isn't so bad. Doesn't even smell. Like the first post quoted, the missing link is money. | |
Re: Depends on how much information you want to save to a file. If it's just a number of song file names, a text file will do. | |
Re: You could get away with this ... [code]output = "The number is: "; num = 12; print output, num; [/code]Note that the end of statement-line marker ';' is optional in Python, and can be used to put two statement on one line. | |
![]() | Re: You can print out [B]the_page[/B] as a byte string, that seems to work. However [B]the_page.decode("utf8")[/B] gives a UnicodeEncodeError. It seems that utf8 is the incorrect character set. Use [B]the_page.decode("iso-8859-1")[/B], that character set works. |
Re: Earth orbits the Sun at an average distance of about 150 million kilometers every 365.2564 mean solar days. Mean days they are at times! | |
![]() | Re: Here is a typical make file created by DevCPP for the TextColor2 console C project ... [code=text]# Project: TextColor2 # Makefile created by Dev-C++ 4.9.9.1 CPP = g++.exe CC = gcc.exe WINDRES = windres.exe RES = OBJ = main.o $(RES) LINKOBJ = main.o $(RES) LIBS = -L"D:/Dev-Cpp/lib" INCS = -I"D:/Dev-Cpp/include" … |
Re: I would go with 4 bpp, 1-bit alpha, 16-slow palette | |
There is also "1001 ways to spam for liquid roofs" or similar title. | |
Re: Generally you would expect something like that from Iran or Saudi Arabia. | |
![]() | Re: You might have to write some batch files to jump start the C compiler from within Sublime Text's Python extension language. Check with our friends in the C forum of DaniWeb. ![]() |
Re: Portable Python installs a portable version of Python right on your USB flash drive (plan on 150MB for each version). You can use the flash drive now on Windows computers that do not have Python installed. It comes in Python25, Python26 and Python30 flavors. See: [url]http://www.portablepython.com/releases/[/url] | |
Re: Since we don't know what your code looks like, try this image load and display test code and see if it works ... [code]# experiments with module pygame # free from: http://www.pygame.org/ # load and display an image using pygame import pygame as pg # initialize pygame pg.init() # pick … | |
Re: [B]None[/B] is used to signify the absence of a value, for instance it is returned from functions that don't explicitly return anything. Its truth value is false. | |
Re: [code=python]prompt = "Did you get your new laptop with windows 7? (y/n) " answer = raw_input(prompt).lower() if 'y' in answer: print "Phantasmagoric!" [/code] | |
Re: I tried your program with some of my own test files and experienced no delay. What OS are you using? How large are your sound files? To speed things up rearrange the if statments and take things out of the eventloop that don't need to be there ... [code]import pygame … | |
Re: Your picture looks more like a spreadsheet. Several good Python editors have been written with wxPython and you can look at the source code. One of them is part of the DrPython IDE, see ... [url]http://drpython.sourceforge.net/[/url] | |
Re: You can not make a copy of a nested list that way, you have to use module copy ... lis2 = copy.deepcopy(lis1) rather then the list comprehension, since the nested list in [B]i[/B] is still passed as a reference. | |
Re: This is not a code snippet and should be a regular forum entry. | |
Re: Do you have to display the photo for the person to pick it? | |
Re: For example, you are trying to open a file that does not exist. This code will give you a Traceback IOError and the program exits ... [code]fname = "xyz.txt" fin = open(fname, "r") """my output (if xyz.txt does not exist) --> Traceback (most recent call last): File "error_fname1.py", line 2, … | |
Re: With the economy still in a hangover I doubt that a few flimsy decorations will inspire shoppers to shop in the land of "Made In China" goods. [QUOTE]Xmas is the time when you sit in front of a dead tree and hope that some obese senior citizen will bring presents … | |
Re: I haven't been able to actually test this, but insert this at the bottom of __init__() ... [code] save_btn = wx.Button(panel,3,'Save Data',(750,450)) wx.EVT_BUTTON(panel,3,self.OnSave) def OnSave(self,event): # 1 is a dummy for event t2, p2, v, k, kt, cp, cpe = self.OnCompute(1) fname = "MyData.dat" fout = open(fname, "w") # this … | |
Re: You are getting confused by the Python shell results. The Python shell is there to quickly explore some Python code lines, not to write working Python programs. | |
Re: Let class Two inherit class One: [code]class One(object): def print_parent_hw(self): self.print_hw() class Two(One): """class Two inherits class One""" def __init__(self): # make instance of One part of self One.__init__(self) def print_hw(self): print "Hello World from One" def have_one_print_two(self): self.print_parent_hw() a = Two() a.have_one_print_two() # Hello World from One [/code] | |
Re: Doesn't Mandriva have a repository? | |
This is an update of an earlier version. In this version the string containing the approximated pi value is created directly from the iteration of the generator. This way the program is simplified and can be used with Python2 and Python3 ... | |
Re: [QUOTE=cwarn23;1084175]I think it's going to be another washed up thread. It's not easy to understand and I couldn't be bothered pming to find out what the question is. For now I will be making a pi calculator lets see who can make the fastest pi calculator using any language. As … | |
Re: The things you are asking for are part of module games. You have to investigate the source of that module. In line ... player = games.Player(name, score) player is the instance of class Player in module games, but you can't be sure unless you check the source of the module. … | |
Re: Can you at least show us what you have tried? Hint, module time is your friend. Use time.strptime(time_str, format_str) and then time.strftime(format_str, time_tuple). |
The End.