|
Khorne posted:Note that varone[0], varone[1] are lists of numerical values. Scaevolus fucked around with this message at 00:06 on Feb 26, 2010 |
# ? Feb 26, 2010 00:00 |
|
|
# ? May 28, 2024 14:05 |
|
Bonus posted:Can you post the exact code to reproduce that? My guess is that the items that are in those lists don't have proper __eq__ methods. Cause this works fine: Khorne fucked around with this message at 07:31 on Feb 26, 2010 |
# ? Feb 26, 2010 00:06 |
|
BeefofAges posted:From what I understand, nose is for testing Python projects. In this case, I'm testing a piece of hardware which is hooked up to my PC via a serial port. My utility doesn't have a command line interface. Instead it has a simple GUI for setting up the serial port and a simple terminal for interaction with the serial port. Could nose still fit my needs? I've rarely used nose to test actual python products (mainly because previous jobs were mainly written in java). Nose is awesome, and can execute a test that's written in python that in turn tests, well, anything.
|
# ? Feb 26, 2010 01:31 |
|
Pycon stuff is online! I recommend this talk by raymond hettinger on data structures: http://python.mirocommunity.org/video/1530/mastering-team-play-four-power
|
# ? Feb 26, 2010 16:34 |
|
Lamacq posted:Can you elaborate a little on this, and/or show me where in the python docs I can read up on this syntax? B/c I don't really understand what's going on here. http://www.python.org/dev/peps/pep-0318/ They're decorators, all they do is take a function and return a function. So doing: code:
code:
|
# ? Feb 26, 2010 17:27 |
|
Bonus posted:http://www.python.org/dev/peps/pep-0318/ I've been looking at this for a while, and I get what basic decorators do, but I don't see what the do/undo decorators are for. If I apply the decorator transformation you showed to the do/undo example, I go from this: code:
code:
|
# ? Feb 27, 2010 05:41 |
|
A basic use of decorators is something like this:code:
code:
code:
code:
|
# ? Feb 27, 2010 13:40 |
|
Now I see. That's cool. I was able to solve the transaction problem using the undo list I posted earlier. I just used inline defs to specify and enqueue the undo-action right after the do-action was complete.
|
# ? Feb 27, 2010 18:33 |
|
edit is not reply god dammit
|
# ? Feb 28, 2010 10:13 |
|
Hey Python people: I'm a Python neophyte using it for a class project and I'm currently fighting with HTMLParser. In particular, I'm trying to parse a page that has Javascript with embedded HTML, and it's confusing the parser. In particular, this line: code:
|
# ? Feb 28, 2010 10:13 |
|
Dijkstracula posted:Hey Python people: Is this quotation mark that is in your code or the parser code?
|
# ? Feb 28, 2010 10:36 |
|
Dijkstracula posted:Hey Python people: Use another library? I would recommend lxml if you've been using element-tree style things or pyquery is a wrapper that uses css selectors.
|
# ? Feb 28, 2010 12:20 |
|
Dijkstracula posted:Hey Python people: Try: code:
|
# ? Feb 28, 2010 16:45 |
|
Maybe you need to wrap the javascript code in HTML comment tags, if that's allowed. Otherwise find a better parser.
|
# ? Feb 28, 2010 17:27 |
|
Yeah, so this is in a random page's code that I can't change (yes, the sample I gave was in the page that the parser dies on), but still needs to work with. It really needs to be tolerant of any sort of broken HTML that I might try. (I mean, I assumed that the built-in parser would be, or at least more so than any third party alternatives) So, lxml is the preferred library, or do people have other parser recommendations that won't choke at the first weird page I throw at it?
|
# ? Feb 28, 2010 18:55 |
|
Dijkstracula posted:Yeah, so this is in a random page's code that I can't change (yes, the sample I gave was in the page that the parser dies on), but still needs to work with. It really needs to be tolerant of any sort of broken HTML that I might try. (I mean, I assumed that the built-in parser would be, or at least more so than any third party alternatives) Lxml is great. Pyquery is also great, and it uses lxml as a parser (among others).
|
# ? Feb 28, 2010 18:59 |
|
Quick question bout numpy. If i have a matrix code:
code:
|
# ? Feb 28, 2010 19:36 |
|
Dijkstracula posted:So, lxml is the preferred library, or do people have other parser recommendations that won't choke at the first weird page I throw at it? I have used lxml in production environments, it is good at html soup.
|
# ? Feb 28, 2010 20:16 |
|
I'm encountering a very strange problem printing a simple text report. I've got some headers, and then some characters that I want inserted under the headers. Here's the code, with some extra stuff thrown in to help me debug:code:
code:
edit : never mind, the problem is that for these operations tuples and lists aren't interchangeable for some reason Sock on a Fish fucked around with this message at 20:38 on Feb 28, 2010 |
# ? Feb 28, 2010 20:32 |
|
Sock on a Fish posted:I'm encountering a very strange problem printing a simple text report. I've got some headers, and then some characters that I want inserted under the headers. Here's the code, with some extra stuff thrown in to help me debug: This fixes it. code:
|
# ? Feb 28, 2010 21:21 |
|
UberJumper posted:Quick question bout numpy. matrix[0, ] = 0 To set the first column: matrix[ ,0] = 0
|
# ? Feb 28, 2010 21:59 |
|
tripwire posted:To set the first row: Numpy. Is Pure. Awesome.
|
# ? Feb 28, 2010 23:10 |
|
tripwire posted:To set the first row: The first seems fine since 0, is (0,), but isn't the second assignment a syntax error?
|
# ? Mar 1, 2010 01:40 |
|
Bonus posted:The first seems fine since 0, is (0,), but isn't the second assignment a syntax error? Woops! Should have a colon in there: code:
|
# ? Mar 1, 2010 01:55 |
|
I have some code that seems like it could be done concisely another way. Any weird lambda or generator tricks I'm missing out on?code:
|
# ? Mar 1, 2010 20:27 |
|
you could do: leap_second_lut = [datetime.datetime(*a) for a in [ (1987,7,1), (....) ] ]
|
# ? Mar 1, 2010 20:49 |
|
Dijkstracula posted:So, lxml is the preferred library, or do people have other parser recommendations that won't choke at the first weird page I throw at it? I threw this completely boring page at lxml.html and it kept breaking on parse. I have used BeautifulSoup before and it was ok-ish, although I've heard people throw around "unpythonic" and other similar epithets.
|
# ? Mar 1, 2010 22:18 |
|
It's unpythonic cuz it works.
|
# ? Mar 1, 2010 22:21 |
|
Try parsing the html as html, rather than parsing as xml (the lxml default) code:
tef fucked around with this message at 22:25 on Mar 1, 2010 |
# ? Mar 1, 2010 22:23 |
|
Lurchington posted:I threw this completely boring page at lxml.html and it kept breaking on parse. It works fine for me. code:
|
# ? Mar 2, 2010 01:11 |
|
Lurchington posted:I have used BeautifulSoup before and it was ok-ish, although I've heard people throw around "unpythonic" and other similar epithets. lxml looks like a serious pain in that it has to be installed rather than my just dropping it in my working directory, and I'm working across OSs and need it to be basically self-contained...this is really preposterous, so I gather there's really no good solution for a reasonably simple thing like this? It's bullshit like this that causes people to just regex the poo poo out of HTML instead of using proper parsers. edit: here's my team's torture test site. If you can find something that can make sense of it, let me know Dijkstracula fucked around with this message at 07:18 on Mar 2, 2010 |
# ? Mar 2, 2010 07:00 |
|
pip install lxml Ta.loving.da.
|
# ? Mar 2, 2010 07:19 |
|
I'm fairly new to Python and have been mostly using it for simple scripting and writing file conversion tools. As my first large-ish project I'd like to generate static callgraphs of a C style language I use at work. Functions are defined as code:
code:
|
# ? Mar 2, 2010 16:51 |
|
the wizards beard posted:I'm fairly new to Python and have been mostly using it for simple scripting and writing file conversion tools. Check out ply
|
# ? Mar 2, 2010 17:06 |
|
Thanks, I had thought of lex/yac/flex/bison but assumed they would be overkill, the articles linked on that page don't look too intimidating though. I'll look into this tonight, any other suggestions would be great.
|
# ? Mar 2, 2010 17:13 |
|
the wizards beard posted:Thanks, I had thought of lex/yac/flex/bison but assumed they would be overkill, the articles linked on that page don't look too intimidating though. I'll look into this tonight, any other suggestions would be great. PyParsing is really nice too, though I've only used it in smallish setups so far. A talk was given at PyCon the other weekend that went over both it and PLY pretty well: slides (video might be on pycon.blip.tv but I can't find it quickly)
|
# ? Mar 2, 2010 19:22 |
|
It looks like PyParsing is what I want, I've already got a script that can read a file and print all the functions declared and their arguments. Thanks guys.
|
# ? Mar 2, 2010 20:30 |
|
Purely out of curiosity, is there a way to do something like code:
|
# ? Mar 2, 2010 21:27 |
|
BeefofAges posted:Purely out of curiosity, is there a way to do something like Yes code:
|
# ? Mar 2, 2010 21:45 |
|
|
# ? May 28, 2024 14:05 |
|
king_kilr posted:Yes Yeah, that's what I said to do, but the guy who asked me was like "I'm doing this in a lot of places, so it would be nice to make it compact". Heh.
|
# ? Mar 2, 2010 21:51 |