761 Posted Topics
Re: [QUOTE=Norbert X;813758]Oh well actually I had to use functions to do this lesson, otherwise I would fail.[/QUOTE] Could you have done it this way?? [code=python] def my_function( language ): if "french" in language: return "Bonjour, comment allez-vous?" elif "german" in language: return "Hallo, wie geht es Ihnen?" elif "hungarian" in … | |
Re: [code=python] import wx import os class MainWindow(wx.Frame): def __init__(self): wx.Frame.__init__(self,None,-1,"Agent-Based Model of Residential Development", size = (640, 480)) self.panel = wx.Panel(self,-1) self.imageFile = "C:/Documents and Settings/12345/My Documents/Files/Misc/everythingisshit.jpg" # provide a diff file name in same directory/path self.bmp = wx.Image(self.imageFile,wx.BITMAP_TYPE_JPEG).ConvertToBitmap() self.bmp.bitmap = wx.StaticBitmap(self.panel, -1, self.bmp) #self.bmp.bitmap.GetSize() #self.SetSize(self.bmp.bitmap.GetSize()) #self.Center() button42 = wx.Button(self.panel, … | |
Re: I too have found shutil copies to be very time consuming, [B][I]especially [/I][/B]when copying between a hard-drive and a thumb-drive. If you are writing a MAC-only utility you could simply use a system call to the recursive copy function, ie (in Linux): [code=python] import os # src_dir = '/home/usr/test_source' dst_dir … | |
Re: What version of Python are you using here? On 2.5.2 I get the following: [code=python] >>> my_lines = [ ... "======================================================", ... "Name Place Age", ... "======================================================", ... "John US 11", ... "Mary UK 12", ... "Mike US 14" ] >>> for line in my_lines: ... if len(line.split()) == 3: … | |
Re: Perhaps this can help: [icode]button.set_sensitive(False)[/icode] [url=http://pygtk.org/pygtk2reference/class-gtkwidget.html#method-gtkwidget--set-sensitive]Documentation[/url] | |
Re: You really should've tried [url=http://lmgtfy.com/?q=python+random]google[/url] But since this is such a simple request here: [code=python] >>> import random >>> random.randint(0, 100) 20 >>> [/code] There are many great functions within the random module... take a look at the documentation for examples of how to use them. | |
Re: In order to use [icode]os.listdir[/icode] you would also want to combine it with [icode]os.path.isdir[/icode] since you'll receive a list of both file and directory names. | |
Re: @Lizapotter: To preserve indentation and get syntax highlighting (and also spare the forum-goer's eyes) please use code tags as such: [code=python] # Your code goes in here [/code] | |
Re: Yeah.. all you're doing is printing a bunch of things. You fail to call any health-affecting functions | |
Re: You would want to initialize the counter to 0 before your while loop like [icode]my_count = 0[/icode] and then near the end of the loop contents you can add a [icode]my_count += 1[/icode] (which is equivalent to [icode]my_count = my_count + 1[/icode]) | |
Re: Maybe you need [code=python]self.gladefile = open( "hello.glade" )[/code] instead of [code]self.gladefile="hello.glade"[/code] ? | |
Re: In the past I've used matplotlib for a real-time data logging utility. It already had a control that took no effort on my part to integrate into wxPython, and because it was very similar to matlab, it took minimal effort to manipulate the graph's data... I suggest looking into it … | |
Re: This would be a great beginner project for Python. The forum members are here to help you but not here to do your work for you. Help us help you by fleshing out your ideas. | |
Re: [QUOTE=gabec94;788434][code=python]elif rows[4][2] and rows[3][3] and rows[2][4] and rows[1][5]=='O': return "O Wins" [/code][/QUOTE] As already stated, you must move the call to main() to the end of your program; however the above syntax is WRONG. It should be: [code=python]elif rows[4][2] == 'O' and rows[3][3] == 'O' and rows[2][2] == 'O' and … | |
Re: [QUOTE=revenge2;789884] [CODE=Python] self.buthello = wx.Button(self, wx.ID_ANY, label ='helo') self.buthello.Bind(wx.EVT_LEFT_DOWN, self.helloevent) [/CODE] Q1. in the line 'wx.Frame.__init__', what is wx.ID_ANY, what is the purpose of it?. Q5. This is another tutorial i was looking at and on this it has used '-1' instead of wx.ID_ANY. whys that? Q2. Also self.buthello isnt … | |
Re: [QUOTE=apolo_x;789914]I can see the teams name in the source code... But, unfortunatly, what I'm getting from the webiste isn't the source[/QUOTE] Take note of the type of webpage you're getting your information from (.aspx) The ASP.NET framework allows dynamic websites to be created (take note of the web address as … | |
Re: [QUOTE=tillaart36;789879] [CODE=python] def printGrid(self): for y in range(self.height): for x in range(self.width): print self[x, y].value, print def printGrid2(self): for y in range(self.height): for x in range(self.width): print self[x, y].value, print [/CODE] the printGrid2 method can't be found or something.[/QUOTE] Indentation is very important in Python. Your printGrid2 method is defined … | |
Re: [QUOTE=demeryjo;789284]I'm not sure how to multiply the digits[/QUOTE] Here's multiplication in Python [code=python]>>> 1 * 2 * 3 * 4 24 >>> [/code] I suggest you peruse the Python documentation to learn yourself something. I suggest the [URL="http://docs.python.org/tutorial/introduction.html#first-steps-towards-programming"]First Steps Towards Programming[/URL] section | |
Re: The extra two characters that you are adding (ie 32 -> 1200) are over writing the '\n' and the '<', which is why editing a file with seek is a terrible idea unless you're simply replacing character for character. A better idea would be to load the file into memory, … | |
Re: Tkinter certainly would let you do it, but if it were me I'd go with [URL="http://www.wxpython.org/"]wxPython[/URL]. It'll probably get you there quicker. | |
Re: Looks like somebody [URL="http://tkinter.unpy.net/wiki/StyledEditor"]made a widget[/URL] that will handle sub/superscripting... I suggest downloading their source code and figuring out how they do it... then possibly try to implement it for your own purposes. | |
| |
Re: Search this forum for mentions of pygame. It's a great module that will help you in making use of your sprites and granting you the ability to move them in response to button presses, etc. | |
Re: [QUOTE=babanner;779999]error: FileCookieJar has not attribue '_self_load'.[/QUOTE] [URL="http://tinyurl.com/84b9ua"]Oh here[/URL] | |
Re: I think I read something in [URL="http://www.python.org/doc/essays/ppt/regrets/PythonRegrets.pdf"]Guido's Python regrets[/URL] that he wished he would've enforced that only spaces be used and not allow tabs whatsoever. It's been a while so perhaps I just made that up. | |
Re: Would it be possible for you to simply use a read() to bring in all the information that you can and then worry about parsing it once that operation has completed? After storing what you've read you can perform a split('\n') and then iterate on the return to perform almost … | |
Re: [QUOTE=evstevemd;776664] [CODE=python] cursor.execute("CREATE TABLE ? (? TEXT, ? TEXT, ? TEXT, ? TEXT, ? TEXT)", (t_name, t_date, t_explanations, t_deposit, t_withdraw, t_balance) ) [/CODE][/QUOTE] Are you allowed to create things with a '?' for the name? That doesn't look right to me... | |
Re: Did you remember to get new versions of your modules when you upgraded ? | |
Re: [URL="http://docs.python.org/library/telnetlib.html"]Reference[/URL] | |
Re: How about you show us what you've tried and we'll help you. That's how it's supposed to work, we're not here to do your homework. And when you're posting code please use code tags: [noparse][code=python] # Code in here [/code][/noparse] When you do that you can make code that looks … | |
Re: When you return someting from a function you should use a container to "catch" it... [code=python] returned_list = mod2.calc(pile2,m,pile3) return returned_list [/code] Understand what I mean? | |
Re: Look into [URL="http://www.wxpython.org/"]wxPython[/URL], as there are multiple options for creating a tabbed interface: [URL="http://wiki.wxpython.org/Simple%20wx.Notebook%20Example"]Tabbed Notebook[/URL] Aui MDI etc... Go for the docs and demos package to get lots of examples of building tabbed interfaces | |
Re: What is it? Python is an OO scripting language. What's good about it? Everything. That's all you need to know, now [URL="http://diveintopython.org"]dive into Python[/URL]! | |
Re: Here's some examples of string formatting: [code=python] >>> my_car = 'Ford' >>> my_friend = 'Bob' >>> print 'Hai. I drive a %s with my friend %s' % (my_car, my_friend) Hai. I drive a Ford with my friend Bob >>> print 'Wait, I too drive a', my_car, 'with my friend', my_friend … | |
Re: Try out [URL="http://code.activestate.com/recipes/148061/"]this guy[/URL] | |
Re: [QUOTE=mikewalsh89;757407]ok this is what i have; from math import * x=input("What value will you give x?:") n=input("Please set a maximium amount of iterations?:") for i in range (n): x = x - ((x-cos(x))/(1 + sin(x))) break y =x if (y-x) <= 10**-8: print y elif (y-x) > 10**-8: continue still … | |
Re: [QUOTE=Salem;771209]What's a [URL="http://www.daniweb.com/forums/thread165986.html"]search engine?[/URL][/QUOTE] The best part is that two people didn't pick up on the sarcasm and actually replied. Makes this triple-funny | |
Re: I think he's talking about saving a python script and then double-clicking the file to launch it. The command dialog is closing once his program exits. To avoid this, it is best to run the program from the terminal/cmd window If your program has no errors and you need to … | |
Re: Ghar. For some reason os.system() isn't friendly with commands that have spaces in their paths (even if you enclose them with ""). Best practice is to swtich to a slightly more robust execution module such as subprocess (if you're on 2.4 or greater), or popen | |
Re: [QUOTE=woooee;755475]file_path = os.path.join("c:", "Broucher.pdf")[/QUOTE] For whatever reason, on Windows os.path.join doesn't play nice with the drive letter: [code=python] >>> import os >>> os.path.join('c:', 'foo', 'bar') 'c:foo\\bar' >>> os.path.join('c:\', 'foo', 'bar') 'c:\\foo\\bar' >>> os.path.join(r'c:', 'foo', 'bar') 'c:foo\\bar' >>>[/code] | |
Re: MySQLdb is not part of the standard python distribution; you can download it [url=http://sourceforge.net/projects/mysql-python]here[/url]. | |
Re: [QUOTE=Hrothgar;759614] s = "ifconfig wlan0 192.168.%s.%s up" % r [/QUOTE] Since your string formatting has two %s, the argument list should also have two values to fill into those spots. So something like this would be more correct: [code=python] s = "ifconfig wlan0 192.168.%s.%s up" % ( r, r ) … | |
Re: Perhaps you need to do something like: [code=python] # Assuming returned string is named inp_chrs inp_chrs = str( inp_chrs ) inp_chrs.partition( my_sep ) [/code] Does that make sense? Simply convert it to a pure python string using the [icode]str()[/icode] method. | |
Re: If those classes are in the file myfile.py the easiest thing to do is: [code=python] from myfile import ClassA from myfile import ClassB # OR, simpler: from myfile import * [/code] If the files are named after the class, are set up correctly, and in the same directory as the … | |
Re: We're here to help. Just post the code that you've already written and we'll be glad to fix any bugs or suggest ways to improve it. | |
Re: Try and see if you can ping that server/port from your office. It seems like it's getting blocked. | |
Re: [QUOTE=kruglok;754226]Would you see what I'm doing wrong.[/QUOTE] You've got an infinite loop at the end there... [code=python] while count < len(word): if (word[count] in vowel): numVowels = numVowels + 1[/code] You see? You never update the count variable, so it'll always be less than the length of word (ie, infinite … | |
Re: Here's a few pointers on possible ways to help you achieve this task: [code=python] f = open( 'filename.txt' ) lines = f.readlines() f.close() # File contents are now contained in lines, # a list of each line as a separate element for each_line in lines: # Now here we iterate … | |
Re: [QUOTE][CODE] Exception in thread "Thread-4" Traceback (innermost last): File "<string>", line 1, in ? TypeError: class.__new__(X): X is not a type object (class) [/CODE][/QUOTE] X is not a type (class) in reference to [icode]class.__new__(X)[/icode] compared to [icode]c.__new__(c)[/icode] would translate to [icode]X.__new__(X)[/icode]. Ya feel me? HTH | |
Re: [code=python] screen.blit(image, (10,10)) [/code] I think.. |
The End.