|
Thermopyle posted:I just want to make sure that I'm not missing something... I tried to figure this out for months and I also could not for the life of me figure it out. It gets even worse when you start trying to do it cross platform. You can really easily hook the keyboard in Windows, but it is inelegant and isn't a viable solution for Linux/OSX. If anyone else has an answer to this, I don't even care what it is, I'd be really curious to hear it.
|
# ? Jun 9, 2014 19:08 |
|
|
# ? May 9, 2024 09:54 |
|
How can I do this in one line:Python code:
|
# ? Jun 9, 2014 20:52 |
|
the posted:How can I do this in one line: You already did do it in one line, though...? quote:Python 3.3.1 (v3.3.1:d9893d13c628, Apr 6 2013, 20:25:12) [MSC v.1600 32 bit (In Add from __future__ import print_function if on Python 2
|
# ? Jun 9, 2014 20:59 |
|
the posted:How can I do this in one line: I guess you want a comprehension: Python code:
Python code:
Python code:
(And of course the more correct way is to use a generator expression there instead of a list comprehension)
|
# ? Jun 9, 2014 21:42 |
|
The March Hare posted:I tried to figure this out for months and I also could not for the life of me figure it out. It gets even worse when you start trying to do it cross platform. You can really easily hook the keyboard in Windows, but it is inelegant and isn't a viable solution for Linux/OSX. Could you run some sort of daemon process in the background that picks up the hotkey presses, and sends them on to your program?
|
# ? Jun 9, 2014 21:46 |
|
ohgodwhat posted: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. I didn't think there were NaNs in the data but there were, basically. Being new to Pandas, I thought the fancy slicing notation like s[(s > 0) && (s < whatever)] was the same as .clip(0, whatever). Turns out the first filters out NaNs and the second doesn't. I did accidentally find an inconsistency between the behavior of .sort and .order, so hooray for stupid newbies, I guess?
|
# ? Jun 9, 2014 22:05 |
|
Nimrod posted:Could you run some sort of daemon process in the background that picks up the hotkey presses, and sends them on to your program? This is what I'm going to end up doing I think. It just kind of sucks that PySide doesn't have the hooks built-in. I'm not exactly familiar with wxPython, but I believe it can do this with RegisterHotKey.
|
# ? Jun 9, 2014 22:46 |
|
Thermopyle posted:I just want to make sure that I'm not missing something... There's no way to do that in Qt in general. It's not a binding issue. It's not something toolkit authors or desktop environments want to expose directly, because there's the great question of "what happens if two apps do this". Under X11 you abuse the key grab system with XGrabKey. Under Windows it's RegisterHotKey. Under OS X you have to use Carbon, the old UI toolkit, because they removed the feature entirely from Cocoa. And that's a giant mess, because Carbon has its own event loop which you have to spin independently. And it won't work on new windowing systems like Wayland or Mir, which don't provide any functionality for that at all. Really, global keyboard shortcuts belong to the user, which means that the user should configure his own settings from the desktop to trigger your app.
|
# ? Jun 9, 2014 23:27 |
|
the posted:How can I do this in one line: use numpy: ads[0:16, 0] Edit: or ads[:, 0] if 0 through 16 is all of the rows BigRedDot fucked around with this message at 01:44 on Jun 10, 2014 |
# ? Jun 10, 2014 01:34 |
|
Symbolic Butt posted:I guess you want a comprehension: I was wondering if there was a way to print all the 16 elements in ads[1][0] through ads[16][0] with array notation, I thought that adding a : somewhere would do it, but I guess not
|
# ? Jun 10, 2014 01:41 |
|
the posted:I was wondering if there was a way to print all the 16 elements in ads[1][0] through ads[16][0] with array notation, I thought that adding a : somewhere would do it, but I guess not That works if you use a numpy array.
|
# ? Jun 10, 2014 01:43 |
|
Nimrod posted:Could you run some sort of daemon process in the background that picks up the hotkey presses, and sends them on to your program? I could yes but I am Too Dumb to know how that would be done. I imagine I'd have to write it in something lower level? I've been wanting to try Go, can Go monitor like that?
|
# ? Jun 10, 2014 03:10 |
|
The March Hare posted:I could yes but I am Too Dumb to know how that would be done. I imagine I'd have to write it in something lower level? Personally, I'm going to use AutoIT because it's easy to do hotkeys with it. It's a decent windows scripting/automation language...you might want to pick that up. Suspicious Dish posted:Really, global keyboard shortcuts belong to the user, which means that the user should configure his own settings from the desktop to trigger your app. Yeah, I've thought that for years. It'd be nice if there was some API and central place an application could register itself as wanting hotkeys for functions X, Y, and Z and there'd be a centralized UI for the user to manage it. Unfortunately, Windows has evolved to the state where every application has them buried it it's own settings somewhere.
|
# ? Jun 10, 2014 03:52 |
|
Thermopyle posted:Personally, I'm going to use AutoIT because it's easy to do hotkeys with it. It's a decent windows scripting/automation language...you might want to pick that up. I've used autoit, but I'm working fully cross-platform. I did some looking around and it looks like I can probably use Go for it, might just give it a...
|
# ? Jun 10, 2014 04:03 |
|
Thermopyle posted:Yeah, I've thought that for years. It'd be nice if there was some API and central place an application could register itself as wanting hotkeys for functions X, Y, and Z and there'd be a centralized UI for the user to manage it. That's basically the thing. Windows (and X11 and classic Mac OS) have historically always provided the developer with way too much control, "in case you might need it", and they've never backed down from it.
|
# ? Jun 10, 2014 13:16 |
|
Suspicious Dish posted:That's basically the thing. Windows (and X11 and classic Mac OS) have historically always provided the developer with way too much control, "in case you might need it", and they've never backed down from it. They can't due to backwards compat. Winrt and ios is a full redesign and gives devs very little control comparatively
|
# ? Jun 10, 2014 13:26 |
|
edit: fixed it!
the fucked around with this message at 18:07 on Jun 10, 2014 |
# ? Jun 10, 2014 17:56 |
|
Malcolm XML posted:They can't due to backwards compat. They can provide better interfaces for desktop developers by deprecating the old APIs and supplying better ones. For games, they could supply a descriptive interface for putting the system into "game mode" which possibly disables the Windows key and Alt-Tab (according to user settings), sets resolution and full-screen mode (according to user settings), enables raw input and disables the screensaver and other such things. Since the current DX APIs are loving terrible about being too low-level, you have a minute or so on every game while they modeset every possible monitor 20 times and then Windows's heuristics kick in that it's a game and sets everything up correctly Game developers would switch over to this immediately, since now they don't have to rewrite and QA the work of disabling all the shortcuts, modesetting, etc. They don't have to lose backcompat for this, too. Unfortunately, the Windows team will never do this.
|
# ? Jun 10, 2014 21:32 |
|
Suspicious Dish posted:They can provide better interfaces for desktop developers by deprecating the old APIs and supplying better ones. For games, they could supply a descriptive interface for putting the system into "game mode" which possibly disables the Windows key and Alt-Tab (according to user settings), sets resolution and full-screen mode (according to user settings), enables raw input and disables the screensaver and other such things. Since the current DX APIs are loving terrible about being too low-level, you have a minute or so on every game while they modeset every possible monitor 20 times and then Windows's heuristics kick in that it's a game and sets everything up correctly Let me tell you about WinRT,
|
# ? Jun 11, 2014 00:12 |
|
Malcolm XML posted:Let me tell you about WinRT, WinRT doesn't really do anything other than add another set of low-level APIs to Windows that MS will deprecate and forget about in two years. There isn't any attempt at solving high-level problems, only the latest replacement for OLE/COM/COM+/DCOM/ATL/MFC/.NET/WPF/Silverlight/XAML.
|
# ? Jun 11, 2014 00:43 |
|
Just wondering how I print out a list of objects. Each object contains the name of a dog and the breed. This is what I have so far but I'm a little confused why I am overwriting things in the list the next time I append an object to the list.Python code:
Any help is appreciated Tacos Al Pastor fucked around with this message at 02:26 on Jun 11, 2014 |
# ? Jun 11, 2014 02:23 |
|
The magic method __str__ determines how the object prints:Python code:
|
# ? Jun 11, 2014 02:53 |
|
So I'm having massive troubles with conda. We're building packages of our own libraries (that do have compiled components) using conda build, and then installing those packages into new environments as a means to deploy them. Half the time this works fine, the other half of the time python doesn't get linked into the environment at all. This is with the same exact packages and the same process to deploy it. There will be envname/bin/python pointing at envname/bin/python3 pointing at envname/bin/python33. but python33 isn't there, even though conda says it's installed/linked it. Of course, conda doesn't throw an error when it symlinks files that don't exist. In fact conda seems to think everything is just fine. Running 'conda install python' will say it's installed python 3.3.5, but still no python will be accessible, however 'conda install python=3.3.2' will actually install/link python, but then none of the installed packages will be found. How can you be on major version 3 of some software and still completely break in simple scenarios without even telling the user? I know this sounds ungrateful, and I know things would be worse without conda, but it's really hard for me to appreciate that when I can't even consistently achieve results using its basic functionality.
|
# ? Jun 11, 2014 03:46 |
|
How is dogs.append(first) not throwing a NameError in your print method? By the way, in addition to the __str__ magic method, you can do someting like this: Python code:
I suggest you also look into a bit called @classmethod, and see how it differs from @staticmethods and regular methods. Anything not clear, please ask! Space Kablooey fucked around with this message at 04:46 on Jun 11, 2014 |
# ? Jun 11, 2014 04:41 |
|
It's not throwing an exception because first is in the global namespace. if __name__ does not create a main method, and just because first is define at the bottom of the script doesn't stop the Dog class from getting it a runtime. Remember, the beginning of the file isn't the global namespace, the entire file is. I would not suggest giving a new python programmer decorator methods either; just define a function outside the class. It's the simplest to understand and a good habit to build first. Functions that don't act on the class object or the instance can be plain functions. Not harpin' on you for helping though.
|
# ? Jun 11, 2014 05:42 |
|
ohgodwhat posted:So I'm having massive troubles with conda. We're building packages of our own libraries (that do have compiled components) using conda build, and then installing those packages into new environments as a means to deploy them. Half the time this works fine, the other half of the time python doesn't get linked into the environment at all. This is with the same exact packages and the same process to deploy it. There will be envname/bin/python pointing at envname/bin/python3 pointing at envname/bin/python33. but python33 isn't there, even though conda says it's installed/linked it. Of course, conda doesn't throw an error when it symlinks files that don't exist. In fact conda seems to think everything is just fine. Running 'conda install python' will say it's installed python 3.3.5, but still no python will be accessible, however 'conda install python=3.3.2' will actually install/link python, but then none of the installed packages will be found. So this sounds really weird. Whether it's a bug or just some docs/communication issue, it should get resolved ASAP. If you will post details on the conda mailing list I will make sure Aaron or Ilan sees it.
|
# ? Jun 11, 2014 05:54 |
|
I'd use HardDisk's solution: __str__() and a list of objects.
|
# ? Jun 11, 2014 09:19 |
|
Suspicious Dish posted:WinRT doesn't really do anything other than add another set of low-level APIs to Windows that MS will deprecate and forget about in two years. There isn't any attempt at solving high-level problems, only the latest replacement for OLE/COM/COM+/DCOM/ATL/MFC/.NET/WPF/Silverlight/XAML. Going ot here, but Winrt is built on com .net xaml and the rest of the tech and is even native to boot. If you're building GUIs for windows it's the nicest place to be. No backwards compat to worry about. It's worth looking into seeing if ironpython works on it. For what it's worth though, the best Python GUI kit is serving an HTML ui and wrapping it in a native web control. Python GUI bindings are usually junk and are more trouble than it's worth.
|
# ? Jun 11, 2014 10:04 |
|
hlfrk414 posted:I would not suggest giving a new python programmer decorator methods either; just define a function outside the class. It's the simplest to understand and a good habit to build first. Functions that don't act on the class object or the instance can be plain functions. Not harpin' on you for helping though. Fair enough. I don't know decorators methods myself as well as I should, and I really should brush up on that. What I wanted to say with that, is that he should look up static classes/methods, but in the general OOP context. That it was implemented via a decorator method just muddled things up.
|
# ? Jun 11, 2014 18:02 |
|
BigRedDot posted:So this sounds really weird. Whether it's a bug or just some docs/communication issue, it should get resolved ASAP. If you will post details on the conda mailing list I will make sure Aaron or Ilan sees it. Thanks, I appreciate that a lot. A senior dev here has been banging his head against a wall with this for a couple days now, and I've had no luck either. Hopefully it's just something we're doing wrong that's very trivial, but our inability to reproduce it has made it tough to test. I've thought I've fixed it several times now, only to find out that something that was working has broken. I wouldn't be so frustrated if conda wasn't worth it, I'd just do something else.
|
# ? Jun 12, 2014 01:03 |
|
ohgodwhat posted:Thanks, I appreciate that a lot. A senior dev here has been banging his head against a wall with this for a couple days now, and I've had no luck either. Hopefully it's just something we're doing wrong that's very trivial, but our inability to reproduce it has made it tough to test. I've thought I've fixed it several times now, only to find out that something that was working has broken. Well we definitely appreciate the help to improve it and make it better (no better way to sharpen tools than to bang them on other people's problems). I sent an internal email about this but definitely write up something for the mailing list if you can, because they may want to ask for more details. Alternatively, the GH issue tracker is a good place too: https://github.com/conda/conda-build
|
# ? Jun 12, 2014 20:44 |
|
Oh BTW the videos from PyData Silicon Valley 2014 are up! https://www.youtube.com/user/PyDataTV Lots of great talks, covering Python with Storm, Kafka, SciDB, machine learning tools, IPython widgets, Conda, Wes Mckinney (of Pandas fame) unveiling DataPad, Rob Story's Python visualization "mega talk", and many others. My extended (three hour!) Bokeh Tutorial is up as well. If you use python and, uh, have data, you'll probably find something useful.
|
# ? Jun 12, 2014 23:31 |
|
HardDisk posted:How is dogs.append(first) not throwing a NameError in your print method? Actually that wont work. Trying to print objects that are stored in a list produces the following output: Name: spot Breed: wolf <__main__.Dog object at 0x59ae70> edit: Got it! Python code:
Thanks guys Tacos Al Pastor fucked around with this message at 01:36 on Jun 13, 2014 |
# ? Jun 13, 2014 01:22 |
|
spiralbrain posted:
Why are you setting self from __init__ as an optional parameter?
|
# ? Jun 13, 2014 09:25 |
|
Symbolic Butt posted:Why are you setting self from __init__ as an optional parameter? Why does that even work in the first place? How come it doesn't raise something like AttributeError: 'NoneType' object has no attribute 'name'?
|
# ? Jun 13, 2014 09:32 |
|
FoiledAgain posted:Why does that even work in the first place? How come it doesn't raise something like AttributeError: 'NoneType' object has no attribute 'name'?
|
# ? Jun 13, 2014 13:51 |
|
I've been experimenting sending queries to Salesforce with a module called Beatbox. Entries are returned as type "instance," and I'd like to save them to a list. I have something like this: Python code:
If I instead do: Python code:
code:
code:
code:
|
# ? Jun 13, 2014 19:17 |
|
First of all, instead of Python code:
Python code:
Thirdly, I think you're looking for the str method join: Python code:
Python code:
|
# ? Jun 13, 2014 19:33 |
|
fake edit: what SurgicalOntologist said Just as a general comment, you should really always use descriptive variable names. You might know what sf means now, but I sure as hell don't, and you likely won't a year later. It's worth doing even in one-off scripts since it helps you reason about your own code (not to mention that one-offs have a nasty habit of sneaking into larger projects).
|
# ? Jun 13, 2014 19:41 |
|
|
# ? May 9, 2024 09:54 |
|
List comprehensions are my favorite Python feature e: And as an addition to the poster above me, short variable names can make it impossible to modify your code later. If you have to search for a variable called 'd' then you're pretty much hosed if you have any variables with a d in their name
|
# ? Jun 13, 2014 20:29 |