4,305 Posted Topics
Re: After you read Gribouillis' suggestion and also read some more of the Python tutorial on string operations, you could explore the hint below. Hint, you could go through your data string line by line this way ... [code]data_str = """\ 0,Salary,14000 0,Bonus,5000 0,gift,6000 """ for line in data_str.split('\n'): print(line) [/code]... … | |
Re: Just about anybody can learn to play the piano, but very few can be a concert pianist. To be good at playing the piano takes real talent and a special mind. The same goes for programmers. To hire a good one you have to hear them play, or in this … | |
Re: [QUOTE=Serunson;524062]I don't really like Football/Soccer to be honest, i mean i watch the international matches, but i really don't care much. Basketball, now there's a proper sport :P Action all the way! Go Guildford Heat! :)[/QUOTE]Basketball is like playing soccer without a goalie, it's too frigging easy to score! On … | |
Re: You have to pass the required arguments to an from your functions. Look at your modified code carefully ... [code]#!C:\Python26\python.exe # Three-times-the-square-root-of-your-age.py # # This is a python program that # will input the user's name and age # the output will be 3 times the # square root of … | |
Re: I started the year with water pipes bursting in my house. The plumber said that all the pipes are butyl rubber (gray plastic stuff), outlawed since 1995 and need to be replaced with something more modern. I hope that niek_e's insurance will pay for most of his car damage. No … | |
Re: Try ... [code] def OnLeftDown(self, event): print 'Left Button clicked at:', event.Coords # clear all objects off the canvas self.canvas.ClearAll() self.canvas.ZoomToBB() [/code] | |
Re: [QUOTE=~s.o.s~;1111811]I wish all the Indians out there a very Happy 61st Republic Day! :-)[/QUOTE]A fantastic achievement! Congratulations! The USA will celebrate its 234th (or is it the 235th) Independence Day on July 4th. It took quite a bid of bloodshed and many years to kick the British overlords out then. | |
Re: Please give us some details on what [B]flex 3[/B] is. | |
Re: What currency are you using to buy oil from Saudi Arabia or manufactured goods from China? | |
Re: You could split the string once ... [code]mystr = "F4K8*72-432*82T-74" mylist = mystr.split("*", 1) print mylist # ['F4K8', '72-432*82T-74'] # add the missing '*' back in print "part1 = %s*" % mylist[0] print "part2 = %s" % mylist[1] [/code] | |
Re: Your problem may be that you are also using [B]file[/B] for variable names. Also [B]if(not os.path.isdir(path):[/B] should be [B]if not os.path.isdir(path):[/B] This works (Windows XP) ... [code]import os class Subfile(file): def __init__(self, path): if not os.path.isdir(path): file.__init__(self, path) self.__path = path def listFiles(self): if os.path.isdir(self.__path): for file1 in os.listdir(os.path.abspath(self.__path)): yield … | |
Re: Who says that a book written by a programmer has to be written in a dull and boring manner? Let them throw in a fresh and mildly spicy word every now and then to stimulate the reader's palate. | |
Re: We will only help those who show some effort! In other words, show us some Python code you have tried to solve your problem. The problem is real easy to solve, hint ... [code]# "f(x)= x + 2 - 3" implies the function below def f(x): return x + 2 … | |
Re: Here is a code snippet that uses sliders to adjust the RGB values of a color. Look at: [url]http://www.daniweb.com/code/snippet216694.html[/url] | |
| |
Re: Since we don't have your data file, we can simply create a sample test file and use that to show you how you can extract the numeric data after the marker ... [code]# create a test data string raw_data = """\ a b c DATA 11 22 17.5 45 19.5 … | |
Re: You mean you want to add the invalid username and password to the database? | |
Re: Hate to think what will happen if those war robots return [U]home[/U] infected with a computer virus. | |
Re: You have done a fine job so far test printing your data. Now let the user input a month with the correct spelling. Index the month using: [B]mon_ix = months.index(mon_str)[/B] That index matches the temperature data index, pull out he right list with: [B]mon_temps = temperatures[mon_ix][/B] Now create a temporary … | |
Re: You got to let us know what [B]T[/B] is. | |
Re: Maybe ten years from now. | |
Re: A simple example of using module timeit ... [code]# using Python module timeit on a simple statement # (timeit turns off garbage collection) import timeit stmt = "x = (12345679 * 63)//7" # use n=1000000 passes (this is also the default) # this way the result will be time per … | |
Re: You may want to read up on passing parameters/arguments to and from functions: [url]http://www.daniweb.com/forums/post104853.html#post104853[/url] Notice that the code examples are written to be used with the older Python2 and the newer Python3 syntax. Also, check your spelling of function names and don't use the same names for variables and functions. | |
Re: In my humble opinion you need to learn Python really well before you tackle many of those projects. Thoroughly read the initial post at: [url]http://www.daniweb.com/forums/post159472.html#post159472[/url] You raised some questions that needed to be answered. Those in turn would have cluttered the project thread. The rules are there to prevent this. … | |
Re: I assume you are talking about the Python shell that comes up with IDLE as an output window. You have to tell Python which type of encoding to use, try this ... [code]# -*- coding: cp1252 -*- print chr(233) # é print chr(130) # ‚ [/code] | |
Re: Kindly let us know which GUI toolkit you are using. Also, can you give us a small sample of your code? | |
Wallpaper or tile images are small images that can be spread across a background repetitively. A common practice on web pages. The surface created with wx.PaintDC() can be used for this effect and still allows other widgets to be put on top of the wallpaper. The small tile image is … | |
Re: If you put the number of primes you want, you called it x, in the outer loop range() you will get x numbers, but since not all of them are prime it will print less than x numbers. You need to make the outer loop an endless loop with a … | |
Re: You may want to look into the Python module pickle. | |
Re: You can also keep a program busy with a for loop, but the exact delay will depend on your computer's capabilities. | |
Re: Which GUI toolkit are you using? | |
Re: You lost me there! Can you explain yourself a little better? | |
Re: Unix/Linux uses '\n' Windows uses '\r\n' Mac uses '\r' for newlines, which manifest themselves in documents/text written on these machines. Python by default uses "Universal Newline" support which translates all of the different newlines to '\n' when you open a document/text file. As to "Standard Newline", there is no agreed … | |
Re: What does the [B]html[/B] code look like? | |
Re: A simple way to make a ticker ... [code=python]# using Tkinter to create a marquee/ticker # uses a display width of 20 characters # not superly smooth but good enough to read import Tkinter as tk import time root = tk.Tk() # width=width chars, height=lines text text = tk.Text(root, width=20, … | |
Re: Interesting! So what is your solution? Actually, some of those things cannot grow exponentially. There won't be enough consumers around! There is also quite a limit of college educated folks that society can productively absorb. We still need folks that grow, harvest and prepare the food, deliver the goods, fix … | |
Re: You might want to let people in on which GUI toolkit you are using. | |
Re: To access a dictionary key use [B]print Card.VALUES["1"][/B] Also in your case there is no key named "1" | |
Re: What does userlist look like? You seem to constantly overwrite the result in a newly created label at the same position. | |
Re: Here is a very simple example ... [code]# show an image using a wx.PaintDC() canvas import wx class ImagePanel(wx.Panel): """ create a panel with a canvas to draw on""" def __init__(self, parent): wx.Panel.__init__(self, parent, wx.ID_ANY) # pick a .jpg, .png, .gif, or .bmp image file you # have in the … | |
Re: Must be Windows7, works fine with Windows XP. | |
Re: You are mixing spaces and tabs as indentations which makes a mess out of your code, at least in my editor. | |
Re: My advice, start writing each function using test parameters and temporary test prints. See if you get the expected results. If you have problems give us the code you have and we will try to help. | |
Re: Why don't you write a simple program using module threading and test it with Windows XP and then Windows7 and check the results. Some Windows versions have problems with prioritizing threads. You can also use this simple test program that shows you how to turn off a thread ... [code]# … | |
Re: If you have to include a series of small image files with your program distribution, it might be simpler to embed the images as base64 strings into your code. The strings are easy to generate. For an example see: [url]http://www.daniweb.com/forums/post1112502.html#post1112502[/url] | |
Re: Are these lines the only totally numeric lines in your file? | |
| |
A lotto simulator with a twist, you pick the winning numbers and the computer buys the lotto tickets. Anyway, the computer at least generates the tickets and checks how many of them would match the winning numbers you selected. Let's assume you would be the state lotto commissioner and your … |
The End.