|
Dominoes posted:How does it relate and overlap with Tensorflow? The Tensorflow alternative in Python is Theano (and interfaces to Theano like Keras). If at all, the Scikit-learn preprocessing tools, like one-hot encoding, should complement Tensorflow well.
|
# ? Dec 5, 2015 12:48 |
|
|
# ? May 31, 2024 19:05 |
|
Nippashish posted:You can use einsum to do it like this: Thanks for this. I've never encountered einsums before so I'll need to do some reading on those but that seems extremely useful.
|
# ? Dec 5, 2015 13:20 |
|
What's the right way to express a complex type hint for a dictionary of the following format:code:
|
# ? Dec 7, 2015 00:44 |
|
There in none. In the complex type system, values of dictionaries are homogeneous. So you can't have two values with different types. Use a class if you want an object with named attributes.
|
# ? Dec 7, 2015 01:18 |
|
Ah, I understand now. I re-rendered it as Tuple[str, Tuple[int,int], Tuple[int,int]], since the names weren't important.
|
# ? Dec 7, 2015 02:16 |
|
chutwig posted:Ah, I understand now. I re-rendered it as Tuple[str, Tuple[int,int], Tuple[int,int]], since the names weren't important. But you're basically creating a bunch of these tuples and then magic-indexing into them to get coord1 and coord2, right? You should really, really consider using a class instead; it'll be so, so much cleaner and easier to understand
|
# ? Dec 7, 2015 07:26 |
|
QuarkJets posted:But you're basically creating a bunch of these tuples and then magic-indexing into them to get coord1 and coord2, right? You should really, really consider using a class instead; it'll be so, so much cleaner and easier to understand
|
# ? Dec 7, 2015 07:32 |
|
I'm trying to read a .csv-file into python, using the open-command. The file contains the Norwegian characters ÆØÅæøå. When I print lines from this file containing these characters, they show up as question marks in the console, and string comparisons with variables created from this file obviously doesn't work either. The code I'm trying to make work is basically something like: code:
Any good tips on how to read this file properly into Python? Edit: Solved the problem, first i determined the filetype using terminal "file <filename> -I", then I imported it correctly into Python using the codec module, before converting everything to utf-8 using .encode("utf-8") Flyndre fucked around with this message at 19:53 on Dec 7, 2015 |
# ? Dec 7, 2015 18:23 |
|
There may be other options that don't depend on an external lib, but . Did you try using unicodecsv? (Install it using pip install unicodecsv)
|
# ? Dec 7, 2015 19:15 |
|
QuarkJets posted:But you're basically creating a bunch of these tuples and then magic-indexing into them to get coord1 and coord2, right? You should really, really consider using a class instead; it'll be so, so much cleaner and easier to understand It's a one-off script for advent of code, not something that anyone but me will ever look at. I know it would be cleaner to create an actual class and pass that around, but for this use case a tuple with magic indexes is fine.
|
# ? Dec 7, 2015 19:24 |
|
chutwig posted:It's a one-off script for advent of code, not something that anyone but me will ever look at. Why do you need to use type hinting then?
|
# ? Dec 7, 2015 19:46 |
|
Flyndre posted:I'm trying to read a .csv-file into python, using the open-command. The file contains the Norwegian characters ÆØÅæøå. What character encoding is the CSV file? Try specifying this encoding explicitly when you open() it in Python. Try tinkering with the encoding of your terminal to make them display correctly (in Windows I find myself needing to do something like `chcp 65001`). If that doesn't work, use `ord()` to get the Unicode code point, then you can look it up online. Make sure `a` has length 1. I don't know if the encoding of your Python script will affect anything here, it might. Also the Norweigan text you gave doesn't start with "Å", but I assume that isn't the problem.
|
# ? Dec 7, 2015 19:58 |
|
Hammerite posted:Why do you need to use type hinting then? Just practicing expressing things in it. Does there need to be a reason? It's different syntax from what I'm used to with Java/Go, so I figured I'd try to formulate the appropriate Python type hints.
|
# ? Dec 8, 2015 00:58 |
|
chutwig posted:Just practicing expressing things in it. Does there need to be a reason? I guess not. In that case go ahead I guess, although a reasonable answer to what you're asking might still be, "part of learning a tool is gaining an appreciation of when to use it and when not to use it, and this is a case where you should not use this tool but use a class instead". I would give you an answer more helpful than that, but I don't really know anything about the type hinting feature, so I can't.
|
# ? Dec 8, 2015 12:12 |
|
Type hinting has become second nature to me now so that I find myself using them in 20 line scripts for whatever reason. In fact, I was providing some simple example code recently, and I realized I had some type hints in there. I took them out because they're not widely known (yet?) and I didn't want to confuse any potential users.
|
# ? Dec 8, 2015 16:22 |
|
I would like a gentle push in the right direction. I document web interfaces at my job. I would like to automate capturing screen shots. I've chosen Python as it's my strongest language. I've already checked this out: https://automatetheboringstuff.com/chapter11/ Here are my problems:
For the first two points, I can use the screen capture program Greenshot to do rolling screen captures of Internet explorer and bind this to a short cut, or otherwise manipulate the program in the notification area. I also don't know how to pass passwords to a box using python. Unfortunately the last point is beyond my css/html understanding. Our company uses frames on our web UIs to keep the menu options visable. The address bar simply reads "192.168.1.1" or whatever with the real 'page' hidden. I want to automatically scrape the the webpages for links, build a list, take a screenshot, and name them based on some text embedded in the page until finished. I've thought about using an offline page viewer application, but I'm not sure how that helps me. If I had code that could do this, it would probably save me a few hundred hours of work per year, and perhaps a couple weeks of man-hours when multiplied out to my team.
|
# ? Dec 9, 2015 06:16 |
|
Use Selenium's Python bindings and http://stackoverflow.com/questions/3422262/take-a-screenshot-with-selenium-webdriver Part of their API lets you pick a frame to interact with http://stackoverflow.com/questions/13567128/selenium-frames Or you can just record your own actions and replay them automagically if hand-coding the workflow is too much http://www.seleniumhq.org/projects/ide/
|
# ? Dec 9, 2015 15:27 |
|
EDIT: Fixed
ButtWolf fucked around with this message at 18:40 on Dec 9, 2015 |
# ? Dec 9, 2015 17:27 |
|
What is a good way to deal with a list of tuples? I'm just a touch above a beginner, so I feel like I'm missing something obvious For context, I'm using pyserial to get the COM port name that contains a certain phrase. I couldn't figure out how to extract the COM port number using list comprehension or whatever, so I converted the list of tuples to a string and extracted the COM port code:
|
# ? Dec 9, 2015 20:49 |
|
You can index the tuple, so likePython code:
Python code:
|
# ? Dec 9, 2015 22:22 |
|
Emacs Headroom posted:but your life would probably be made a little easier by converting that data into a dictionary, with something like:
|
# ? Dec 9, 2015 22:43 |
|
Munkeymon posted:Use Selenium's Python bindings and http://stackoverflow.com/questions/3422262/take-a-screenshot-with-selenium-webdriver Rats... selenium is Firefox only. Unless I learn this: https://www.youtube.com/watch?v=GxTHU_91Z1Q I spent several hours researching possible solutions. This program webshot gave me some ideas: http://www.websitescreenshots.com/usage.php#faq But, unfortunately I will still need to take some screenshots by hand for certain dialogs which can't be automated and webshot isn't rendering the images to match the screenshots I took. I tried adjusting the registry to change Internet Explorer 11 to run in standards mode instead of quirks mode, but I didn't have any luck. Here's what I came up with: code:
Next I want to use Greenshot to take a screenshot. I tried using SendKeys, but it hasn't been updated since 2003/2008 and doesn't work without visual studio installed. Instead I found pywinauto. https://github.com/pywinauto However, I'm having trouble calling up a list of available windows, plus Greenshot runs in the taskbar. https://pywinauto.googlecode.com/hg/pywinauto/docs/code/pywinauto.taskbar.html pywinauto.taskbar.ClickSystemTrayIcon(button) Anyone have any experience using this?
|
# ? Dec 10, 2015 06:12 |
|
Okay, I'm getting somewhere with pywinauto, I just need another kick in the right direction: This clicks on the greenshot icon in the system tray/notification area. Greenshot produces a popup that disappears as soon as I click away, so wrote some code to try and find the window ID. code:
[262580, 525414, 265030, 722260, 132856, 1180792, 657050] [66056, 461540, 262580, 525414, 265030, 722260, 132856, 1180792, 657050] Which leads me to believe that 66056 is the greenshot popup window. Now all I need to do is tell it to click the 5th menu option down. But how do I do that? How do I connect to this window? How do I confirm that greenshot is 66056? edit - found this text: "Often when you click/right click on an icon - you get a popup menu. The thing to remember at this point is that the popup menu is part of the application being automated not part of explorer." So it's possible I'm connected to the wrong thing. politicorific fucked around with this message at 11:27 on Dec 10, 2015 |
# ? Dec 10, 2015 10:10 |
|
How does iPython's ipyparallel compare to joblib?
|
# ? Dec 10, 2015 13:48 |
|
politicorific posted:Rats... selenium is Firefox only. Unless I learn this: https://www.youtube.com/watch?v=GxTHU_91Z1Q This is not the case. You just have to download the InternetExplorerDriverServer which is linked from the main Selenium download page. Similarly for Chrome/Safari you simply need to download and point your script to the correct executable for the driver executable.
|
# ? Dec 10, 2015 15:12 |
|
How do I install MKL with the new Anaconda?code:
|
# ? Dec 11, 2015 23:46 |
|
What's vc14? I've had 3.5 and MKL in the same environments for a while now. But I don't have vc14.
|
# ? Dec 11, 2015 23:58 |
|
Dominoes posted:How do I install MKL with the new Anaconda? Either don't install it into a 3.5 environment or wait until they build it for 3.5? This is how I interpreted it. It works in environments for every other version of Python, and that is what it looks like when any package is unavailable for a new version of Python.
|
# ? Dec 12, 2015 04:14 |
|
Anaconda 2.4.1 is out, seems to have the packages built (this is on OS X):code:
BigRedDot fucked around with this message at 04:54 on Dec 13, 2015 |
# ? Dec 13, 2015 04:51 |
|
please bump mpi4py to 2.0.0 in anaconda 2.4.2 / 2.5, thanks~
|
# ? Dec 13, 2015 18:47 |
|
After someone in this thread posted about type annotations I took some time to read a little about them and thought they could help me solve a problem I've been mulling over to do with a personal project. I started writing this personal project in Python but quickly found that it was getting to be quite hard work because I was wanting to enforce types in my methods all over the place; that's a lot of boilerplate and I realised after a while that I was trying to write statically typed code in Python. So I tried writing the same thing in C# but hit precisely the opposite problem where C# places all sorts of batty restrictions on what you can and can't do that are quite separate from being type-checked (what do you mean I can't have a method that returns an object that has the same type as "this" when called on a subclass object? what do you mean I can't have a constant value in my class that gets overridden by a subclass?) and found I wanted something more flexible again. So, is anyone aware of any packages that enforce type annotations? A decorator seems like the natural thing. I found this but there are a couple of things about it that I'm wary of. It uses some funny annotations that don't match the ones shown off in PEP 0484 ({int: str}??) and I don't like all this talk of type coercion it does - if I gently caress up types I want to know about it, if I wanted the language to try that hard to fix it for me I'd use PHP.
|
# ? Dec 13, 2015 21:50 |
|
Hammerite posted:After someone in this thread posted about type annotations I took some time to read a little about them and thought they could help me solve a problem I've been mulling over to do with a personal project. mypy The creator of MyPy, Jukka Lehtosalo, was pretty involved with the type annotations and stuff in Python 3.5, thus it's kind of the canonical type annotation consumer. edit: Oh yeah, you can get stub files with type annotations for popular libraries at the typeshed. Thermopyle fucked around with this message at 22:01 on Dec 13, 2015 |
# ? Dec 13, 2015 21:55 |
|
That's a very interesting project. It is all about statically analysing code, though. I suppose my post wasn't very explicit about what I have in mind. What I'm really thinking of is something that rather than try to analyse my code ahead of time, will check types when I call annotated functions. i.e. just as this code will throw when run:code:
code:
Hammerite fucked around with this message at 23:01 on Dec 13, 2015 |
# ? Dec 13, 2015 22:54 |
|
I don't think anyone has anything like that out. I guess what I'd ask is, what value do you envision getting out of adding type annotations and then using a library to parse those and check your types over just checking your types with isinstance or whatever logic? I mean, there are advantages, but they're dependent upon the type of project and other factors.
|
# ? Dec 13, 2015 23:18 |
|
Thermopyle posted:I don't think anyone has anything like that out. If I have 10 methods with a parameter or two each, and I want to check that all of those parameters belong to classes I've approved, and raise an exception if not, then that quickly adds up to a lot of boilerplate. If there are several possible acceptable types for each parameter and I branch on the types, then including branches for the case where an unacceptable type was supplied adds noise to the code that impacts readability.
|
# ? Dec 13, 2015 23:59 |
|
i have a bunch of python scripts that i need to turn into a persistent service. flask is fine for what i am doing but i am clueless when it comes to running python in production. most of what i can find via google is aimed at people running on shared hosting or heroku or similar. is docker my best option here? do i need to reverse proxy from nginx/apache or can flask handle traffic directly?
|
# ? Dec 14, 2015 06:11 |
|
If you can use a shared hosting, then I can't see why not use that. Failing that, I use nginx + uWSGI. The biggest problem so far is that uWSGI prevents me from upgrading to Python 3. Otherwise, it works fine for me. Space Kablooey fucked around with this message at 13:30 on Dec 14, 2015 |
# ? Dec 14, 2015 13:26 |
|
HardDisk posted:The biggest problem so far is that uWSGI prevents me from upgrading to Python 3. Otherwise, it works fine for me. Why? I've been using uwsgi with Python 3 in production for almost two years, first with Python 3.2 and now 3.4.
|
# ? Dec 14, 2015 19:05 |
|
That's nice, then. I checked the WoS and uWSGI is listed as not supporting Python 3, and I thought that it couldn't run applications made with Python 3.
|
# ? Dec 15, 2015 18:43 |
|
|
# ? May 31, 2024 19:05 |
|
Is there a way to set variable type once and be done? Designating a variable as int(input(variable),10) every time I redefine it doesn't seem right. If I don't do that it wants it to be a string, I guess because I'm using input but yeah.
|
# ? Dec 16, 2015 04:40 |