|
http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm ?
|
# ? May 31, 2009 20:12 |
|
|
# ? May 9, 2024 10:43 |
|
Centipeed posted:What is the "accepted" way of implementing a simple substring search for plain text? Is there something wrong with str.find()?
|
# ? May 31, 2009 22:00 |
|
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. code:
|
# ? May 31, 2009 22:02 |
|
deimos posted:Windows Server 2008 x64 shits itself on virtualenv, easy_install and pip. I haven't had any problems installing any other modules (using their binaries).
|
# ? Jun 1, 2009 01:48 |
|
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.
|
# ? Jun 1, 2009 02:31 |
|
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 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.
|
# ? Jun 1, 2009 03:42 |
|
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. 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 |
# ? Jun 1, 2009 04:04 |
|
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.
|
# ? Jun 1, 2009 10:12 |
|
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.
|
# ? Jun 1, 2009 19:13 |
|
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:
|
# ? Jun 2, 2009 07:33 |
|
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:
send ha;lp
|
# ? Jun 3, 2009 14:45 |
|
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.
|
# ? Jun 3, 2009 15:57 |
|
tef posted:I have never had any success with python soap implementations I would much rather use xmlrpc but that option isn't available. It makes me a sad panda.
|
# ? Jun 3, 2009 16:32 |
|
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 .
|
# ? Jun 3, 2009 17:35 |
|
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++. 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.
|
# ? Jun 3, 2009 18:02 |
|
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++. 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.
|
# ? Jun 3, 2009 19:35 |
|
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++. 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.
|
# ? Jun 3, 2009 21:24 |
|
Someone used 'buttbot' as a simple irc bot to implement
|
# ? Jun 3, 2009 21:32 |
|
tef posted:Someone used 'buttbot' as a simple irc bot to implement 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.
|
# ? Jun 4, 2009 04:22 |
|
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?
|
# ? Jun 4, 2009 05:57 |
|
CrazyPanda posted:hi guys,
|
# ? Jun 4, 2009 06:49 |
|
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 |
# ? Jun 4, 2009 13:13 |
|
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?
|
# ? Jun 4, 2009 14:31 |
|
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).
|
# ? Jun 4, 2009 16:38 |
|
CrazyPanda posted:thanks Janin!!! can you also tell me what generic iterables are? how are they so much better than lists? code:
|
# ? Jun 4, 2009 17:35 |
|
HatfulOfHollow posted:Can anyone explain in small words how the gently caress to use ZSI to access a SOAP service with WSDL? 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.
|
# ? Jun 4, 2009 20:00 |
|
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 |
# ? Jun 4, 2009 22:44 |
|
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.
|
# ? Jun 5, 2009 04:00 |
|
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?
|
# ? Jun 6, 2009 18:03 |
|
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. Loading code: code:
code:
|
# ? Jun 6, 2009 18:32 |
|
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.
|
# ? Jun 6, 2009 19:43 |
|
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 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.
|
# ? Jun 6, 2009 21:01 |
|
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.
|
# ? Jun 6, 2009 21:59 |
|
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:
code:
|
# ? Jun 6, 2009 22:17 |
|
Janin posted:Auto-registering classes with a metaclass is *not* fine! It's impossible to test/debug, non-standardized, and usually half-broken. 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).
|
# ? Jun 6, 2009 22:17 |
|
Janin posted:Auto-registering classes with a metaclass is *not* fine! It's impossible to test/debug, non-standardized, and usually half-broken. 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.
|
# ? Jun 6, 2009 22:20 |
|
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": I think you want p.findall(source)
|
# ? Jun 6, 2009 22:21 |
|
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 |
# ? Jun 6, 2009 22:29 |
|
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?
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). m0nk3yz posted:Also, there is *no* standard "plugin approach" - setuptools is far from a standard.
|
# ? Jun 6, 2009 22:37 |
|
|
# ? May 9, 2024 10:43 |
|
checkeredshawn posted:Thanks for the tip, but that returned an empty list, so I'm guessing there's something wrong with my regular expression? I can't recommend retest enough for these kinds of things
|
# ? Jun 6, 2009 23:08 |