761 Posted Topics
Re: The problem is all those int casts: casting a fraction between 0 and 1 to int results in a zero. Here's a slightly modified program that makes that change as well as hoisting some of the code out of the 'beer' block. I really don't understand what all the arithmetic … | |
Re: You should avoid changing things in the course of the os.walk() call, as it stores information before it descends, and if you rename, you screw up the state. Instead, I'd use some kind of data structure to stash needed changes, then after returning from os.walk(), I'd do the renaming work. … | |
Re: tar -c will not accept input from stdin, so your [icode] ... | tar <args> [/icode] cannot succeed. Think about these options: 1: Do you really need tar format for a single file? Why? 2: Do this in two steps: First dump the data, then zip or tar zip the … | |
Re: Firefox doesn't guarantee a command line interface, though by tradition, several options have been available and are likely to continue so. Among other things, Firefox's configuration may modify how new views are displayed (tabbed or windowed). I might prefer to create a simple HTML page that has links to the … | |
Re: branching is just 'which part of the program runs next'. Branches in python are mostly made using 'if', 'elif' and 'else', so for example [code] a = 10 if a < 5: print 'this branch handles case where a < 5' elif a < 10: print 'this branch handles case … | |
Re: The stated problem is that [icode] if [ $x = 'something' ] [/icode] will fail if $x is the empty string. Protect it with double-quotes: [icode] if [ "$x" = 'something' ] [/icode] ; or (old fashioned hack) append some prefix to both sides: [icode] if [ _$x = '_something' … | |
I'm re-designing a database that will facilitate registration at various events. One column in the event_person table describes the current status of the registrant. The forces that apply here are: - Various events may have different sets of status values - We may ship this as a framework to various … | |
Re: [QUOTE=andydeans;1194099]Hi, Fairly new to MYSQL, still learning. I have create basic web databases before but the project i am working on just now is slightly more complex than before and need some advice. i have had some help with queries which has been great however i need some advice from … | |
Re: Check out [url]http://www.ietf.org/rfc/rfc2446.txt[/url] to make sure you aren't forgetting some aspect of what your calendar application will need. | |
Re: Yeah. Programmers write programs. Newbies modify programs. Students write snippets. I'm feeling bored, so I wrote this snippet. I use bash. If you use ksh, change all the [icode] [ ... ] [/icode] to [icode] [[ ... ]] [/icode], and see what happens. You may also need to declare local … | |
Re: Nicer, in my opinion is this (which is basically the same as tonyjv's code). I have added the possibility to parse dates with various separators, and made the code a little more self-documenting. I have not protected against alternate input date formats. [code=python] import datetime import re datesep = re.compile('[/.-]') … |
The End.