snippsat 661 Master Poster
import re

text = '''\
#include "hello.h"
#include "d/hello.h"
#include "dir/hello.h"
#include "dir\hello.h"
#include <hello.h>
#include "a\b\c.h"
#include <ref\six\eight.h>
#include "123\456/789.h"
#include "bye.h"
'''

new_text = re.findall(r'\w+\.\w' ,text)
print new_text  #list
print '\n'.join(new_text) #string
print set(new_text)  #No duplicate

"""Output-->
['hello.h', 'hello.h', 'hello.h', 'hello.h', 'hello.h', 'c.h', 'eight.h', '789.h', 'bye.h']
hello.h
hello.h
hello.h
hello.h
hello.h
c.h
eight.h
789.h
bye.h
set(['eight.h', '789.h', 'hello.h', 'c.h', 'bye.h'])
"""
snippsat 661 Master Poster

Should I use rename or soemthing?

Yes you can try this.

import os
import fnmatch

for i,fn in enumerate(os.listdir("C:/Bilder")):
    if fnmatch.fnmatch(fn, 'IMG*'):
        os.rename(os.path.join('C:/Bilder', fn), os.path.join('C:/Bilder','Bilde%d.jpg' % i))
snippsat 661 Master Poster

What is the full name,and what should the new full name be?,you most explain better.
IMG.jpg to HH.jpg?
HH1.jpg HH2.jpg....?

snippsat 661 Master Poster

import os
os.chdir('D:/Python24/pyasn1')
python setup.py install

This is wrong.
Do you know what cmd is?
http://www.bleepingcomputer.com/tutorials/tutorial76.html
When you have unpacked files you need to navigate to that folder in cmd.
Then use python setup.py install .
This is one way.

The other are using setuptools as postet before.
It took my 15sek to install pysnmp with setuptools.
This is also done in cmd and not in IDLE easy_install pysnmp

#!/usr/bin/env python

This is only for linux,on windows you dont need that line.

snippsat 661 Master Poster

From CMD. easy_install pysnmp .
To do this you need to install Setuptools
Or as Gribouillis posted from CMD navigate to folder for unpack files and write python setup.py install

>>> import pysnmp
>>> dir(pysnmp)
['__builtins__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 'majorVersionId',
 'version']
>>> pysnmp.version
(4, 1, 15)
>>>
snippsat 661 Master Poster
>>> l = ['asd',"asd'das",'qw','213']
>>> l
['asd', "asd'das", 'qw', '213']
>>> l.pop(0)
'asd'
>>> l
["asd'das", 'qw', '213']
>>> l.pop(1)
'qw'
>>> l
["asd'das", '213']
>>>

This is what`s happens.
l.pop(0) take out take out 'asd'
Then "asd'das" take place as element 0
Next when you use l.pop(1) it will take our element 1 'qw'
Maybe you get confused that "asd'das" is one element in the list.

snippsat 661 Master Poster

You are looking for random.shuffle().
To see all method under random module use dir(random)
For help use help(random.shuffle)

>>> random_name = ['Mohamed', 'Ahmed','Aboubakr']
>>> random.shuffle(random_name)
>>> random_name
['Mohamed', 'Aboubakr', 'Ahmed']
>>> random.shuffle(random_name)
>>> random_name
['Ahmed', 'Mohamed', 'Aboubakr']
>>> random.shuffle(random_name)
>>> random_name
['Ahmed', 'Aboubakr', 'Mohamed']
>>>
vegaseat commented: thanks +13
snippsat 661 Master Poster

Any idea how to change the format to something like this?

You can use the new string formatting has a lot of powerful features an was new in python 2.6
http://docs.python.org/library/string.html#formatstrings
An example.

google = {
    'facebook.com': 230,
    'yahoo.com': 9,
    'fifa.org': 67,
    'msn.com': 3}

print 'google.com'
for name in sorted(google):
    print("\t\t{name:11}{score:>10.4f}".format(name=name, score=google[name]))

"""Out-->
google.com
	facebook.com  230.0000
	fifa.org      67.0000
	msn.com        3.0000
	yahoo.com      9.0000
"""
snippsat 661 Master Poster

i m using python 2.5 ,i m getting error in the first line(i.e,with open line)

Why are using an so old version as 2.5?.
I shall test later on my laptop there i have 2.5 and see if it work.
The with statement did come with the release of python 2.5.
http://docs.python.org/whatsnew/2.5.html#pep-343-the-with-statement
You can try to add this as first line.
from __future__ import with_statement

snippsat 661 Master Poster

Write this in IDLE.

>>> import sys
>>> sys.path

The list you get is where python look for .py files,when you are using a import statment.
http://docs.python.org/tutorial/modules.html#the-module-search-path

snippsat 661 Master Poster

Dont use bold character for everthing.
Here is and example you can look at and try out.

#average.py
#saved in python dir
from __future__ import division

def average(seq_in):
    if isinstance(seq_in, (list, tuple)):
        return sum(seq_in) / len(seq_in)
    else:
        return 'Input can only be list or tuple'

So we save this as average.py in python folder(or a python path folder so python can find it)
Import and test it out before we use it in new script.

>>> from average import average
>>> average
<function average at 0x04D2C430>
>>> average([1,2,3,4])
2.5
>>> average(88)
'Input can only be list or tuple'
>>> average('hi')
'Input can only be list or tuple'
>>>

It work as it should.
Then we can use it in a new code like this.

from average import average

def calc_average(l):
       return average(l) #Here we use the imported code

def radius_2():
    '''Not finish yet'''
    pass

def main():
    '''Main menu'''
    while True:
        print '(1) Calculate average'
        print '(2) Calculate radius'
        print '(Q) Quit'
        choice = raw_input('Enter your choice: ')
        if choice == '1':
            user_in = raw_input('Enter numbers for average calculation: ')
            a = [float(i) for i in user_in]
            print calc_average(a)
        elif choice == '2':
            radius_2()
        elif choice in ['Q','q']:
            return False
        else:
            print 'Not a correct choice:', choice

if __name__ == '__main__':
    main()
snippsat 661 Master Poster

Use code tag,are you using python 3?
Then you have to change print statement,because as mention many times print is a function in python 3.

#python 3
"""
file_1.txt-->
99 root S 5176 95 41.2 8.3 snmpd

file_2.txt-->
99 root S 5176 95 1.0 8.3 snmpd
"""

with open('file_1.txt') as file_1:
    with open('file_2.txt') as file_2:
        f1 = [float(item.split()[5]) for item in file_1]
        f2 = [float(item.split()[5]) for item in file_2]
        print (f1[0] - f2[0])  # 40.2
snippsat 661 Master Poster

with open(('file2.txt') as file_1):

That is not my code,you can just copy it.
Now you have made 3 error in that short line.
Just compare then you should see it.

snippsat 661 Master Poster

Another way to do this.

"""
file_1.txt-->
99 root S 5176 95 41.2 8.3 snmpd

file_2.txt-->
99 root S 5176 95 1.0 8.3 snmpd
"""

with open('file_1.txt') as file_1, open('file_2.txt') as file_2:
     f1 = [float(item.split()[5]) for item in file_1]
     f2 = [float(item.split()[5]) for item in file_2]
     print f1[0] - f2[0] #40.2
snippsat 661 Master Poster

Wrong post.

snippsat 661 Master Poster

Try this.

import urllib.request

page = urllib.request.urlopen("http://www.randompickupline.com/")
text = page.read().decode("utf8")

where = text.find('<p id="pickupline">')
start_of_line = where + 19
end_of_line = start_of_line + 150
line = (text[start_of_line:end_of_line])

pick_text = line.find('</p>')
print (line[:pick_text])

"""Out-->
Do I know you? (No.) That's a shame, I'd sure like to.
"""

When it comes to parse website,using a good parser like BeautifulSoup or lxml can make it eaiser.
Here is an example that do what you want,this is for python 2.x

from BeautifulSoup import BeautifulSoup
import urllib2

url = urllib2.urlopen("http://www.randompickupline.com/")
soup = BeautifulSoup(url)
tag = soup.find("p", {"id": "pickupline"})
print tag.text

"""Out-->
It's dark in here. Wait! It's because all of the light is shining on you.
"""
snippsat 661 Master Poster

i agree with the splicing which i've found helpful.

"splicing" is that a secret python slicing method,just kidding :icon_wink:
"splicing" in action.

>>> s = 'hello'
>>> s[::-1][-1]
'h'
>>>
snippsat 661 Master Poster

As first line use this and it will work.
from __future__ import division

Or.

TF = float(raw_input("Enter a Farenheit temp: "))
TC = (5/9.0)*(TF-32) #9.0 make it float

Read this.
http://www.ferg.org/projects/python_gotchas.html#contents_item_3

snippsat 661 Master Poster

The array module is kind of one of those things that you probably don't have a need for if you don't know why you would use it (and take note that I'm not trying to say that in a condescending manner!). Most of the time, the array module is used to interface with C code.

Use list as i have canged in your code.
sum(list/tuple) not list/tuple.sum.

#The normal way off making list/array in python
homescore = []
visitingscore = []

for x in range(2):
    home = int(raw_input('The home team score this inning. '))
    homescore.append(home)

for x in range(2):
    visiter = int(raw_input('The visiting team score this inning. '))
    visitingscore.append(visiter)

print 'The Home team score is ', sum(homescore)
print 'The Visiters team score is %d ' % sum(visitingscore) #with string formatting

if sum(homescore) > sum(visitingscore):
    print"The Home team wins!"
else:
    print"The visiting team wins!"
snippsat 661 Master Poster

now i can't figure out what does find+1 means..

A clue most programming start indexing/counting at 0.

def find_genes(gene,sequence):
    my_list= []  #Dont use list as a varible name,it`s a python keyword

    count = sequence.count(gene)
    find = sequence.find(gene)
    my_list.append(find)

    while find > -1:
        find = sequence.find(gene,find+1)
        my_list.append(find)
        return count,my_list  #Move to remove -1

text = """\
My name is Fred Flintstone and I am a famous TV
star.I have as much authority as the Pope,I
just don't have as many people who believe it.
Fred
"""
gene = 'Fred'

count,index_word =  find_genes(gene,text)
print '%s occurred %s times,at index %s' % (gene,count,index_word)
snippsat 661 Master Poster

It work fine for me,it has no error so it should work for you to.
In your first code both __int__ statement was wrong should be __init__

import wx

class my_window(wx.Frame):
    def __init__(self, parent, id):
        wx.Frame.__init__(self,parent,id,'My Window', size=(300,200))
    
        self.SetBackgroundColour('BLACK')

if __name__ == "__main__":
    app=wx.PySimpleApp()
    frame=my_window(parent=None,id=-1)
    frame.Show()
    app.MainLoop()
snippsat 661 Master Poster
import wx

class my_window(wx.Frame):
    def __init__(self, parent, id):  #error __int__
        wx.Frame.__init__(self,parent,id,'My Window', size=(300,200))

        #Panel for frame
        self.panel = wx.Panel(self)
        self.SetBackgroundColour('blue')

if __name__ == "__main__":
    app=wx.PySimpleApp()
    frame=my_window(parent=None,id=-1)
    frame.Show()
    app.MainLoop()
snippsat 661 Master Poster

Should not be so hard to understand it`s a slice method that work on string.
your string[start:end]

>>> s = 'my car'
>>> s[0]
'm'
>>> #m is first,we cont from zero

>>> #So if we want to take out car,we count [start:end]
>>> start = 3
>>> end = 6
>>> s[start:end]
'car'
>>>
snippsat 661 Master Poster
'''
#part.txt
This is a test.
I want to take out this part,of the text
'''

f = open('part.txt')
#readlines() return a list,so string slice wont work [start:end]
print f.readlines()
#--> ['This is a test.\n', 'I want to take out this part,of the text']


f = open('part.txt')
#read() return a string and you can use string slice
print f.read()[35:44]
#--> this part

#Join() as you may now convert a list to string
''.join(['This is a test.\n', 'I want to take out this part,of the text'])[35:44]
#--> this part
snippsat 661 Master Poster

No,i dont get None at the end.

and
the
happy
summer
days
the
end
>>>

read_book(file_in) #ok
print read_book(file_in) #will return None,because you are calling a function that has no return statement

snippsat 661 Master Poster

Some advice,and no None as d5ed poinet out.

import string

def read_book(file_in=None):
    '''
    Read in file,strips whitespace-punctuation
    Returns them in lowercase
     '''
    f = open(file_in)  #r is default
    for l in f:        #Dont need readlines
        book_line = l.strip().translate(None, string.punctuation)
        for w in book_line.split(" "):
            if w != "":
                print w.lower()

def main():
    """main function"""
    file_in = 'alice.txt'
    read_book(file_in)  #The function you calling has print
    #return 0           #Not needed in python how has an excellent garbage collection

if __name__ == "__main__":
    main()
snippsat 661 Master Poster

This should help,and try to post some code next time.

>>> from __future__ import division
>>> my_list = [1,2,3,4]
>>> avg = sum(my_list)/len(my_list)
>>> avg
2.5
>>>
snippsat 661 Master Poster

PyQt is compitable with python 3,and of course build in Tkinter.
http://www.riverbankcomputing.co.uk/news
For beginner there is a massive amount of quality book/tutorials/forum help that are almost all inn pyhon 2.x.
Is not a smart ting to overlook all that info because you look only for for python 3 stuff.

snippsat 661 Master Poster
snippsat 661 Master Poster

Just have both installed as most of us have.
Wxpyhon is a excellent GUI toolkit use python 2.x if you need to use that.

This topic has been upp several times,python is python dont get hang up in python 2.x or 3.x.
If you are learning python 3.,you are learing python 2.x and visa versa.
Just get ourself uppdatet what the differences are.

snippsat 661 Master Poster

Nice one woooee.
Just need a fix of range[1, 6] to range(1, 6)

snippsat 661 Master Poster

Not your lucky day snippsat, double post and:

Yes,a misstype when a did some edting of forum code thx.
Did fix it now.

snippsat 661 Master Poster

You have to some reading about dictionary.
Some stuff you can look at.

>>> z = {'a': 1, 'a': 2, 'a': 3, 'b': 4, 'c': 5}
>>> z
{'a': 3, 'b': 4, 'c': 5}
>>> #Keys are unique within a dictionary while values may not be
>>> #That`s why only last value 3 is bind to key 'a'

>>> d = {'a' (1,2,3)
>>> d['a']
(1, 2, 3)
>>> #now key 'a' has value of 1,2,3
>>> d.keys()
['a']
>>> d.values()
[(1, 2, 3)]
 
>>>#some explation  about get.
>>>#dict.get(key, default=None)
>>>#For key key, returns value or default if key not in dictionary
>>> z.get('a')
3
>>> d.get('a')
(1, 2, 3)
>>> print d.get('b')
None
>>>
snippsat 661 Master Poster

A rule that can be good to remember.
Never delete something from or add something to the list you are iterating over.

The solution is:
Iterate over your original list, and put everything which passes your test into another list.

Some way of doing this.
Using List comprehensions.

>>> l = [1,2,3,4,5,6,7,8]
>>> odd_remove = [item for item in l if item %2 != 1]
>>> odd_remove
[2, 4, 6, 8]
>>>
l = [1,2,3,4,5,6,7,8]

even_list = []
for item in l:
    if item %2 != 1:
        even_list.append(item)

print even_list  #[2, 4, 6, 8]
l = [1,2,3,4,5,6,7,8]

for item in l[:]: #make a copy of list
	if item %2 != 0:
	    l.remove(item)

print l  #[2, 4, 6, 8]
snippsat 661 Master Poster

Getters and setters are evil. Evil, evil, I say! Python objects are not Java beans. Do not write getters and setters. This is what the ‘property’ built-in is for. And do not take that to mean that you should write getters and setters, and then wrap them in ‘property’.

http://tomayko.com/writings/getters-setters-fuxors

The link over is follow up from python is Not java.
http://dirtsimple.org/2004/12/python-is-not-java.html

snippsat 661 Master Poster

An example i make some code that calulate average.

#average.py
#saved in python dir
from __future__ import division

def average(average_list):
    if isinstance(average_list, (list, tuple)):
        return sum(average_list)/len(average_list)
    else:
        return 'Input can only be list or tuple'

So import it and test it out.
Save it in python sys.path or same folder as your other .py-file.

#Check out path
>>> import sys
>>> sys.path
>>> from average import average
>>> average
<function average at 0x04D2C430>
>>> average([1,2,3,4])
2.5
>>> average(88)
'Input can only be list or tuple'
>>> average('hi')
'Input can only be list or tuple'
>>>
snippsat 661 Master Poster

Use code tags.
A shorter way to average.

from __future__ import division

def getAverage(numList):
    return sum(numList)/len(numList)

print getAverage([1,2,3,4])
snippsat 661 Master Poster

Some pratice you can try out in IDLE.

>>> name = raw_input("Enter Name: ")
Enter Name: joe
>>> name
'joe'
>>> list(name)
['j', 'o', 'e']

>>> #This is called list comprehension
>>> [i for i in name]
['j', 'o', 'e']

>>> #Written as an ordenarry loop
>>> my_list = []
>>> for i in name:
	my_list.append(i)	
>>> my_list
['j', 'o', 'e']

#one with map()
>>> map(str, name)
['j', 'o', 'e']

>>> #convert to string
>>> ''.join(my_list)
'joe'

>>> n = (1+2+3+4+5+6)
>>> n
21

>>> l = list(str(n))
>>> l
['2', '1']

#list comprehension
>>> [i for i in l]
['2', '1']
>>> [int(i) for i in l]
[2, 1]
>>> sum([int(i) for i in l])
3
>>>
snippsat 661 Master Poster

ran it and I was so happy with it, but then... why on Earth does it tell me that "5" is higher than "24"? Or why does it tell me that "5" is higher than "45"?? Or why "5" is higher than "13"?

Because you are comparing string and not integer.
Python 3 has only input() and it return a string,but you can choose what datatype it shall return with int() float() .

Just an advice.
For beginner there is a massive amout of tutorials/books/forum help that are in python 2.x this is important stuff for learing python.
If you learn python 2.x you learn of course python 3.x,have both installed is a good chooice.
Most pepole still use python 2.x in wait for many 3 part moduls to be rewritten in python 3.

#python 3
>>> x = input('Give a value for \'a\': ')
>>> Give a value for 'a': 5
>>> type(x)
<class 'str'>

>>> x = int(input('Give a value for \'a\': '))
>>> >>> Give a value for 'a': 3
>>> type(x)
<class 'int'>

>>> #Or use float for decimal number
>>> x = float(input('Give a value for \'a\': '))
>>> Give a value for 'a': 5.3  
>>> type(x)
<class 'float'>

>>> #You can also convert later in code
>>>  if float(a) > float(b):
snippsat 661 Master Poster
>>> Z = []
>>> X=['a']
>>> Y=['b','c','d','e','f']
>>> for i in Y:
...     Z.append(X[0] + i)
...     
>>> Z
['ab', 'ac', 'ad', 'ae', 'af']
>>>
snippsat 661 Master Poster

I have to compare 5 words so writing a seperate for each combination would take too long

I don see why you should use for loop like that for comparing 5 words.
Give an example of the words,and how you think the comparing output should look.

snippsat 661 Master Poster

And it's not working, so how should i do shuffel thing?

import random

my_string = 'abcdefghijklmnopqrstuvxyzo'

my_list = []
for i in range(len(my_string)):
    if i == 10:
        my_list.append(my_string[:i])


r =  list(''.join(my_list))
print r #now we can shuffle
random.shuffle(r)
shuffle_string = ''.join(r)
print shuffle_string         #string
#--> ebdihfjgca
print shuffle_string.split() #make list
#--> ['ebdihfjgca']
snippsat 661 Master Poster

If you want to shuffle it`s need to more than 2 elements in list.
Look into spilt(),list(),to split upp upp a string or a list.

>>> a = 'abc'
>>> list(a)
['a', 'b', 'c']

>>> a = 'a b c'.split()
>>> a
['a', 'b', 'c']
>>> from random import shuffle
>>> help(shuffle)
Help on method shuffle in module random:

shuffle(self, x, random=None, int=<type 'int'>) method of random.Random instance
    x, random=random.random -> shuffle list x in place; return None.
    
    Optional arg random is a 0-argument function returning a random
    float in [0.0, 1.0); by default, the standard random.random.

>>> #This list has 3 element
>>> l = ['a', 'b', 'c']
>>> shuffle(l)
>>> l
['b', 'a', 'c']
>>> my_list
['abcdefghij']
>>> #my_list has only 1 element an can not be shuffled
>>> print shuffle(my_list)
None
>>>
snippsat 661 Master Poster

Dont use list as a variable name,it`s a python keyword

>>> list
<type 'list'>
>>> a = 'abc'
>>> list(a)
['a', 'b', 'c']

Loop over the len() of my_sting,stop at 10 and use slice.

my_string = 'abcdefghijklmnopqrstuvxyzo'

for i in range(len(my_string)):
    if i == 10:
        print my_string[:i]
        #--> abcdefghij

If you want to save 10 chars in a list.

my_string = 'abcdefghijklmnopqrstuvxyzo'

my_list = []
for i in range(len(my_string)):
    if i == 10:
        my_list.append(my_string[:i])
        
print my_list
#--> ['abcdefghij']
snippsat 661 Master Poster

Make it an integer with int()

>>> paid_value = '55'
>>> type(paid_value)
<type 'str'>
>>> paid_value = int(paid_value)
>>> type(paid_value)
<type 'int'>
>>> paid_value ** 5
3025
snippsat 661 Master Poster

Key in a dictionary can not use list.
If you turn it around is ok,and set list as an value.

>>> codes = {}
>>> inpt = raw_input("<<<").split()
<<<my car
>>> inpt
['my', 'car']
>>> inpt2 = raw_input("?...")
?...black
>>> inpt2
'black'
>>> codes[inpt] = inpt2

Traceback (most recent call last):
  File "<pyshell#16>", line 1, in <module>
    codes[inpt] = inpt2
TypeError: unhashable type: 'list'
>>> codes[inpt2] = inpt
>>> codes
{'black': ['my', 'car']}
>>>
snippsat 661 Master Poster
>>> xdate = 5
>>> print 'value of xdate is %d' % xdata
value of xdate is 5

String formatting operations has been in python since day one.
http://docs.python.org/library/stdtypes.html#string-formatting-operations

A new and more powerful string formatting operations,from python 2.6-->
http://docs.python.org/library/string.html#format-examples
http://www.daniweb.com/code/snippet232375.html

snippsat 661 Master Poster

Some hint
You will not get finish code or so much help if you dont show some effort.

>>> a = 3
>>> if a <=5 and a >= 1:
...     print 'Number are between 1 and 5'
...     
Number are between 1 and 5
>>> a = 7
>>> if a <=5 and a >= 1:
...     print 'Number are between 1 and 5'


>>> b = int(raw_input('Enter a number: '))
Enter a number: a

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    b = int(raw_input('Enter a number: '))
ValueError: invalid literal for int() with base 10: 'a'

>>> try:
	b = int(raw_input('Enter a number: '))
except ValueError:
	print 'Please number only'

	
Enter a number: a
Please number only
snippsat 661 Master Poster

@doffing81 i will give som advice about code design.
This can be very important as code grow,to much code in global space can be a real pain.
when you work with function code is local to that function(you have to call it)
Learn to work with function first,of course class is also an option later.
But is important to get comfortable with function.

So some code to show you what i mean.
Look how this work,and a make some documation(called dok_string)

from random import shuffle

def make_deck():
    '''This function retur a sorted deck'''
    rank = 'A23456789TJQK'
    suit = 'CDHS'
    deck = []
    for r in list(rank):
        for s in list(suit):
            card = r + s
            deck.append(card)
    return deck

def shuffle_deck(deck, number=None):
    '''Shuffle deck and return card number(5) return five card'''
    shuffle(deck)
    return [deck.pop() for k in range(number)]

def foo():
    '''Not finsih yet'''
    pass

def main():
    #Here we put it all together
    #Make a note that no code is in global space,this make it eaiser to add remove code
    #We can just add remove function.
    deck = make_deck()
    five_card = shuffle_deck(deck, 5)
    print 'A test give player five card: %s' % five_card
    #-->A test give player five card: ['AH', '5S', '9H', '2S', '9S']

if __name__ == '__main__':
    main()
snippsat 661 Master Poster

One way to make a deck,that is ok to understand.
@askrabal remember that import statement shall never be inside a class or function.
Import statement shall alway be on top.

rank = 'A23456789TJQK'
suit = 'CDHS'

deck = []
for r in list(rank):
    for s in list(suit):
        card = r + s
        deck.append(card)

print deck

One with list comprehension.

deck = [rank + suit for rank in "A23456789TJQK" for suit in "CDHS"]
print deck

Shuffle deck and deal some card.

>>> from random import shuffle
>>> #Shuffle deck
>>> shuffle(deck)
>>> #Deal out 5 card
>>> [deck.pop() for k in range(5)]
['7S', 'TC', 'TD', '8C', 'QS']