226 Posted Topics
Re: You have to use some sort of web framework, Ruby by itself doesn't work on the web, so that's why there is Rails. Same thing with Python, you have to use something like Django, web2py, pylons, etc. | |
Re: [QUOTE=vegaseat;1190832]Actually Python2's input() used raw_input() and eval() to come up with a number, a dangerous combination. Now input() returns a string, and it is up to the user to convert it into the correct type.[/QUOTE] And BDFL didn't like it, so that's another reason why its changed :). | |
Re: I would say you have to get/make 6 images, something like this: [INDENT]dice-1.gif dice-2.gif dice-3.gif dice-4.gif dice-5.gif dice-6.gif[/INDENT] I would just download the images from the website you gave us. That would be the place to start. | |
Re: [QUOTE=Noliving;1188719]When eval an equation does it follow the PEMDAS rules? For example: 2.0-1.0-3.0*6.0+5.0*4.0 when evaluated equals 3.0 when evaluated by python. To me that doesn't seem correct, I get a much larger number than 3.0 When I evaluate in python eval("6/2*3") it should equal 1 but in python it equals … | |
Re: [QUOTE=Hummdis;1187347]The user did have to enter the 'admin' password in order to get to this page, [/QUOTE] How did that work? | |
Re: Please use the code tag! - (can't interpret your code, when Python's blocks are defined by whitespace, but here they don't exist. imagine C, C++, C#, Java without brackets) class BeautifulIndent(object): @staticmethod def BeautifulIndentedMethod(): pass Your error is caused because int isn't iterable, so somewhere you have something like this: … | |
Re: Start with the basics, because muds get very complicated. You can't expect to make one without a lot of experience it a broad range of coding topics. | |
I personally prefer the 3 syntax over 2, but I notice most of the code snippets in this forum are for Python 2. Is it because we are still in a steady transition from 2 to 3, or is it something else? | |
Re: Well you can use many languages for autobot program creation. Python works, but I don't think it is the best way since you have to mess with Win32API and hooks. I think one of the best ways is to write an Autoit script. | |
Re: [QUOTE=Purnima12;1188716] If the user inserts a number that is not 5 - 20, I want the program to shut down, this value error only restarts the program if the user enters a letter or symbol.... how can i fix this? thanks![/QUOTE] Like this? Although if the user inputs something like … | |
Re: does it have to be recursive? something like this (I haven't tested this code, just typed it down really quickly) [CODE] def print_out_in(text): if len(text) % 2: end = ((len(text) - 1)/2) + 1 for x in range(1,end): print text[x] print text[(-1)*x] print text[end+1] else: end = len(text)/2 + 1 … | |
Re: well looking at the cpp code behind wxpython's NullBitmap: [CODE=c++] //this code is from wxpython's //_gdi_wrap.cpp line 7026 to 7124 SWIGINTERN PyObject *_wrap_Bitmap_GetSubBitmap(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; wxBitmap *arg1 = (wxBitmap *) 0 ; wxRect *arg2 = 0 ; SwigValueWrapper<wxBitmap > result; void *argp1 … | |
Re: range is only for integers. You should either use numpy: [CODE]import numpy numpy.arange(0,1,0.1)[/CODE] or you can do this: [icode][x * 0.1 for x in range(0, 10)][/icode] or you can do this: [code]def floatrange(start, stop, step): while start < stop: yield start start += step print ["%s" % x for x … | |
Re: [QUOTE=kjock002;1187316]the random function gives you a number between 0.0 and 1.0 . im trying to get a random number between -0.5 and 0.5. i asked someone for help and they told me to go off of this: [0, 1) + .1 this changes the range to [1, 2) and i … | |
Re: This is what you need to add at the end of the [icode]while true[/icode]: [code] while True: #...OMITTED #this is what you can add to fix the problem if going.lower() == "n": break [/code] | |
Re: Here's are the main problems in your code, explanations in comments. I fixed it so that it runs. [CODE]import random def randWalk(n): #n = raw_i... <- (Don't need that!) n = int(n) #Str to int conversion steps = 0 h = 0 t = 0 while (h + t ) … | |
Re: That's not the purpose of Guid, I think. Guid.NewGuid() creates a unique identifier. | |
Re: Well Python is open-source, so you can always just look at its source. It's very advanced C coding and stuff, so I'm not sure why you are curious. | |
Re: In my opinion, this is a better way to write fight(): [CODE] def fight(self): weapon = self.weapon.get() op = self.comp_choice() defeats = {"scissors":"paper", #scissors defeats paper "paper":"rock", #paper defeats rock "rock":"scissors"} #rock defeats scissors if not weapon: #if the user didn't select a radiobutton outcome = "Please choose a weapon!" … | |
Re: After [icode]print(attrs[1][1])[/icode], maybe you can put a line [icode]self.reset()[/icode]? I am just guessing. I've never used HTMLParser before. | |
Re: I'm sure you can use os.walk and it yields a 3-tuple (dirpath, dirnames, filenames) | |
Re: Why do you have a "methods" method? It seems very weird to me. also it should be [icode]if __name__ == "__main__":[/icode] also, you have a "self" reference outside the class, which will raise a NameError. Keep working on your program. | |
Re: Use the code tag so that your code can look like this: class StringBuffer: def write(self, input): s = input t = s if '*' in input: input += t # input = input.'do not print anything that comes after the *, but retain it) print input else: s += … | |
Re: You are right, threads are the best way to go. Just google "python threading" and learn from there. I don't know anything about it, I always use the .NET version of threading. | |
Re: In a static language like C or Java, of course. But, doing exactly that in Python is impossible. The closest way is to do use the above solutions. Here's why... :) In Python, variables don't actually have a type. So that's why you can do this: [CODE] x = 1 … | |
Re: [I]Use the code tag.[/I] You need to add this line in the beginning. [code]import sys[/code] | |
Most people would do something like this: [icode]input("Press any key to continue") #or raw_input[/icode] This way, if the user presses a key other than the Enter (return) key, then the program will still continue. It looks something like this: [URL="http://i42.tinypic.com/2yvp9hj.png"]http://i42.tinypic.com/2yvp9hj.png[/URL] | |
Re: [CODE] def remove_first_column(text): splitString = text.split('--') splitString.pop(0) finalString = " -- ".join( [item.strip() for item in splitString]) return finalString def main(): testString = """US --9--15--13--37 GE --10 --13--7--30 CA-- 14 -- 7 -- 5-- 26""" for line in testString.split("\n"): print(remove_first_column(line)) #py2.5 print remove_first_column(line) if __name__ == '__main__': main() [/CODE] Just … | |
Re: [QUOTE=megaflo;1183621]Why? Without knowing the OP use case there may or may not be a reason to store the numbers.[/QUOTE] No, Gribouillis's code is the most efficient. There probably is a need to store the numbers, since his original code was something like [code] firstNumber = int(array[0]) secondNumber = int(array[1]) thirdNumber … | |
Re: I'm not sure, but I think you have to include these: cairo, pango, pangocairo, atk, gobject I was reading that from the code here: [CODE]http://www.py2exe.org/index.cgi/Py2exeAndPyGTK[/CODE] | |
Re: [QUOTE=vegaseat;1182028]Take a look at the approach taken in: [url]http://www.daniweb.com/forums/post1122938.html#post1122938[/url] The word [B]the[/B] will give you a real problem since it can translate to [B]der, die or das[/B] If you use lower case only: the cat --> die katze the dog --> der hund the house --> das haus[/QUOTE] Also [B]den[/B]. … | |
Re: It's even hard to do with Windows native API, and even harder with .NET. So I think it might be possible, but you would have to use lots of ctypes and win32api. I don't think it's worth a try. | |
Re: [QUOTE=vsagarmb;1180309] I start the above thread in another objects constructor and i am trying to call the stopParser() method in the destructor. [/QUOTE] I'm not understanding you there. Why can't you call the stopParser method? | |
Re: Run using a window? As in run with a Graphical User Interface? | |
Re: You can use decorators, or you can use metaclasses to decorate all the methods in a class. Then you can make the decorator modify each function on the fly. | |
Re: [QUOTE=Ronnicus;1176433]Why is the test in the function local? I meant to have it change the one outside, how would I do so without returning the variable?[/QUOTE] You'd do [icode]global test[/icode], which is a bad idea, since it is evidence for bad code structure. Scopes make Python a clean and professional … | |
Re: For such a task, the Python code is easy. The real challenge for you is to find a way to make some sort of English-Spanish dictionary. I would just use a translator tool like Google Translate, and use its API. | |
Re: [QUOTE=vegaseat;1176872][B]Jython[/B] comes to mind. It would allow you to run Python code under Java.[/QUOTE] I was about to say that. Jython is Python for Java, so just download Netbeans and the latest version of Jython, and copy the file over and see if it compiles. I've never worked with Jython, … | |
Re: Well you use a web framework. Django is a good example; it is considered one of the best frameworks for web programming. You can do some research on that. Web2py is also great. | |
Re: [QUOTE=SgtMe;1172242]Nope. In your code, which I copied and pasted in, the line.rstrip("\n") bit was in there already. I use line.strip() but that didn't work...[/QUOTE] line.rstrip() doesn't do anything at all to line it returns a string that is the rstripped version. gotta remember that. use [B]line = [/B]line.rstrip() | |
Re: [QUOTE=pyprog;1172476][CODE]list1 = [[],[],[]] list2 = [[1,2,3],[4,5,6],[7,8,9]] i = 0 j = 0 k = 0 while i < len(list1): list1[i].append(list2[j][k]) i += 1 k += 1[/CODE] I want my output for list1 to be [[1,4,7],[2,5,8],[3,6,9]]. The problem is I don't know how to advance through the lists in list2. Can … | |
Re: I'm not quite understanding the problem here, you have boyle's, charles's, and etc. calculators all written out but you want to combine them so that you can access then all from a single top menu? | |
Re: I guess you can add something like this: (not sure if you are using py2 or 3, this is 3) [CODE] Scores = [] while True: a = int(input("Enter score (0 to stop):")) if not a: break Scores.append(a) [/CODE] I think that should do it. Didn't test it. | |
Re: Can you click the reference and then hit delete? | |
Re: Good luck! OOP to GUI is a very broad range of topics. For OOP, I guess you can learn it from a tutorial, but practicing by writing code really helps to make you a better programmer. For GUI, just find a good toolkit, i.e. wxPython would be a good one. … | |
Re: VB.NET and IronPython can be easily converted to and from eachother because they both run on the CLI. You would use System.Windows.Forms for both in order to make gui, for example. I don't know about just VB. | |
Re: At the for loop, you need to add a [icode]userid = ""[/icode] or a [icode]del userid[/icode] I would do it right after line 8 of your code. | |
Re: If Python is freezing, I suggest you use threading to put the busy work of the program in another thread. Once you solve the freezing problem with threading, I'm sure you can solve the rest. | |
Re: Get SharpDevelop ([URL="http://sharpdevelop.net/"]http://sharpdevelop.net/[/URL]) It'll do that for you. IronPython supports System.Reflection.Emit, and SharpDevelop uses that to create an executable. Of course, you can also use the pyc.py tool included with ipy, but I prefer SharpDevelop. I'm so glad I'm not the only one who uses IronPython. It's awesome isn't it. | |
Re: Try using SendDlgItemMessage [URL="http://msdn.microsoft.com/en-us/library/ms645515(VS.85).aspx"]http://msdn.microsoft.com/en-us/library/ms645515(VS.85).aspx[/URL] |
The End.