Open Side Menu Go to the Top

03-06-2012 , 03:19 AM
The Badugi problem in Project Euler was written by me, by the way.
** Python Support Thread ** Quote
** Python Support Thread **
150% up to $2,000 Welcome Bonus on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** Python Support Thread **
03-06-2012 , 11:04 AM
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"
** Python Support Thread ** Quote
03-06-2012 , 12:02 PM
Quote:
Originally Posted by Alex Wice
The Badugi problem in Project Euler was written by me, by the way.
crowd sourcing strategies for your bot?

genius
** Python Support Thread ** Quote
03-07-2012 , 01:03 AM
fwiw there's a dedicated PE thread here too: http://forumserver.twoplustwo.com/19...group-1024853/
** Python Support Thread ** Quote
03-08-2012 , 05:33 PM
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.
** Python Support Thread ** Quote
03-08-2012 , 05:38 PM
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?
** Python Support Thread ** Quote
03-08-2012 , 06:22 PM
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)
** Python Support Thread ** Quote
03-08-2012 , 06:46 PM
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

Last edited by DavidC; 03-08-2012 at 06:56 PM.
** Python Support Thread ** Quote
03-08-2012 , 06:49 PM
In case anyone hasn't seen this yet...
https://gist.github.com/289467

Brilliant imo
** Python Support Thread ** Quote
03-08-2012 , 07:04 PM
Quote:
Originally Posted by DavidC
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?
This is a blind guess, but there's something to be said for having it so that when you put two variables of the same type into an operator, the output is also of that type. Python is far from the first language to behave this way which may have been a factor as well. (not saying I don't like the Python 3 behavior better, mind)

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
** Python Support Thread ** Quote
03-08-2012 , 07:16 PM
That would be my exact assessment as well Xhad. Well said.
** Python Support Thread ** Quote
03-08-2012 , 07:44 PM
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.
** Python Support Thread ** Quote
03-08-2012 , 07:46 PM
Thanks for answering questions, guys.
** Python Support Thread ** Quote
03-08-2012 , 07:47 PM
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
** Python Support Thread ** Quote
03-08-2012 , 08:57 PM
Awesome. If I get the editor situation sorted I'll have enough to start writing.
** Python Support Thread ** Quote
03-11-2012 , 07:15 PM
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
** Python Support Thread ** Quote
03-12-2012 , 07:28 PM
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.
** Python Support Thread ** Quote
03-12-2012 , 07:33 PM
Can you give an example of what you're trying to do?
** Python Support Thread ** Quote
03-12-2012 , 07:36 PM
Is this what you mean?

Code:
def fun(*args):
    
    print args
    
my_args = [1,2,3,4,5]

fun(*my_args)  #prints (1,2,3,4,5)
** Python Support Thread ** Quote
03-12-2012 , 07:41 PM
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.
** Python Support Thread ** Quote
03-12-2012 , 07:49 PM
Looks like it's as Neko said then. You would pass *parameters[2:] if so.
** Python Support Thread ** Quote
03-12-2012 , 07:53 PM
Quote:
Originally Posted by Xhad
Looks like it's as Neko said then. You would pass *parameters[2:] if so.
But would the scipy.stats function really accept it and know how to handle *args?

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.
** Python Support Thread ** Quote
03-12-2012 , 07:55 PM
Yes.

Code:
def f(a,b,c):
   return a+b+c

print f(*[1,2,3]) # will print 6
** Python Support Thread ** Quote
03-12-2012 , 08:06 PM
Thanks! It works (almost). Apparently, my interpolation technique is wrong. How would I call the function that corresponds to the string parameters[1]?
** Python Support Thread ** Quote
03-12-2012 , 08:08 PM
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'
print eval(instring)(1,2,3)
** Python Support Thread ** Quote
** Python Support Thread **
150% up to $2,000 Welcome Bonus on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** Python Support Thread **

      
m