|
good jovi posted:Try upgrading pip Way ahead of you on this exciting adventure! code:
|
# ? Jun 4, 2014 14:03 |
|
|
# ? Jun 11, 2024 07:22 |
|
Ooh, I know, how about we update pip, wheel, and setuptoolscode:
|
# ? Jun 4, 2014 14:34 |
|
tef posted:Way ahead of you on this exciting adventure! ah, huh... easy_install -U pip? I've seen similar errors in the past where the pip executable wasn't actually pointed at the same code that was being installed, usually caused by poor $PATH hygiene. The fix there was often running rm `which pip` several times followed by easy_install pip.
|
# ? Jun 4, 2014 14:34 |
|
Are you by any chance using homebrew to install python?
|
# ? Jun 4, 2014 14:36 |
|
Ok, ok maybe i'll try using easy_install to update pip, setuptools, wheel It works, although there is a problem with running easy_install now code:
|
# ? Jun 4, 2014 14:36 |
|
good jovi posted:Are you by any chance using homebrew to install python? This is on an AWS machine.
|
# ? Jun 4, 2014 14:36 |
|
I think something has either fixed itself or I was trying to debug something on a broken slate. Managed to get everything working again, but honestly I don't believe the workaround is to do 'pip install -U pip wheel' because I am pretty sure I tried this earlier.
|
# ? Jun 4, 2014 15:33 |
|
Don't use setuptools.
|
# ? Jun 4, 2014 15:41 |
|
Suspicious Dish posted:Don't use setuptools. Can you elaborate? setuptools is required for lots of things as far as I know, no? What would replace it and why?
|
# ? Jun 4, 2014 16:09 |
|
Suspicious Dish posted:Don't use setuptools. (Well, setuptools being the new version of distribute). The moral was: if you have to upgrade setuptools and pip, do it one package at a time, especially with old versions of pip.
|
# ? Jun 4, 2014 16:19 |
|
SurgicalOntologist posted:I didn't get any responses on this the first time around, and this kind of design has come up again and I'm thinking about it. Having squinted at this for a while, a few thoughts: * "outsourcing" a protocol to something, sure. Many ways to do this. * I'm a little unclear however as to whether you're trying to "outsource" for a class or a class instance I guess your vision is a factory of some sort that you pass a list of "parts" to that will provide functionality for the individual methods?
|
# ? Jun 4, 2014 16:34 |
|
outlier posted:Having squinted at this for a while, a few thoughts: Well I came up with the word delegation, and after googling it turns out that's an actual OOP concept, and I think it's pretty much what I was thinking. Although it's unclear to me how general delegation is supposed to be--maybe I'm just talking one particular sort of delegation. Yeah, that's why my example wouldn't actually work, because I was mixing levels between class and class instance. I wanted it to be for a class I guess (every instance of it). Anyways if I'm having trouble describing what I mean... I actually got it working so this should clear it up: Python code:
|
# ? Jun 4, 2014 16:57 |
|
What's the use case you have in mind?
|
# ? Jun 4, 2014 20:29 |
|
Well twice recently I have used a similar design pattern--though I haven't gone back and changed it to use this trick because I'm not sure how robust my implementation is. I wouldn't be at all surprised if there was a better way to design it in both cases, but anyways... The first, and primary use case I had in mind, is for a library I've been working on which has a tree as its primary data structure. It's for designing experiments, and an experiment is represented as a tree with named levels--the experiment contains participants which contain sessions which contain blocks which contain trials, for example. So I found myself writing code like for participant in experiment.children until I learned about magic methods, when I changed it so I could write for participant in experiment. That required writing a few methods like: Python code:
The second time it came up was writing code that interfaced between a 2D geometry library and pyglet--because pyglet has sprites but not simple shapes like rectangles. Someone somewhere convinced me not to inherit from the geometry library's Polygon class but instead use composition. Which maybe was a mistake, because I soon found myself in a similar situation. I wanted to be able to, for example, transpose my shape with in-place addition and resize it with in-place multiplication, like Polygon did. So again I found myself writing repetitive code like Python code:
SurgicalOntologist fucked around with this message at 02:42 on Jun 5, 2014 |
# ? Jun 5, 2014 02:36 |
|
Megaman posted:Can you elaborate? setuptools is required for lots of things as far as I know, no? What would replace it and why? One of our founders puts it pretty well: quote:Fundamentally, distutils conflates several things: build specification, package metadata, and installation specification. To make this even worse, it stuck all these *inside an imperative executable* called setup.py. It's like taking a swarm of angry hornets and arming them with nukes. There are only a small, finite number of ways to make this significantly worse. And some images from a recent keynote: The only marginally useful feature I found of setuptools was "python setup.py develop" but you can reproduce that by hand with five lines of code in your setup.py which is exactly what we did for Bokeh, rather than use setuptools. As for a replacement, naturally I will suggest taking a look at conda, but of course I am biased (I wrote the first version of conda two years ago, it's been taken over by others and taken much further since then). BigRedDot fucked around with this message at 03:58 on Jun 5, 2014 |
# ? Jun 5, 2014 03:47 |
|
You should use setuptools. In fact if you use pip your setup.py is going to be forced to use setuptools whether you import it or not. Yes setuptools sucks, distutils sucks more. We're slowly unraveling this great big ball of poo poo and it's getting better and a lot of that is going to be shimming the new stuff in via setuptools. One of the biggest problem with distutils is that it's impossible to actually fix anything in it, in a way that anyone is able to actually take advantage of in the next 20 years. Even if we waved our hands and made ti the perfect system, the earliest it would land is 3.5, which means no one could depend on it unless 3.5 was the minimum version for it. On the other hand, gently caress easy_install and everything it stands for.
|
# ? Jun 5, 2014 06:40 |
|
Every time I want to package something it feels like a nightmare all over again.
|
# ? Jun 5, 2014 07:57 |
|
BigRedDot posted:And some images from a recent keynote: For some reason I skipped all of this and used vendor packaging formats whenever I had to deploy python. Anyway, is conda planning to support or use wheels internally?
|
# ? Jun 5, 2014 15:37 |
|
Bundling everything in distro-specific packages is generally the right way to handle deployment to single-purpose linux servers regardless of what you're deploying, but doesn't really work for anything else.
|
# ? Jun 5, 2014 15:44 |
|
What do you guys think of using docker to package your python app? I know it's overkill but in the interest of getting stuff done, it seems like the cleanest way.
|
# ? Jun 5, 2014 16:52 |
|
tef posted:For some reason I skipped all of this and used vendor packaging formats whenever I had to deploy python. Conda will interoperate with wheels to some degree, but I am not sure to what extent. The conda and wheel package formats are quite similar but not identical. That would be a great question for the conda mailing list, though. tef posted:For some reason I skipped all of this and used vendor packaging formats whenever I had to deploy python. ployrkeran posted:Bundling everything in distro-specific packages is generally the right way to handle deployment to single-purpose linux servers regardless of what you're deploying, but doesn't really work for anything else. This is exactly the primary motivating use case that drove conda development: reproducible, cross-platform deployments (and not just of python). The best description I've heard is "cross platform homebrew"
|
# ? Jun 5, 2014 20:45 |
Python code:
|
|
# ? Jun 6, 2014 01:41 |
|
Your file isn't closed. Unindent the last two lines of your program so that they are outside the scope of the "with" line (which automatically closes your file when the block's scope ends). Edit: But you'd have to open the file again, first. Or do f.seek(0) before Image.open(f) I guess. Gangsta Lean fucked around with this message at 02:03 on Jun 6, 2014 |
# ? Jun 6, 2014 02:01 |
Gangsta Lean posted:Your file isn't closed. Unindent the last two lines of your program so that they are outside the scope of the "with" line (which automatically closes your file when the block's scope ends). Ok that does make sense. f.seek(0) didn't seem to do it though. And how do I re-open it if it's a TemporaryFile? Do I have to use a NamedTemporaryFile and hang on to the name of it? edit: NamedTemporaryFile doesn't seem to work either, the file is already gone before it gets to Image.open it fletcher fucked around with this message at 02:17 on Jun 6, 2014 |
|
# ? Jun 6, 2014 02:08 |
This seemed to work...am I leaking file descriptors?Python code:
|
|
# ? Jun 6, 2014 02:26 |
|
Doesn't look like it to me - the context manager handles everything when you exit the scope of the with clause, then PIL (p.s. use Pillow if you aren't already, it's actually maintained) will close its own handle. Also, OverflowError exists, and is more descriptive than throwing a generic Exception.
|
# ? Jun 6, 2014 10:25 |
|
Unit tests: What's an ideal place to put overall setup code? Ie loading a large database that multiple tests use. SetUp() won't do, since that's executed for each test. Are globals the right answer, or is there an ideal way to insert it as a unittest.TestCase class var?
Dominoes fucked around with this message at 11:16 on Jun 6, 2014 |
# ? Jun 6, 2014 10:46 |
|
make a helper method or function, make it a context manager, and use it in a with statement?
|
# ? Jun 6, 2014 11:11 |
|
Not really specifically a Python question, but what are some good resources for learning how to actually design OOP stuff? I know the why, what and technically how, but I think I basically still program in an imperative way but with classes and functions. Like, it's broken up, but I'm not sure it's reusable.
|
# ? Jun 6, 2014 11:38 |
|
BigRedDot posted:The only marginally useful feature I found of setuptools was "python setup.py develop" but you can reproduce that by hand with five lines of code in your setup.py which is exactly what we did for Bokeh, rather than use setuptools. As for a replacement, naturally I will suggest taking a look at conda, but of course I am biased (I wrote the first version of conda two years ago, it's been taken over by others and taken much further since then). What are those 5 lines? (As I adored working with "python setup.py develop".) Setuptools always worked nicely for me - but that's as a user who never had to delve into the innards of the package.
|
# ? Jun 6, 2014 11:57 |
|
Dominoes posted:Unit tests: What's an ideal place to put overall setup code? Ie loading a large database that multiple tests use. SetUp() won't do, since that's executed for each test. Are globals the right answer, or is there an ideal way to insert it as a unittest.TestCase class var? If you need to set up a database, then you're not writing unit tests. Stub that stuff out. That said, unittest provides module-level and class-level setup/teardown hooks. Nose will respect those, and I think it might even have a package-level setUp. Nose2 has a concept of layers that I haven't used, but looks weird.
|
# ? Jun 6, 2014 13:22 |
|
fletcher posted:This seemed to work...am I leaking file descriptors? Open your file in binary mode for writing ('wb') too.
|
# ? Jun 6, 2014 14:51 |
|
outlier posted:What are those 5 lines? (As I adored working with "python setup.py develop".) Something like: code:
|
# ? Jun 6, 2014 16:32 |
|
BigRedDot posted:Something like: Makes complete sense. While I'm here, a regex problem. I have a complex dataset extracted from a database as a csv file. The headers of the columns are written as "Foo(Bar)(Baz)" where Foo is a field in the Bar subsection of the Baz section. I'm trying to rewrite the headers as something more sensible, e.g. Baz_Foo_Bar, Baz.Bar.Foo, etc. Problems: - there's a variable number of levels. E.g. some headers are just "Foo", others are "Foo(Bar)(Baz)(Quux)". - even more problematic, some genius named a bunch of the fields things like "Bar(x)", or "Baz(Plugh)" . So you end up with headers like "Foo(Bar(x))(Baz(Phlugh))" - there is zero change of getting a different or better formatted output. While it's our data, the db is proprietary and in someone else's hands. Ideas on how to split these suckers?
|
# ? Jun 6, 2014 17:50 |
Crosscontaminant posted:Doesn't look like it to me - the context manager handles everything when you exit the scope of the with clause, then PIL (p.s. use Pillow if you aren't already, it's actually maintained) will close its own handle. Lysidas posted:Open your file in binary mode for writing ('wb') too. Very helpful! Thanks guys!
|
|
# ? Jun 6, 2014 19:24 |
|
vikingstrike posted:Here are the docs for a Series sort: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.sort.html?highlight=sort#pandas.Series.sort I know this is from forever ago, but these (and .order) are even more hilariously broken. unrelated, but has GitHub never had the ability to just search bugs or have I just never reported a bug on a project with hundreds of bugs?
|
# ? Jun 6, 2014 22:13 |
Munkeymon posted:I know this is from forever ago, but these (and .order) are even more hilariously broken. Use the search at the top of the page (it should be set to 'this repository') and then there will be multiple categories of results you can flip through on the left side (i.e. Code, Issues, etc)
|
|
# ? Jun 6, 2014 22:36 |
|
Can someone explain to me what's going on when you call a method like this:code:
What does some.method()[0] do exactly? e: nm I figured it out. conn.get_all_groups returns a list. conn.get_all_groups()[0] returns the first element of that list. namaste friends fucked around with this message at 07:08 on Jun 7, 2014 |
# ? Jun 7, 2014 07:02 |
|
Munkeymon posted:I know this is from forever ago, but these (and .order) are even more hilariously broken. I've never had an issue with pd's sorts, which isn't to say it can't happen, I'm just curious what you're doing that you're seeing a problem.
|
# ? Jun 7, 2014 19:40 |
|
|
# ? Jun 11, 2024 07:22 |
|
I just want to make sure that I'm not missing something... There's no way in PySide/PyQT to set global hotkey shortcuts? By global, I mean hotkeys that trigger even when your GUI doesn't have focus. I can't find a way to do it from PySide, and the other two things I find don't work for my needs. PyHK has an incompatible license, and PyGS hasn't been updated in 4 years and doesn't work or compile. I'm at a tipping point where I'm going to either wire up some monstrosity between AutoIT and my GUI or scrap this project.
|
# ? Jun 9, 2014 18:09 |