614 Posted Topics
Re: 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. | |
Re: 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 … | |
Re: 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] | |
Re: 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 … | |
Re: 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 … | |
![]() | Re: 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 … |
Re: 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 … | |
Re: What is the error that you are getting? Or whats going wrong, how do you know it fails? | |
![]() | Re: 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] >>> … ![]() |
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: … | |
Re: 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. | |
Re: 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 | |
Re: 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 … | |
Hey everyone! I was wondering apart from [noparse] [noparse] [code] [icode] [url] [/noparse] What other tags are there? | |
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. … | |
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? | |
Re: 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] | |
Re: Try having a look at some socket tutorials. They are great for network tutorials | |
Re: 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] | |
Re: You have to install it if your wondering. But on linux its different. Repositries and such. | |
Re: You can return it like this: [code=python] def returnTwoThings(): return 1,2 a,b = returnTwoThings() print a print b #output #1 #2 [/code] | |
Re: 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 … | |
![]() | |
Re: 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] | |
Re: 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 | |
Re: 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: … ![]() | |
Re: 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. | |
Re: 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 = … | |
Re: 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", … | |
Re: 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 … | |
Re: 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] | |
Re: Here! [code=python] s = '/home/dir1/dir2/folder1/file' list_s = s.split('/') print '/'.join(list_s[1:] [/code] | |
Re: 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 | |
Re: 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 … | |
Re: Python 2.6 has known issues with wxPython, i would reccomend that you download 2.5 | |
Re: if you are using wx then just go: [code=python] text.SetValue("Default Value Here") [/code] Where text is your wx.TextCtrl | |
Re: 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 … | |
Re: 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] | |
Re: 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 … | |
Re: 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. | |
Re: If you post the actual error message it will make it a lot easier. I tells us the line in which the error happened | |
Re: 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 | |
Re: 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] | |
Re: 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 … | |
Re: 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] | |
Re: 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 … | |
Re: 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, … | |
Re: To make a number go up by one you either go: [code=python] i += 1 [/code] OR [code=python] i = i+1 [/code] | |
Re: 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 | |
Re: 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 … |
The End.