614 Posted Topics

Member Avatar for daniwebnewbie

Personally i think if your that worried about efficiency then you should try a language like C++ which is a lot faster then python anyway. But my bet would be on the larger one as that would take up less memory on your computer then lots of smaller ones.

Member Avatar for paddy3118
0
261
Member Avatar for jascase901

Yeah also have a look at [url]www.pythonchallenge.com[/url]. If you want practice have a look at the projects for beginners, Also for other skills it might be useful to be able to document all your code very well and check up of the python style guide.[url]http://www.python.org/dev/peps/pep-0008/[/url] Apart from that, just try …

Member Avatar for lllllIllIlllI
0
161
Member Avatar for hurbano

Here is an A* Path finding tutorial, it will be able to help, because path finding is probably the easiest way to get through this problem. [url]http://www.policyalmanac.org/games/aStarTutorial.htm[/url]

Member Avatar for hurbano
0
112
Member Avatar for harrykokil

Pygame can be what you make of it. It is very suited to games certainly. It is very efficient at moving things around and taking events, though its harder to write applications in, its really not meant to apps. But traffic simulation. I reckon that that could be done rather …

Member Avatar for lllllIllIlllI
0
86
Member Avatar for artemis_f

There really arent many wxPython books at all, i think the above poster is right, wxPython in Action is one, but the problem is that was written a long time ago and so it is slowly out dating. If you want to learn wx then have a look over at …

Member Avatar for lllllIllIlllI
0
128
Member Avatar for leegeorg07

You could just do a quick count function to see if enough relevant words are in your page. So for example: [code=python] body = "The Royal Air Force (RAF) is the United Kingdom's air force, the oldest independent air force in the world.[2] Formed on 1 April 1918,[3] the RAF …

Member Avatar for lllllIllIlllI
0
108
Member Avatar for siddhant3s

If you want to make python into an executable file, thats easy with py2exe! [url]http://www.py2exe.org/[/url] I started learning C++ as my first language a couple of years ago but was almost killed by the amount of syntax i didnt understand, so i started python instead. Its easy, simple and great …

Member Avatar for sneekula
0
773
Member Avatar for slik33

What is the error that you are getting? Or whats going wrong, how do you know it fails?

Member Avatar for kenji
0
98
Member Avatar for leegeorg07

What i would do is just sleep the program until the next song is ready, to find out how long to sleep though is the hard thing, so you can either make a dictionary with all the songs and their times. Or you can use something like this: [code=python] >>> …

Member Avatar for leegeorg07
0
119
Member Avatar for lllllIllIlllI

I am using this code here: [code=c++] #include "stdafx.h" #include "windows.h" int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK); return 0; } [/code] But no matter what i do i keep getting this built error: ------ Build started: Project: Gui, Configuration: …

Member Avatar for lllllIllIlllI
0
279
Member Avatar for maru2

It seems that it is really up to personal preference. At the style guide at [url]http://geosoft.no/development/cppstyle.html[/url] it seems that is it often interchanged, so whatever feels right to you. I know i always use the one with the brace on the next line.

Member Avatar for Narue
0
119
Member Avatar for artemis_f

All you have to do is do something like: [code=python] self.page1.campus.GetValue() [/code] And that would return the value of that textCtrl, all of what you need is accessed through self.pagenumber.textctrl

Member Avatar for lllllIllIlllI
0
186
Member Avatar for Rooking

Just a word of advice, instead of using [code=python] from wxpython.wx import * [/code] Use [code=python] import wx [/code] And then you just refer to things like wx.TextCtrl, rather then wxTextCtrl. So just add a dot. And i cant find a fault on my computer, or i am not looking …

Member Avatar for lllllIllIlllI
0
73
Member Avatar for lllllIllIlllI

Hey everyone! I was wondering apart from [noparse] [noparse] [code] [icode] [url] [/noparse] What other tags are there?

Member Avatar for lllllIllIlllI
0
82
Member Avatar for lllllIllIlllI

Hi guys, When i run my programs in c i always use things like [code=c++] include "stdio" [/code] But then i see things like [code=c++] include "stdio.h" [/code] and [code=c++] include <stdio> [/code] I was wondering which one i should use and also why there are so many different ways. …

Member Avatar for lllllIllIlllI
0
239
Member Avatar for lllllIllIlllI

I was just wondering, in all of the code snippets i see there is no #include "stdafx.h" in them, but i cannot compile a program without it. Is this a Microsoft Visual C++ that is the problem or am i just missing the point here?

Member Avatar for lllllIllIlllI
-1
695
Member Avatar for Rooking

Use a list with them all in. And you only need strings, not checkBox Items [code=python] self.box = wxCheckListBox ( self.panel, 100, size = ( 250, 200 ), choices = ["One",'Two','Three'], style = wx.LB_HSCROLL ) [/code]

Member Avatar for lllllIllIlllI
0
98
Member Avatar for mahela007
Member Avatar for slate
0
182
Member Avatar for breatheasier

Yeah thats it! Well done, there are other ways to do it as well. [code=python] class disk(object): y = 1 x = 2 [/code] This means you dont have to make an instance of the class [code=python] print disk.x print disk.y #output #1 #2 [/code]

Member Avatar for breatheasier
0
93
Member Avatar for digiPixel

You have to install it if your wondering. But on linux its different. Repositries and such.

Member Avatar for digiPixel
0
490
Member Avatar for Norbert X

You can return it like this: [code=python] def returnTwoThings(): return 1,2 a,b = returnTwoThings() print a print b #output #1 #2 [/code]

Member Avatar for jlm699
0
149
Member Avatar for Norbert X

For that you will need to use a GUI toolkit, have a look at Tkinter, wxPython, or pyQT. They are good ones. We have a whole sticky on learning wx so if you want to learn there are lots of resources here. Tkinter comes packaged wxPython can be downloaded from …

Member Avatar for Norbert X
0
125
Member Avatar for scru
Member Avatar for Stefano Mtangoo

I used this tutorial and then modified it a bit to make my own chat program [B][url]http://www.devshed.com/c/a/Python/Sockets-in-Python-Into-the-World-of-Python-Network-Programming/[/url][/B]

Member Avatar for lllllIllIlllI
0
174
Member Avatar for pythononmac

Use a try, except statement: [code=python] import os, sys folder = os.path.abs("pathtoscriptsfolder") sys.path.append(folder) for script in os.listdir(folder): if script.endswith(".py"): try: mod = __import__(script) res = mod.run_test() fh = open("tests.res", "a") fh.writeline(str(res)) except TypeOfErrorHere: print "Test case didnt work... continuing" [/code] I hope that helps

Member Avatar for lllllIllIlllI
0
117
Member Avatar for Norbert X

Yeah there sure is [code=python] #use the current directory or absolute path f = open("File.txt",'w') #write mode 'w' answer = 5*3 #make a string, only stings can be added to files answer = str(answer) f.write(answer) f.close() #then open it back up o = open("File.txt",'r') #read mode 'r' print o.readline() #Output: …

Member Avatar for leegeorg07
0
139
Member Avatar for vmars

Yeah i would reccomend you do not use python 3.0 for a while, the modules just arent out for it yet. If you use python 2.5 then you will find that you can get modules for everything you need. wxPython, XRCed, BoaConstrictor will all have modules for python 2.5.

Member Avatar for vegaseat
0
225
Member Avatar for LateNiteTippin

Well on the forums remember to use code tags [noparse] [code] code here [/code] [/noparse] But here is the code you have [code=python] def count(sub, s): """ >>> count('is', 'Mississippi') 3 >>> count('an', 'banana') 3 >>> count('ana', 'banana') 3 >>> count('nana', 'banana') 3 >>> count('nanan', 'banana') 3 """ count = …

Member Avatar for LateNiteTippin
0
126
Member Avatar for Norbert X

Well if you want them to all be in a different category then you have to get a new number each time. Also you can use random.choice() to get a random choice from a list. Here is what i would do [code=python] import random house = ["a mansion", "an apartment", …

Member Avatar for lllllIllIlllI
0
176
Member Avatar for Norbert X

Well i think your first problem is here: [code=python] w = input(random.randrange(100)+) [/code] input is a built in function that only needs a string and gets input from the user. There are a few other things that dont work in your program, like print w*random will just times w by …

Member Avatar for Norbert X
0
133
Member Avatar for StarZ

But if you do really want to keep it in the procedure you have now, then os.startfile is what you need to look at. [code=python] #at the end of your code you put something like this os.starfile(os.getcwd()+"\\Name of Python File.py") #that will re-start your python file. [/code]

Member Avatar for StarZ
0
99
Member Avatar for starzstar

Here! [code=python] s = '/home/dir1/dir2/folder1/file' list_s = s.split('/') print '/'.join(list_s[1:] [/code]

Member Avatar for starzstar
0
59
Member Avatar for Sohvkhan

there is a really quick way to get a list of even numbers: [code=python] list_of_evens= [f for f in range(1,500) if f%2==0] [/code] that should give all the even numbers from 1 to 500 in a list

Member Avatar for sneekula
0
1K
Member Avatar for StarZ

Just a thought, i cant see how it breaks out of the loop, so maybe move the other raw_input() in a bit: [code=python] # -*- coding: iso-8859-15 -*- # check encoding in http://www.python.org/dev/peps/pep-0263/ def function1(): print "Bonjour, comment allez-vous ?" def function2(): print "Hola, cómo esta usted?" def function3(): print …

Member Avatar for lllllIllIlllI
0
108
Member Avatar for Blujacker

Python 2.6 has known issues with wxPython, i would reccomend that you download 2.5

Member Avatar for lllllIllIlllI
0
1K
Member Avatar for jloyzaga

if you are using wx then just go: [code=python] text.SetValue("Default Value Here") [/code] Where text is your wx.TextCtrl

Member Avatar for vegaseat
0
854
Member Avatar for codedhands

Here is an example of how one works: [code=python] import wx import wx.lib.scrolledpanel as scrolled class TestPanel(scrolled.ScrolledPanel): def __init__(self, parent): scrolled.ScrolledPanel.__init__(self, parent, -1) vbox = wx.BoxSizer(wx.VERTICAL) desc = wx.StaticText(self, -1, "ScrolledPanel extends wx.ScrolledWindow, adding all " "the necessary bits to set up scroll handling for you.\n\n" "Here are three fixed …

Member Avatar for codedhands
0
2K
Member Avatar for super zach

Yeah thats not too hard: [code=python] def printfunc(star=star, *printers): for item in printers: print star[item] #if you want it all on one line then use pring star[item], [/code]

Member Avatar for lllllIllIlllI
0
145
Member Avatar for Sohvkhan

Dont worry, this can be lots easier. First we can find the minimun of a list by using the min function, the max by using the max function! So : [code=python] li = [1,2,3,4,5,6,7,8,9,1,11,5,0,64] print min(li) #0 print max(li) #64 print li.index(max(li)) #position 13 print li.index(min(li)) #position 12 [/code] To …

Member Avatar for woooee
0
155
Member Avatar for starzstar

something is wrong with the actual dictionary, when i put it into python i get errors along the lines of SyntaxError: EOL while scanning single-quoted string and i tried for a few minutes but i couldnt get it to work, the "" marks were all out of place.

Member Avatar for starzstar
0
121
Member Avatar for mruane

If you post the actual error message it will make it a lot easier. I tells us the line in which the error happened

Member Avatar for vegaseat
0
93
Member Avatar for icu222much

This loop will increment by 2! [code=python] for f in range(start=0, end=10, step=2): print f [/code] Just replace 2 with anything you need

Member Avatar for icu222much
0
205
Member Avatar for beanryu

Just press space 4 times, then you have it indented the right amount. Do this for all of them, not the actual if statement but the stuff afterwards. So [code=python] >>>if stuff == True: ... print "stuff" #i pressed space 4 times ... else: ... print 'no' [/code]

Member Avatar for breatheasier
0
2K
Member Avatar for MaxVK

Yeah i got the same issue when i did a program using a richtextctrl. I fixed it by binding the delete key to an event where i called something along the lines of [code=python] self.text.SetSelection(self.text.GetCursor()[0],self.text.GetCursor()[1]+1) self.text.DeleteSelection() [/code] I remember having to bind it to a wx.EVT_KEY_DOWN event because i could …

Member Avatar for MaxVK
0
131
Member Avatar for ihatehippies

Couldnt you just bind it to an event that called SetSelection before doing anything kinda like: [code=python] def method(self,event): self.richtext.SetSelection() #and then do all of your usual stuff here [/code]

Member Avatar for lllllIllIlllI
0
94
Member Avatar for mahela007

And you can add to things as well and change things around. So you can have a class of Line, that has: Attributes start end And if you wanted to make box, well a box is just a complicated set of lines, so if you inherit from lines then you …

Member Avatar for lllllIllIlllI
0
651
Member Avatar for curiouskitten

Okay, well not to fully solve the problem for you i would do something like this: [code=python] S = raw_input("Enter a sentence:") vowels = 'aeiou' for letter in S: if letter in vowels: #letter is a vowel letter.upper() [/code] Now that does nothing at all, just shows you an idea, …

Member Avatar for Ene Uran
0
11K
Member Avatar for thehivetyrant

To make a number go up by one you either go: [code=python] i += 1 [/code] OR [code=python] i = i+1 [/code]

Member Avatar for thehivetyrant
0
122
Member Avatar for scru

Yeah i can help a bit as well... maybe a bit slow.. i have a broken computer and i am left with using an old decrepit computer from years and years ago

Member Avatar for lllllIllIlllI
0
215
Member Avatar for strobon

Well can you post the whole error because that usually also shows what line it is on, it makes it easy to debug. But ill give you an example of something that would get that error: [code=python] f = open("infile.txt") f() #here i would get my error. The file variable …

Member Avatar for strobon
0
2K

The End.