|
EDIT: I've just realized that I don't even need the De Casteljau algorithm so this post is pretty pointless now...Thermopyle posted:For one thing, follow the Coding Horrors thread. I've got a coding horror for you right here. I'm trying to implement De Casteljau's algorithm. It gives the wrong results though and I don't know why. Here's the code: Python code:
code:
What's wrong with my De Casteljau implementation? ArcticZombie fucked around with this message at 14:54 on Mar 16, 2013 |
# ? Mar 16, 2013 12:45 |
|
|
# ? May 8, 2024 04:37 |
|
Hmm, I just tried it. Pseudo code taken from here: http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/Bezier/de-casteljau.htmlPython code:
|
# ? Mar 17, 2013 20:41 |
|
Two questions: 1. How can I automatically save the PNG file from a pylab plot? I want to save a bunch and animate them. 2. Also, why doesn't this work: Python code:
|
# ? Mar 18, 2013 21:56 |
|
the posted:Two questions: You just specify the path to the output PNG as the first argument to savefig. http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.savefig the posted:2. Also, why doesn't this work: Where did you look that made you think that would work? The documentation doesn't say anything about concatenating additional inputs. Try something like: Python code:
|
# ? Mar 18, 2013 22:06 |
|
Can you explain to me what you're doing in that last line? Thanks. edit: I'm using the savefig command, but having some issues. I'm having an integer N that goes from 1 to 20, and I want to save files 1 thru 20. I don't think the savefig command likes the integer I'm using, so I tried converting it to a string, but it's still not working: Python code:
quote:Traceback (most recent call last): edit: I changed it to: Python code:
the fucked around with this message at 22:20 on Mar 18, 2013 |
# ? Mar 18, 2013 22:12 |
|
str(N) is a function that takes N as an argument, and returns a string. If you just do code:
If you do code:
If you wanted to do what you were trying originally, you'd want something like code:
|
# ? Mar 18, 2013 22:59 |
Are there any resources with interesting/challenging python exercises for someone with novice-intermediate Python skills?
|
|
# ? Mar 19, 2013 00:33 |
|
az jan jananam posted:Are there any resources with interesting/challenging python exercises for someone with novice-intermediate Python skills? Python Challenge!
|
# ? Mar 19, 2013 01:54 |
|
Rosalind is a platform for learning bioinformatics through problem solving. The problems are quite neat; my only gripe with the site is that they recommend installing Python 2 instead of 3.
|
# ? Mar 19, 2013 02:44 |
|
Lysidas posted:The problems are quite neat; my only gripe with the site is that they recommend installing Python 2 instead of 3. Probably because the scientific python world still lives in 2.7.
|
# ? Mar 19, 2013 04:48 |
|
the posted:Can you explain to me what you're doing in that last line? Thanks. The, I use matplotlib virtually every day, and I have to recommend against using pylab. It's really a big mistake, and even the matplotlib documentation recommends against it. Pylab, as I remember it, is numpy and pyplot in the same namespace. This is rather wreckless and also doesn't hammer home which functions are in numpy and which are in pyplot. Generally, this isn't a huge deal, but I definitely prefer it. Pylab could be (slightly) better if you were making a program in which you wanted to interact with your graph, but even then, the only difference that I can think of would be simply one of convenience. Also, as another suggestion, I used to make plots using figures also, but I moved on to using subplots. Even if you are making ONE subplot, it's a decent habit to get into and many of the commands are basically the same. Most of them just require a "set_" in front of the commands you are used to. For example, your plot above may turn into: Python code:
Python code:
You can also manually set how big you want the subplots to be, which I find useful if I'm plotting residuals of a fit for example. Just a few suggestions. These are really style choices, but I really never use the figure space ever anymore.
|
# ? Mar 19, 2013 15:46 |
|
Has anyone used DiscoProject for anything serious? I just got it up and running on our lab cluster, and I'm moving some computation stuff to it (and I'm thinking about adding some functionality to automatically spool up EC2 instances and add them in to supplement when we need to). It's definitely on the immature side, but so is Hadoop I guess. Anyone got good / bad /indifferent stories on using it in the wild?
|
# ? Mar 20, 2013 00:48 |
|
Emacs Headroom posted:Has anyone used DiscoProject for anything serious? I just got it up and running on our lab cluster, and I'm moving some computation stuff to it (and I'm thinking about adding some functionality to automatically spool up EC2 instances and add them in to supplement when we need to). It's definitely on the immature side, but so is Hadoop I guess. Anyone got good / bad /indifferent stories on using it in the wild? I don't know about Disco but for all your Python automated EC2 needs everything is already there in StarCluster.
|
# ? Mar 20, 2013 03:29 |
|
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 |
|
I've used wxWidgets for a small project, and if I was doing it over I would use QT instead. wxWidgets has problems being actually good at cross-platform (especially on OSX), and the style is not good. Using the MVC pattern in QT will be better, as it's a more modern (and sane) way to organize GUIs and other systems use that kind of pattern.
|
# ? Mar 20, 2013 15:53 |
|
Dominoes posted: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? I dunno why you want it through IDLE but try using the PyNPP plugin for Notepad++ and bind a key to run scripts.
|
# ? Mar 20, 2013 16:46 |
|
I've been learning Qt and loving it, much more so than tkinter and wx. The only downside is that a lot of the documentation is for C++. It also has great cross platform support, as good as anything else or better.
|
# ? Mar 20, 2013 18:22 |
|
evensevenone posted:I've been learning Qt and loving it, much more so than tkinter and wx. The only downside is that a lot of the documentation is for C++. I would have to second Qt via Pyside. Just look at this documentation!
|
# ? Mar 20, 2013 20:23 |
|
Emacs Headroom posted:I've used wxWidgets for a small project, and if I was doing it over I would use QT instead. wxWidgets has problems being actually good at cross-platform (especially on OSX), and the style is not good. Using the MVC pattern in QT will be better, as it's a more modern (and sane) way to organize GUIs and other systems use that kind of pattern. WxPython seemed like a great idea over Christmas break when I tried to do a GUI program. I quickly learned how awful it is with OSX. There's a lot of times where the commands simply don't work on OSX systems. You'll go mad because it's the right command, but it won't work right because WxPython just simply is intended for Windows. Period. I should look at QT, though.
|
# ? Mar 20, 2013 20:49 |
|
I have used Qt and wxPython on Redhat and Windows. I couldn't say that one was necessarily better than the other, so if wxPython has Mac problems then you may as well go to Qt
|
# ? Mar 20, 2013 21:44 |
|
accipter posted:I would have to second Qt via Pyside. Just look at this documentation! PySide is pretty great.
|
# ? Mar 21, 2013 00:18 |
|
If you guys like PySide you should contribute to it Development is mostly dead, and the mailing list is a real sad place to be these days.
|
# ? Mar 21, 2013 00:22 |
|
Dominoes posted: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? If you're new to both python and programming I recommend Tkinter. It's incredibly easy to learn, handles data binding simply, and comes bundled with the standard python installation. Using the widgets from ttk makes things look nicer than Tk's reputation let's on. Just make sure the python ttk package is installed and imported. Then all it takes is changing your widget definitions like Button(...) to ttk.Button(...) and you'll get a better themed look. wx and Qt are great, but they're also a lot to take in for very little gain when you're just learning and want to make something that adds two numbers.
|
# ? Mar 21, 2013 02:43 |
|
DARPA posted:If you're new to both python and programming I recommend Tkinter. It's incredibly easy to learn, handles data binding simply, and comes bundled with the standard python installation. Using the widgets from ttk makes things look nicer than Tk's reputation let's on. Just make sure the python ttk package is installed and imported. Then all it takes is changing your widget definitions like Button(...) to ttk.Button(...) and you'll get a better themed look. That said, all of the Tkinter examples that I've seen look like poo poo, so think of it as a good educational tool only
|
# ? Mar 21, 2013 09:22 |
|
Here's an interface I'm currently working on using ttk on Windows 7: It's written in Tcl/Tk, but you could make something identical in Python quite easily. For some software that logs some data when you hit a button, it doesn't look like garbage, does it? I've chopped padding down and compressed things to use up less real estate. Don't discount Tkinter for quick and basic UIs. That being said, we're right at the point where we're laying the groundwork to switch to Qt, but we already have a prototype and can wait a little bit to do something "properly".
|
# ? Mar 21, 2013 16:28 |
|
That looks fine to me. When I think of bad user interfaces, I think of those horrible bundled utilities from video card and motherboard manufacturers.
|
# ? Mar 21, 2013 16:39 |
|
sund posted:Here's an interface I'm currently working on using ttk on Windows 7: One quick thing you could do to free up a little room is probably color "Timing Valid" and "Vertical Sync" green or red themselves rather than having to place a "yes"/"no" next to it. Still pretty easy to gather what it means and uses up less space.
|
# ? Mar 21, 2013 16:46 |
|
What's the most Pythonic way of checking if all elements in a list are also present in another list? I know I could probably do something like: code:
Edit: I also realized that this approach is O(n*m) which isn't exactly great.
|
# ? Mar 21, 2013 16:50 |
|
how aboutPython code:
|
# ? Mar 21, 2013 16:53 |
|
Civil Twilight posted:how about This requires that all elements are hashable.
|
# ? Mar 21, 2013 18:51 |
|
Is there a module out there that could help me set up NFS, CIFS, and AFP network shares in Linux via Python? I'm doing it via subprocess right now and it's not really my favorite way to handle these things.
|
# ? Mar 21, 2013 21:15 |
|
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 |
|
Dominoes posted:pypdf I think you might want to try to install pypdf2, since pypdf stopped being developed 3 years ago.
|
# ? Mar 21, 2013 22:21 |
|
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 |
|
Dominoes posted:IDLE is the only program I know of that runs uncompiled python scripts, other than a command line. What do you recommend instead? I'll try PyNPP. PyNPP will basically run the script in command line for you as a shortcut, alongside other features.
|
# ? Mar 21, 2013 23:44 |
|
IPython also will run scripts from the command line or using "IPython Magic" (which does many other really cool things, like RPy2 integration) in the interpreter itself, as well as give you tab-completion, shell access, and more goodies. fake edit: Reading comprehension failed me so I didn't realize you were talking about editor integration.
|
# ? Mar 22, 2013 00:03 |
|
Have any of you guys used VPython? If I wanted to make a short animation of, say, a few "molecules" (basically connected spheres) moving around, could that be easily accomplished in VPython? edit: Follow up question, how do I see my output? I installed the package from Vpython.org. I open up VIDLE and run one of their demo programs. It just ... runs... but no 3D output pops up. It looks like I need something called "Visual?" edit: No, looks like Visual is just the module that I'm supposed to import, which I am. What the heck is going on here? Why am I not getting any windows of 3D images popping up? final edit: Looks like VIDLE was the problem. I can run it in IPython. Bleh. the fucked around with this message at 01:55 on Mar 22, 2013 |
# ? Mar 22, 2013 01:08 |
|
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 |
|
Dominoes posted:urllib in Python 3 Why don't you just surround the urlopen in a try/catch statement on urllib.error.HTTPError?
|
# ? Mar 23, 2013 00:10 |
|
|
# ? May 8, 2024 04:37 |
|
I made a post in here about two weeks ago asking about a cryptography assignment that I was having some major problems with. Now I've come to an assignment that's due in four hours, and I don't know what I'm doing. I don't even know how to go about it. AT ALL. I think I need to buy some beer and read the provided online book all weekend until I figure it out. Maybe I can submit it for partial credit before Monday. http://www.openbookproject.net/thinkcs/python/english2e/index.html
|
# ? Mar 23, 2013 00:12 |