- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 11
- Posts with Upvotes
- 8
- Upvoting Members
- 7
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
I am a self-employed travel agent in Namibia who spends a great deal of time developing website, for myself and other, and I have a general interest in programming. I work mainly with Python, and use the Django Web Framework now for all my website work.
- Interests
- Nature, computers, kids, and I would love to fly
- PC Specs
- Linux Ubuntu (10.04, sometimes others just for kicks) Windows for website testing
47 Posted Topics
I am still trying to get a grasp on the php/mysql interaction. Why does something like this not work and without all the error catching, can one do something like this? [CODE] $result = mysql_query("SELECT * FROM stadium WHERE gametime = `$_z`;"); $row = mysql_fetch_row($result); $bababa[name] = $row[0]; $bababa[town] = … | |
Re: Maybe something like this: [CODE]option_input = raw_input(">>> ").upper() if option_input == "V": print "High Scores:\n" saveFile = open("scores.txt", "r") scores = saveFile.readlines() for line in scores: if "," in line: userScore, userName = line.split(',') print "%2s, %s" % (userScore, userName.strip())[/CODE] At the end of the program you're assigning the variables … | |
Re: I only use Linux. My main work station runs Ubuntu 10.04 (although I'll move up soon - 10.10). I have some old computers around just for playing with and for my kids. On those I play around with other Linux distros - just to learn or see how they work … | |
I am new to working with Django, and have found it really fun and interesting to develop with. But I have been trying to upload it to a hosted server and just not getting it to work. I have followed the instructions they give, but just not getting it to … | |
Re: Okay, I think I have the whole thing working for you. I have left the file paths as I had them on my system (working on Ubuntu Linux). Just change them for your system. I have spent a couple hours figuring this out and so I haven't commented very well. … | |
Re: Here is how you can approach it: create an empty list: [CODE]newVals = [][/CODE] First of all deal with the file. Open the file, read it to a variable (The hint vegaseat gave you - in the file.readlines()) and then close the file, you have the contents already in 'line' … | |
Re: If you just want to find the file with the highest value, that should be simple if the files all have the same format. Something like this: [CODE]high = 0 for i in files: if i[2] > high: high = i[2] change_file = i [/CODE] Then you can just append … | |
Re: There are a couple things to set right with your code first. n = random.randint(0, 99) for i in range(1): First, don't indent the `for i in ....` part. It is a code block itself. Second, why have a code block that loops once. Just drop it. The only loop … | |
Hello, if I start to distribute some software I have written under a copyright, using a free software license, I would like to know what do the dates of the copyright stand for. If I say (c) 2009-2010 Vernon Swanepoel, what does it mean that I did on those dates. … | |
Re: time.sleep() [CODE]import time x = 1 for it in range(5): x = x*2 time.sleep(x) print "Dude!...."[/CODE] | |
Re: [QUOTE=gangster88;1097025]thx for the help but how could i print the length of whatever the parameters are?.. like length("tree", "computer") and it prints out the string the with length?... this is what i dnt get[/QUOTE] [QUOTE]how could i print the length of whatever the parameters are[/QUOTE] Well, if you tried the … | |
Re: I assume that you indented correctly when you tried the code on your own? [CODE]View = wx.Menu() ###the python gives on this line and held my system### self.shtl = view.Append(1, 'Show toolbar', 'Show Toolbar', kind=wx.ITEM_CHECK) view.Check(1, True)[/CODE] 'The Python' gives on this line due to the fact that you have … | |
One aspect of computers that I just don't find clear learning material on is networking. There seems to be loads of information on 'how to' but I still don't understand the underlying basics. What is meant by a Port? Why are ports numbered so strange (as in, not 1,2,3). I … | |
Re: > I have a follow up question, i cant get a grip of this random stuff..:) > How do i change this code line > `del data_list[3:5+1]` > > so instead of removing specifik elements i want to remove random ones, amount of elements to be removed as well. > … | |
Re: Put your code in code tags, and try to boil it down to what is going wrong a little. Your 'View' and 'view' should be the same caps. | |
Re: I think it would be more useful to specify where this text is. If you are working with HTML it would be very different, say, from text in a gui app. | |
Is there a way to incorporate a spell checker within a wxPython gui? I would like to be able to check the spelling of wx.TextCtrl values before they get posted to a sqlite3 database. I would imagine that the spell checker would be very os specific, but for me it … | |
Hi there, I would like to be able to change a button during the runtime of a gui. I can change the value no problem (set Label) but I need to change the size of the button as well. I have managed to change it with SetSize((120, 30)) but then … | |
Re: To give you a more simple answer, your problem with the player's score is that you keep resetting it. Why not just pass it in as a function argument. Your coding is a little strange...did you work with C before? I have just cleaned up what you have done a … | |
Re: You had a few issues. Most significant, if you used raw_input instead of input you were getting strings instead of ints. You complicate things with the different functions. I would even take out the get_length() function and just pass that as a parameter to make_pass() and deal with it there. … | |
Re: [QUOTE]why and where are we usıng None.whats the aım to use that[/QUOTE] Using None as a default value to a function is often useful to give different options. Here is a small example: [CODE]def zed(a, b=None): name = a.capitalize() if b: name = name + " " + str(b).capitalize() print … | |
Re: [URL="http://www.daniweb.com/forums/misc-explaincode.html"]Put your code in code tags[/URL] | |
Re: Okay, I am on a linux system and so I haven't worried to much about the escape characters, but I think that what you were after is getting the prompt to change from C:\\ to D:\\ What you need to do is take the [icode]initial_drive = r"C:\\"[/icode] out of the … | |
Re: Wildplace, your code is rather strange. I think that you are trying to do something well above your level of knowledge at the moment. Perhaps the best thing you can do is get a good Python tutorial and work through the chapters on functions and object orientation. Anyway, lets look … | |
Re: [QUOTE]I need your help with a simple program I'm trying to make[/QUOTE] It doesn't sound simple. It would be a fun problem to try to work on. Could you post the gist of your code. | |
Re: I have been playing with it and didn't get index() to work, mainly because index always returns the first instance of the string if it occurs multiple times. I assume that normally it would be different values and then it wouldn't matter. But just in case the email is repeated … | |
Re: Is the class in the same file as the function? Otherwise you need to import the module it is in: from langFile import LANGUAGE Or something like that. You shouldn't need to do anything before. It depends on how the rest of the file goes, for example, where is translate._languages … | |
[COLOR="Red"]Note two things: First off, I don't guarantee that it works well. Writing to files, if done wrong can always break things. Be careful. I mostly participate in this forum (the Python part) for fun, and my code is written like that. Second: this script is about copying things. I … | |
Re: [CODE]#! /usr/bin/python # parse_logfile.py import re class GetMySQLLog: """Search a logfile for mysql entries blocks""" def __init__(self): self.logfile = open('/path/to/test/file/logfile', 'r') # Correct this path self.logLi = self.logfile.readlines() self.logfile.close() self.counter = 0 self.plus = "" self.storeli = {} self.isMysql = [] def getSql(self): """Set each block to a dictionary, and … | |
Re: Don't let the object paradigm confuse you. It is actually rather easy to understand...maybe tricky to code at first, but it is not a confusing concept. 'object' means different things in different programming languages, and as mentioned before, in python almost everything is an object. An object basically is something … | |
Re: [CODE]element = {'H':1, "N":6, "F":7, 'Cl':7} i = raw_input('Enter: ') dots = '*' totalDots = element[i]*dots [/CODE] | |
Re: If the file is a Microsoft Excel file, why not work on it in Excel. Otherwise you have to deal with the formating that Excel adds to it. Otherwise if you could change it to a database, text file or xml file you would find it much easier to manage. | |
Re: This is how I got it to work: [CODE]def pullNumbers(data): NumData, total, x_full = ([], 0, "") for x in data: try: int(x) x_full = x_full + x except: if x_full is not "": NumData.append(x_full) x_full = "" if x_full is not "": NumData.append(x_full) OutNumData = " + ".join(NumData) for … | |
Re: If you have one file and want to see what buttons are in that .py file without reading it, why not go to your python ide and open the file, read it through and search for buttons by the test used to create the buttons. If that doesn't answer your … | |
Re: My answer to your first question: [CODE]stripped = [] print "Input the file, including it's full path, to strip" a = raw_input("--> ") stripper = open(a, 'r') st_lines = stripper.readlines() stripper.close() for lines in st_lines: stripped_line = " ".join(lines.split()) stripped.append(stripped_line) print "\n".join(stripped)[/CODE] I don't know how to answer the second … | |
Re: Please could you clearly say what you are trying to do, I don't really understand. Your code looks really messy. I am going to try to clearly ask you a few questions and then you could perhaps rephrase your question. [QUOTE]I proceed to convert every item in the list, one … | |
Re: You need to put your code in the code tags. I have not worked with Tkinter and don't understand how the program you are working on should work. What is [QUOTE]menu_widget_test.pyw[/QUOTE] If you want to run a different module you need to import it at some point or if you … | |
Re: I couldn't resist having a go as well. The way I have done it makes it easy to change, say to every forth value and add three letters in. You also have no issue of over running the values: [CODE]string_thing , di, Fi, z = (raw_input("Enter a string thing\n-->"),[], [], … | |
Re: "string".lower() is simple and you could do it in various places. Here is a really simple way to handle the whole thing: [CODE](letters, alph, di) = (list(raw_input('Enter your string -->').lower()), " abcdefghijklmnopqrstuvwxyz", []) for lets in letters: if lets in alph: di.append(alf.index(lets))[/CODE] | |
I am trying to create an RSS feed dynamically with php, and for the most part it seems to work out right. When I try to validate, it gives me an error with this line: [CODE]<link><a href='index.php?tt=Getting it all together&m=1'>Getting it all together</a></link>[/CODE] And it points to the = between … | |
If I have a function included within a page, and that function is in it's own file, in a different directory (/scripts/thefunction.php) how would I go about writing a file path to another file that is in a different directory. In a nutshell, a file in /index.php includes a file … | |
Re: [QUOTE=pritaeas;1024321]If you really need to do this this way, then creating a msqli_multi_query could help. That way the server gets all queries at once, and does not need to handle each query separately. [url]http://php.net/manual/en/mysqli.multi-query.php[/url][/QUOTE] Thank you. I am not sure that I need to do it that way? I am … | |
Please could someone just clear up, or point me to the right thing to read regarding mysql and php. Once you have made a query and saved it to results, I understand that the query accessed with a number of functions to extract that, such as mysql_fetch_array() and so on. … | |
I am busy with a project for fun and I am finding it tricky to set balues for mysql queries. If I do the following: [CODE]function CalcPostByTime(){ include 'DB_connection.php'; $result = mysql_query("SELECT ztime FROM blogpost;");[/CODE] What is the simplest way to set an array, which will be a return value … | |
I am sorry to ask such a beginner question: I am just learning to use classes and objects in php and would like to know one simple thing - how to you reference one function (or should I call them methods?) from another within the class. When I specify a … | |
I have been working on a site for a while now, and finally wanted to load it up to the server. I have been working on my own computer with xampplite. Everything was working just fine. When I uploaded it, after a few little things to resolve, I got most … |
The End.