761 Posted Topics

Member Avatar for Norbert X

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

Member Avatar for jlm699
0
128
Member Avatar for karenmaye

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

Member Avatar for jrcagle
0
863
Member Avatar for chris.eastwood

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 …

Member Avatar for chris.eastwood
0
4K
Member Avatar for starzstar

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

Member Avatar for jlm699
0
98
Member Avatar for marcux

Perhaps this can help: [icode]button.set_sensitive(False)[/icode] [url=http://pygtk.org/pygtk2reference/class-gtkwidget.html#method-gtkwidget--set-sensitive]Documentation[/url]

Member Avatar for marcux
0
355
Member Avatar for StarZ

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.

Member Avatar for StarZ
0
229
Member Avatar for mahela007

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.

Member Avatar for mahela007
0
109
Member Avatar for Sohvkhan

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

Member Avatar for sneekula
0
1K
Member Avatar for StarZ

Yeah.. all you're doing is printing a bunch of things. You fail to call any health-affecting functions

Member Avatar for jlm699
0
125
Member Avatar for eyewirejets

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

Member Avatar for eyewirejets
0
112
Member Avatar for strobon

Maybe you need [code=python]self.gladefile = open( "hello.glade" )[/code] instead of [code]self.gladefile="hello.glade"[/code] ?

Member Avatar for strobon
0
2K
Member Avatar for lllllIllIlllI

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 …

Member Avatar for lllllIllIlllI
0
83
Member Avatar for Jigs_ff

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.

Member Avatar for jlm699
0
128
Member Avatar for gabec94

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

Member Avatar for lllllIllIlllI
0
138
Member Avatar for revenge2

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

Member Avatar for Ene Uran
0
125
Member Avatar for apolo_x

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

Member Avatar for Stefano Mtangoo
0
223
Member Avatar for tillaart36

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

Member Avatar for jlm699
0
36K
Member Avatar for demeryjo

[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

Member Avatar for Stefano Mtangoo
0
109
Member Avatar for codedhands

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

Member Avatar for lllllIllIlllI
0
99
Member Avatar for starzstar

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.

Member Avatar for jlm699
0
115
Member Avatar for Stonehambey

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.

Member Avatar for Ene Uran
0
2K
Member Avatar for Aue
Member Avatar for Apollo64

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.

Member Avatar for jlm699
0
112
Member Avatar for babanner

[QUOTE=babanner;779999]error: FileCookieJar has not attribue '_self_load'.[/QUOTE] [URL="http://tinyurl.com/84b9ua"]Oh here[/URL]

Member Avatar for jlm699
0
85
Member Avatar for mn_kthompson

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.

Member Avatar for sneekula
0
135
Member Avatar for tzushky

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 …

Member Avatar for Gribouillis
0
14K
Member Avatar for Stefano Mtangoo

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

Member Avatar for Stefano Mtangoo
0
2K
Member Avatar for wheatontrue
Member Avatar for romilana
Member Avatar for jlm699
0
109
Member Avatar for san245

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 …

Member Avatar for jlm699
0
145
Member Avatar for revenge2

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?

Member Avatar for Murtan
0
332
Member Avatar for surealis

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

Member Avatar for Stefano Mtangoo
0
268
Member Avatar for winrawr

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

Member Avatar for bcasp
0
153
Member Avatar for StarZ

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 …

Member Avatar for sneekula
0
595
Member Avatar for elvenstruggle
Member Avatar for Gribouillis
0
141
Member Avatar for mikewalsh89

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

Member Avatar for Nuez_Jr
0
149
Member Avatar for nitu_thakkar

[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

Member Avatar for Stefano Mtangoo
-1
355
Member Avatar for woah

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 …

Member Avatar for mn_kthompson
0
108
Member Avatar for _Core

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

Member Avatar for anurag_bagaria
0
1K
Member Avatar for dilbert_here00

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

Member Avatar for anurag_bagaria
0
433
Member Avatar for rajasekhar1242

MySQLdb is not part of the standard python distribution; you can download it [url=http://sourceforge.net/projects/mysql-python]here[/url].

Member Avatar for nikhilvishnupv
0
457
Member Avatar for Hrothgar

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

Member Avatar for Stefano Mtangoo
0
175
Member Avatar for Rejinacm

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.

Member Avatar for Rejinacm
0
110
Member Avatar for nuaris

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 …

Member Avatar for nuaris
0
152
Member Avatar for kruglok

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.

Member Avatar for shadwickman
0
142
Member Avatar for anilk

Try and see if you can ping that server/port from your office. It seems like it's getting blocked.

Member Avatar for Stefano Mtangoo
0
1K
Member Avatar for kruglok

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

Member Avatar for jlm699
0
17K
Member Avatar for wotthe2000

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 …

Member Avatar for Murtan
0
277
Member Avatar for jcafaro10

[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

Member Avatar for jlm699
0
98
Member Avatar for tomtetlaw

The End.