![]() |
|
Re: ** Python Support Thread **
The Badugi problem in Project Euler was written by me, by the way. :D
|
Re: ** Python Support Thread **
Haha that's pretty random but I was scrolling through the problems yesterday and was thinking to myself "Badugi?..I guess I'll try that some day"
|
Re: ** Python Support Thread **
Quote:
genius ;) |
Re: ** Python Support Thread **
fwiw there's a dedicated PE thread here too: http://forumserver.twoplustwo.com/19...group-1024853/
|
Re: ** Python Support Thread **
searched this thread, textpad didn't come up:
Textpad lets you put in tools like a python compiler, which is pretty awesome, but I got one of the python addons off their site and it didn't seem to work, neither with coloring the script nor with doing the tab indentation to 4! I don't have the newwest ver of textpad though, but what it says it should do, it does not do. Anyways, I'm curious if anyone has some tips for writing python using textpad, or if anyone has recommendations for a better editor that would help with the dev process. I'm just trying to get started in programming again after a long hiatus. |
Re: ** Python Support Thread **
oh and I know I'm going to ask this anyways later so: How do you divide in python?? Like normal division where 5/2=2.5... Do I have to float() everything every time I want to do that, or at least one thing? :(
|
Re: ** Python Support Thread **
in python 2, your options are:
-use float() -make sure division has floats in it (i.e. 5/2.0) -from __future__ import division The last one imports Python 3's division behavior, which is / for "true" division (changes int->float if it doesn't divide evenly) and // for floor division (preserves types where possible) |
Re: ** Python Support Thread **
how different is python 2 vs 3? I'd be willing to change languages just to get division with less keystrokes. Why was it this way in the first place?
Also I'm looking at pydev and eclipse right now for dev tools, any good? Someone recommended eclipse to me but all I see are java/c stuff for it. http://www.eclipse.org/downloads/ edit: pydev has a video and it looks great. :) Hopefully can be used with P3 |
Re: ** Python Support Thread **
|
Re: ** Python Support Thread **
Quote:
Python 2 and Python 3 are barely different really. In fact if you look at programming help forum you'll see people posting code and responders not being able to tell which it is! From what I can tell the main arguments for one or the other are Unicode support (Python 3) and legacy code/library support (Python 2). In particular if you want to do web stuff you may want to stick to Python 2 and cherry pick individual Python 3 features from the __future__ module. Of course if you're on the fence 3 is probably the default since Python 2 is essentially frozen in its last release. http://wiki.python.org/moin/Python2orPython3 http://docs.python.org/py3k/whatsnew/3.0.html |
Re: ** Python Support Thread **
That would be my exact assessment as well Xhad. Well said.
|
Re: ** Python Support Thread **
Ok, based on the availability of the legacy code I guess py2 and I'll just have to learn to divide the hard way. I'm very picky sometimes! :(
Can I cherry pick the division out of PY3? I don't need to know how yet, just curious (yes/no). :) How should I write code in this; I'm using windows xp, what editor should I use? I'd like to find something that I can force to tab on 4 and also pydev has a thing where you shift-enter at the end of a line and it indents into the next line for you, which is, of course, amazing. Problem is I have no idea how to download pydev, as they switched to their own site and their sourceforge page is what's refered to (afaik) on their download page, so SF page is broken. But yeah, finding an editor is the next step for me, hopefully a free program. |
Re: ** Python Support Thread **
Thanks for answering questions, guys. :)
|
Re: ** Python Support Thread **
http://docs.python.org/library/__future__.html
In particular, what you want to do is start all your files with: Code:
from __future__ import division |
Re: ** Python Support Thread **
Awesome. :) If I get the editor situation sorted I'll have enough to start writing.
|
Re: ** Python Support Thread **
Gogo PyCon imo...that 2.5h thingy on game development with pygame is pretty cool if you want to get into it (first 30 minutes by the chick is general game theory stuff, you can skip it if you want to...includes FF7 spoilers as well)
http://pyvideo.org/category/17/pycon-us-2012 |
Re: ** Python Support Thread **
Does anyone have any idea how I could pass the elements of a list as arguments to a function when the list in question contains an arbitrary number of elements? Arguments separated by a comma, so I can't just pass the whole list. And I can't modify the function because it's from Scipy.
|
Re: ** Python Support Thread **
Can you give an example of what you're trying to do?
|
Re: ** Python Support Thread **
Is this what you mean?
Code:
|
Re: ** Python Support Thread **
I'm trying to use the statistical functions from Scipy.
scipy.stats.%(parameters[1]).rvs(loc = currentValue, float(parameters[???]), float(parameters[???])) parameters[0] is something of not directly related. parameters[1] is the name of the function parameters[2:] are the optional parameters. They can range from 0 to 4, depending on the function and the user. I could just use a bunch of if statements for all the different possibilities, but I was wondering if there was something more elegant. |
Re: ** Python Support Thread **
Looks like it's as Neko said then. You would pass *parameters[2:] if so.
|
Re: ** Python Support Thread **
Quote:
norm for example : http://docs.scipy.org/doc/scipy/refe...ipy.stats.norm The best way would be to try it I guess. I shall reboot in Linux and see if it works. |
Re: ** Python Support Thread **
Yes.
Code:
def f(a,b,c): |
Re: ** Python Support Thread **
Thanks! It works (almost). Apparently, my interpolation technique is wrong. How would I call the function that corresponds to the string parameters[1]?
|
Re: ** Python Support Thread **
you mean parameters[1] is a string and you want to call a function by that name? Sounds like something that could be done with eval:
Code:
instring = 'f' |
| All times are GMT -4. The time now is 11:10 PM. |
|
Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Copyright © 2008-2020, Two Plus Two Interactive