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.
 
  • Locked thread
dorkanoid
Dec 21, 2004

Mr. Heavy posted:

Is there any really good standard library reference for Python? Compared to Ruby, the official documentation absolutely sucks, and it's really frustrating me because I absolutely adore the Pylons framework and then doing more menial Python stuff in the framework is comparatively painful.

I you're using Windows, pywin32 includes a nice .chm of the official documentation, with the usual fast keyword searching of a Windows help file.

Adbot
ADBOT LOVES YOU

dorkanoid
Dec 21, 2004

I have a system at work where I run about 10 processes in the background using pythonw.exe - this is a bit tricky if I want to kill a specific process from the task manager, since they are all listed as, well, "pythonw.exe"

Anybody know if there's a way of "renaming" the python interpreter short of renaming the .exe/compiling with py2exe so that it's easier to kill? My current solution involves adding a XMLRPC interface to all of the processes, which kind-of solves the killing problem (unless it's stopped responding totally), but still makes it hard to see which of the processes is the one taking up 99% CPU :(

dorkanoid
Dec 21, 2004

pokeyman posted:

Having been turned on to Pygame in this thread and elsewhere, I've decided I really want to make a version of the board game Acquire.

Before I even start, I'm wondering what I can do with my game if I make it using Pygame. Ideally I'd like to wrap it up into an installer/app for Windows/Mac/*nix/whatever that comes with its own copies of everything needed, so average Joe can download my game, set it up and then just run it. But everything I can find online tells me that for someone to play my game, they'd need to download Python (if they don't have it), Pygame and various other libraries. I don't know about you, but if I had to install that much crap to play a game, I'd never play anything.

So does anyone know about distributing games made in Pygame in completely standalone packages? Can I do it?

py2exe should be able to create a nice runnable distribution for Windows, and there is a py2app in the default Mac python 2.5 installation, if I remember correctly (but, that requires you to have a Mac to create it, and the files become insanely large (40+Mb), since you have to include the entire Python installation in the .app - why can't it be like py2exe and have python in a single 500kb .dll? :()

For Linux, I'm not really sure, though...

dorkanoid
Dec 21, 2004

porkface posted:

Yahoo!, NASA

What I love most about Python's current growth rate is that it's almost entirely due to things Python has been doing all along, not just some new flashy framework or idea.

Indeed; I remember some map editor for Quake implemented scripting in Python back...in the old days (fake edit: it was called Quake Army Knife (ninja edit to my fake edit: 1996? drat :D)), and I'm sure tons of places used it at that time, but not as "visible" as it is today :)

dorkanoid
Dec 21, 2004

code:
self.genome = [gene + random.gauss(0,1) for gene in self.genome]
...should work :)

dorkanoid
Dec 21, 2004

The first part is not "selected", you're effectively only finding the "latest whitespace before 450 chars"

code:
(.{1,450})(?:[\s\-\:]|$)
works for me in http://cthedot.de/retest/

EDIT:
code:
(.{1,450})(?=(?:[\s\-\:]|$))
is probably closer to what you want; the other one consumes the whitespace character

dorkanoid fucked around with this message at 09:48 on Apr 3, 2009

dorkanoid
Dec 21, 2004

dancavallaro posted:

I used py2exe to make an executable of a Python script I wrote. It works great on the Windows XP computer that I created it on, and it works great on my Windows Vista laptop at home. But it doesn't work on my boss's Vista computer, and fails with the error "the application has failed to start because its side-by-side configuration is incorrect. Please see application event log for more details". Any ideas what could be wrong?

For the record (even if this is an old post, and seems resolved), this is most likely because the target computer needs the Visual C++ 2008 SP1 Redistributable Package (I'm guessing you use Python 2.6.0-2.6.1?)

I think this was fixed in 2.6.2, and it's related to issue #4566 (downgrading to Python 2.5 was not an option for me - I've used a lot of time getting stuff to work on 2.6).

dorkanoid
Dec 21, 2004

checkeredshawn posted:

I'm trying to parse the results from onelook.com for words related to a given word, and then store them in a list, but I can't figure out what the regexp should be to match the lines to grab the words. Here are some example lines from the source of the site after searching for words related to the word "emotion":

code:
1. <a href="/?loc=rescb&refclue=emotion&w=emotional">emotional</a><br>
2. <a href="/?loc=rescb&refclue=emotion&w=sentiment">sentiment</a><br>
3. <a href="/?loc=rescb&refclue=emotion&w=feeling">feeling</a><br>

4. <a href="/?loc=rescb&refclue=emotion&w=passion">passion</a><br>
5. <a href="/?loc=rescb&refclue=emotion&w=emotive">emotive</a><br>
6. <a href="/?loc=rescb&refclue=emotion&w=fear">fear</a><br>
And there would be 100 of those, and then random stuff that I don't care about makes up the rest of the HTML. The regexp I came up with was:

code:
p = re.compile('^\d+[.] <a href.*>(\w+)</a><br>$')
And then I'd try p.split(""" [the whole source here] """) but I'm doing something wrong. Any help would be greatly appreciated.

I think you want p.findall(source) :)

dorkanoid
Dec 21, 2004

checkeredshawn posted:

Thanks for the tip, but that returned an empty list, so I'm guessing there's something wrong with my regular expression?

Edit: Never mind, it looks like the reason it wasn't working was the ^ and $ in the regular expression, so it went from p = re.compile('^\d+[.] <a href.*>(\w+)</a><br>$') to p = re.compile('\d+[.] <a href.*>(\w+)</a><br>') and now it works.

I can't recommend retest enough for these kinds of things :D

Adbot
ADBOT LOVES YOU

dorkanoid
Dec 21, 2004

Habnabit posted:

I know it's from the last page, but this bugs me every drat time.

This is unfortunately impossible, since regular expressions can only parse regular languages and HTML is not a regular language! Fortunately, there's BeautifulSoup for actually really parsing HTML. The API is dead simple; you'd search for A tags where the 'href' attribute matches a particular pattern.

Why do you have to enable bad behavior. :(

Seriously, guys! Even (actual, real) perl programmers will tell you to use an HTML parser for parsing HTML.

:woop: REGULAR EXPRESSIONS! :woop:

And yes, BeautifulSoup is nice when it works, but the latest version is annoying (breaks on invalid/strange HTML).

I still use it when I can, but regular expressions typically work (until the page changes slightly ;))

  • Locked thread