2,190 Posted Topics

Member Avatar for trihaitran

You can use a class to do that in the following way. You could also use a list or dictionary as a container for the 10 variables and pass one list/dictionary instead of 10 variables. IMHO using the class method is preferred. [CODE]class test_class: def __init__(self): self.a="dog" self.b="cat" self.c=1 print …

Member Avatar for woooee
0
100
Member Avatar for roelandt

As stated previously, it is difficult to tell without code tags (use the "#" in the icon list). One problem is the two lines below: one is the function definition and the other is the calling line of that function. It is unlikely that this is the problem however. It …

Member Avatar for woooee
0
102
Member Avatar for lkk2116

os.path.walk has a callback function. Note this is untested code. Now that you know what to look for it should be fairly easy to find examples.[CODE]import os def processDirectory ( args, dirname, filenames ): print 'Directory',dirname for filename in filenames: print ' File',filename # top_level_dir = "/usr/local" os.path.walk(top_level_dir, processDirectory, None …

Member Avatar for jrcagle
0
101
Member Avatar for +--RagS--+

You want to use .set() but it must be with a Tkinter control variable. Look for the paragraph that starts with "For example, you could link an Entry widget to a Label widget" and the "Entry" paragraph at this link. The New Mexico Tech Tkinter pages are well done. [url]http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html[/url]

Member Avatar for +--RagS--+
0
108
Member Avatar for abhinemo

os.system should work if you just want to run a command. If that doesn't work then subprocess is the next step up. os.system("perl test.pl -testconfig <config file> > test.log 2>&1")

Member Avatar for woooee
0
75
Member Avatar for dagray

ctn_no has to be an integer instead of a string-note that all of the dictionary indexes are now integers and not strings so that you have to use an integer to find something in the dictionary. Also, if ctn_no can not be converted to an integer, you will get an …

Member Avatar for woooee
0
82
Member Avatar for nirmalarasu

Key "python" into a terminal. If you get the python prompt (>>>) then you have Python installed. Ctrl-D exits python. Most distros will have it installed in /usr/bin, so you can also check for a /usr/bin/python2.x file.

Member Avatar for Duoas
0
153
Member Avatar for KomodoM

Have you tested the code below to see if it does what you think. I don't know myself but it is unclear at best and if you have to explain it, will you be able. The following untested code breaks it down into steps[CODE]def leap_year(self, year): if (year % 4 …

Member Avatar for KomodoM
0
117
Member Avatar for gusbear

[QUOTE]i get to down as far as the tax equation and it won't run, [/QUOTE]And you'll have to be more specific. "Won't run" does not say enough and where in hell is the tax equation. Include the error message at the very least (which I am sure is a syntax …

Member Avatar for jrcagle
0
115
Member Avatar for Begjinner

[QUOTE]Firstly, I can't get the '\n' from the line before putting it in a list.[/QUOTE]I don't think "firstly" is a word, but I'm not sure. var=var.strip() will remove all whitespace before and after the text for the variable var. Whitespace is spaces, tabs, newlines, etc. As for the "too many …

Member Avatar for woooee
0
125
Member Avatar for linux

GUI's are specific to the OS. What GUIs are available for the IPod and how are you packaging your programs. I don't know what's available for IPods but if there is something like py2exe, you may be able to enbed the graphics in the executable. Also, TCL/Tk/Tkinter, GTK et all …

Member Avatar for linux
0
152
Member Avatar for flazwy

Is it defined as a CollapsiblePane, see here [url]http://www.wxpython.org/docs/api/frames.html[/url] You can also check with the wxpython mailing list if you don't find an answer here [url]http://www.wxpython.org/maillist.php[/url]

Member Avatar for woooee
0
121
Member Avatar for morpheus063

There are no doubt other and probably better ways to do this, but try print url.split("/") You want the 3rd item, or result[2]. You can then add it to a list or dictionary if it is not already in the list or dictionary.

Member Avatar for woooee
0
103
Member Avatar for Matt You

You can also read all of the file into memory, process it once to search for the string, and then process it a second time to write it to a file if necessary.[CODE]data = open(filename, "r").readlines() found = 0 for rec in data: if ("sa001:" in rec) or ("SA001:") in …

Member Avatar for micdareall
0
111
Member Avatar for mg0959

KDE and Gnome both have startup options in the menu. If you are using some other desktop manager then you may have to add it to /etc/init.d depending on which Linux distro you are using.

Member Avatar for Duoas
0
258
Member Avatar for AJG

When the users makes a choice, i.e. choice = input("What do you wish to produce?")-1 you should test for bounds. (choice < 1) or (choice > max) would yield an error and ask the user to choose again.

Member Avatar for AJG
0
395
Member Avatar for raghuramos

Did you find a solution to this? If not, ask on the Ubuntu forum [url]http://ubuntuforums.org/forumdisplay.php?f=39[/url] You probably have to install one of the libcairo or libcairo dev packages.

Member Avatar for woooee
0
85
Member Avatar for LanierWexford

I am assuming that every other record is a county followed by population housing location. This is how to use a readline() loop, (and is untested code):[CODE]def process_county(r_list): print "County =", r_list[0] print "Housing Loc =", r_list[1] fp=open(filename, "r") r_list=[] rec=fp.readline() ##county rec while rec: r_list.append(rec) rec=fp.readline() ## housing rec …

Member Avatar for Ene Uran
0
108
Member Avatar for mg0959

How is the swipper connected to the computer. If it is through a serial port, then you can use pyserial and detect when there is data in the serial port to be read. Without more info there is no way to help.

Member Avatar for mg0959
0
79
Member Avatar for kimvolker

Not too many people will open an attached pdf file. What is wrong with plain text and posting it with the thread? It can't be that long. This is the Dr Python forum which will likely know more about this. [url]http://sourceforge.net/forum/?group_id=83074[/url]

Member Avatar for vegaseat
0
342
Member Avatar for sarabhjeet

I almost never read a thread that starts with "Please help me". It is too vague to even bother with. This was one of the results of a google for "python ascii" . You can also use the ord() function (google for it) on each character to see if the …

Member Avatar for woooee
0
113
Member Avatar for sneekula

Or put them both in the same dictionary. There is only 100 or so-times 2[CODE]# small dictionary of chemical symbols symbol_dic = { 'C': 'carbon', 'H': 'hydrogen', 'N': 'nitrogen', 'Li': 'lithium', 'Be': 'beryllium', 'B': 'boron' } keys_list=symbol_dic.keys() for key in keys_list: symbol_dic[symbol_dic[key]]=key[/CODE]

Member Avatar for jrcagle
1
245
Member Avatar for Racoon200

NoneType usually means you are trying to use a variable that has not been defined. Without code and the error message it is impossible to tell anything at all.

Member Avatar for Racoon200
0
2K
Member Avatar for furkankamaci

With most GUI's you can pass parameters with the function call, so button 1 would use button_press("1") and button 2 would use button_press("2"). If this does not work with the graphics you are using, use a pass-through function [code]def button_pressed(): ##do common stuff here def button_one(): print "button one pressed" …

Member Avatar for Racoon200
0
124
Member Avatar for mhslax13

[QUOTE]I'm in a computer security class and am working on a project involving linux viruses.[/QUOTE]That's a little difficult to believe. If you want to know how to combat viruses, then look at Bastille or Security-Enhanced Linux from the NSA.

Member Avatar for woooee
0
71
Member Avatar for gusbear

easygui is a better solution for a simple interface. If you want to learn how to program using GUIs, use Tkinter or one of the other toolsboxes. [url]http://www.ferg.org/easygui/[/url]

Member Avatar for Ene Uran
0
2K
Member Avatar for gusbear

The link [url]http://www.daniweb.com/forums/thread94059.html&highlight=five+click+house[/url] yields a 404 File Not Found. Try one of these (and learn how to search) [url]http://www.daniweb.com/forums/thread94059.html[/url] [url]http://www.daniweb.com/forums/thread40738.html[/url]

Member Avatar for Duoas
0
281
Member Avatar for tuse
Member Avatar for tuse
0
107
Member Avatar for jliu66

[QUOTE=jliu66;508074]So when you make the change to the attritutes of objects, it will change other attributes in other copied objects.[/QUOTE] This is what a copy is. I think you may want separate instances of the class.[CODE]class some_class: def __init__(self, msg): print msg self.var=0 if __name__== "__main__": class_list=[some_class("test "+str(x)) for x …

Member Avatar for jliu66
0
206
Member Avatar for laspal
Member Avatar for katharnakh
0
3K
Member Avatar for axn

The Python Cookbook is the first place to look. The following link states "- Added conversion to and from Julian Day number". I haven't tried it. [url]http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/117215[/url]

Member Avatar for Duoas
0
2K
Member Avatar for gaowei

Some online books and tutorials are here [url]http://www.python-eggs.org/?row=0[/url] click on the Python link here [url]http://ubuntuforums.org/showthread.php?t=333867#5[/url] Google will list many, many more.

Member Avatar for Impact4ever
0
107
Member Avatar for sneekula

A split on a number followed by a letter is the obvious place to start. It would be nice if all of the symbols were camel case, but I don't think you can rely on that. For the "OOH" in "C6H3Cl2COOH" (no pun intended), you can look for a match …

Member Avatar for sneekula
0
118
Member Avatar for Bezukhof

Somewhere in the function you will have to add x (list item value) to a cumulative total and compare it to goal. If total is greater than goal then return number of days (can also be a total or the for loop index+1 or iter if you use a for …

Member Avatar for woooee
0
133
Member Avatar for elvenson

Since no one else has answered, I use one string to do the job, but don't think that this is Pythonic or "SQLic". So [QUOTE]cursor.execute(""" INSERT INTO %s (name, gender, job, level, str, dex, intel, cha, luc) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s) """, (CharAccount, CharName, …

Member Avatar for elvenson
0
281
Member Avatar for rjmiller

I think you would use a function and pass variables to it. So if the Laplace operator is a+b-c you could do something like[CODE]def laplace_func(a, b, c): return a+b-c # if __name__ == '__main__': laplace_list=[ [1 ,2 ,3], [3, 2, 1], [1, 3, 2]] for eachlist in laplace_list: result = …

Member Avatar for woooee
0
91
Member Avatar for yelpy

Try one or more of the "Learning Python" links here. There are a lot of tutorials available elsewhere on the web [url]http://python-eggs.org/?row=0[/url]

Member Avatar for vegaseat
0
172
Member Avatar for MstrOfPppts

"So the result of printSubs([1,2,3])" You would increment a counter or use a for() loop in the range of 0-->len(list_passed) to append an increasing number of items to the "sublist_list" based on another counter or for() loop. So the first pass would append one/each individual item, the second pass would …

Member Avatar for woooee
0
108
Member Avatar for mruane

main() in the first program block calls itself, so yes it is an infinite loop. I think what you want is [code]if __name__ == "__main__": main()[/code] This calls main() once and then exits when main() is finished - assuming you also removed main() from def main() Also, you can do …

Member Avatar for woooee
0
83
Member Avatar for animatinator

It is possibly the video header that is resizing. You should be able to resize and move the window manually depending on your operating system. Something along the lines of wx.Frame.__init__(self, parent, -1, title, pos=(10,10), size=(640, 480), etc should work also (with the emphasis on 'should').

Member Avatar for woooee
0
198
Member Avatar for mn_kthompson

They are not printable characters (probably) and so who knows where they come from. To test this, try printing the decimal value of each character. It might just be a bunch of decimal zeroes (which is zero, the printable zero is decimal 48), or EOFs, or garbage created by some …

Member Avatar for woooee
0
892
Member Avatar for nish88

You have to convert the background color to a transparent color. With imagemagick you would use the convert -transparency options, but whatever method you choose, the computer does not know what is background and what is not so you have to tell it what to do. Here is Google's result …

Member Avatar for woooee
0
304
Member Avatar for Noliving

I have never heard of, let alone used graphics22. That being said, in general you have to declare a string variable, (which is different from a python string variable in Tkinter), and then use the graphics22 variation of "setText". Likewise, to retrieve text you would use some form of "getText". …

Member Avatar for vegaseat
0
120
Member Avatar for jliu66

[quote] How can I combine 30 attributes into a tuple as you mentioned above so that I loop through thousands of people?[/quote]You don't have to use a tuple. That was just a convenient container for the example presented above. As vegaseat already stated, a little more info would be helpful. …

Member Avatar for woooee
0
167
Member Avatar for mruane

I am guessing that there are no replys here because the problem was not explained well enough. Perhaps a simple step by step example or some pseudo-code will garner more response. Example: User enters data Data is saved when user clicks save button etc

Member Avatar for jrcagle
0
118
Member Avatar for LanierWexford

You can also combine them and Python's garbage collector will then automatically close the file for you for line in open(fname, "r"): ## One line at a time ## or data = open(fname, "r").readlines() for line in data:

Member Avatar for vegaseat
0
207
Member Avatar for cyberdon

Use string.split() instead and split on the commas. Python has a csv module (comma separated variables), but it looks like that would be overkill here.

Member Avatar for woooee
0
78
Member Avatar for viswanadh

I would not use root permissions, but make this an exception to the redundancy rule and create a redundant program/function with a different name that does what you want.

Member Avatar for woooee
0
87
Member Avatar for tphilbin

Have you seen this link. If all else fails you will have to convert to some known image format (pbm/netpbm?) and display that. [url]http://effbot.org/tkinterbook/bitmapimage.htm[/url]

Member Avatar for woooee
0
97
Member Avatar for kuoz

Here is an example using Tkinter. A Google for "graph python" will turn up all kinds of examples [url]http://www.daniweb.com/code/snippet583.html[/url]

Member Avatar for vegaseat
0
83

The End.