|
GrumpyDoctor posted:Is IronPython still being developed?
|
# ? Feb 4, 2013 21:42 |
|
|
# ? May 9, 2024 03:11 |
|
For anyone that will be (or would like a reason to to be) in the bay area from March 18-20 (right after PyCon), the semi-annual PyData conference that we host will be going on: http://sv2013.pydata.org Obviously we'd love to have anyone interested in python and data analysis attend! For everyone that can't make it, all the tutorials and talks will be recorded and and made freely available on Vimeo shortly after the conference. (You can see all the previous talks and tutorials from previous events here.)
|
# ? Feb 6, 2013 07:26 |
|
I have a super basic python script for updating the XBMC library, all it does is send the VideoLibrary.Scan command. I've recently discovered that if the HTTP web server in xbmc hangs up for some reason the script hangs with it never exiting the Scan command. I discovered this when I looked in my SABnzbd queue and found 10 downloads waiting to be processed because the script hadn't exited. Anyone have recommendations on how to add a timeout to it? I'm doing some reading and all the solutions I've found are simply overly complex. When the web server is functioning correctly the command is nearly instantaneous so I really only need to do a simple "count to 5 then exit" or something.
|
# ? Feb 6, 2013 08:48 |
|
I'm trying to call wpa_supplicant from a python script, but it's putting a space between the path (pwd) and the file name. Any idea why? Or why it's including a path at all? This is the call: call(['wpa_supplicant', '-B', '-Dwext', '-i {0}'.format(interface), '-c {0}'.format(config_file_path)]) And this is the error wpa_supp gives: Failed to read or parse configuration '/home/hefty/scripts/ generated-wpa-supplicant.conf'. Also, string.format seems like a really stupid way to do those command arguments. Is there a better way?
|
# ? Feb 6, 2013 09:05 |
|
When I'm typing in secondary prompt and I hit enter, it doesn't give me a new line, but instead executes the thing. What's up with that?
|
# ? Feb 6, 2013 13:23 |
|
Ashex posted:I have a super basic python script for updating the XBMC library, all it does is send the VideoLibrary.Scan command. Start it in a thread and then kill it if it's still going after n seconds?
|
# ? Feb 6, 2013 14:00 |
|
hey guys dumb question regarding overflow. I want to do some math with **very** big numbers, like 35**200 big etc. Now, if they were just integers, this wouldn't be a huge deal. Python would just automatically convert them to longs, and woo. However, I want to be precise here (for example, 35 is really more like 35.3). Sooooo there's the problem. I had thought that stuff like decimal.Decimal would work but it seems to also only be confined to integers. Is there a way to do math, particularly things like this without just admitting a degree of defeat on the decimal and just making all the numbers integers? This DOES make a difference!!! I was hoping to find a way to force it using a float128 or something. Thanks! JetsGuy fucked around with this message at 00:27 on Feb 7, 2013 |
# ? Feb 7, 2013 00:18 |
|
Use bigfloat? http://packages.python.org/bigfloat/
|
# ? Feb 7, 2013 00:19 |
|
BeefofAges posted:Use bigfloat? http://packages.python.org/bigfloat/ Hmm. I didn't know about this package, thanks! I was kind of hoping for a built-in solution (although I could certainly use this), does one exist?
|
# ? Feb 7, 2013 00:23 |
|
How much precision do you actually want? Do you need 2 decimal points of precision with a number that's 35**200? GMPY gives you a lot of multiprecision options. You might find Sage useful as well. It's a comprehensive Python-based math system.
|
# ? Feb 7, 2013 00:28 |
|
Scaevolus posted:How much precision do you actually want? Do you need 2 decimal points of precision with a number that's 35**200? Perhaps precision isn't the right word here. And maybe even more to the point, I maybe mis-stated my question to begin with. I don't really care about the decimals precision so much as being able to do the operations to begin with. For example: code:
EDIT: Holy breakage Batman! JetsGuy fucked around with this message at 00:38 on Feb 7, 2013 |
# ? Feb 7, 2013 00:35 |
|
Hefty posted:... it's putting a space between the path (pwd) and the file name. Any idea why? Or why it's including a path at all? How did you assign config_file_path?
|
# ? Feb 7, 2013 00:40 |
|
JetsGuy posted:Perhaps precision isn't the right word here. And maybe even more to the point, I maybe mis-stated my question to begin with. I don't really care about the decimals precision so much as being able to do the operations to begin with. Python code:
|
# ? Feb 7, 2013 00:44 |
|
The Gripper posted:I suppose you could use fractions.Fraction, which is for rational number arithmetic. I actually came up with a solution that this is kinda doing on my drive home. Excellent. I was thinking of doing something like: code:
I'd also have to do a similiar treatment if the power was a decimal like 200.1... ugh. EDIT: I would have expected something like this to exist in the built-ins. It's an obvious thing that would be needed!! JetsGuy fucked around with this message at 01:28 on Feb 7, 2013 |
# ? Feb 7, 2013 01:19 |
|
Completely unrelated to the current discussion but I only just found out that _ represents the last value that wasn't assigned to a variable in the Python console. All these years I'd never known, this would have saved a lot of time!
|
# ? Feb 7, 2013 01:27 |
|
Houston Rockets posted:How did you assign config_file_path? I'm just setting it to the file name. config_file_path = 'generated-wpa-supplicant.conf' It's gotta be the call() method that's doing it. I just tried appending the current working directory, thinking maybe it wants an absolute path: code:
Failed to read or parse configuration '/home/hefty/scripts/ /home/hefty/scripts/generated-wpa-supplicant.conf'.
|
# ? Feb 7, 2013 02:33 |
|
Hefty posted:It's gotta be the call() method that's doing it. I just tried appending the current working directory, thinking maybe it wants an absolute path: Try popen with the cwd keyword argument.
|
# ? Feb 7, 2013 03:58 |
|
Houston Rockets posted:Try popen with the cwd keyword argument. Sorry if this is really basic stuff, I just started learning python. So do you mean like this? I hard-coded the current directory just to see if it works. code:
Failed to read or parse configuration '/home/hefty/scripts/ generated-wpa-supplicant.conf'. I tried passing all the command args to Popen individually, but it complained that 'TypeError: bufsize must be an integer'.
|
# ? Feb 7, 2013 04:42 |
|
JetsGuy posted:hey guys dumb question regarding overflow. Can you change everything to log scale and just do log operations (so * is + etc.)?
|
# ? Feb 7, 2013 04:47 |
|
Hefty posted:Sorry if this is really basic stuff, I just started learning python. Oh to be able to bold a space. I would bet some money at this stage that the problem is with wpa_supplicant and that '-c{0}' will fix it.
|
# ? Feb 7, 2013 07:40 |
|
breaks posted:I would bet some money at this stage that the problem is with wpa_supplicant and that '-c{0}' will fix it. Welp, that was it . Thanks guys!
|
# ? Feb 7, 2013 08:45 |
|
Instead of directly using subprocess, I suggest using a wrapper like sarge or envoy. subprocess is really annoying to work with directly.
|
# ? Feb 7, 2013 10:32 |
|
BeefofAges posted:Instead of directly using subprocess, I suggest using a wrapper like sarge or envoy. subprocess is really annoying to work with directly. Seems like it could be vulnerable to shell injections. I don't see what's that bad about subprocess, other than having to know how arguments work.
|
# ? Feb 7, 2013 10:46 |
|
Suspicious Dish posted:Seems like it could be vulnerable to shell injections. I don't see what's that bad about subprocess, other than having to know how arguments work. Hmm, google'ing envoy turns up this example: envoy.run('rm -v %s' % item) Which could presumably turn into: envoy.run('rm -v %s' % '-f /') Not that anyone is using this stupid little script I'm writing, but I'll probably stick with parameterized arguments since I don't know what the hell I'm doing.
|
# ? Feb 7, 2013 12:20 |
|
Suspicious Dish posted:Seems like it could be vulnerable to shell injections. I don't see what's that bad about subprocess, other than having to know how arguments work. iirc Reading from stdin or stderr can block the other. It's easier to spawn off threads to collect them.
|
# ? Feb 7, 2013 14:56 |
|
Hey y'all, I tried using bigfloat, but there was some library issue. I had installed mpfr and that other thing no problem, but it was still complaining. So I instead took the route of evaluating the function in log space like was suggested before. This helps evaluate, but ultimately, when trying to convert back to linear space. For further clarification, I'm trying to evaluate the Poisson distribution at large numbers. Other problems I'm seeing is that virtually all the factorial/gamma functions I am finding limit themselves to double precision. The problem is definitely in the overflow and not in the precision, so sorry about the earlier confusion. EDIT: I hate to say this, but this would be easier in MATLAB, which a colleague of mine is using and having no problems. I guess MATLAB automatically has some kind of built in quadruple precision avail if need be. JetsGuy fucked around with this message at 22:38 on Feb 7, 2013 |
# ? Feb 7, 2013 22:35 |
|
Welp, I have now thoroughly embarrassed myself before the entire thread. I swear, I googled for this before, and only could find RNGs.... Nonetheless, after all this time looking for how to handle huge floats, after wasting colleagues time looking for answers as to how best to "trick" the system... I find this: code:
I still am kind of interested in how that is calculated though, seeing as python/scipy seem to be so vehemently against doing any kind of long-float operations, as I've now seen. JetsGuy fucked around with this message at 00:00 on Feb 8, 2013 |
# ? Feb 7, 2013 23:57 |
|
JetsGuy posted:Hey y'all, I tried using bigfloat, but there was some library issue. I had installed mpfr and that other thing no problem, but it was still complaining. If you're doing anything like evaluating likelihoods of Poisson random variables, you know you can rescale the log-likelihoods before you convert them back (since you're going to be normalizing to get probabilities anyway). E.g, you have Python code:
|
# ? Feb 8, 2013 00:50 |
|
Long shot here, but I'm occasionally doing a lot of blitting in pygame and tried to just run the function doing it in a new process but that didn't work because a separate process doesn't share the same display and I just get 'pygame.error: display Surface quit' errors. I considered using threads but from what I can see they are likely to have the same problem and pygames builtin thread support gives me a bunch of errors when I call threads.init() it and probably hasn't been ported to the Python 3 version. Is there a way around this or is loading some graphics in the background too much to ask?
|
# ? Feb 8, 2013 02:38 |
|
Suspicious Dish posted:Seems like it could be vulnerable to shell injections. I don't see what's that bad about subprocess, other than having to know how arguments work. The syntax is overly complex, given that all I usually want is "run this in the command line and give me the output".
|
# ? Feb 8, 2013 05:14 |
|
JetsGuy posted:I still am kind of interested in how that is calculated though, seeing as python/scipy seem to be so vehemently against doing any kind of long-float operations, as I've now seen. They work with the log: code:
https://github.com/scipy/scipy/blob/master/scipy/special/cdflib/gamln.f https://github.com/scipy/scipy/blob/master/scipy/special/cdflib/gamln1.f
|
# ? Feb 8, 2013 06:19 |
|
BeefofAges posted:The syntax is overly complex, given that all I usually want is "run this in the command line and give me the output". Python code:
|
# ? Feb 8, 2013 06:36 |
|
Suspicious Dish posted:
I'll post some examples tomorrow when I'm in the office.
|
# ? Feb 8, 2013 08:09 |
|
Is there a way I can make all instances of a class share specific properties? Here is a pseudocode example of what I mean: code:
>> 5 code:
>> 20 I'm almost certain that I read it was easy to do this but I can't find it on google because I don't know what the concept is called. If anyone knows and could tell me I'd very much appreciate it, thank you. I thought it was a matter of using, for example, 'Tiger' instead of 'self' when defining class properties but that doesn't appear to work. Kosani fucked around with this message at 18:55 on Feb 9, 2013 |
# ? Feb 9, 2013 18:46 |
|
You do that by setting the variable on the Tiger class. You define "paw_size" (don't use camel case, its not python style) on the Tiger class:code:
|
# ? Feb 9, 2013 19:08 |
|
how!! posted:You do that by setting the variable on the Tiger class. You define "paw_size" (don't use camel case, its not python style) on the Tiger class: Thank you for getting back to me so quickly. Can you explain why you inherit from object when defining the class? For me, your code works either way (using 'class Tiger(object):' or class Tiger: ') Is that just good practice for some reason? I'm new to python. Kosani fucked around with this message at 19:46 on Feb 9, 2013 |
# ? Feb 9, 2013 19:41 |
|
Kosani posted:Thank you for getting back to me so quickly. Can you explain why you inherit from object when defining the class? For me, your code works either way (using 'class Tiger(object):' or class Tiger: ') Is that just good practice for some reason? I'm new to python. "New-style classes" inherit from object: http://www.python.org/doc/newstyle/
|
# ? Feb 9, 2013 19:49 |
|
Rothon posted:"New-style classes" inherit from object: http://www.python.org/doc/newstyle/ * except in Python 3.x where you don't have to do that.
|
# ? Feb 9, 2013 19:57 |
|
In Python 2.6 I want to take a dictionary and convert all of the keys, which are strings with various cases, to lowercase strings. Right now I am doing it like this:code:
I just want to change the keys to lowercase, not create a second copy of the dictionary in memory. Does this code do that, and how can I check that this is the case?
|
# ? Feb 11, 2013 19:42 |
|
|
# ? May 9, 2024 03:11 |
|
QuarkJets posted:In Python 2.6 I want to take a dictionary and convert all of the keys, which are strings with various cases, to lowercase strings. Right now I am doing it like this: I'm pretty sure that immediately after that line both the old and new dictionaries are in memory in full, because olddict isn't being modified and is still in scope. Given you want to overwrite the old dictionary as you go, you might have to do something like this (although there might well be a builtin I'm not aware of that does the same thing) code:
|
# ? Feb 11, 2013 19:52 |