Re: Cutting a deck of cards

2013-05-26 Thread Kamlesh Mutha
I guess, you will have to use list slicing mechanism to achieve the desired
result.

Hope this helps,

Cheers,
Kamlesh





On Sun, May 26, 2013 at 11:22 PM, RVic rvinc...@gmail.com wrote:

 Suppose I have a deck of cards, and I shuffle them

 import random
 cards = []
 decks = 6
 cards = list(range(13 * 4 * decks))
 random.shuffle(cards)

 So now I have an array of cards. I would like to cut these cards at some
 random point (between 1 and 13 * 4 * decks - 1, moving the lower half of
 that to the top half of the cards array.

 For some reason, I can't see how this can be done (I know that it must be
 a simple line or two in Python, but I am really stuck here). Anyone have
 any direction they can give me on this? Thanks, RVic, python newbie

 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Faith waiting in the heart of a seed promises a miracle of life which it
can not prove!
-Ravindranath Tagore
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-25 Thread Kamlesh Mutha
You can use paramiko module. Very easy to use.



On Thu, Oct 25, 2012 at 4:04 PM, Laszlo Nagy gand...@shopzeus.com wrote:

 On 2012-10-25 12:16, Schneider wrote:

 Hi Folkz,
 how can i create a SSH-Connection with python? I have to send some
 commands to the remote host and parse their answers.
 greatz Johannes

 http://www.lag.net/paramiko/

 Another solution would be to use subprocess and/or pexpect


 --
 http://mail.python.org/**mailman/listinfo/python-listhttp://mail.python.org/mailman/listinfo/python-list




-- 
Faith waiting in the heart of a seed promises a miracle of life which it
can not prove!
-Ravindranath Tagore
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simple string format question

2012-10-15 Thread Kamlesh Mutha
There doesn't seem to be any direct way to achieve this.

Maybe you can do something like this:

import math

x = 3.05

if math.modf(x)[0] != 0.0: print x


Cheers,
-Kamlesh




On Mon, Oct 15, 2012 at 5:59 PM, Chris Rebert c...@rebertia.com wrote:

 On Mon, Oct 15, 2012 at 5:12 AM, Neal Becker ndbeck...@gmail.com wrote:
  Is there a way to specify to format I want a floating point written with
 no more
  than e.g., 2 digits after the decimal?  I tried {:.2f}, but then I get
 all
  floats written with 2 digits, even if they are 0:
 
  2.35  yes, that's what I want
  2.00  no, I want just 2 or 2.

 Not that I can find. Seems you'll have to implement it yourself.


 In the event that your project uses Django, there happens to be a
 template tag for this (pass it -2 in your case):

 https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#floatformat

 Cheers,
 Chris
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Faith waiting in the heart of a seed promises a miracle of life which it
can not prove!
-Ravindranath Tagore
-- 
http://mail.python.org/mailman/listinfo/python-list