244 Posted Topics
Re: Because your temporary list is the same thing as your other list. You said [icode]temp_list1 = list1[/icode]. This means that the value for temp_list1 will be the same address in memory as the value for list1, i.e. they reference the same thing. Modifying one modifies the other because they are … | |
Re: There are [I]plenty[/I] of things you could have easily found through Google. You're just showing absolutely no effort on your part. | |
Re: Please take Ancient Dragon's advice. If you don't even know how to compile and run a C++ program, you obviously shouldn't be working on a game. Look up tutorials and books on the language so that you can actually get an understanding of how it all works, then practice. And … | |
![]() | Re: Also, please put your code in [noparse][code][/code][/noparse] tags next time so that the indentation is kept, as it's a crucial part of Python. Other than that, I'm still confused what you are having a problem with. Maybe the removing of the number from the whole square has to do with … ![]() |
Re: And make sure that your file isn't some huge size that you shouldn't be loading into memory all at once. You can just go through the lines with the [icode]xreadlines()[/icode] iterator instead. [code=python] # this requires the output file to already exist and it should be # blank, as opening … | |
Re: Before trying to create a game, try learning a programming language first so that you understand how it works and you've grasped the basics. If you want games anyway, I'd suggest C++, but for simple 2D stuff you can use Python + pygame. @Salem Thank you for posting that link … | |
![]() | Re: As for making the keylogger, you may want to have a look at [URL="http://pyhook.wiki.sourceforge.net/"]pyhook[/URL], which can capture all keyboard events and mouse clicks in Windows (so even when your program's window isn't in focus). Definitely a useful thing to have access to for your purposes. |
Re: You will have to make separate executables for Windows and Linux too. | |
Re: You may also want to look into unwrapping, like this example: [code=python] coords = [14, 16, 4] x, y, z = coords """result --> x = 14 y = 16 z = 4 """ [/code] | |
Re: Well first of all, you don't need to make an [icode]enumerate_list[/icode] class as there's already the built-in one [icode]enumerate[/icode] which you can use on lists, strings, tuples, etc. Meaning that you could use this instead: [code=python] for i, ch in enumerate(xStr): xDict[i] = ch [/code] Also, don't use [icode]str[/icode] as … | |
Re: And as a side note, you shouldn't be using [icode]stdio.h[/icode] or [icode]stdlib.h[/icode] as those aren't standard C++ headers. Use [icode]cstdio[/icode] and [icode]cstdlib[/icode] which [I]are[/I] the standard C++ headers. And as u8sand said, you're only executing things through once. Loop until the game is over, then ask to if the player … | |
Re: [QUOTE=vegaseat;907717]Better test it, that won't work![/QUOTE] Why not? It worked for me when I tested his code... and there's nothing wrong with his binding as I added another menu item with a separate function and ID and that still worked without conflict. | |
Re: What operating system are you using? If MS Windows, you can use [icode]os.system('cls')[/icode] to clear the console window before reprinting the progress display. Yes, yes, I know that clearing the screen isn't good because a) this won't work on Mac or GNU/Linux, b) it may cause users to lose any … | |
Re: I'd definitely suggest going with G++. MinGW is the port of that for Windows. And as Ancient Dragon said, please don't go for DevC++. That died back in 2005 and so it hasn't been updated since. | |
Re: Yep, no errors whatsoever with my Python 2.5.4 installation either... | |
Re: Adam's Crunchy is by far the best. You can't beat it. | |
Re: @XTRobot I know your problem's solved, but I thought I felt like saying that I'd advise against using DevC++. I used to use it, but it's been dead since 2005, so I'd use something like GCC or CodeBlocks now to keep the compiler up to date. | |
Re: When you generate an .exe with py2exe it also makes other files that I think the .exe is dependent on. Like some .pyd files and such. Well, all the .exes I generated with py2exe did that for me, at least. I may have been doing something wrong though, as I … | |
Re: It seems you are just laying down a flat-out request for us to code you something. Not gonna happen. Post the code you have come up with so far and where you got stuck, etc. and I'll try helping from there. | |
Re: You don't really need to be using regular expressions on something this simple though... | |
Re: By the way, please use code tags around your code instead of typing "Code" and "end of code". Anyways, I don't see what your problem is exactly. Don't you just need to actually code in whatever you want performed into the final function and you're all set? | |
Re: If by each "word", you mean strictly at every space, then you could read the file line by line, and perform this on every line: [code=python] fh = open('filename', 'r') for line in fh.readlines(): # use 'xreadlines()' if the file is large and you just want an iterator words = … | |
Re: Alas, "shadwickman" was too long for it so I had to settle to just "shadwick". S.H.A.D.W.I.C.K.: Synthetic Handcrafted Android Designed for Worldwide Infiltration and Ceaseless Killing It gives the same for the "C.K." as you. | |
Re: Well, seeing as you didn't read [this simple post](http://www.daniweb.com/forums/announcement114-3.html) about using code tags, your Python has no indentation. Brilliant. I'm not going to try to fix your code's indentation so that I can begin to help with your problem. If you can post it with those helpful tags around it, … | |
Re: Yield is for generator functions. Return ends the function and sends back the specified value. Generators are functions that return iterators, i.e. they 'yield' a value after each iteration of them, before proceeding to the next one. This is generally used for things where you don't need all the results … | |
Re: You can try the built-in [icode]filter[/icode] function. Here's what I tried in the interpreter: [code=python] >>> a = [ 'filter', 'lol', 'filter', 'lol', 'lol', 'filter', 'lol' ] >>> b = ['filter'] >>> c = filter(lambda x: if x in b, a) >>> c ['filter', 'filter', 'filter'] [/code] As you can … | |
Re: [QUOTE=funfullson;902044]Sorry I think it will overwrite on print when its its callers prameters be like its own.or else print will call. Is it true?[/QUOTE] I believe you're thinking of overloading a function, like in C++. Python doesn't have that capability. | |
Re: Well, there is no return statement at all in that function... so it would return <i>None</i>. | |
![]() | Re: sraven, this only works when the command prompt window is in focus. If you're trying to capture all input for other applications too, then you'll need to use pyHook or be able to expand on sneekula's getch() example, but I'm not sure how to make that grab key presses with … |
Re: PLEASE! Use code tags! If you look at your post, you realize your Python code has no indentation anymore, and indentation is a crucial part of Python. I'm not going to bother looking through your code until you edit that post and put your code in those tags to preserve … | |
Re: If you look at this forum, there is a permanent thread called "Projects for the Beginner". See [URL="http://www.daniweb.com/forums/thread32007.html"]here[/URL]. It has a huge amount of projects/ideas in it, so you can start looking through it for stuff to do. | |
Re: Doesn't the windows installer come with it? EDIT: for Ubuntu, it should be [icode]sudo apt-get install idle-python3.0[/icode] | |
Re: Can you post some of your code? I'm confused as to why you need to hold so many files open at one time... could you just cycle them one by one and not have them all open? | |
Re: As a side note, "super" is a reserved keyword in Python already, and you named your script that. It shouldn't cause this problem at all but in the future it might raise some sort of issue if you expand on this. As for the current situation, what was the value … | |
Re: Because when you read lines from a file, a string is returned. Your data[3] is "0833.6323" (as a string). You can just convert it to a float first before the calculation like this: [icode]latitude=str(float(data[3])/100.0)[/icode] EDIT: I noticed you signed your post "sraven". You already have an account here (under that … | |
Re: I think you can have it pass the command to the computer via the [icode]os[/icode] module. Like for Debian-based GNU/Linux distros you could write: [code=python] import os os.system("halt") [/code] The only problem I can think of is that this would require super-user privileges to execute the shut down. With Windows, … | |
If anyone is still interested in those old, nostalgic text-based games to run in the console, there's Python Universe Builder by Joe Strout. Yes, it's a dead project as the last release dates back to 2006, but it still works fine if anyone is interested. On the [URL="http://py-universe.sourceforge.net/"]Sourceforge page for … | |
Re: Got it :D [code=python] data = [['4/18/94', '29.125', '442.46'], ['4/19/94', '29.336', '442.54'], ['1/20/04', '75.175', '1138.77'], ['1/21/04', '75.711', '1147.62'], ['1/22/04', '75.595', '1143.94']] result = [] for item in data: # current middle index as a float n = float(item[1]) # if there are no items in the result list yet if … | |
![]() | Re: Threading is for running multiple things at once. Such as having a thread run to update a GUI while another performs some sort of data manipulation. So, threading is much different than what you're after. ![]() |
Re: As for a regular application, I'd go with [URL="http://wxpython.org/"]wxPython[/URL] for sure. Best GUI toolkit I've used for Python (I can't stand Tkinter at all). If you want to make it more graphics-rich and not look like a regular program, you can try [URL="http://www.pygame.org/news.html"]pygame[/URL], but that might be a bit difficult … | |
Re: Expanding even further: [code=python] import random mini = 1 # min. number of tuple indices maxi = 5 # max. number of tuple indices low = 1 # low-end of range of number high = 9 # high-end of range of number result = [] for j in range(10): current … | |
Re: Just store your data in one file for each map, simple solution. Each row is a row in the map, and each value between commas in a column: [code] 1,5,6,3,5 4,8,9,6,4 2,4,6,7,6 0,0,1,3,2 5,7,4,2,1 [/code] That could be a 5 x 5 map. Then just read the file and split … | |
Re: Yeah, HTML can't do anything like that on its own, it's just a mark-up language. If you want to develop text-based games first, and have no prior programming experience, I'd suggest [URL="http://python.org/"]Python[/URL]. The syntax is simple and understandable. The one thing is that the recipient's computer needs Python installed on … | |
Re: If you haven't done programming/development before, please, for the love of god, do not start trying to make 3D games. You need to learn the basic concepts first, then work your way up. And I wouldn't suggest Java for 3D games anyway. C++ would be your best bet. If you … | |
Re: If you want a copy of the sorted object, instead of directly modifying the object itself, use the built-in "sorted" function. [code=python] >>> L = ['z', 'aa', 'g', 'ab', 'yz'] >>> Ls = sorted(L) >>> Ls # returned copy ['aa', 'ab', 'g', 'yz', 'z'] >>> L # original stays the … | |
Re: Please, edit your above post and put whatever is Python code inside tags like this: [B][noparse][code=python] CODE GOES HERE [/code][/noparse][/B] Indenting is essential to Python, so your code needs to retain it in the post. | |
Re: I'm curious why you have the lines [code]length_of_buy_list = [] length_of_sell_list = [] ... length_of_buy_list = len(BuyList) length_of_sell_list = len(SellList)[/code] You declared them as empty lists, then changed them to an integer of the list length... And also, you store these lengths at the beginning but you don't change them … | |
Re: Your "items" dictionary doesn't have a key named "o" which apparently you are trying to locate. The line [icode]if p.weapon == items[sitem[1]][/icode] is basically equating to [icode]if p.weapon == items["o"][/icode]. That seems to not be in the chunk of "relevant code" that you posted, but even so, the code you … | |
Re: Well, if you ran what you posted, nothing will happen. You defined these functions and classes but you haven't actually done anything with them. None of these get called during the execution of the script. | |
Re: I haven't done this in forever, and I'm not on a linux machine at the moment, but I'll try to say what I remembered doing :P If you originally installed it using "sudo apt-get install ...." then you may have not installed any other packages it requires to run. I … |
The End.