|
I'm new to Python and programming. Which GUI do you recommend? There's lots of info on the internet, with conflicting opinions, much of which may be out of date. The most popular seem to be TKinter and wxPython. I've heard each is easier to use from different sources, and wxPython looks better/more native for every OS. I've also heard reverences to gtk and qt. Which do you prefer, and why? Any tips for getting notepad++ to run Python code through IDLE? Dominoes fucked around with this message at 15:52 on Mar 20, 2013 |
# ¿ Mar 20, 2013 15:46 |
|
|
# ¿ Apr 27, 2024 07:47 |
|
Thanks for the GUI advice dudes - I'm going to use QT.aeverous posted:I dunno why you want it through IDLE but try using the PyNPP plugin for Notepad++ and bind a key to run scripts. Is there a trick to getting the pyPdf module to work? I've been able to get several other modules to install and work, including Pip, Py2exe, requests and Rauth. If I run 'pip install pypdf', it appears to install, and populates pypdf and pypdf.... egg-info folders in python27/lib/site-packages. However, I get a crash at import module, both with 'import pypdf' and import 'pypdf2'. If I try to 'pip install pypdf2', pip can't find the package. I downloaded pypdf manually from here. Running the setup script from command prompt (setup build / setup intstall), I get an error about not finding the pypdf2 directory to install things with. If I edit the script and change the directory to the precise path, it installs a PyPDF2-1.15-py2.7.egg-info file in site-packages, but no folders, and the import command still bugs out. Dominoes fucked around with this message at 22:32 on Mar 21, 2013 |
# ¿ Mar 21, 2013 22:15 |
|
accipter posted:I think you might want to try to install pypdf2, since pypdf stopped being developed 3 years ago.
|
# ¿ Mar 21, 2013 22:30 |
|
Can anyone help me with a Python 2 to 3 conversion problem? I'm switching to Python 3, and one of the functions in a project I'm working on won't convert well. I'm looping through a website's possible urls for files until I find a valid one with URLLIB. I'm using urlopen, and verifying that the file size is a reasonable size. However, now in Python 3, I get a crash with HTTP errors when I present an invalid URL, instead of passing a bogus file, realizing it's bogus and continuing the loop. Python 2 working code: code:
code:
Error: I've spent lots of time Googling this, and haven't found a solution.
|
# ¿ Mar 22, 2013 23:47 |
|
accipter posted:Why don't you just surround the urlopen in a try/catch statement on urllib.error.HTTPError? code:
Houston Rockets posted:Why not use requests or urllib2? BeefofAges posted:Just stop what you're doing and use requests. It's interesting how I don't need to (am no longer allowed to) convert the iterator 'i' to a str in Python 3, when it was required in Python 2. Dominoes fucked around with this message at 05:07 on Mar 23, 2013 |
# ¿ Mar 23, 2013 04:51 |
|
BeefofAges posted:Don't do this. This will catch every exception. code:
code:
|
# ¿ Mar 23, 2013 16:15 |
|
Learning Qt with no programming experience is proving to be a PITA. The Zetcode tutorial has some great example code that I've been able to use and manipulate, but is fairly limited in what it demonstrates. There are several other tutorials online, all of which seem to use very different syntax - and I can't get any of them to work. I setup Qt Designer, and have been creating windows, then analyzing the code using puic, but can't get the gui to display, even when trying wrapper styles from several tutorials. Can anyone explain how to get QT Designer 5 code ->puic to run in Python 3? I'm not getting any errors, just an output of >>>. What style do you recommend as the best way to learn Qt? I'm planning to stick with the Zetcode style, but am having some issues doing things not directly described in it: For example, how can I have two separate layout widgets in a main window? This seems dramatically more difficult than learning basic Python - it might be due to lack of strong tutorials, like Codeacademy's. Dominoes fucked around with this message at 04:29 on Mar 29, 2013 |
# ¿ Mar 29, 2013 04:07 |
|
What's the most current form of Oauth for Python 3? I'm trying to create a stock screener using my broker's API, which uses Oauth. Most of the info I find is out of date or conflicting. I've seen the following modules referenced: Oauth - seems to be the original, now outdated. I get an error of "'module' object has no attribute 'Consumer'" Oauth2 - Newer version, apparently also outdated? The one most referenced one online. Glitches out in pip/can't figure out how to install it. Oauthlib - IIRC, claims to be the new replacement for Oauth and Oauth2 Rauth.OAuth2Service - Also potentially replacement for Oauth and Oauth2? Requests - ? Oauth_hook - ? pyoauth2 - I get an error about not having a module named "client" in pyoauth2's init. Which should I use? Dominoes fucked around with this message at 18:39 on Mar 31, 2013 |
# ¿ Mar 31, 2013 18:29 |
|
I'm new to programming (Finished Codeacademy labs recently), and am running into long data-crunching times on a stock screener I'm working on. The functions below parse a .CSV file and compare its values to input numbers. Doing this for a maximum* of 20,000 cells takes 1 minute. *The actual number should be smaller, since a failed cell should skip the rest of its row. (The break in the second function below) Is the time due to sloppy code? Is it normal? Is it a limit of python, compared to C++? Python's using 35% of my CPU while the evaluation's occurring. The 'evaluate' function is a method of a class whose instances are contained in 'parameters' input for the 'passing_stocks' function. I removed some dubugging, output and formatting code. code:
code:
Dominoes fucked around with this message at 16:32 on Apr 3, 2013 |
# ¿ Apr 3, 2013 16:26 |
|
a lovely poster posted:Is there any way you can the data you're pulling to do some of the heavy lifting for yourself? What kind of screens do you want to use? How many stocks are you pulling information for? I want to screen for price, % change, average volume, and possibly some other real-time criteria. I also want to screen for price changes over selectable increments of time - a function I haven't found on any existing screener. I'm using Yahoo Finance. For now, I'm using a canned list of stocks pulled from the nyse, nasdaq and s&p500 website - about 5,000 total. I'm pulling the real-time data into a .csv, in 200-stock-per-query increments, the max allowed by Yahoo. Surprisingly, this takes substantially less time than the actual number crunching. I'm also pulling and analyzing historical price data, which the functions I posted don't deal with. I'll post them, or the whole program if you're curious. Unfortunately, I can only seem to pull the historical data one-stock-at a time, so I've been pulling and analyzing a stock, then looping, instead of pre-downloading. I'm only pulling/analyzing historical data for stocks that passed the real-time screening. I'm trying to set up the program to work with my broker (tradeking) as well, but I'm having trouble getting Oauth to work with Python 3 - that's what my previous post in this thread was about. Dominoes fucked around with this message at 16:47 on Apr 3, 2013 |
# ¿ Apr 3, 2013 16:38 |
|
DARPA posted:What does the function read_cell look like? code:
Dominoes fucked around with this message at 16:57 on Apr 3, 2013 |
# ¿ Apr 3, 2013 16:46 |
|
Thanks guys - Really appreciate it. Going to fix it this evening!
|
# ¿ Apr 3, 2013 17:17 |
|
Problem solved! I used evilentity's load_csv function. I added this line at the top of passing_stocks: "data = load_csv('data.csv')" Read cell now looks like this:code:
Pivotal Lever posted:Another tip, if there's a module for what you're trying to do in the standard library, use it instead of rolling your own solution.
|
# ¿ Apr 3, 2013 21:19 |
|
DARPA posted:You are still walking the full length of the lists. You can directly address the cell. Dominoes fucked around with this message at 22:23 on Apr 3, 2013 |
# ¿ Apr 3, 2013 22:18 |
|
Another CSV / memory vs drive write question. If I want to download a CSV from a url, is there a way I can put the file information directly into a variable in memory? I've tried many combinations using list(), read(), csv.reader() etc, but can't find a working solution that skips writing the csv to disk, and reading it. Code like this works: Python code:
Python code:
|
# ¿ Apr 6, 2013 01:40 |
|
maniacripper posted:Should I bother with ver2 at all? Should I just start learning ver3? I'm learning Python, and chose Python 3 because it's the newer, refined version. You're more likely to run into compatibility problems with external modules in Python 3, since most of the information and development resources available are for Python 2. Philosophically, I suggest using Python 3 - you'd be helping push the community to upgrade. Dominoes fucked around with this message at 19:48 on Apr 7, 2013 |
# ¿ Apr 7, 2013 18:55 |
|
Is there a way to procedurally change a function based on variables, like in a loop? The best way I can describe it is with psuedocode:Python code:
|
# ¿ Apr 10, 2013 01:25 |
|
Hammerite posted:There's probably a better way to do this, and I'm tired or I would think about it and suggest one. But yes you can do that using __getattribute__.
|
# ¿ Apr 10, 2013 02:01 |
|
Is there a working PDF manipulation module for Python 3? I've tried Pypdf, but it glitches out when I try to install with PIP. I'd like to merge PDF files. If I use Pypdf2, I get the following message using this code:code:
"File "c:\...merger.py", line 97, in merge elif type(fileobj) == file: NameError: global name 'file' is not defined" Line 97 of merger.py is " elif type(fileobj) == file:" I get similar errors in my own code when using code such as "input1 = PdfFileReader(file("document1.pdf", "rb"))" - that's a copy and paste from http://www.blog.pythonlibrary.org/2012/07/11/pypdf2-the-new-fork-of-pypdf/ Dominoes fucked around with this message at 02:22 on Apr 11, 2013 |
# ¿ Apr 11, 2013 00:41 |
|
I'm hoping someone can help me with a QT / designer question. The example code I've included shows how I've been setting up the code, which may not be correct. I'm trying to get programs that are not in classes that work with QT directly to change aspects of the GUI. I've set up example code showing the structure of my programs. My goal is to get the function btn_about2, in the main program (or another class) to change the main window's statusbar. I've included two windows in this example, to clarify how my gui code's structured.Python code:
Dominoes fucked around with this message at 15:12 on Apr 13, 2013 |
# ¿ Apr 13, 2013 14:54 |
|
Dominoes posted:I'm hoping someone can help me with a QT / designer question. The example code I've included shows how I've been setting up the code, which may not be correct. I'm trying to get programs that are not in classes that work with QT directly to change aspects of the GUI. I've set up example code showing the structure of my programs. My goal is to get the function btn_about2, in the main program (or another class) to change the main window's statusbar. I've included two windows in this example, to clarify how my gui code's structured. code:
Method 2: using os.path.dirname(__file__). This works in the uncompiled script, but the compiled program loads the GUI, then glitches out with the following error: Dominoes fucked around with this message at 00:38 on Apr 15, 2013 |
# ¿ Apr 15, 2013 00:22 |
|
I finished my first program! I'm having trouble making a binary using Python 3 and cx_freeze. The binary runs on my computer, but on another computer I'm testing it on, I get the message "Can't find MSCVR100.dll". I looked this up, and it appears to be a visual studio C++ file. I located the DLLin my Windows/sysWOW64 directory, and moved it into my application directory on the computer with the error. (Both are Win 8 64-bit) I now receive an error 0xc000007b, which appears to be a 64-bit compatibility error. This website describes receieving these two errors in sequence, presumably using C++. He found the fix to be installing Visual Studio. Doesn't make sense. Very little of the information available on either the DLL or the 07b error mentions python or cx_freeze, which is why I'm stumped. The program does use QT, which I feel may have something to do with it. Any ideas? Dominoes fucked around with this message at 04:27 on Apr 19, 2013 |
# ¿ Apr 19, 2013 02:07 |
|
Plorkyeran posted:Install the Visual Studio 2010 redistributable package.
|
# ¿ Apr 19, 2013 02:58 |
|
QuarkJets posted:Do you have the Visual Studio 2010 redistributable package on the computer that you're using to create the binary?
|
# ¿ Apr 19, 2013 04:29 |
|
The computer where the program's not working has an x86 visual c++ runtime, but not x64. It has mscrv100.dll in the syswow64 folder, but not the sys32. If I remove the .dll I added to the program folder, I get the missing .dll error. If I move it to sys32, I get the 000007b error. This is a pretty simple program; there's got to be a better way. Whenever I'm thinking about installing a new program, and it makes me install some weird package, I get annoyed and consider not bothering. I don't want to program that way. I'm surprised more about this doesn't come up in searches about qt, cx_freeze etc; it seems like something lots of people would run into. Does wx_widgets have this problem? Dominoes fucked around with this message at 13:36 on Apr 19, 2013 |
# ¿ Apr 19, 2013 13:24 |
|
Modern Pragmatist posted:Any standalone executable you create for windows relies upon the c++ runtime regardless of which libraries you use. The runtime is required for the python interpreter that is included with the executable. accipter posted:It seems like underscores break URL tags... edit: Solved! The required files are msvcr100.dll and msvcp100.dll from the Sys32 directory. Dominoes fucked around with this message at 17:02 on Apr 20, 2013 |
# ¿ Apr 20, 2013 00:23 |
|
Lesson in reinventing the wheel today: I created a function that allows date addition and subtraction using modulus and floor division. Turns out the datetime function already does that! It was a good learning experience.
Dominoes fucked around with this message at 02:37 on Apr 21, 2013 |
# ¿ Apr 21, 2013 02:33 |
|
Suspicious Dish posted:And chances are you got it wrong.
|
# ¿ Apr 21, 2013 05:30 |
|
Technique question: I have two similar very similar, and lengthy bits of code (Pulling financial data from two different sources, one uses json, the other csv). There are common replaceable items. For example, where one function uses 'data[i][4]', the other might use 'data[n][day]['date']'. I'd pass '[n][day]' and '[i][4]' as parameters to the new function, reusing the code instead of having it exist twice. Logically, it seems easy to combine these into a common function, but simply turning them into arguments doesn't seem to work. Option 1: Keep the functions separate due to this issue. Don't try to reuse the code Option 2: I've read about using exec(), but it seems like a messy hack, and I can't get it working. Option 3: A Python solution designed for this scenario that I haven't found. Someone earlier helped me with a similar problem using __getattribute__ with %s, but I can't seem to get it working in this scenario, and it also feels like a weird hack. What's the preferred way to handle this? example: Python code:
Dominoes fucked around with this message at 18:55 on Apr 21, 2013 |
# ¿ Apr 21, 2013 18:34 |
|
Nippashish posted:
Python code:
Python code:
Dominoes fucked around with this message at 19:42 on Apr 21, 2013 |
# ¿ Apr 21, 2013 19:27 |
|
Thanks Plork - that works too. Last one! I think this can be solved with an if statement asking which input format you're entering (as an additional parameter) and having two separate return lines, but I'm wondering if there's a cleaner way. Python code:
Dominoes fucked around with this message at 20:09 on Apr 21, 2013 |
# ¿ Apr 21, 2013 20:02 |
|
Suspicious Dish posted:Please share more about your actual problem. This seems like overengineering at the highest level. It looks like I have a working solution using Nippa's and Plork's examples. I used an if statement as described to sort the last example I posted. Here's the current implementation: Python code:
|
# ¿ Apr 21, 2013 20:33 |
|
QuarkJets posted:Agreed; I have no idea what you're asking for at this point. What is this most recent Python code supposed to do? I'm now curious if there's a way to clean up the duplicate 'if' statements in a situation like this. Dominoes fucked around with this message at 20:43 on Apr 21, 2013 |
# ¿ Apr 21, 2013 20:36 |
|
Suspicious Dish posted:Why do you have variables named n2 and n3? Dominoes fucked around with this message at 22:35 on Apr 21, 2013 |
# ¿ Apr 21, 2013 22:33 |
|
QuarkJets posted:Don't do this: edit: I like your True/False return suggestion more than returning the symbol name. Changed. Removed the "failed" variable. Suspicious Dish posted:Name them something better. I also see a lot of issues with your code; use more variables. Like, I see that some of your code references date_loc1, which AFAICT doesn't exist. I don't know much about your data structures, but you should be able to use zip() or something instead of the range. Dominoes fucked around with this message at 02:22 on Apr 22, 2013 |
# ¿ Apr 22, 2013 00:44 |
|
Replaced all instances of "n" and "i" iterators with names that make sense in both my programs. Do y'all usually include __repr__ functions in classes containing instances? Dominoes fucked around with this message at 02:22 on Apr 22, 2013 |
# ¿ Apr 22, 2013 02:01 |
|
Dren posted:Dominoes, you were talking about having data from two sources. One dataset is in json the other is in csv. Do the two data sources provide you the same data? If so, you should look at creating your own type, call it StockData. When you ingest data, load it into a StockData object. The custom code for how to read in each type of data will go into those load functions. Your code will access the StockData object. This way you don't have to write nutty custom accessor stuff (like the code you have). I finished my first computer program, and sent it to my coworkers tonght! It provides an interface for quickly downloading the latest version of a selection of FAA instrument procedures, and saving them as a combined PDF, or individual ones. I'm hoping to make it universal later, with the ability to select any FAA procedure, instead of just the ones I loaded. Dominoes fucked around with this message at 02:30 on Apr 23, 2013 |
# ¿ Apr 22, 2013 23:50 |
|
dantheman650 posted:I am completely new to programming and am playing around with Python after learning some basics on CodeAcademy. I tried using Notepad++ on a friend's recommendation but it turns out getting Python code to run from it is a pain. The OP of this thread is mostly going over my head and the tutorial on setting up VIM is much more advanced and complicated than anything I need at this point. What is a good, simple IDE to write and run Python code? The wiki has a huge list and I don't know which to pick. Run scripts with alt+shift+f5, or ctrl+alt+shift+f5 for GUI-only.
|
# ¿ May 1, 2013 11:12 |
|
dantheman650 posted:I downloaded the Notepad++ plugin and I have no idea what to do with it. The installation guide says to copy to the Notepad++ directory but should I copy and replace the plugin folder that is already there? Dominoes fucked around with this message at 00:08 on May 2, 2013 |
# ¿ May 2, 2013 00:00 |
|
|
# ¿ Apr 27, 2024 07:47 |
|
Solution to a question I posted a month ago:Dominoes posted:Another CSV / memory vs drive write question. If I want to download a CSV from a url, is there a way I can put the file information directly into a variable in memory? I've tried many combinations using list(), read(), csv.reader() etc, but can't find a working solution that skips writing the csv to disk, and reading it. Got it working by 1: Using Requests instead of urllib.request, and 2: using splitlines(). Here's what the working code looks like: Python code:
Dominoes fucked around with this message at 22:15 on May 4, 2013 |
# ¿ May 4, 2013 21:39 |