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
Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm ?

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Centipeed posted:

What is the "accepted" way of implementing a simple substring search for plain text?

Is there something wrong with str.find()?

ChiralCondensate
Nov 13, 2007

what is that man doing to his colour palette?
Grimey Drawer

Centipeed posted:

What is the "accepted" way of implementing a simple substring search for plain text? I think it's called that. Basically a user types in a search term and it searches for those exact characters, so it also shows them if they're within a word.

I've thought about it, and I figured this might be the way to do it:

1. Get input
2. Find length of input
3. Step through text in these lengths, one character at a time
4. Return when string is found

But there might be a better way?

Also, if I wanted to highlight all instances of the found string, would I have to store the locations in a list or something? I want to highlight them in the text, but on a command line, so I need the locations of the specific characters.
code:
positions = []
n = text.find(substr)
while n >= 0:
    positions.append(n)
    n = text.find(substr, positions[-1] + len(substr))

supster
Sep 26, 2003

I'M TOO FUCKING STUPID
TO READ A SIMPLE GRAPH

deimos posted:

Windows Server 2008 x64 shits itself on virtualenv, easy_install and pip.
Oh. Well how else can I go about installing a module? The Twisted binary installer fails too because it doesn't detect that Python is installed.

I haven't had any problems installing any other modules (using their binaries).

Xaranthius
Nov 27, 2002

Grimey Drawer
I'm not exactly a regex master, but the problem sounds like a regex problem to me.
After a quick google search, the following regex function looks like it'd do what you want.

findall() - Find all substrings where the RE matches, and returns them as a list.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

supster posted:

Oh. Well how else can I go about installing a module? The Twisted binary installer fails too because it doesn't detect that Python is installed.

I haven't had any problems installing any other modules (using their binaries).

I used to have a problem when my registry settings pointed to an old install instead of the new hotness python26. If you've updated recently I'd look into that.

Make sure you're downloading the correct version for your python runtime, if the runtime is x86 get an x86 version otherwise x64.

supster
Sep 26, 2003

I'M TOO FUCKING STUPID
TO READ A SIMPLE GRAPH

deimos posted:

I used to have a problem when my registry settings pointed to an old install instead of the new hotness python26. If you've updated recently I'd look into that.

Make sure you're downloading the correct version for your python runtime, if the runtime is x86 get an x86 version otherwise x64.

It's a fresh install of Windows 7 with Python 2.6.2 AMD64. Is there just an alternative way to install a module? Can I just copy twh Twisted source to my site-packages folder?

edit: Sucessfully installed by just copying the Twisted source into site-packages.

supster fucked around with this message at 06:46 on Jun 1, 2009

ahobday
Apr 19, 2007

Thermopyle posted:

Is there something wrong with str.find()?

Crap. I don't know why I always assume I have to reinvent the wheel in programming languages. Of course there's an inbuilt method. Thanks guys.

tripwire
Nov 19, 2004

        ghost flow

Centipeed posted:

Crap. I don't know why I always assume I have to reinvent the wheel in programming languages. Of course there's an inbuilt method. Thanks guys.

Python especially is really good for this. You mostly don't have to worry about the crusty stuff you had to build by hand in C, like memory management, proper string handling, avoiding buffer overflows etc.

jupo
Jun 12, 2007

Time flies like an arrow, fruit flies like a banana.

Thermopyle posted:

Is there something wrong with str.find()?

If you're not interested in the position of the match I'd use "in"

code:
if search_term in some_string:
Much more natural considering it works the same across many different types, lists, dicts, etc.

deedee megadoodoo
Sep 28, 2000
Two roads diverged in a wood, and I, I took the one to Flavortown, and that has made all the difference.


Can anyone explain in small words how the gently caress to use ZSI to access a SOAP service with WSDL?

Using the SOAPpy module this is simple as all hell...

code:
import SOAPpy

service = SOAPpy.WSDL.Proxy('http://localhost/service/wsdl')
but for some reason I just don't understand the ZSI way to do this.

send ha;lp

tef
May 30, 2004

-> some l-system crap ->

HatfulOfHollow posted:

Can anyone explain in small words how the gently caress to use ZSI to access a SOAP service with WSDL?

I have never had any success with python soap implementations :(

They seem old, unmaintained and dependant on even more unmaintained libs.

deedee megadoodoo
Sep 28, 2000
Two roads diverged in a wood, and I, I took the one to Flavortown, and that has made all the difference.


tef posted:

I have never had any success with python soap implementations :(

They seem old, unmaintained and dependant on even more unmaintained libs.

I would much rather use xmlrpc but that option isn't available. It makes me a sad panda.

Twitchy
May 27, 2005

I keep wanting to get into Python but have yet to think of something I could build with it. Does anyone have any ideas for small apps that would make use of a lot of Python features and provide a decent challenge for someone not new to programming but new to Python (so less syntax stuff and more about using the various libraries)? Anything that would show the aspects of Python which are most powerful would be a definite++.

Curse my lack of imagination :(.

m0nk3yz
Mar 13, 2002

Behold the power of cheese!

Twitchy posted:

I keep wanting to get into Python but have yet to think of something I could build with it. Does anyone have any ideas for small apps that would make use of a lot of Python features and provide a decent challenge for someone not new to programming but new to Python (so less syntax stuff and more about using the various libraries)? Anything that would show the aspects of Python which are most powerful would be a definite++.

Curse my lack of imagination :(.

Here's an itch I have, I want a python app which will walk two trees of files (mp3s) and basically unify them - ditch dupes (check the ID3 tags), merge A into B (without dupes), etc. In a world of unicorns and fairies, it would also be able to hack the iTunes DB XML. But just de-duping/fixing tags/merging would be awesome.

Just an idea. I haven't had time to do this myself. :(

tef
May 30, 2004

-> some l-system crap ->

Twitchy posted:

I keep wanting to get into Python but have yet to think of something I could build with it. Does anyone have any ideas for small apps that would make use of a lot of Python features and provide a decent challenge for someone not new to programming but new to Python (so less syntax stuff and more about using the various libraries)? Anything that would show the aspects of Python which are most powerful would be a definite++.

Curse my lack of imagination :(.

to be honest, most of the low hanging fruit often exist. you might want to look at the small apps that don't deserve their own thread thread in sh/sc if it is still going.

you might be better off picking a library and then writing a program. python isn't really a powerful language (in terms of macho programming features), but it is a realtively simple language to do things in.

king_kilr
May 25, 2007

Twitchy posted:

I keep wanting to get into Python but have yet to think of something I could build with it. Does anyone have any ideas for small apps that would make use of a lot of Python features and provide a decent challenge for someone not new to programming but new to Python (so less syntax stuff and more about using the various libraries)? Anything that would show the aspects of Python which are most powerful would be a definite++.

Curse my lack of imagination :(.

Build an IRC client. I actually built a web based one for the django dash in 48 hours (with 2 other people), so it's not super hard but you'll have to learn both the standard lib and some external libraries (Twisted). It's also incredibly good fun.

tef
May 30, 2004

-> some l-system crap ->
Someone used 'buttbot' as a simple irc bot to implement :3:

good jovi
Dec 11, 2000

'm pro-dickgirl, and I VOTE!

tef posted:

Someone used 'buttbot' as a simple irc bot to implement :3:

buttbot is the bestbot.

seconding the IRC idea, client or bot, whatever. I started on building a bot a while back, and it was a fun little project. Of course I got bored and quit, but if you are actually someone capable of finishing things you might enjoy it.

awesomepanda
Dec 26, 2005

The good life, as i concieve it, is a happy life.
hi guys,

can someone explain to me what happened to the key or value methods of a dictionary? previously, in the older version of python, key or value methods would return a list. right now, its returning "dict_keys(['213', '34'])"

where my list go?

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

CrazyPanda posted:

hi guys,

can someone explain to me what happened to the key or value methods of a dictionary? previously, in the older version of python, key or value methods would return a list. right now, its returning "dict_keys(['213', '34'])"

where my list go?
map, filter, dict.keys/values/items, and probably some other stuff now return generic iterables instead of lists. It's faster for most cases, but if you need the "oh god copy everything" behavior back, use list({}.keys())

Balam
Dec 12, 2006
Complete Newb here. I am using John Zelle's introductory book to Python and Computer Programming, on a MacBook. I am using Python 2.6.2 and he includes graphics.py which has to be imported, he says place it where my graphics program is or in a system directory where the other libraries are stored, but none of it is working. I still get an error when I try to import graphics. Where I am supposed to put this thing? Thank you.

Edit: I might have redeemed myself. I put it in the documents folder with the rest of my python stuff. Maybe I had to publicly humiliate myself before figuring it out.

Balam fucked around with this message at 13:15 on Jun 4, 2009

awesomepanda
Dec 26, 2005

The good life, as i concieve it, is a happy life.

Janin posted:

map, filter, dict.keys/values/items, and probably some other stuff now return generic iterables instead of lists. It's faster for most cases, but if you need the "oh god copy everything" behavior back, use list({}.keys())

thanks Janin!!! can you also tell me what generic iterables are? how are they so much better than lists?

king_kilr
May 25, 2007

CrazyPanda posted:

thanks Janin!!! can you also tell me what generic iterables are? how are they so much better than lists?

In python 2.x when you did dict.keys() it would create a new list that had copies of all the key names, that is you would be storing the list of keys 2x in memory, once with the dictionary itself and another in your new list. This is obviously memory inefficient, so the new dict.keys() returns an iterator, so that it basically just traces it's position in the dictionary's keys, without all the new memory usage. In practice it's just about the same for post usage (ie in a forloop).

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

CrazyPanda posted:

thanks Janin!!! can you also tell me what generic iterables are? how are they so much better than lists?
a "generic iterable" is any object that can have items taken out of it one at a time (ie iterated over). For example, these statements all produce iterables:

code:
iterable = [1, 2, 3] # A list
iterable = (1, 2, 3) # A tuple
iterable = (x for x in [1, 2, 3]) # A generator

# Another generator
def gen():
    for ii in range (10):
        yield ii * 2
iterable = gen()
In Python 2, dict.keys() returns a list, which makes a copy of the key set. This has nicely defined behavior when modifying the dict within a loop, but is slow, because it requires the key list to be copied. It can also use a lot of memory when iterating over a large dictionary. By relaxing the contract from "returns a list" to "returns an iterable", implementations are allowed to use more efficient iterator objects.

deedee megadoodoo
Sep 28, 2000
Two roads diverged in a wood, and I, I took the one to Flavortown, and that has made all the difference.


HatfulOfHollow posted:

Can anyone explain in small words how the gently caress to use ZSI to access a SOAP service with WSDL?

Using the SOAPpy module this is simple as all hell...

code:
import SOAPpy

service = SOAPpy.WSDL.Proxy('http://localhost/service/wsdl')
but for some reason I just don't understand the ZSI way to do this.

send ha;lp

I figured out that the actual issue I was having is that ZSI makes assumptions about the format of the wsdl document. ZSI tries to read ahead on certain node types because it assumes that those nodes have children, which causes all kinds of errors. It's some hosed up xml parsing that makes no sense. Just walk the doman tree you loving loonies.

In any case I switched to suds. It does everything I need (correctly) and seems to be recent and/or at least maintained a bit better. It even supports http proxies and wsdl that doesn't live at the same address as the service.

tef
May 30, 2004

-> some l-system crap ->
Thanks for pointing out suds: I haven't seen that library before, I might give it a try if I have to deal with SOAP again.

tef fucked around with this message at 22:48 on Jun 4, 2009

Captain Capacitor
Jan 21, 2008

The code you say?
Does anybody know how to get a description or any kind of information when working with Twisted's PB library? I have an app (buildbot) that provides a broker, but I'll be damned if I can't figure out what object I'm actually getting back when I connect.

Boblonious
Jan 14, 2007

I HATE PYTHON IT'S THE SHITTIEST LANGUAGE EVER PHP IS WAY BETTER BECAUSE IT IS MADE FOR THE WEB AND IT USES MYSQL WHICH IS ALSO USED BY GOOGLE AND THATS WHY ITS SO MUCH BETTER THAN PYTHON EVEN HTML IS A BETTER PROGRAMMING LANGUAGE THAN PYTHON
So I'm working on a software project written in Python, and I'd like to incorporate some kind of plugin system so extra functionality can be included. Problem is, I don't have much of an idea of how to go about writing a plugin framework, or even what that means exactly.

I found this page in the course of my googling, and while I don't quite understand all the trickery going on with __metaclass__, it seems to be a good place to start. Does anyone see anything terribly wrong with those techniques, or have any better ways to implement a plugin architecture?

Is some kind of "hook" system where plugins can register their code to run at certain points in the codebase the "right way" to do plugins?

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Boblonious posted:

So I'm working on a software project written in Python, and I'd like to incorporate some kind of plugin system so extra functionality can be included. Problem is, I don't have much of an idea of how to go about writing a plugin framework, or even what that means exactly.

I found this page in the course of my googling, and while I don't quite understand all the trickery going on with __metaclass__, it seems to be a good place to start. Does anyone see anything terribly wrong with those techniques, or have any better ways to implement a plugin architecture?

Is some kind of "hook" system where plugins can register their code to run at certain points in the codebase the "right way" to do plugins?
I like pkg_resources, which is included with setuptools and thus probably already installed. It's pretty easy to use -- it will search your Python path, and any additional directories you specify (user-defined plugin dirs, etc) for loadable python modules that advertise "entry points". You can then retrieve the list of available plugins for each entry point.

Loading code:
code:
from pkg_resources import Environment, working_set

# Non-PYTHONPATH directories to search
PLUGIN_DIRS = ["/home/user/.local/share/myapp/plugins", "/usr/share/myapp/plugins"]

env = Environment(PLUGIN_DIRS)
plugins, errors = working_set.find_plugins(env)
for plugin in plugins:
    plugin.activate()

    # Each plugin may advertise many different entry points, and different types
    # of entry point. Here we retrieve any entry points with the key
    # "myapp.myplugintype"
    entry_points = plugin.get_entry_map("myapp.myplugintype")
    for name, entry in entry_points.items():
        try:
            cls = entry.load()
        except (KeyboardInterrupt, SystemExit):
            raise
        except Exception, exc:
            print "Error loading entry point %r from %r" % (name, plugin.project_name)
            continue

        # cls is whatever class, function, object, etc the plugin defined for "myapp.myplugintype"
        # You can register it for callbacks, insert it into a menu, whatever is
        # appropriate for your application.
Each plugin should have the following lines added to its setup.py:
code:
from setuptools import setup
setup(
    name = "exampleplugin",
    # blah blah blah

    entry_points = {"myapp.myplugintype": [
        "helloworld=exampleplugin.HelloWorld",
        "whatever=exampleplugin.Whatever",
    ]}
)

m0nk3yz
Mar 13, 2002

Behold the power of cheese!

Janin posted:

I like pkg_resources, which is included with setuptools and thus probably already installed. It's pretty easy to use -- it will search your Python path, and any additional directories you specify (user-defined plugin dirs, etc) for loadable python modules that advertise "entry points". You can then retrieve the list of available plugins for each entry point.

I can not recommend against using setuptools enough. Even the Nose project is looking at moving away from it (http://code.google.com/p/python-nose/issues/detail?id=271). Setuptools is a giant hack on top of distutils, it's virtually unmaintained, and causes headaches for everyone.

I'd use something else:

http://lucumr.pocoo.org/2006/7/3/python-plugin-system
http://yapsy.sourceforge.net/
http://pypi.python.org/pypi?%3Aaction=search&term=plugins

Even marty's approach (which you linked to) is fine. As for this:

quote:

Is some kind of "hook" system where plugins can register their code to run at certain points in the codebase the "right way" to do plugins?

Yes, and no - it depends on what you want to do. This is how I would approach it, but other people may have more expansive thoughts. I would just avoid setuptools.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

m0nk3yz posted:

I can not recommend against using setuptools enough. Even the Nose project is looking at moving away from it (http://code.google.com/p/python-nose/issues/detail?id=271). Setuptools is a giant hack on top of distutils, it's virtually unmaintained, and causes headaches for everyone.

I'd use something else:

http://lucumr.pocoo.org/2006/7/3/python-plugin-system
http://yapsy.sourceforge.net/
http://pypi.python.org/pypi?%3Aaction=search&term=plugins

Even marty's approach (which you linked to) is fine.
Auto-registering classes with a metaclass is *not* fine! It's impossible to test/debug, non-standardized, and usually half-broken.

I'd like to hear about what problems you've encountered with pkg_resources or setuptools -- they seem to work fine for me, and I've configured several sites using pip + virtualenv without any issues.

Also, I think you copied the wrong issue link for "nose moving away from [setuptools]", since the linked issue doesn't involve setuptools at all.

Lonely Wolf
Jan 20, 2003

Will hawk false idols for heaps and heaps of dough.
Likewise I don't see why auto-registering a class is so problematic and impossible. It is semi-magicy but looks reasonably straightforward and less work than defining a plugin system that feels less Pythonic than the metaclass approach to me. What problems have you had with such things?

To answer the original question, re metaclasses, the metaclass is called when the new classes are instantiated (versus when the class's objects are instantiated) and just adds each plugin class to a list that you can get to easily.

checkeredshawn
Jul 16, 2007

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.

king_kilr
May 25, 2007

Janin posted:

Auto-registering classes with a metaclass is *not* fine! It's impossible to test/debug, non-standardized, and usually half-broken.

I'd like to hear about what problems you've encountered with pkg_resources or setuptools -- they seem to work fine for me, and I've configured several sites using pip + virtualenv without any issues.

Also, I think you copied the wrong issue link for "nose moving away from [setuptools]", since the linked issue doesn't involve setuptools at all.

pip only uses the decent parts of setup tools (according to Jannis Leidel, who's a core pip developer). A huge amount of it (like the easy_install part) is a steaming, festering, pile of poo poo (this is absurdly well documented).

m0nk3yz
Mar 13, 2002

Behold the power of cheese!

Janin posted:

Auto-registering classes with a metaclass is *not* fine! It's impossible to test/debug, non-standardized, and usually half-broken.

I'd like to hear about what problems you've encountered with pkg_resources or setuptools -- they seem to work fine for me, and I've configured several sites using pip + virtualenv without any issues.

Also, I think you copied the wrong issue link for "nose moving away from [setuptools]", since the linked issue doesn't involve setuptools at all.

There's plenty of other plugin approaches (http://pypi.python.org/pypi?%3Aaction=search&term=plugins) beyond what he pointed out. Sorry I seemed to rubber stamp the metaclass approach, I do like Marty's approach, but your point about testing/debug is a good one. Also, there is *no* standard "plugin approach" - setuptools is far from a standard.

As for the nose issue I linked to, it's the start of removing the current plugin architecture (based on setuptools). I was to lazy to link to the nose-users mailing thread.

Setuptools has some good ideas, but it is far from a standard, breaks in the oddest ways possible. Sure, I consume a lot of setuptools-based stuff ( I too use pip, easy_install and virtualenv), but I hope to never build on it in a personal project.

Also:

king_kilr posted:

pip only uses the decent parts of setup tools (according to Jannis Leidel, who's a core pip developer). A huge amount of it (like the easy_install part) is a steaming, festering, pile of poo poo (this is absurdly well documented).

Here's a decent discussion by James Bennett: http://www.b-list.org/weblog/2008/dec/14/packaging/ and more from ian: http://blog.ianbicking.org/2008/12/14/a-few-corrections-to-on-packaging/

Essentially, setuptools tries to be everything, for all people, while thats admirable, when it breaks (and it does break) it's impossible to debug and fix. At pycon a bunch of us talked about how to "fix" packaging. The summation of that is that Tarek is writing a series of PEPs to extract the useful parts of setuptools and pull them into disutils, add uninstall capabilities, etc.

I think using setuptools for a plugin system is just excessive.

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) :)

checkeredshawn
Jul 16, 2007

dorkanoid posted:

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

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.

checkeredshawn fucked around with this message at 22:55 on Jun 6, 2009

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Lonely Wolf posted:

Likewise I don't see why auto-registering a class is so problematic and impossible. It is semi-magicy but looks reasonably straightforward and less work than defining a plugin system that feels less Pythonic than the metaclass approach to me. What problems have you had with such things?
  • There's no way to separate the definition and registration of a plugin. This makes testing difficult -- do you want all your test classes showing up as plugins?
  • Violates the principles of duck-typing -- merely implementing a prescribed interface is no longer sufficient, as only classes inheriting from the registration class will be found.
  • Multiple applications can't share plugins without a separate, shared registration library.
  • Violates "explicit is better than implicit" -- registration is hidden in a magic class, and is difficult to discover except through grepping through the source for "__metaclass__".
  • There's no way to know what plugins are available without invoking their definitions, which may depend on libraries that aren't installed. Rather than displaying a helpful error message ("FooPlugin requires libfoo >= 1.7"), plugin scanning will barf with an ImportError.

king_kilr posted:

pip only uses the decent parts of setup tools (according to Jannis Leidel, who's a core pip developer). A huge amount of it (like the easy_install part) is a steaming, festering, pile of poo poo (this is absurdly well documented).
OK? Merely because there are badly written utilities (easy_install) that use setuptools doesn't mean setuptools itself is a bad idea. Obviously, since it's used by many good tools (pip, virtualenv) it contains useful code. And remember that I'm talking about pkg_resources, which is a separate library -- it's simply bundled with setuptools, the same way that setuptools is bundled with virtualenv.

m0nk3yz posted:

Also, there is *no* standard "plugin approach" - setuptools is far from a standard.
Any installation system that writes egg-info files (distutils.setup, easy_install, pip) can be used with pkg_resources. PEP 376 will move egg management into the stdlib. I can't think of how egg-info could be *more* standardized, until it gets into the stdlib.

Adbot
ADBOT LOVES YOU

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

  • Locked thread