Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Allie
Jan 17, 2004

dougdrums posted:

So I was :420: (not now, earlier) and programming and thinking about the finally statement. Is there any god drat reason for the finally statement? The only situation I see using finally in is if I didn't want to put a catch statement after a try which is a horrible practice anyways. And even if I did want to do that, couldn't I just use catch { } instead?

Sorry if I'm retarded and there actually is a good use for finally and I just never figured it out.

Edit: C#.

It's used in Python for the same reasons other people stated:
code:
f = open('/dev/null')
try:
    # do some stuff
finally:
    f.close()
The finally block is always executed, regardless of where execution stopped in the try block (due to an exception, or returning).

Newer versions of Python have a nicer syntax for that:
code:
with open('/dev/null') as f:
    # do some stuff
No need for the explicitly finally/close, the with statement sets it up so f.__exit__ is always called, which simply calls close() (and this __enter__/__exit__ protocol can be adapted to other kinds of classes, like database cursors, thread locks, etc.)

Adbot
ADBOT LOVES YOU

Allie
Jan 17, 2004

I normally run "sudo python setup.py install" when I install Mercurial. I don't know if the Makefile differs, but the local site-packages directory is in /Library/Python/2.5/site-packages/ on 10.5, and I believe it lives inside the Python.framework folder on 2.4.

Allie
Jan 17, 2004

outlier posted:

Maybe this is less of a programming question and more of a programming tool or programmer question but: can anyone suggest alternatives to Trac?

We're a small bioinformatics lab, rolling our own software and libraries for use by ourselves and sometimes other people. For a while, I've felt that we should be more disciplined about our code and knowledge: have all the code committed to central repositories and backed, have a single place for logging issues, writing down common knowledge and going to for downloading the latest version of our releases. Trac seemed to be the obvious choice - everyone uses it - and I delegated the job to one of my colleagues. However, he's been having terrible problems getting it configured, stumbling over one problem after another and has been roadblocked for a week trying to get it to talk to the database. (The db is running, the connection details are correct, but Trac just keeps reporting that it is unable to connect.) From mailing lists and googling, it looks like our experience isn't uncommon.

Naturally, I wonder what the alternatives are. Any suggestions? For what it's worth, we mainly work in Python, with some Javascript and Java sidelines.

Trac's pretty amazing, I can't imagine why you'd want to throw away such a great piece of software. Are you trying to use MySQL or PostgreSQL with it? It's really meant to be used with SQLite, and there really isn't any good reason not to use SQLite, and that's painless to set up.

If you are using SQLite, make sure the user running Trac has read/write permissions to the Trac instance folder and the database file. Beyond that, there isn't really much that could go wrong with the database.

Allie
Jan 17, 2004

JoeNotCharles posted:

Absolutely - both wxPython and PyQT are fantastic GUI frameworks (I prefer PyQT). Google will find you lots of good stuff.

Have you implemented any applications that bundle either framework? I downloaded wxPython's OS X framework and the disk image is around 33 MB. I don't know what that says about how much space it occupies in frozen form, but it definitely turned me off to messing around with it initially. I'd be curious to see if PyQt is any easier or harder to bundle with a frozen Python application.

Allie
Jan 17, 2004

jonnii posted:

I've monkeyed around with the repository uri and nothing i try seems to work. pumpqin.com is in the hosts file pointing to 127.0.0.1. Any ideas?

A lot of programs don't support specifying SSH port numbers, and I don't think OpenSSH even supports it that way (it has a command line flag for it).

I usually just sidestep the issue entirely and add a Host entry to my SSH config. You'll need the config wherever you're running ssh or ssh-based utilities (it sounds like you'll need it on more than one machine in this case).

Add something like this to ~/.ssh/config:
code:
Host pumpqin
HostName pumpqin.com
Port 1337
Now you should be able to just use "pumpqin" as the host name with ssh-based utilities. So the path in your case would be "ssh://pumpqin/home/jonnii/apps/ae.git".

Allie
Jan 17, 2004

checkeredshawn posted:

The files are stored in an array in the script, and I'd like to diff all of them to see if any of the results differ, and then output which DNS servers gave different results.

Just choose one file as a base file and diff each of the other files against the base one individually. This will tell you if there any overall differences, but I'm not sure what you're actually trying to accomplish here. If you're trying to verify that your DNS records haven't changed, it might be better to actually compare the results against known good output (which would then be your base file).

As far as how that would look in bash, I'd use a for loop to iterate over the array (excluding the base file) and run diff -q on each file against the base file. You could build up results in a temporary file/buffer, or just have the program exit when when one of the diffs returns any output.

Allie
Jan 17, 2004

Plastic Jesus posted:

I meant that there's no reason to use anything other than Terminal.app

Terminal.app doesn't do mouse reporting, which is definitely a huge reason not to use it. It's also pretty spartan feature-wise. The only thing it has going over the only other native terminal emulator, iTerm, is that it's much faster and less buggy. It really is a matter of preference. Terminal.app isn't leagues ahead of everything else or anything like that.

Allie
Jan 17, 2004

You can use TerminalColours to customize the color scheme.

If you want mouse reporting, I'm working on MouseTerm which implements it for Terminal.app. So far it only does mouse wheel scrolling, but it does simulated scrolling in fullscreen applications as well (like gnome-terminal).

Adbot
ADBOT LOVES YOU

Allie
Jan 17, 2004

The objects aren't being "swapped", you're just changing what objects the names a, b, c, and d refer to. If you use a temporary variable for whatever reason, you're just creating an extra reference, not a copy of the object.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply