|
Avenging Dentist posted:Ok so strip out all elements more than a standard deviation from the mean: awesome, thats perfect!
|
# ? Feb 8, 2010 19:48 |
|
|
# ? Jun 2, 2024 20:18 |
|
Ugh. I'm frustrated with trying to extend unittest so the test cases will run in their own thread. I have a collection of tests which take 15-20 minutes each to run, but all do something completely different than any of the others (install VirtualBox guests) and running this test in serial will take too long. Has anybody screwed around with trying to thread test cases?
|
# ? Feb 8, 2010 22:27 |
|
spankweasel posted:Ugh. I'm frustrated with trying to extend unittest so the test cases will run in their own thread. I have a collection of tests which take 15-20 minutes each to run, but all do something completely different than any of the others (install VirtualBox guests) and running this test in serial will take too long. Have you tried using nose with its multiprocess plugin?
|
# ? Feb 8, 2010 23:27 |
|
Avenging Dentist posted:Ok so strip out all elements more than a standard deviation from the mean: drat. Numpy's fancy array indexing is awesome.
|
# ? Feb 9, 2010 03:36 |
|
I'm trying out a build of Python 3.2 from the Mercurial branch, and I came across this tidbit after I encountered some build errors on OSX.README posted:On OSX and Cygwin, the executable is called python.exe; elsewhere it's just python. Anyone have any idea why it's named as such now?
|
# ? Feb 9, 2010 15:48 |
|
Captain Capacitor posted:Anyone have any idea why it's named as such now? I don't know if this is exactly what you're asking, but that's just the pre-installation binary. It's that way in 2.6 as well. As for why, I cannot imagine.
|
# ? Feb 9, 2010 16:30 |
|
Sailor_Spoon posted:Have you tried using nose with its multiprocess plugin? I'll give this a shot today. Thanks for the idea.
|
# ? Feb 9, 2010 16:37 |
|
Captain Capacitor posted:I'm trying out a build of Python 3.2 from the Mercurial branch, and I came across this tidbit after I encountered some build errors on OSX. The original reason was the fact that HFS+ in normal operation, like windows, is case insensitive. having a Python directory, and a binary named "python" makes things unhappy.
|
# ? Feb 10, 2010 03:51 |
|
Edit: doublepost
maskenfreiheit fucked around with this message at 01:22 on Mar 13, 2017 |
# ? Feb 10, 2010 05:18 |
|
GregNorc posted:How intelligent is python about using resources? http://docs.python.org/library/multiprocessing.html
|
# ? Feb 10, 2010 06:02 |
|
ATLbeer posted:http://docs.python.org/library/multiprocessing.html Just came from a talk at a local Python authors group, someone gave a talk about Twisted and Multiprocessing
|
# ? Feb 10, 2010 07:06 |
|
Edit: doublepost
maskenfreiheit fucked around with this message at 01:23 on Mar 13, 2017 |
# ? Feb 10, 2010 16:18 |
|
GregNorc posted:So without using that library, python will restrict all work to one core? One thread. edit:link added tehk fucked around with this message at 16:35 on Feb 10, 2010 |
# ? Feb 10, 2010 16:32 |
|
tehk posted:One thread. No, you can have multiple threads (using the threading module), they might even be assigned to multiple cores by your operating system's scheduler, however they will not be run concurrently.
|
# ? Feb 10, 2010 17:19 |
|
Captain Capacitor posted:Just came from a talk at a local Python authors group, someone gave a talk about Twisted and Multiprocessing Twisted and multiprocessing? I'm interested in hearing more.
|
# ? Feb 10, 2010 17:49 |
|
m0nk3yz posted:Twisted and multiprocessing? I'm interested in hearing more. I'm interested in hearing less. I mean twisted's ok (in an 800lb gorrilla sense of the term), and multiprocessing is pretty snazzy, but BOTH AT ONCE? I'm pretty sure twisted isn't even threadsafe.
|
# ? Feb 10, 2010 18:26 |
|
king_kilr posted:I'm interested in hearing less. I mean twisted's ok (in an 800lb gorrilla sense of the term), and multiprocessing is pretty snazzy, but BOTH AT ONCE? I'm pretty sure twisted isn't even threadsafe. It depends; is it multiprocessing, or process management within twisted, which is completely different?
|
# ? Feb 11, 2010 00:11 |
|
king_kilr posted:No, you can have multiple threads (using the threading module), they might even be assigned to multiple cores by your operating system's scheduler, however they will not be run concurrently. I meant that without using a module like threading or multiprocessing you will be stuck on one thread. I assumed his question was indirectly asking "What is python's default behavior in terms of concurrency/multithreading/whatever"
|
# ? Feb 11, 2010 03:08 |
|
m0nk3yz posted:Twisted and multiprocessing? I'm interested in hearing more. I've asked the presenter to send me a copy at his convenience, I'll post a link to it at some point. How he arranged it was using Twisted to handle the web service and start/stop workers created using the Multiprocess package. For those (like myself) who have a less than keen interest in Twisted, I've heard good things about Celery
|
# ? Feb 11, 2010 04:34 |
|
Captain Capacitor posted:I've asked the presenter to send me a copy at his convenience, I'll post a link to it at some point. Yeah, using multiprocessing for work start/stop is common - celery uses multiprocessing inside of it as well.
|
# ? Feb 11, 2010 19:53 |
|
Perfectly timed for the GIL page of this megathread http://ec2-174-129-96-143.compute-1.amazonaws.com/index.html
|
# ? Feb 11, 2010 19:59 |
|
Is there a good library for sanitizing unicode text to Windows safe filenames while using some sort of heuristics for converting characters? I have just been using this: code:
My app takes movie titles from imdb.com and uses them to name files. Some example heuristics that I would like: 1. Alien³ should be converted to "Alien 3". 2. "—" (em dash) should be converted to "-". The problem is that I keep adding special cases for all these things and it feels like there should be a better way, or at least that someone else would have already came up with a bunch of these special cases.
|
# ? Feb 11, 2010 23:02 |
|
Thermopyle posted:Is there a good library for sanitizing unicode text to Windows safe filenames while using some sort of heuristics for converting characters? Those are some nasty edge cases. I don't think something like that would exist in the way you want because should Alien³ be Alien 3 or Alien^3 or Alien*Alien*Alien?
|
# ? Feb 11, 2010 23:45 |
|
Thermopyle posted:Is there a good library for sanitizing unicode text to Windows safe filenames while using some sort of heuristics for converting characters? Behold: code:
Sure, it doesn't do everything you want, but hey, it's a solution. Note: I couldn't test your examples.
|
# ? Feb 12, 2010 00:57 |
|
How about os.path.normpath()? http://docs.python.org/library/os.path.html#os.path.normpath I'm not sure if it can take in unicode, but it's worth trying.
|
# ? Feb 12, 2010 03:23 |
|
Make sure the user is actually using a filesystem that doesn't support Unicode before you start mangling names. NTFS supports every single character other than \ / : * ? " < > |.
|
# ? Feb 12, 2010 03:29 |
|
Plorkyeran posted:Make sure the user is actually using a filesystem that doesn't support Unicode before you start mangling names. NTFS supports every single character other than \ / : * ? " < > |. Wikipedia posted:The Windows kernel forbids the use of characters in range 1-31 (i.e., 0x01-0x1F) and characters " * : < > ? \ / |. Although NTFS allows each path component (directory or filename) to be 255 characters long and paths up to about 32767 characters long, the Windows kernel only supports paths up to 259 characters long. Additionally, Windows forbids the use of the MS-DOS device names AUX, CLOCK$, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, CON, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9, NUL and PRN, as well as these names with any extension (for example, AUX.txt), except when using Long UNC paths (ex. \\.\C:\nul.txt or \\?\D:\aux\con). (In fact, CLOCK$ may be used if an extension is provided.)
|
# ? Feb 12, 2010 11:58 |
|
Plorkyeran posted:Make sure the user is actually using a filesystem that doesn't support Unicode before you start mangling names. NTFS supports every single character other than \ / : * ? " < > |. I have no way to guarantee that it's going to be on NTFS without making that a system requirement...which I'd rather not do.
|
# ? Feb 12, 2010 19:39 |
|
Try to open the filename with the unmangled name and only mangle it if that fails. If you can create a file with a unicode filename, the filesystem supports unicode.
|
# ? Feb 12, 2010 20:21 |
|
Plorkyeran posted:Try to open the filename with the unmangled name and only mangle it if that fails. If you can create a file with a unicode filename, the filesystem supports unicode. I ran into this on a script I wrote that took tv episode titles and used them to name files. I removed the characters disallowed by NTFS, then attempted to write the file with the unicode characters. If an exception was thrown, I encoded as ascii. I didn't run into any cases other than accented characters (which encode to ascii somewhat gracefully)
|
# ? Feb 12, 2010 21:00 |
|
I'm having a problem getting a script to work. I've traced the problem back to getopt returning two empty lists no matter what arguments are supplied to the script. Here's how it is being used:code:
Is getopt just plain broken in Windows? I've tried running it with Python 2.6.4 and even 2.5.4 with no luck.
|
# ? Feb 13, 2010 08:25 |
|
BattleMaster posted:I'm having a problem getting a script to work. I've traced the problem back to getopt returning two empty lists no matter what arguments are supplied to the script. Here's how it is being used: Are you sure sys.argv[1:] has data in it? It seems likely to have data so that might be something easily overlooked. That same script works perfect for me on OS X.
|
# ? Feb 13, 2010 22:29 |
|
leterip posted:Are you sure sys.argv[1:] has data in it? It seems likely to have data so that might be something easily overlooked. That same script works perfect for me on OS X. You're right, it's empty. Clearly the arguments are not being passed to the script. I tried running it with "c:\python25\python.exe pmImgCreator.py [arguments]" rather than "pmImgCreator.py [arguments]" and it seems to work now. Something must have been wrong with the Windows file associations. Thanks for the advice.
|
# ? Feb 13, 2010 22:52 |
|
Does anyone have any good suggestions and recommendations for good practices when creating python packages? Basically i am tasked with combining a dozen or so modules, a lot of them have overlapping functionality, in some cases certain functions have just been copied and pasted. The other important part is, certain methods have 2-3 different ways of doing certain things depending on what modules currently exist in the system. For example if the user has python 2.4 then generally they will have win32com, however in 2.5 win32com is not installed by default with ArcGIS python install, so we write a method of doing the same thing via ctypes. So there is alot of: code:
So basically this is what i am looking at right now: code:
Also the second thing i also am tasked with, is that we want these modules to have a debugging logger. Such that certain key bits of information is stored. I know i can simply use code:
Can anyone shed some light on good practices for packages, and is there anything terribly wrong with my design?
|
# ? Feb 16, 2010 17:35 |
|
UberJumper posted:Does anyone have any good suggestions and recommendations for good practices when creating python packages? It's probably best to just end it all now. Death is the only escape from distutils/setuptools et al. (I'll discuss more in detail later. This is as much a reminder for me to write a big pile of words as it is me being snarky.)
|
# ? Feb 16, 2010 17:37 |
|
We have a site that uses some hosted Filemaker databases to serve up some webpages and act as an e-commerce site. The host does not do a good job of monitoring the databases and they close 2-3 times a week causing the site to not load. I'm sick of getting calls about the site going down and being the only person in the company that has the capability to pick up the phone and call the host to have them open the files again. I put this together (this is my first ever attempt at something like this) to check the url and if I gett an HTTP Error response send out an email to our host's support inbox. I was wondering if any of you saw any problems with my script. Also, is there a way to run this with cron on OSX or is there a better way to run this? I want the script to run every 10 minutes. code:
|
# ? Feb 16, 2010 17:52 |
|
UberJumper posted:The other important part is, certain methods have 2-3 different ways of doing certain things depending on what modules currently exist in the system. For example if the user has python 2.4 then generally they will have win32com, however in 2.5 win32com is not installed by default with ArcGIS python install, so we write a method of doing the same thing via ctypes. Why not just specify a dependency on the ctypes distribution when you're in Python 2.4? If you're using setuptools, it's as easy as adding install_requires = ['ctypes'] to your setup call (when running Python 2.4). UberJumper posted:
More to the point though, this should happen only once per file (if at all). What's the point in doing this for every function/function call? It just makes code hard to read. Do this: code:
UberJumper posted:
Why is there a root-level __init__.py? That doesn't really even make sense.
|
# ? Feb 16, 2010 18:40 |
|
Avenging Dentist posted:Why not just specify a dependency on the ctypes distribution when you're in Python 2.4? If you're using setuptools, it's as easy as adding install_requires = ['ctypes'] to your setup call (when running Python 2.4). Didn't realize that i'll take a look at it. The ctypes stuff is pretty much a very small user group, who does not have pywin32 installed. I'll take a look tho. quote:More to the point though, this should happen only once per file (if at all). What's the point in doing this for every function/function call? It just makes code hard to read. Do this: Thats awesome i love it. quote:Why is there a root-level __init__.py? That doesn't really even make sense. I thought by default all python packages require an __init__.py file, in the root of the package?
|
# ? Feb 16, 2010 19:15 |
|
UberJumper posted:I thought by default all python packages require an __init__.py file, in the root of the package? The root of the package, yes (i.e. foo_package/__init__.py). Not in the directory containing the package directory. It's like index.html for a website.
|
# ? Feb 16, 2010 19:32 |
|
|
# ? Jun 2, 2024 20:18 |
|
Avenging Dentist posted:The root of the package, yes (i.e. foo_package/__init__.py). Not in the directory containing the package directory. It's like index.html for a website. Blah thanks i think i just screwed up my example.
|
# ? Feb 16, 2010 20:05 |