4,305 Posted Topics

Member Avatar for Godflesh

`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

Member Avatar for Godflesh
0
85
Member Avatar for Cornholio

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) …

Member Avatar for Godflesh
0
26K
Member Avatar for sknake
Member Avatar for redesignunit
0
175
Member Avatar for GrimJack
Member Avatar for serra01

Looks like classic Chomsky generated text! Those things are fun to work with.

Member Avatar for adams161
-9
293
Member Avatar for cwarn23

Maybe a Black Hole after it has eaten a whole Universe gets indigestion and answers with a big belch (bang).

Member Avatar for Dope 7560
0
318
Member Avatar for zrin

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.

Member Avatar for zrin
0
111
Member Avatar for Dokino

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.

Member Avatar for Dokino
0
130
Member Avatar for Skeltpl

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 …

Member Avatar for Skeltpl
0
132
Member Avatar for eva yang
Member Avatar for GrimJack
Member Avatar for cwarn23
0
183
Member Avatar for deonis

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]

Member Avatar for deonis
0
13K
Member Avatar for DimaYasny
Member Avatar for DimaYasny
0
3K
Member Avatar for Namibnat

It might be a lot simpler to use the Python module enchant, see: [url]http://www.rfk.id.au/software/pyenchant/[/url]

Member Avatar for Namibnat
0
369
Member Avatar for ivh90

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 …

Member Avatar for vegaseat
0
164
Member Avatar for Namibnat

Could be as simple as using [code=text] " OK " that has the size of "Edit Birdlist" [/code]

Member Avatar for Namibnat
0
278
Member Avatar for mahimahi42

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 …

Member Avatar for jcao219
0
147
Member Avatar for senateboy

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 …

Member Avatar for vegaseat
0
9K
Member Avatar for vlady

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 …

Member Avatar for vlady
1
258
Member Avatar for SoulMazer
Member Avatar for mrnutty

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.

Member Avatar for VernonDozier
-1
269
Member Avatar for SoulMazer

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.

Member Avatar for SoulMazer
0
146
Member Avatar for letlet_pogs

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.

Member Avatar for sneekula
0
113
Member Avatar for yoni0505

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.

Member Avatar for sneekula
0
228
Member Avatar for cwarn23

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!

Member Avatar for vegaseat
-3
183
Member Avatar for leegeorg07

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" …

Member Avatar for vegaseat
0
103
Member Avatar for SoulMazer
Member Avatar for vegaseat
Member Avatar for vegaseat
0
97
Member Avatar for cwarn23
Member Avatar for vegaseat
0
192
Member Avatar for The Dude
Member Avatar for leegeorg07

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.

Member Avatar for leegeorg07
0
152
Member Avatar for mahela007

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]

Member Avatar for mahela007
0
12K
Member Avatar for mordicaii

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 …

Member Avatar for vegaseat
0
175
Member Avatar for rehber344

[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.

Member Avatar for hondros
0
126
Member Avatar for ShadyTyrant

[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]

Member Avatar for ShadyTyrant
0
167
Member Avatar for emir_gradacac

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 …

Member Avatar for Lardmeister
0
426
Member Avatar for punter999

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]

Member Avatar for vegaseat
0
127
Member Avatar for flatree

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.

Member Avatar for snippsat
0
82
Member Avatar for JaiChand2
Member Avatar for nezachem
-2
97
Member Avatar for fferrandini
Member Avatar for vegaseat
0
167
Member Avatar for eva yang

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, …

Member Avatar for eva yang
0
98
Member Avatar for Ancient Dragon

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 …

Member Avatar for hotmatrixx
2
126
Member Avatar for GihanFernando

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 …

Member Avatar for vegaseat
0
107
Member Avatar for mahela007

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.

Member Avatar for snippsat
0
1K
Member Avatar for xvalentinex

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]

Member Avatar for xvalentinex
0
89
Member Avatar for Stefano Mtangoo
Member Avatar for vegaseat

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 ...

1
592
Member Avatar for mrnutty

[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 …

Member Avatar for cwarn23
1
283
Member Avatar for lewashby

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. …

Member Avatar for jcao219
0
112
Member Avatar for rmsagar

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).

Member Avatar for vegaseat
0
201

The End.