|
nbv4 posted:Does anybody know of a RSS feed or something one can subscribe to thats comprehensive on all the goings on of the python community? Apparently there was a loving pycon 20 minutes from where I live a few days ago but I missed it because I had no idea it was going on. http://planet.python.org/rss20.xml ?
|
# ? Aug 3, 2010 00:31 |
|
|
# ? May 17, 2024 22:26 |
|
So... this may be getting into coding horror territory but, I'm fiddling around with the idea of streaming MP3's over HTTP. Not hard but, I need the ability to seek to portions of MP3 via a query parameter. I'm doing some basic experiments with a very simple WSGI application and am having problems with getting more than 5 or so concurrent streams. Here's the basic WSGI HTTP server code:
code:
ATLbeer fucked around with this message at 13:05 on Aug 3, 2010 |
# ? Aug 3, 2010 12:55 |
|
Hughlander posted:http://planet.python.org/rss20.xml ? that's the one I used, and you just need to remember it's an aggregator of a lot of personally-run blogs so there's a fair amount of whitenoise. b0lt posted:It might be helpful to brush up on itertools/functools, they're pretty handy and will make your whiteboard examples more impressive. An excellent idea. I've used itertools in the past, but not functools. edit: multiprocessing on windows experts, is printing a string not atomic? I copy+pasted the second example from PyMOTW and was surprised at this kind of output: code:
Lurchington fucked around with this message at 15:20 on Aug 3, 2010 |
# ? Aug 3, 2010 14:26 |
|
Lurchington posted:I'm wondering if this is a side effect of the magic necessary to get multiprocessing on windows?
|
# ? Aug 3, 2010 19:30 |
|
Sneftel posted:Yes. The manner in which multiprocessing funnels all output to the same place is OS-dependent; the short answer is, if you're going to do output from multiple processes, grab a lock first. Or use the built in logging module support
|
# ? Aug 3, 2010 20:49 |
|
code:
edit: the value I'm starting with looks like this: code:
nbv4 fucked around with this message at 21:16 on Aug 3, 2010 |
# ? Aug 3, 2010 21:06 |
|
Welp; I can't remember off hand but it had something to do with the unicodedata encoding. But what I was thinking only worked for accents. Whoops
tef fucked around with this message at 23:24 on Aug 3, 2010 |
# ? Aug 3, 2010 23:19 |
|
nbv4 posted:asciiDammit is a function that turns funky characters such as the 'Æ' character into the two character ascii equivalent "AE". This asciiDammit function only works when it gets a plain string such as '\xc6nima'. How do I go from "Ænima" to '\xc6nima'? I've tried all sorts of combinations of unicode(), str(), .decode('utf-8'), .encode('utf-8'), .decode('ascii'), .encode('ascii'), but nothing works. '\xc6' for Æ is a latin-1 encoding, not utf-8 (utf-8 is u'\xc6' or '\xc3\x86'). code:
For future reference: http://www.fileformat.info/info/unicode/char/00c6/index.htm this site has prevented many an encoding migraine (of special note is the "More..." link below encodings. deimos fucked around with this message at 00:24 on Aug 4, 2010 |
# ? Aug 3, 2010 23:55 |
|
Disclaimer: I'm teaching myself Python as a hobby, not in a class. I'm trying to write a very simple program to track my expenses. Right now I have it setup where it will ask for how much money was spent, and the type of expense. It will then write that information to a text file. There is a TAB separating the amount and the type. The format is as follows: code:
Hughmoris fucked around with this message at 23:29 on Aug 4, 2010 |
# ? Aug 4, 2010 23:27 |
|
Try reading in the whole file then operating on the information contained in it. You can do it your way by doing a combination of read() and seek() on your open file handle, but why bother for a small file?
|
# ? Aug 4, 2010 23:31 |
|
Hughmoris posted:Disclaimer: I'm teaching myself Python as a hobby, not in a class. Read up on readline() and split()
|
# ? Aug 4, 2010 23:58 |
|
So I'm working with IronPython and Windows Forms, and trying to get the simplest possible form to work:code:
I'm running IronPython 2.6.1, but the form code was originally generated for 1.1.2(?) with some slight fixups, the same error occurs if I set a 'TextChanged' handler for a text widget. Without the += the form displays but obviously the load/textchanged functions aren't invoked. Any one know what I'm doing wrong? Further, anyone know what the best resource for IronPython questions are? My google-fu feels really weak to me.
|
# ? Aug 5, 2010 02:04 |
|
deimos posted:Read up on readline() and split() Thank you, after reading up on those I was able to fumble something together. It ain't pretty but it works.
|
# ? Aug 5, 2010 02:05 |
|
Sneftel posted:Yes. The manner in which multiprocessing funnels all output to the same place is OS-dependent; the short answer is, if you're going to do output from multiple processes, grab a lock first. m0nk3yz posted:Or use the built in logging module support Thanks both of you*. This will be good for actual implementations I end up doing. I was mostly surprised that the lack of a "gotcha" on PyMOTW and the lack of a specific answer on google searches. *m0nk3yz: I finally got around to seeing your PyCon 09 intro to multiprocessing talk, and I thought it was great
|
# ? Aug 5, 2010 03:28 |
|
Lurchington posted:Thanks both of you*. This will be good for actual implementations I end up doing. I was mostly surprised that the lack of a "gotcha" on PyMOTW and the lack of a specific answer on google searches. Thanks! I should do a follow up talk next pycon - sadly though, my own usage of multiprocessing in the past year is really low, as I'm working on single-core, lower memory boxes. I do use a lot of threads though.
|
# ? Aug 6, 2010 02:56 |
|
Why must you hate me, pyparsing? You look so shiny and wonderful, but refuse to do as you're told.
|
# ? Aug 6, 2010 04:32 |
|
I wanted to ask for some advice on a function I have in my program.code:
editted for table breaking k-selectride fucked around with this message at 22:55 on Aug 6, 2010 |
# ? Aug 6, 2010 22:50 |
|
Cool, you figured out how to write C in python
|
# ? Aug 6, 2010 22:58 |
|
Use slices, theyre one of the nicest features of numpy.code:
tripwire fucked around with this message at 23:19 on Aug 6, 2010 |
# ? Aug 6, 2010 23:15 |
|
tripwire posted:Use slices, theyre one of the nicest features of numpy. This is very nice, thanks
|
# ? Aug 7, 2010 18:21 |
|
I'm writing a desktop gui program in python and I need to make an installer for windows users. Asking windows users to install python and then setuptools, and then extract a zip file, navigate there on the commandline and then type in "python setup.py install" is asking too much. I need to make it a one single exe that will install python (if not already installed), wxpython (and a few others), etc. all in one process. Is this possible, if so, where should I start?
|
# ? Aug 8, 2010 00:06 |
|
nbv4 posted:I'm writing a desktop gui program in python and I need to make an installer for windows users. Asking windows users to install python and then setuptools, and then extract a zip file, navigate there on the commandline and then type in "python setup.py install" is asking too much. I need to make it a one single exe that will install python (if not already installed), wxpython (and a few others), etc. all in one process. Is this possible, if so, where should I start? Might py2exe fit the bill?
|
# ? Aug 8, 2010 00:11 |
|
The Journey Fraternity posted:Might py2exe fit the bill? I looked into that, but it seems to be just for simple one-file scripts. I'm looking for a big installer that will install a bunch of dependencies.
|
# ? Aug 8, 2010 00:13 |
|
nbv4 posted:I looked into that, but it seems to be just for simple one-file scripts. I'm looking for a big installer that will install a bunch of dependencies. I've had some success with py2exe for programs that use several third party modules. You should give it a try, at least. When it does work, there's no installation necessary - your users just launch the exe. It won't work if you're doing any tricky stuff like importing modules in exec statements, though.
|
# ? Aug 8, 2010 00:22 |
|
nbv4 posted:I looked into that, but it seems to be just for simple one-file scripts. I'm looking for a big installer that will install a bunch of dependencies. I've used py2exe for a script with something like 10 dependencies or something.
|
# ? Aug 8, 2010 17:25 |
|
We have an automated job that is creating hot backups of a couple dozen SVN repositories and storing them with revision numbers as a tar.gz. The files end up looking something like one of these: reponame-qa-567-608.tar.gz, testrepo-670.tar.gz, or somerepo-34-434.tar.gz I wrote the following section of code as part of a recovery operation, that will take the filenames, strip the revisions, and move the directories so that the above repos would end up like: reponame-qa, testrepo, and somerepo code:
|
# ? Aug 9, 2010 15:00 |
|
From my experience, regex is pretty slow. Also, you're compiling the regex every time through the loop. # precompile the regex entry_re = re.compile("\D") <...> if entry_re.match(word) is not None: tmpArray.append(word) <...> You could also move to using the built-in calls in the os module to get around using popen (which has to go through the overhead of making fork() system calls): i.e. os.popen("ls") becomes os.listdir(".") os.popen("mv -f") becomes os.rename(src, dst) Moving away from popen and compiling the regex should increase the speed by a considerable margin (if you're operating on a large number of files). If this is just a dozen files or so, it won't matter too much, however.
|
# ? Aug 9, 2010 15:26 |
|
os.walk is the go-to for this kind of thing. That and shutil.move are both preferred to popping open your own terminal processes. The glob module is good if you don't need multiple levels and will always be looking for *.tar.gz edit: well, looks like I'm second, and with some different resources. Spankweasel's suggestions are fine, but when you said "more efficient" I didn't necessarily take that as in minimizing runtime speed. I assumed you meant quickest in terms of writing something readable and that did the job. edit2, here's what I'd do: code:
Lurchington fucked around with this message at 15:40 on Aug 9, 2010 |
# ? Aug 9, 2010 15:28 |
|
inveratulo posted:Can anyone do it better? code:
code:
Threep fucked around with this message at 15:45 on Aug 9, 2010 |
# ? Aug 9, 2010 15:43 |
|
Goddamn guys thanks a ton! My attempt was truly infantile.
|
# ? Aug 9, 2010 15:50 |
|
The glob module may be of use.
|
# ? Aug 9, 2010 16:09 |
|
king_kilr posted:The glob module may be of use. FUUUUUUU.. I just wrote a script that had to go slosh a 700,000 file directory system that was about 10 layers deep at some points and do some patch work and clean up some bugs. The standard library is too drat good. I have so many square wheels that I have reinvented and then learned there was a stdlib that did just that.
|
# ? Aug 9, 2010 20:52 |
|
I'm learning python (day 4!) and mostly its going well. I'm coming from PHP, and my transition project is to recreate my gallery web site I run on my HTPC in Python. (cherrypy) Looking like about 3 days to re-implement something I originally wrote in an evening Anyway: Any thoughts on which image manipulation library is the one to go for if you, say, wanted to get to grips with just one rather than spend time learning 3 or 4 and then picking? Is there a best library? Any dogs to definitely avoid?
|
# ? Aug 10, 2010 15:58 |
|
KuruMonkey posted:I'm learning python (day 4!) and mostly its going well. I'm coming from PHP, and my transition project is to recreate my gallery web site I run on my HTPC in Python. (cherrypy) PIL
|
# ? Aug 10, 2010 16:55 |
|
A word of caution: if you are at all interested in manipulating/encoding animated gifs, PIL is going to be a pain in the rear end.
|
# ? Aug 11, 2010 01:17 |
|
m0nk3yz posted:PIL Thanks; I would have probably started with one of the GD wrappers (what I use in PHP) and PIL looks pretty similar to the wrapper I ended up making for GD2 in PHP. Got my thumbnailer re-done in a little under an hour - including installing PIL and having to read the docs for every step of the process, that's pretty sweet tripwire posted:A word of caution: if you are at all interested in manipulating/encoding animated gifs, PIL is going to be a pain in the rear end. Also thanks; that's the kind of info I was hoping for. I'm not going to immediately look at gifs - if I were, is there a library that's particularly better for that?
|
# ? Aug 11, 2010 11:50 |
|
I have a need to validate quickly if an input field actually contains english text rather than "DErrrrrrrp" for users overriding a setting that usually shouldn't be messed with. Anyone have experience? I'm running on hundreds of machines win32/win64/linux/macosx so something contained would be fantastic.
|
# ? Aug 11, 2010 14:35 |
|
I'm reading this as checking that a field contains a valid English word. and if so, I found (googling for python validate input as english language): MacOSX: http://www.mail-archive.com/python-list@python.org/msg287570.html Linux (and also mac apparently): leveraging the words file Windows came up dry so far, but maybe you could confirm what exactly you wanted here's another link that looked promising on a cursory glance: http://code.activestate.com/recipes/117221-spell-checking/#c4
|
# ? Aug 11, 2010 14:47 |
|
Any english word at all? Not some list of specifc words like ['yes', 'no'] or I dunno ['development', 'staging', 'production']?
|
# ? Aug 11, 2010 14:59 |
|
|
# ? May 17, 2024 22:26 |
|
crip drinkn milk posted:I have a need to validate quickly if an input field actually contains english text rather than "DErrrrrrrp" for users overriding a setting that usually shouldn't be messed with. Anyone have experience? get them to type the change in twice
|
# ? Aug 11, 2010 16:45 |