new_results = []
for row in results:
found = False
row_dict = dict(row)
for k, v in measures_as_dict.items():
print(k)
print(row_dict)
print(k in row_dict)
if k in row_dict:
row_dict = {**row_dict, **v}
break
new_results.append(row_dict)
print(json.dumps(new_results, default=default))
@MoxieBall & @OlivierMelançon That factorial encoding card trick was devised by Fitch Cheney. I wrote some C code years ago that generalised it, I guess it'd be easy for me to translate it to Python.
About 5 hours ago, version 4.1.0 was released. It is breaking my unit tests. Here is a clean MVCE displaying this:
Version 3.12:
>>> import numpy as np
>>> import yaml
>>> x = np.int64(2)
>>> yaml.dump(x, Dumper=yaml.Dumper)
'!!python/object/apply:numpy.core.multiarray.scalar\n- !!python/object...
@Anthony Click the hamburger icon on the far right of the menu bar. It opens up a list of Stack Exchange communities, but right near the top are links to help & chat.
@PM2Ring yeah thanks. can u lend a helping hand? does u know if there are relative path selectors in Selenium like there are in Scrapy (i.e. ele = response.css('#id'); ele.css('#relative'))
@Anthony Sorry, I don't know Selenium. You might get a response to your Selenium question later, this room is usually pretty quiet at this time of day.
well, the things we're yaml'ing isn't really of tip top performance bottleneck or anything. The format doesn't matter, but the guarrantees that come with yaml should at least be respected
maybe with donald stufft on the maintainers list now it will become less garbage
@OneRaynyDay So, if you weren't using yaml.safe_load your code was already broken :P
yaml.load is allowing arbitrary code execution, it's as bad as eval. the ruby community got seriously burned by the same issue (basically every ruby gem was compromised). fortunately python community was generally using .ini for config files, not yaml.
@OneRaynyDay what "guarantee" - 3.1 to 4.1 is a major version bump, that means backwards compat is broken. read semver if you don't know what I'm talking about.
@wim In the yaml documentation, they stated explicitly that "beware that yaml will execute arbitrary code like pickle"
and that was what they specified, so for current purposes we treat a part of the serialization like pickle (that we know will not execute malicious code, and don't worry it will be changed in consequent updates)
But I did not actually know about the semantic versioning thing; good read, thanks
And thanks for bringing the PyYAML release to my attention. Because this required a change in my lib oyaml for which I will releasing a new version shortly.
btw, little known trick in pip that might be handy for you to know, the squiggle equals operator. if you pip install something~=3.1 it will upgrade any point release as they become available in the future (3.2, 3.3... up to 3.9) but won't upgrade a major release.
so when you pin something, it's good to pin it like ~= so that you get the point releases / bugfixes, but you don't get the backwards breaking changes (assuming the proj maintainer are doing semver correctly).
I see. That is very useful, thanks. I'll probably cork up the errors with the ~= operator tomorrow and then do some proper cleanup afterwards and remove some unecessary yaml and move the actual pickling into pickle
"If your code makes use of the ast module, you are strongly encouraged to test (or retest) that code with 3.7.0b5, especially if you previously made changes to work with earlier preview versons of 3.7.0".
We (and by we I mean SO) have gotten pushback from our sister sites, esp. codereview, when we push low quality stuff over there. It comes up on meta from time to time.
hello folks, I am trying to install this gurobi interface Previously I've done it with Anaconda on Win OS with no problem. Now I am trying to install it on Ubuntu without Anaconda. Where is setup.py in Ubuntu? or what am I supposed to do, if you guys can take a look?
according to askubuntu.com/a/507714 you can install locally (without sudo) and use that, in which case there's no way for it to mess with system python
you could still edit your $PATH so that you can just run it as anaconda or whatever
but there are warning such as
Be careful as Anaconda seems to install their own version of moc (for building Qt apps), which may conflict with the system libraries if you compile when /home/USER/anaconda3/bin is in your path. — landroniFeb 28 '17 at 17:16
No worries. Unfortunately I don't use any fancy package manager tools (other than pip) so I can't help further :) There are a few regulars who use conda, so if you get stuck they'll eventually be able to help, probably
OK, so I read your link again: it says "the Gurobi installation includes everything you need to use Gurobi from within Python"
so yeah, there should be an existing gurobi installation of yours, inside which there's the setup.py
also I'm pretty sure you can use setup.py with --user in which case the installed files will be kept separate from the system ones, put in your home directory
@Neoares and a tendency to forget where I put things, and a need to have one of these around in about 5 different locations. Add one spare for travel, and 6 is just about perfect.
Serious question: Why does a card game need 7(!) hours of server downtime to unroll a new expansion? What do they have to do other than copy/paste some new files?
@Simon I've voted to close as unclear. The title implies that it's a Data Science problem, but then the code has things like find_dotenv() load_dotenv(dotenv_path) KAGGLE_USERNAME = which just isn't syntactically correct.
Hey, print('Roll Tide') but on a serious note. What does QUOTE_ALL really mean in the import Csv module?
Does it just mean it is gonna take into consideration that all input is a string or something and not worry about the CSV formate since there is no standard?
if a function call has a single positional argument, it can be a generator expression without extra parentheses, but in all other cases you have to parenthesize it.
it explicitly compares a function call to an assignment, so whatever the reason it's on purpose
@OlivierMelançon collisions between ants can actually be replaced by treating the ants as non-interacting (the ants can go around one another by stepping aside a bit along the stick), in which case the solution is trivial