|
I have only used this briefly, but if you guys are trying to write code without the GIL slowing things down, there is the multiprocessing library. (Python 3 link)
|
# ¿ Jun 19, 2012 05:23 |
|
|
# ¿ May 19, 2024 22:01 |
|
OnceIWasAnOstrich posted:Take a look at the BeautifulSoup library or Scrapy, much easier than trying to extract bits of HTML with string commands. Seconding BeautifulSoup. Made my life much easier when parsing poorly formatted HTML.
|
# ¿ Aug 4, 2012 23:18 |
|
MC Fruit Stripe posted:Either they changed the meaning of parsing (unlikely), what I am trying to do is more complicated than space exploration (less likely), or I am just not loving seeing this (very likely). I have no idea how to suggest improvements as I have no clue what you are doing.
|
# ¿ Aug 5, 2012 00:31 |
|
Ulio posted:nvm fixed it, thanks. IDLE was just being weird. Screenshot?
|
# ¿ Aug 8, 2012 04:23 |
|
Pangolin Poetry posted:Python code A couple things make this code tricky to read. In particular, the long length of lines caused by comments. This is true for any language, but Python programs in particular tend to keep their line length to 80 characters or less, but no one Instead of doing Python code:
Python code:
Python code:
Python code:
|
# ¿ Sep 18, 2012 07:50 |
|
MeramJert posted:I hope NumPyPy exists soon because people have apparently donated $45,000 to fund its development There was a commit 10 days ago that commented out some code... I'm not sure this was the best investment
|
# ¿ Sep 21, 2012 05:16 |
|
Kerpal posted:Does anyone have experience with the _winreg module? I'm trying to write a script that deletes a registry key in HKLM\Software\Classes\Installer\Products, however the _winreg DeleteKey method cannot delete keys with subkeys, which gives a WindowsError exception "Access is denied" error 5. The only solutions I could think of was to create a function that recursively deletes every subkey in the input key before deleting the primary key. I'm trying to do this remotely, so I have to be able to connect to a remote registry. Another solution was to call the reg command like: The "rdelete" function here might help: http://code.activestate.com/recipes/476229-yarw-yet-another-registry-wrapper/
|
# ¿ Oct 4, 2012 16:38 |
|
the posted:http://pastebin.com/3q8dW3EY Perhaps someone who knows more about this than me see something I don't, but other than doing a couple calculations ahead of time (e.g. 1./6, (b_width**2/(6*enot))), I don't see anything in particular you can do to speed this up. This is not unusual, but I am surprised this is so much slower so hopefully I am missing some insight someone else will have.
|
# ¿ Oct 10, 2012 03:05 |
|
MeramJert posted:See if you can reduce the number of nested for loops. Right now you have 4 nested for loops (your while loop is just another for loop in disguise), and that's what's slowing you down. Specifically, you should be able to eliminate all of the inner for loops using itertools.product. Itertools is made for these kinds of things, and I bet you'll see a nice speedup just from that. Itertools might be useful (I'll be reading the documentation on itertools after this post..) but the other suggestions I don't think will be. Each iteration of the loop has a dependency on a prior iteration, so there isn't anything to parallelize. PyPy doesn't have NumPy support ("soon"), and if he is going to use Cython he might as well just write the entire thing in C.
|
# ¿ Oct 10, 2012 03:12 |
|
Misogynist posted:I just finished my first legitimate (non-toy) Python project, Metricinga, a daemon that forwards Nagios/Icinga performance data to Graphite. Would anyone mind taking a minute to look over my code and tear it apart so I can write better code? Some nitpicks: Python code:
Python code:
Python code:
Python code:
Python code:
Python code:
In stop() you call str(err) twice, the second time it will always already be a string. In run(), your finally block has a "shutdown successfully" message. If joinall throws some other non-expected error, that message will be false. See the following regarding string formatting: http://docs.python.org/2/tutorial/inputoutput.html#old-string-formatting And this regarding your use of file vs. open: http://stackoverflow.com/questions/112970/python-when-to-use-file-vs-open
|
# ¿ Nov 2, 2012 02:07 |
|
Drunk Badger posted:I'm making a serious attempt at learning Python, so I'm looking for a good Python IDE. The only other IDE I have good experience with is Visual Studio for a C# and C++ class, pop up tips and the ability to set break points with a nice list of variables and their values are probably the two things that helped the most in learning those, and as a novice programmer, probably things I require to hold my hand as I get into Python. I've always liked PyDev http://pydev.org/
|
# ¿ Nov 8, 2012 23:27 |
|
Thern posted:Testing woes Looking at it, my guess is you should change @patch("subprocess.Popen") to @patch("popen"). I'm not familiar with this testing framework though so that could be entirely off base.
|
# ¿ Nov 16, 2012 08:12 |
|
Masa posted:What's the best way to copy text to the clipboard in a program using PyQt? I've tried using QApplication.clipboard, but it only works while the program that copied the text is still running. What system is this on? That sounds like an X11 problem.
|
# ¿ Dec 2, 2012 07:42 |
|
|
# ¿ May 19, 2024 22:01 |
|
The Rosalind project has some good problems to practice programming on. I have done a few of them and didn't need any biology background. I can't speak for the higher level stuff.
|
# ¿ Dec 11, 2012 03:22 |