Is it possible to use anonymous pipes with subprocess? I have bash command which I would like to run from my python script, which looks like this:Bash code:
Bash code:
|
|
# ¿ Jul 7, 2016 01:01 |
|
|
# ¿ Apr 27, 2024 09:29 |
Edison was a dick posted:That works by bash either making a fifo or using the /dev/fd symlinks to turn an open file descriptor into a file path. Thanks, this is really helpful.
|
|
# ¿ Jul 7, 2016 08:52 |
So there are lots of times in Python when I find myself wishing I had enums. For example, let's say I'm writing a Blackjack game and I want to model the possible player actions. In C or something I would have an enum containing STAND, HIT, SPLIT, etc. But since Python doesn't have enums / ADTs / whatever, I find myself at a loss for how to model things like that. What's the idiomatic Python solution? edit: Right after I posted this, my friend informed me of the fact that Python has enums. So that solves that, although I am curious how people accomplished this sort of thing before enums were added. VikingofRock fucked around with this message at 00:04 on Aug 2, 2016 |
|
# ¿ Aug 1, 2016 23:59 |
Zero Gravitas posted:Got a question for you fine folks. The problem here is that when you have an M which is slightly less than 1, and you take arcsin(1/M), you get NaN since 1/M > 1 and arcsin isn't defined for values > 1. When you enter the very long floating representation, probably M gets rounded to exactly 1.0 and things work out. Depending on your application, a decent work around might be to just say that if M < 1.0, M = 1.0 (if M can be <= -1 you'll need to modify this slightly). edit: Didn't see your edit. If you are getting in trouble with re-assigning M, you could just say M_prime = M if M >= 1.0 else 1.0. Then use M_prime in your formulae. VikingofRock fucked around with this message at 23:48 on Aug 3, 2016 |
|
# ¿ Aug 3, 2016 23:46 |
LochNessMonster posted:I noticed you mentioned my for loop overwriting the variable with each iteration but changed your reply so it's gone. That was a relevant remark as well though, I'm kinda ashamed I didn't notice that myself. Half the code I post on this site has some stupid mistake like that, so don't sweat it. It happens.
|
|
# ¿ Nov 2, 2016 21:32 |
Is python 2.6 still the default python for CentOS? The only time I ever see it nowadays is on old CentOS machines.
|
|
# ¿ Nov 3, 2016 01:07 |
Eela6 posted:
Is this line common python style? I've never seen that before and it took me a minute or two to puzzle through what it does.
|
|
# ¿ Nov 22, 2016 09:21 |
Dominoes posted:Hey dudes, running into issues scraping this image: http://www.feynmanlectures.caltech.edu/img/FLP_I/f16-01/f16-01_tc_big.svgz I'm getting a 403 too. Maybe you need to be logged into something to see that image?
|
|
# ¿ Dec 6, 2016 23:01 |
Hey so I finally got around to watching this talk, and it was pretty good! Thanks for linking it.
|
|
# ¿ Dec 24, 2016 02:23 |
Hey so what's the state of the art way of doing packaging? I want something where I can run some command(s) on the command line and it'll download all the right dependencies for my script, download the right version of python, and run the script. But it seems like there are a million different tools that each do a part of this and it's not really clear to me how they intersect.
|
|
# ¿ Feb 10, 2017 07:22 |
Fergus Mac Roich posted:I feel that half-open has been fairly universal in the languages that I've used. For example, Java's Arrays.sort() uses half-open indexing. Dijkstra essentially makes an argument for it here Yeah the only exception to this in the languages I've used is in Haskell, where [1 .. 5] is the list [1, 2, 3, 4, 5]. Generally I like half open indices, and the only time it's bitten me is in languages where I can't easily express a max bound for some reason. For example in Rust, expressing the range (i .. 256u8) doesn't work because you can't have 256 as an unsigned 8-bit value. They've talked about adding an inclusive range syntax to rectify this, so I could do (i ... 255u8) instead.
|
|
# ¿ Feb 21, 2017 05:54 |
Dominoes posted:Hey dudes. What are the best ways to learn Python, for someone with no experience? I learned from Codeacademy, which was OK. The OP looks out of date. I've heard a lot of good things about Fluent Python.
|
|
# ¿ Feb 27, 2017 19:13 |
Dominoes posted:Thread's up. Maybe add some stuff about Python 2 vs. Python 3? Someone new to the language is bound to have questions about it, since it comes up fairly often in Python discussions, and there is still a lot of Python 2 code floating around out there (particularly in scientific circles). Even if the section is just "Python 3 is better and you should definitely use it and here is why", it's probably worth having that section IMO.
|
|
# ¿ Mar 6, 2017 23:14 |
Dominoes posted:I deliberately omitted that; too political.If anything, it would be a note about missing features etc when working with old codebases. Fair enough--I didn't realize this was still a political issue within the python community. I figured most serious python programmers had switched over to 3 at this point unless they were working with a legacy codebase which used python 2. Are there large numbers of people who advocate 2 over 3?
|
|
# ¿ Mar 7, 2017 19:14 |
QuarkJets posted:For some reason Enthought (their product Canopy is basically like Anaconda) only supports Python2. I've asked their sales people in the past why they haven't moved to Python3 and their answer was basically "we think scientists still prefer and use 2" Okay, that's more similar to how I thought it was (I'm also in science academia). Mostly to me it seems like academics use python 2 because that's what's provided by default by Mac OS, CentOS, and Ubuntu, and that's like 99% of what your code is going to be running on.
|
|
# ¿ Mar 7, 2017 19:52 |
|
|
# ¿ Apr 27, 2024 09:29 |
9-Volt Assault posted:Love it that we now have 2 python threads. Feels just like real life! Don't worry, I'm sure this thread will get end-of-lifed in
|
|
# ¿ Mar 8, 2017 09:31 |