- Strength to Increase Rep
- +9
- Strength to Decrease Rep
- -2
- Upvotes Received
- 24
- Posts with Upvotes
- 24
- Upvoting Members
- 18
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
244 Posted Topics
Re: The variable [icode]timesflipped[/icode] used for the while loop is undefined before the comparison [icode]while timesflipped < 100:[/icode]. This script should just return a NameError and not run. Here's a fixed version: [code=python] import random coin_heads, coin_tails, times_flipped = 0, 0, 0 timesflipped = 0 # <-- here's what I added. … | |
![]() | Re: By putting "s = d / t" before the conditionals would only calculate speed - but what happens when you give speed and distance for example? It wouldn't calculate time. You have to put each individual case within the appropriate conditional branch like Lardmeister did. P.S. This kind of program … |
Re: Is there a file in the [I]C:\Python25\Lib\site-packages[/I] folder named [I]mechanize.pth[/I] or a folder named [I]mechanize[/I] in that directory? There should be, and the data in [I]mechanize.pth[/I] should simply say "mechanize" (without the quotes). | |
Re: For Python 2.x: People seem to overlook the usefulness of built-in functions for handling common issues with lists. A lot of times, [ICODE]filter[/ICODE], [ICODE]map[/ICODE], and [ICODE]reduce[/ICODE] can easily and efficiently serve typical purposes that most people attempt without these. Here's an example of their usage (I use lambda expressions in … | |
Re: I don't know if this idea has already been added, but beginners can create an address book. That was the first real project I undertook. Ask the user for: name, address, phone, cell, fax, etc. Then store the data in a .txt file. Let the user search people in the … | |
Re: I'd say split the string into a list and use the filter method: [code=python] file_Name1 = 'abc123de' # store that string as a list of characters L1 = list(file_Name1) # call filter on it using a lambda expression L1 = filter(lambda x: x in '1234567890', L1) # L1 now = … | |
Re: [URL="http://www.youtube.com/watch?v=T5hOzLUa2IM"]Under The Oak[/URL] by [URL="http://en.wikipedia.org/wiki/Candlemass"]Candlemass[/URL] :D | |
Re: Hooray! I got pyHook working with Python 2.6 for Windows. I just downloaded the source and edited a few things, hacked it together and built. As far as I know, it all works with 2.6 :D You'd just need to manually install it to your Python's site-packages directory if you … | |
Re: Firefox 3! I just can't stand IE for the issues I get with it when writing stuff for the web. It always happens that IE buggers up something by implementing it in a non-standard way, which [I]always[/I] complicates things. And for this reason, I shall never show it any love … | |
![]() | Re: If you mean by "Python OS", an operating system that's built purely on Python, then no. As far as I know, that wouldn't work anyway because the interpreter to run Python needs an OS to run on in the first place (?). Correct me if I'm wrong though... And I'm … |
Re: Trainspotting One Flew Over the Cuckoo's Nest A Clockwork Orange A Scanner Darkly Fear and Loathing in Las Vegas | |
I'm not sure if this is the best place to post this, but I've noticed a large request for pyHook for Python 2.6. I had a solution to this in a recent thread [URL="http://www.daniweb.com/forums/thread203368.html"]here[/URL], but people are most likely going to miss that. I built pyHook's source for use with … | |
Re: [QUOTE=serkan sendur;913335]if my best friends dont get featured i am going to organize them to leave for a better c# forum where their skills are appreciated.[/QUOTE] I'm not trying to start slinging shit here, but is this a mutual agreement or are you just putting words into your friends' mouths? … | |
Re: First, your whole_thing variable should be [icode]text_file.read()[/icode] if you want to return all the contents as a string. Or [icode]text_file.readlines()[/icode] if you want to return all the contents as a list of each line. Change this and see if that fixes any problems with your code. I don't fully understand … | |
Hello, I was wondering how to go about having a redirect of stdout with Python take effect in a C extension. My python script redirects sys.stdout into a file handle created with [i]open(...)[/i], but within the function in my compiled C-extension, any output ([i]printf[/i], [i]puts[/i], etc) is still given to … | |
Re: @Aia You just strike me as an extremist for your beliefs (Conservative right?). And I hate extremists because they only lead to problems, such as the ones caused by religious fanatics, or by those who are too damn bull-headed to try to even [I]consider[/I] a different viewpoint. You fall into … | |
Hello! I have a question in regards to [I]malloc[/I]/[I]calloc[/I] and [I]free[/I] in C. What I'm unsure about is the "depth" (for lack of a better word) that [I]free[/I] operates to. I know that sounds strange so let this example hopefully explain what I mean: [code=c] #include <stdlib.h> int main () … | |
Re: And before anybody makes a comment about either the shades or the colourful bedsheets in the background, they are my ex girlfriend's, hence the feminine tinge to them. | |
Re: Hello EAnder - welcome to DaniWeb. I myself only got into Python about a year ago, after deciding to give up on Java and C++; luckily I found that Python is fast, easy, and most importantly, fun. Anyways, to get back on topic, I created the basis for a sort … | |
Re: C++ is among the top of the widely used languages for games. It retains the quick execution speed of C, and brings in much needed and required things such as objects and class inheritance ([URL="http://en.wikipedia.org/wiki/Object-oriented_programming"]OOP[/URL]). Naturally, you'd be using graphics libraries with this, such as OpenGL or DirectX. Possibly even … | |
Hello, I know you probably get quite a few threads asking this, but the DaniWeb search didn't pull up what I was looking for. So here we go: I have a page that I've made as "private" by including my access control script at the top. The access control script … | |
| |
Re: Sneekula's correct. You're storing each item in the [I]inComments[/I] like so: [icode](lineNumber, lineText)[/icode]. So you just need to access the correct index of the tuple, the same way you would access an item in a list (or Array in Java); just use the square brackets to get the value from … | |
Re: Python is a good choice for easy-going desktop application development. Of course, you're going to want to get adjusted to and familiarized with classes, methods/functions, etc. before starting on GUI projects. And for GUIs, I'd still really suggest wxPython over Tkinter. I personally can't stand the non-native look of Tk's … ![]() | |
Re: [QUOTE=Merlin33069;916033]ive looked around for some tutorials and cant find a lot, really all i need is a 2d environment, laid out kind of like a computer desktop, different functionality in different areas of the screen, maybe some layers for different things[/QUOTE] Sorry, what exactly do you mean by this segment? … | |
Hello, I am currently trying to figure out some event stuff with Javascript. I have the page capturing all [I]onkeypress[/I] events by calling my function [I]keyPress[/I], and passing the event as an argument. The key presses get passed to a text field that I have on the page (even if … | |
Re: It would be nice if you explained the code above rather than just plopping it down on the page. | |
For some reason (this hasn't happened to me in the past), any wxPython scripts I package via py2exe crash on my other Windows computer (lacking a Python install). If I try running it on my other machine, I get an error message telling me to look at a log file … | |
Re: I started reading through an article on gamedev about creating a game engine from scratch; a basic game engine, written in C++ and using SDL for the graphics. It's a start, and I think after being able to successfully understand and create one like in this article, you can attempt … | |
Hello, I've just recently tried to make a class template whose constructor should be able to accept a variable amount of arguments of the class passed to the template. I have something like this, with the prototype inside the class definition, and the actual implementation of the constructor defined outside: … | |
Hello, I'm using easyPHP to locally test some scripts I'm building, but I came across a problem that I can't seem to resolve. Within one of my PHP scripts, there's a segment where I end the PHP ([icode]?>[/icode]) and output a form in HTML, then resume the PHP section ([icode]<?php[/icode]). … | |
Re: Well if you install it manually, you need to put it into the C:\Python2[I]X[/I]\Lib\site-packages directory in its own folder. Then in that site-packages folder, make a file called [I]chilkat.pth[/I], and in it, write only [I]chilkat[/I] (which is the name of the folder for it in the site-packages directory). Hopefully after … | |
Re: Judging by your first post, when you said "link it to another ..." did you mean pass the values and variables from the first function to the second one? If you specify what this "previous issue" is that you're trying to fix we can help you out better :P | |
Re: If you don't mind as much about memory usage, you could use [code=python] if number in range(10, 24): # careful! # This gives a range of 10 - 23. # The end index (24) isn't included in it. if number in xrange(10, 24): # The xrange doesn't load the range … | |
Re: Like Hiroshe said, learning a programming language depends on what you're trying to use it for. Different ones are suited for different things. They also all have pros and cons so you'll most likely be using a variety of languages. Although, there are general theory aspects that you can usually … | |
Re: [QUOTE=sleign;934078]The armRight variable is declared and assigned to True before it is called for anything.[/QUOTE] I'm quite sleepy, so excuse me if I'm way off here, but is [I]armRight[/I] declared within the global scope of the script? If so, then you need to state [icode]global armRight[/icode] within your function so … | |
Re: I could give you a full example written for wxPython, but not for Tkinter, sorry :P But regardless, you'll probably need to use threading for this, as your program will stall until the zip command is complete (I think?...) before continuing along with the rest of the script. If that … | |
Re: Flash can take command-line arguments. So you can do [icode]os.system("flash.exe myFileToOpen.fla")[/icode]. That'll open Flash and have it open the document "myFileToOpen.fla". If the FLA is in a different directory however, you'll need to give the path in front of the filename in the command line argument. It can be relative … ![]() | |
Re: You're a new programmer, yet wanting to create a game engine already? And a networked game too... wow. I assume you have a server set-up for the online transactions; or will you be converting a good computer you have sitting around at your home already? And that you'll be writing … | |
Re: You should add an else statement at the end of the checking, so that if I enter anything other than 1 to 4, it'll tell me I gave bad input and then it'll let me re-enter until it's correct. Also, you can rewrite your [I]if[/I] statements because they use a … | |
![]() | Re: Bumsfeld is putting you on the right track. I'll say not to convert the raw_input to an integer like you're doing now, so that you can cycle through each character in it as a string. Then just make sure to convert to integers at the right times (i.e. when adding … |
Re: I have some really bad ones (and consequently, the funniest) which I don't even think are appropriate to share here... told to me by none other than my uncle haha. I just don't want to get in trouble for posting them, but at the moment they're all I can think … | |
Re: Um... you provided absolutely no information. So as of right now, I can't answer your question. What are you using as a 2D engine for Python? etc. | |
Hello. I haven't ever needed to bother trying to do things to the console such as clearing one line, changing colours, etc. But now I was wondering if there is a (preferably built-in) cross-platform way of clearing just the current line in the console. I have a program which does … | |
![]() | Re: As far as I know you'll have to set up your server for this to work. It's not going to happen client-side, for security reasons AND because the client would need Python installed AND because web-browsers don't execute python code in them. If you customize the server I'm sure you … ![]() |
Re: From what I can tell, you don't have a main-scope variable named [icode]car_list[/icode] within the [I]car_list[/I] module. You sure it isn't a simple mistake like that? | |
Re: If you want to use Blender for your 3D stuff, that's an option as it's open-source, very advanced, [B]supports Python integration[/B], and [B]has a game-engine built-in[/B]. This means that you can control your models and such if you integrate in Python scripts for it, or you could go with the … | |
Re: I can tell you've come from C++. You're making things much harder than they need be. Python has such a simple syntax, yet you're clogging it up by doing things similar to how you would in C++. [B]For #1[/B], in C++ you couldn't just write Candidate[20] anyways because that doesn't … | |
Re: [QUOTE=vegaseat;930339]Or mildly more elegant ...[/QUOTE] In that case, you could just use [I]filter[/I] with a lambda expression :P [code=python] mylist = ['apple','orange','mango','pear','strawberry'] target = 'pear' newlist = filter(lambda x: x == target, mylist) # or ... multiple targets mylist = ['apple','orange','mango','pear','strawberry'] targets = ['pear', 'apple'] newlist = filter(lambda x: x … | |
Re: [QUOTE=jhoms;927887]i make a game with the use of flash but i want ti make more interactive what will i do,can you offer me or send codes to make the game more interactive[/QUOTE] Ahaha! It's called reading up on the subject and understanding what it is you're actually doing. I can't … |
The End.