4,305 Posted Topics
![]() | Re: Sorry, just a little late with the same cure. ![]() |
Re: The latest survey amongst graduating students indicates that job security ranks higher than job satisfaction. | |
Re: [B]print_cmd = 'echo "IN;PU" x "," y | lpr -P %s %s'[/B] should be written [B]print_cmd = 'echo "IN;PU%s,%s | lpr -P %s %s' % (x, y, printer, "")[/B] and later use [B]os.system(print_cmd)[/B] | |
Re: You simply form a new list excluding the item that contain a given substring ... [code]mylist = [ '192.168.255.1 00:01:02', '172.14.0.1 00:0f:01', '172.14.0.1 01:ff:dd:34', '192.168.255.3 00:dd:01:ff' ] exclude = '172.14.0.1' newlist = [] for item in mylist: if exclude not in item: newlist.append(item) print(newlist) """my result --> ['192.168.255.1 00:01:02', '192.168.255.3 … | |
Re: Talk about a lean and nimble IDE, I am still a friend of [B]ConText[/B]. You can set it to the language you are using, and even specify which version of Python you want to use. Best of all, I can run C, CPP, Ruby, Lua, IronPython and Python on it. … | |
Re: Hope this link is correct, I am just getting used to Windows7: [url]http://www.daniweb.com/forums/post1158775.html#post1158775[/url] | |
![]() | Re: You mean a recursive function like this ... [code]def sum_digit_squares(intNum, total=0): """ return the sum of the squares of intNum digits """ if intNum > 0: last = intNum % 10 x = last**2 print( last, x ) # for testing only # recursive action return sum_digit_squares(intNum//10, total+x) else: return … |
Re: Sometimes you have to ask 'stupid' questions to get smarter! We are glad to help. In your case [B]i[/B] is simply the name of a variable that holds the value as you iterate over a given range of numbers. You can use any allowed variable name, I usually use k … | |
Re: I assume you have downloaded the installation programs for the correct version of Python. So the next question is: What is your operating system? | |
Re: Got to show some code! Also, which version of Python are you using? | |
Re: Your military time has to be a 4 character numeric string of format hhmm. You can use function zfill() to pad with the proper amount of leading zeros. To extract the numbers for hh and mm respectively use string slicing. You should let your function return True or False to … | |
Re: [B](ranx, rany) >= button1(Point(x,y))[/B] is most likely not the same data type and therefore not comparable. | |
Re: Generally the eval() function will do ... [code]def add(x, y): return x + y input_str = raw_input("Enter add(4,3) ") print eval(input_str) """result for entering add(4,3) --> 7 """ [/code]... however, employ some checking so a nasty user does not wipe out your drive with an improper input. | |
Re: Line 74 has the answer. | |
Re: This might be a good example you can customize to your needs: [url]http://www.daniweb.com/forums/post1154551.html#post1154551[/url] | |
Re: random.choice returns a random element of the list. Change your code [code] for i in range (0, No_trials): headlight = random.choice([headlight3, headlight1]) if headlight == headlight1: [/code] | |
Re: Your assumption about [B]graydata[/B] is probably correct if you just follow [B]GetImg()[/B] and [B]pImage[/B] in header file [B]loadbmp.h[/B] Are you passing [B]graydata[/B] in as a pointer? | |
Re: You are trying to compare floating point numbers. The computer deals with floating point numbers internally in binary form. This leads to small roundoff errors. Just about all computer languages have that problem When you are calculating [B]b = b + 0.1[/B] by the time you get to [B]b = … | |
Re: There is a code example that might help at: [url]http://www.daniweb.com/forums/post1146095.html#post1146095[/url] | |
Re: Try something like this ... [code]cs = ['CMSC 201','CMSC 202','CMSC 203','CMSC 304','CMSC 313', 'CMSC 331','CMSC 341','CMSC 345','CMSC 411','CMSC 421','CMSC 441'] math = ['MATH 151','MATH 152','MATH 221'] stat = ['STAT 355'] required = cs + math + stat # assume user entered this cmsc = ['CMSC 201','CMSC 202','CMSC 203','MATH 151'] for … | |
Re: There is also a good example of a wx.ListCtrl here: [url]http://www.daniweb.com/forums/post650657.html#post650657[/url] It shows you how to organize your data to load the widget and retrieve selected info. | |
Re: Oh my God! You are using a wild mix of [B]tabs[/B] and [B]spaces[/B] for your code indentations! That is an absolute [B]nono[/B]. Avoid tabs, since sooner or later you will mix them with spaces. Most Pythonians use 4 spaces for indenting a code block. Stick with that! | |
![]() | Re: Hint ... [code]word = "python" for letter in word: index = word.find(letter) print( "letter %s is at index %s" % (letter, index) ) [/code] ![]() |
Re: I don't have module graphics.py, but your problem could be that you might have Button in that module, competing with Button from button.py This could be solved by using name-spaces. | |
Re: Let's not forget Jython. Jython is an implementation of Python in Java. With it, you can embed Python directly into your Java applets and applications, or you can use Java classes in Python. Take a look at: [url]http://www.jython.org[/url] | |
Re: [QUOTE=jonsca;1150443]You missed the obvious option, jwenting. Open the skull, put black ink over the cortex, stamp it on a sheet of paper. Voila, brain fingerprinting.[/QUOTE]That wouldn't be [B]brain fingerprinting[/B] that would be [B]brain cortexprinting[/B]. You got to get a finger in there somewhere. :) | |
Re: First help us out by indenting your code blocks properly as required by the Python syntax. | |
Re: Here you have an example of a class name [B]Animal[/B] and some instance names ([B]dog, cat, cow[/B]) ... [code]class Animal: """ class names by convention are capitalized """ # category is global to the class and is available to all # instances of class Animal category = "animal" def __init__(self, … | |
Re: Also see: [url]http://www.daniweb.com/forums/post104834.html#post104834[/url] | |
Re: [QUOTE=customtshirts;1144687]Well i always like to prefer USA whether they win or lose. They are my all time favorite.[/QUOTE]I assume you are selling a t-shirt about that topic. | |
Re: The simplest way to get your x values in small increments is with a while loop. Then simply append (y, x) tuples to a list and use the min() and max() functions. | |
Re: [QUOTE=Tech B;1148423]... I just noticed 2 wasn't shown. Maybe I don't have it....[/QUOTE]A little simpler, and you might just have it ... [code]s = """ 2 6 18 22 """ s = s.split() i = 1 while i <= 26: if str(i) in s: print "gotcha" else: print str(i) i … | |
Re: [QUOTE=Cyproz;1147880]Ok i got the endswith and the startswith. but im not sure how to check for the @ symbol. so what method checks for a symbol?[/QUOTE]You are on the right track ... [code]def isValid(s): if "@" not in s: print "There is no @ symbol" return False if s.startswith("@"): print … | |
Re: Someone at Google forgot to hand over the envelope of cash to make Italian justice work better. | |
Re: Well, it wasn't that long ago: [url]http://www.daniweb.com/forums/thread12718.html[/url] I was still a C and BCX nut then. Amazing, BCX still exists: [url]http://bcx-basic.sourceforge.net/[/url] | |
Re: I don't see any reason why a space and number characters couldn't be added to your Polybius square. | |
Re: The way you derive db_date, it clearly is a string. Your error comes from before that item. After all, sql_cmd = ... is just one line of code. Simply put all incoming_data[x] into str(incoming_data[x]) that should fix it. | |
Re: Take a look at the C code snippet at: [url]http://www.daniweb.com/code/snippet109.html[/url] | |
Re: Usually you can give your Python code a [B].pyw[/B] extension. This will use the [B]pythonw.exe[/B] interpreter avoiding the DOS console. If you create a distribution with py2exe then you have to make sure you specify windows in the setup ... [code]""" file = wx2exe.py Py2Exe (version 6.6 and higher) setup … | |
Re: A little playful ... [code]s = "knockknock" s2 = s.replace("knock", "bam", 1) print s2 s3 = s.replace("knock", "bam") print s3 s4 = s3.replace("bam", "knock", 1) print s4 # combine s3 and s4 action s5 = s.replace("knock", "bam").replace("bam", "knock", 1) print s5 """ my result --> bamknock bambam knockbam knockbam """ … | |
Re: By default the buttons will appear on the root window. If you want them somewhere else, you have to specify the new master. | |
Re: You can create a list of lists this way ... [code]# assume that raw data is read/obtained as a string data_str = """\ d.complex.1 24 25 67 123 764 d.complex.2 23 54 35 64 d.complex.3 1 2 3 """ data_list = [] # split at the 'd' char, later put … | |
Re: Without some pertinent code it will be impossible to help you. Which program/server event triggers the message box to appear? | |
Re: One way to accomplish this is shown in code snippet: [url]http://www.daniweb.com/code/snippet263775.html#post1144145[/url] | |
Re: Here is one example how to do this ... [code]# a look at wxPython menu radio buttons import wx class MyFrame(wx.Frame): def __init__(self, parent, mytitle, mysize): wx.Frame.__init__(self, parent, -1, mytitle, size=mysize) #self.SetBackgroundColour("white") # set up the menu file = wx.Menu() color = wx.Menu() self.color = color help = wx.Menu() id_blue … | |
Re: There is a nasty bug in all your approaches to frange() ... [code]# both frange functions written by Luke Endres (fallopiano) # If your going to use it, please give credit! def frange(start, end=None, step=None): 'A range function that can accept float increments' if end == None: end = start … | |
You can use Python modules math, wave, and struct to create and save a synthetic sine wave of given frequency and duration (size) ... | |
Re: IMHO, Tkinter GUI code is too simple to write to warrant a visual approach. It's so much easier to build yourself a few Tkinter code templates and go with that. BTW, code produced by [B]Visual Tkinter[/B] doesn't seem to follow any Python syntax guidelines. | |
Re: If you are interested in reading particular lines from a data file, look at module linecache. |
The End.