|
Mido posted:Django!! Django.
|
# ? Jun 18, 2010 14:43 |
|
|
# ? May 11, 2024 13:15 |
|
Thermopyle posted:I hate web design with a passion. Everyone posted:Django I'm not sure this is the right answer. He said he hates web design. Django doesn't remove any web design...you still have to write all the HTML and CSS yourself; the templating just makes it easier. If you don't want to touch HTML, I think you'd want something higher level. I'm not sure what that is, but I'd be very surprised if there wasn't some framework for making CRUD apps without HTML.
|
# ? Jun 18, 2010 15:07 |
|
Stabby McDamage posted:I'm not sure this is the right answer. He said he hates web design. Django doesn't remove any web design...you still have to write all the HTML and CSS yourself; the templating just makes it easier. Thermopyle posted:Something useful for getting input from a user via forms or whatever web magic is possible and displaying results to them. That says to me he's doing the usual conflation of "web design" with "web development" and doesn't actually mean the visual design aspect of things. So he probably does want Django Regarding the HTML/CSS crap one does have to deal with either way, something like Blueprint CSS can help make a simple site look significantly better than CSS-less HTML will, with almost no work necessary. Certainly from a typography and layout perspective.
|
# ? Jun 18, 2010 15:18 |
|
Having done quite a bit of Django recently, I do not understand the appeal at all. In fact, I hate it. Among my many complaints:
Use TurboGears. It does a lot more work for you. MaberMK fucked around with this message at 17:19 on Jun 18, 2010 |
# ? Jun 18, 2010 17:15 |
|
I'm sorry, was that a list of complaints, or a list of the best features of Django?
|
# ? Jun 18, 2010 17:35 |
|
Stabby McDamage posted:If you don't want to touch HTML, I think you'd want something higher level. I'm not sure what that is, but I'd be very surprised if there wasn't some framework for making CRUD apps without HTML. This is more along the lines of what I'm looking for. In my ideal world, I'm looking for "print" and "raw_input" for the web. bitprophet posted:That says to me he's doing the usual conflation of "web design" with "web development" and doesn't actually mean the visual design aspect of things. I don't want to do web development or design. If that's not possible, then I'm looking for the thing that gets me the closest.
|
# ? Jun 18, 2010 18:15 |
|
This is really pissing me off, I will only post the parts of the code I feel are relevant to the problem, but let me know if you need to see more. I have:code:
|
# ? Jun 18, 2010 22:28 |
|
You need another ) at the end of the first (and second) print lines.
|
# ? Jun 18, 2010 22:30 |
|
Thanks, I got rid of all my syntax error but now I can't get it to run. code:
angel opportunity fucked around with this message at 23:43 on Jun 18, 2010 |
# ? Jun 18, 2010 23:41 |
|
uh, don't you have to call a method in Round(), with P1Round() instead of P1Round? edit: you're not assigning the values properly in Round() at all, how does it know what P1Action is?
|
# ? Jun 18, 2010 23:53 |
|
Sorry, I've only been learning Python for a few days. I'm reading tutorials on localscope/namespaces etc. and I'm trying to figure out how to apply this to Round(). I'm not sure how to apply what you just said, do I need to put parameters into Round() and P1Turn(), if so which ones?
|
# ? Jun 19, 2010 01:33 |
|
systran posted:Sorry, I've only been learning Python for a few days. I'm reading tutorials on localscope/namespaces etc. and I'm trying to figure out how to apply this to Round(). I'm not sure how to apply what you just said, do I need to put parameters into Round() and P1Turn(), if so which ones? I believe he's saying that here: quote:def Round(): You want "P1Turn()" not "P1Turn"
|
# ? Jun 19, 2010 01:42 |
|
Thanks guys.. I tried everything you were saying and it still wasn't working, then I noticed my attempt to execute "Round" was written as "Round" instead of "Round()"
|
# ? Jun 19, 2010 02:22 |
|
king_kilr posted:I'm sorry, was that a list of complaints, or a list of the best features of Django? Seconding this. I do not like the routing stuff, and I despise templates (meaning, code in HTML) that evaluates real, unrestricted python. Everything you listed, modulo the ORM (which I am completely ambivalent about), seems like a feature.
|
# ? Jun 19, 2010 02:42 |
|
systran posted:Thanks guys.. I tried everything you were saying and it still wasn't working, then I noticed my attempt to execute "Round" was written as "Round" instead of "Round()" You're trying to return a value I presume, but that's not what's happening here: code:
|
# ? Jun 19, 2010 03:43 |
|
I finished the program finally after going through a lot of bugs. This was the first program I ever did, and I (obviously) am having a lot of trouble with namespaces. The original way I planned out the program was to define a lot of functions ahead of time and then execute them on the global scope. The problem I kept running into was that I wanted the players' health to be accessible and modifiable; I couldn't figure out how to do this unless I just made everything inside Round(). My original program (that didn't work) had a bunch of functions defined ahead of time and then I called on them as needed. My final product threw everything into Round(). The game was basically a complicated Rock/Paper/Scissors style thing: There were four choices and you rolled dice. I had it where if you did "attack" and rolled an 11 or 12 you knocked the other player down. This resulted in the other player having very limited/poor options while you had several good options. I tried to just define a function P1Knockdown() and P2Knockdown(), then basically code:
|
# ? Jun 19, 2010 06:05 |
|
Read about the global keyword
|
# ? Jun 19, 2010 06:30 |
|
Lonely Wolf posted:Read about the global keyword Better yet, don't, and just learn proper OO practices instead.
|
# ? Jun 19, 2010 19:02 |
|
Teaching OO anything to someone at that level is useless at best and destructive at worst. Let him get to the point where he has a program that could benefit from OO, not just scream BEST PRACTICE! and make him throw a bunch of stuff that makes no sense in his program.
|
# ? Jun 19, 2010 19:49 |
|
I disagree completely. What you learn first is inevitably going to be what you are most comfortable with and using globals all over the place without an appreciation for why its generally a bad idea is likely to instill bad habits in you. It's not like I'm nitpicking about best practices, or even saying OO is necessary for small programs. It would be perfectly acceptable to use standard types like ints and strings rather than touching the class system, so long as you simply pass them around explicitly and learn not to rely on the global keyword. I'm just saying that establishing a good foundation will pay off in the long run. systran mentioned that one of their goals was to be able to access/manipulate the values of each players life. While its technically possible to do this by writing procedural code and using global variables, it will probably end up being making for more work in the long run as soon as the complexity of your game rises past the bare minimum. To systran: Functions which don't have a "return" or "yield" keyword somewhere in their body will return None. If you want to set the value of a variable to the result of a function, you have to return that value in the function. Also, you should try to avoid the "input" function as it evals the data it receives. Instead, get in the habit of using "raw_input", and explicitly try to parse the data. Finally, rather than copy-pasting player1's code and changing the 1 to a 2, try using generalized functions. code:
|
# ? Jun 19, 2010 20:16 |
|
Lonely Wolf posted:Teaching OO anything to someone at that level is useless at best and destructive at worst. Let him get to the point where he has a program that could benefit from OO, not just scream BEST PRACTICE! and make him throw a bunch of stuff that makes no sense in his program. So the solution is to get them using obscene hacks like globals() instead?
|
# ? Jun 19, 2010 21:23 |
|
global not globals() Having a few global variables in an incredibly small program that runs once and then dies is hardly a hack. Better ways to structure code can be explored after he has the satisfaction of getting something working, but baby steps. Systran, get something to work. Let it be ugly. When you're sure it works, figure out ways to clean it up and keep asking questions.
|
# ? Jun 19, 2010 21:41 |
|
Is it possible to do:code:
|
# ? Jun 20, 2010 06:53 |
|
Uhh, you mean:code:
|
# ? Jun 20, 2010 06:58 |
|
^ Thanks. I know that there is a hex(number) command in python to convert and integer into its hexadecimal representation. Is there a method that does this but converts the number into its binary representation?
|
# ? Jun 20, 2010 08:43 |
|
In python 3 bin(number) or bin(number)[2:] if you do not want 0b in front of it. In older versions the python wiki suggests: code:
RichardA fucked around with this message at 09:58 on Jun 20, 2010 |
# ? Jun 20, 2010 09:53 |
|
RichardA posted:In python 3 bin(number) or bin(number)[2:] if you do not want 0b in front of it.
|
# ? Jun 20, 2010 10:38 |
|
Thanks, just what I needed.
|
# ? Jun 20, 2010 10:41 |
|
rawstorm posted:Thanks, just what I needed. Also, int(string, base) will let you convert back to an integer, e.g. int('101001', 2).
|
# ? Jun 20, 2010 11:15 |
|
Thanks guys, I did get the program to work without using global or without using return. I guess it's good to know that global exists, but I'm going to end up using this program as the combat engine to a much larger program, so I'm guessing I'll want to avoid it. Thanks for the suggestion to not copy/paste and change the numbers, as I was doing that I knew it wasn't the most efficient method, I've been understanding parameters better lately and will incorporate that into my next revision. If I want to work on making an isometric grid should I use pygame?
|
# ? Jun 20, 2010 19:17 |
|
tripwire posted:I disagree completely. What you learn first is inevitably going to be what you are most comfortable with and using globals all over the place without an appreciation for why its generally a bad idea is likely to instill bad habits in you. Completely agree with this. I am still waiting on an acceptable reason to use global variables.
|
# ? Jun 20, 2010 20:43 |
|
Are you familiar with singletons? Those are just globals in disguise
|
# ? Jun 20, 2010 21:07 |
|
Otto Skorzeny posted:Are you familiar with singletons? Those are just globals in disguise Although a singleton is a safer and more OO approach to a global variable, I still feel that there are very few situations that would warrant the use of either of these. Its just that I have yet to run into a situation where I can't refactor my code to avoid using globals. Conversely, I have run into many headaches when dealing with others' code that relies upon globals.
|
# ? Jun 20, 2010 21:24 |
|
Modern Pragmatist posted:Although a singleton is a safer and more OO approach to a global variable, I still feel that there are very few situations that would warrant the use of either of these. While a singleton is certainly more OO it is not inherently more or less safe. It's the same thing with a different name. I gave a use for globals: short programs that run one and then quit, which I had thought systran's code was. You can certainly refactor globals away. The question is, is it worth the added complexity? On the other hand, globals are like gotos. Generally to be avoided but if it's simpler to use it, use it. Furthermore, in the context of someone new to programming, refactoring code and data flows to avoid global state is hardly justifiable. If you show them how to do it without showing them why or letting them learn why, then you get a coder who codes by dogma not experience and reason. The reason code with gotos and globals get a bad rap is because most of it is written by people who leap to them unreflexively without weighing the consequences or alternatives first. But bad code is bad code. That doesn't mean that the ingridients of bad code are themselves inherently bad. Bad code has plenty of if statements as well, after all.
|
# ? Jun 20, 2010 21:46 |
|
I have a program that has around 10-15 modules, and I want most of them to have access to command line options. I ended up having a global singleton instance of the (subclassed) OptionsParser that everything just imported. I don't know if it's a good use-case for that kind of thing, but I tried setting up a whole bunch of __init__ statements passing in an OptionsParser instance, and it sucked.
|
# ? Jun 20, 2010 22:16 |
|
Nevermind, fixed the problem
angel opportunity fucked around with this message at 05:02 on Jun 21, 2010 |
# ? Jun 21, 2010 04:20 |
|
Lurchington posted:I have a program that has around 10-15 modules, and I want most of them to have access to command line options. I ended up having a global singleton instance of the (subclassed) OptionsParser that everything just imported. Could you not, as part of __init__, pass sys.argv into each module's OptionParser?
|
# ? Jun 21, 2010 04:43 |
|
Captain Capacitor posted:Could you not, as part of __init__, pass sys.argv into each module's OptionParser? That's an alternative, and assuming you mean each module has an OptionParser with only the options relevant to it, wouldn't that wreck output on -h/--help at my program's point of entry? If each module has its very own instance of the exact same OptionParser, then I didn't necessarily see how it was better unless I was slavishly "NO GLOBALS OR SINGLETONS"
|
# ? Jun 21, 2010 13:49 |
|
Lurchington posted:That's an alternative, and assuming you mean each module has an OptionParser with only the options relevant to it, wouldn't that wreck output on -h/--help at my program's point of entry? I'm not entirely familiar with the structure of your app, but if each sub module maintained its own Parser, the parent package could combine all of the options into one big OptionParser object. Or, you could do like what some other projects do, have a specific "help" command that spits out the options for a module.
|
# ? Jun 22, 2010 05:02 |
|
|
# ? May 11, 2024 13:15 |
|
sometimes i use a global variable for a database connection yet to suffer any material downsides to it
|
# ? Jun 22, 2010 15:56 |