[Tutor] Paython as a career

2009-03-16 Thread Hussain Ali
Dear all

I want to start learning python but before going further I need answer to my 
questions so that my path can be clear to me. I shall be grateful for your 
answers:

1) Where does python stand as compared to other programming languages?
2) What is the future for python?
3) Will it survive for long in this rapidly changing trends and new languages?
4) Should I start it to earn my bread and butter? I mean is that beneficial for 
income.


Sincerely

Hussain___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Modifying Grayson's Example 5_14

2009-03-16 Thread Wayne Watson
Title: Signature.html




That worked. Why the "extra" blank window though? 

Martin Walsh wrote:

  Wayne Watson wrote:


  
  
it.  It works pretty well, but puts up a a few probably top level
windows that are blank. How do I get around them, and is there anything

  
  


  
  
root = Tk()

  
  
Try adding this,

root.withdraw()

  
  
dialog = GetPassword(root)

  
  
HTH,
Marty
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

  


-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


“Life is one damn thing after another."
 -- Mark Twain 





___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with ftplib and file modification date

2009-03-16 Thread Kent Johnson
On Mon, Mar 16, 2009 at 6:27 PM, Rene Bourgoin  wrote:
> i'm doing a simple upload to an FTP server using the ftplib module and
> wanted to know how i can preserve the file modification date all the way
> through the process. I lose the file mod date because i read the original
> file then ftp writes a new file to the server which changes the mod date
> to the time and date of the file transfer.

Apparently there is no standard way to do this but some servers
support using the MDTM command to set time stamps:
http://forum.filezilla-project.org/viewtopic.php?f=1&t=4122

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] help with ftplib and file modification date

2009-03-16 Thread Rene Bourgoin
i'm doing a simple upload to an FTP server using the ftplib module and
wanted to know how i can preserve the file modification date all the way
through the process. I lose the file mod date because i read the original
file then ftp writes a new file to the server which changes the mod dateto
the time and date of the file transfer.
Here is the basic code i used;

for file in os.listdir("C:\\dir"):
i=file  # i catpures file
z="STOR " + i #STOR is upload command to FTP server
filename=open(i,'r')
f.storlines(z,filename) #FTP upload command

filename.close()
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to connect to an email server?

2009-03-16 Thread Eduardo Vieira
Tim wrote:
>
>
> SMTP has to be enabled specifically on the Exchange Server:
> it usually uses its own built-in protocols. It looks
> as though your Exchange isn't running it. Either switch it
> on (or ask your admins to do so) or look at using MAPI
> or CDO instead.
>
> TJG
> ___
> Tutor maillist  -  tu...@python.org
> http://mail.python.org/mailman/listinfo/tutor
>

I guess I'll use MAPI, CDO, as these have worked before.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to connect to an email server?

2009-03-16 Thread Emile van Sebille

Eduardo Vieira wrote:

Hello, I'm fairly new to programming and Python and am trying to
explore Python's email libraries. But I am having trouble making a
connection with an email server, I guess.
I'm running Windows XP, in a server environment. I have administrator
privileges to my machine (not the server machine) to install, delete
programs, for example. My email program (Outlook 2007) says that
Exchange Server is albertapdc.express.local
I would like to send emails using smtp in a script, but when I do
these lines, I get an error:

import smtplib
server = smtplib.SMTP('localhost') # if I replace 'localhost' with
'albertapdc.express.local' I get the same.

Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, port)
  File "C:\Python25\lib\smtplib.py", line 310, in connect
raise socket.error, msg
error: (10061, 'Connection refused')


The server refuses your connection attempt...



The same error 'Connection refused' I get trying IMAP:
import imaplib
se = imaplib.IMAP4('albertapdc.express.local')
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\imaplib.py", line 163, in __init__
self.open(host, port)
  File "C:\Python25\lib\imaplib.py", line 230, in open
self.sock.connect((host, port))
  File "", line 1, in connect
error: (10061, 'Connection refused')


The server again refuses your connection attempt...



What should I do? 


I'd start by pinging the server and running nmap on it.  Forget imap if 
your goal is sending mail.  If you don't see port 25 or 465 opened you 
won't make it much further without getting the mail system 
administrator's help.


HTH,

Emile



And how can I know I can use smtp or IMAP?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to connect to an email server?

2009-03-16 Thread Tim Golden

Eduardo Vieira wrote:

Hello, I'm fairly new to programming and Python and am trying to
explore Python's email libraries. But I am having trouble making a
connection with an email server, I guess.
I'm running Windows XP, in a server environment. I have administrator
privileges to my machine (not the server machine) to install, delete
programs, for example. My email program (Outlook 2007) says that
Exchange Server is albertapdc.express.local
I would like to send emails using smtp in a script, but when I do
these lines, I get an error:

import smtplib
server = smtplib.SMTP('localhost') # if I replace 'localhost' with
'albertapdc.express.local' I get the same.

Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, port)
  File "C:\Python25\lib\smtplib.py", line 310, in connect
raise socket.error, msg
error: (10061, 'Connection refused')

The same error 'Connection refused' I get trying IMAP:
import imaplib
se = imaplib.IMAP4('albertapdc.express.local')
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\imaplib.py", line 163, in __init__
self.open(host, port)
  File "C:\Python25\lib\imaplib.py", line 230, in open
self.sock.connect((host, port))
  File "", line 1, in connect
error: (10061, 'Connection refused')

What should I do? And how can I know I can use smtp or IMAP?



SMTP has to be enabled specifically on the Exchange Server:
it usually uses its own built-in protocols. It looks
as though your Exchange isn't running it. Either switch it
on (or ask your admins to do so) or look at using MAPI
or CDO instead.

TJG
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] reading lists from a text file

2009-03-16 Thread عماد نوفل
2009/3/12 Kent Johnson 

> 2009/3/12 Emad Nawfal (عماد نوفل) :
> > Hi Tutors,
> > I've never had a situation in which this was useful for me, but I'm just
> > curious.
> > If there is a text file that has a list or number of lists in it, is
> there
> > is a way to read the lists in the file as lists, and not as a string.
> Sample
> > file attached.
>
> For the individual lines, there are various solutions. eval() is easy
> but not recommended because of the security risk. There are several
> recipes in the Python cookbook - search for "safe eval". Python 2.6
> includes ast.literal_eval() which does the job safely:
>
> In [1]: from ast import literal_eval
>
> In [4]: data = '''["this", "is", "a", "list"]
>   ...: ["this", "is", "another", "list"]
>   ...: ["this", "is","list", "#", "2"]'''
>
> In [5]: for line in data.splitlines():
>   ...: print literal_eval(line)
>
> ['this', 'is', 'a', 'list']
> ['this', 'is', 'another', 'list']
> ['this', 'is', 'list', '#', '2']
>
> Extending from parsing a single line to parsing all the lines in a
> file is trivial.
>
> Kent
>


Thank you all for the answers.
-- 
لا أعرف مظلوما تواطأ الناس علي هضمه ولا زهدوا في إنصافه كالحقيقة.محمد
الغزالي
"No victim has ever been more repressed and alienated than the truth"

Emad Soliman Nawfal
Indiana University, Bloomington
http://emnawfal.googlepages.com

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] How to connect to an email server?

2009-03-16 Thread Eduardo Vieira
Hello, I'm fairly new to programming and Python and am trying to
explore Python's email libraries. But I am having trouble making a
connection with an email server, I guess.
I'm running Windows XP, in a server environment. I have administrator
privileges to my machine (not the server machine) to install, delete
programs, for example. My email program (Outlook 2007) says that
Exchange Server is albertapdc.express.local
I would like to send emails using smtp in a script, but when I do
these lines, I get an error:

import smtplib
server = smtplib.SMTP('localhost') # if I replace 'localhost' with
'albertapdc.express.local' I get the same.

Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, port)
  File "C:\Python25\lib\smtplib.py", line 310, in connect
raise socket.error, msg
error: (10061, 'Connection refused')

The same error 'Connection refused' I get trying IMAP:
import imaplib
se = imaplib.IMAP4('albertapdc.express.local')
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\imaplib.py", line 163, in __init__
self.open(host, port)
  File "C:\Python25\lib\imaplib.py", line 230, in open
self.sock.connect((host, port))
  File "", line 1, in connect
error: (10061, 'Connection refused')

What should I do? And how can I know I can use smtp or IMAP?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Modifying Grayson's Example 5_14

2009-03-16 Thread Martin Walsh
Wayne Watson wrote:
...

> it.  It works pretty well, but puts up a a few probably top level
> windows that are blank. How do I get around them, and is there anything

...

> 
> root = Tk()

Try adding this,

root.withdraw()

> dialog = GetPassword(root)

HTH,
Marty
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Modifying Grayson's Example 5_14

2009-03-16 Thread Wayne Watson
Title: Signature.html




I thought I'd explore Tkinter a bit more before diving into widget
design. Grayson has some examples on the web, which look like they
could help a bit. He uses Pmw, so I thought I'd just remark out the
import for it.  It works pretty well, but puts up a a few probably top
level windows that are blank. How do I get around them, and is there
anything else I should be aware of in this code?  It produces a small
dialog for entering a new pwd.

# Grayson 5_14.py
from   Tkinter import *
from   tkSimpleDialog import Dialog
import tkMessageBox
#import Pmw

class GetPassword(Dialog):

    def body(self, master):
    self.title("Enter New Password")
    
    Label(master, text='Old Password:').grid(row=0, sticky=W)
    Label(master, text='New Password:').grid(row=1, sticky=W)
    Label(master, text='Enter New Password Again:').grid(row=2,
sticky=W)

    self.oldpw   = Entry(master, width = 16, show='*')
    self.newpw1  = Entry(master, width = 16, show='*')
    self.newpw2  = Entry(master, width = 16, show='*')

    self.oldpw.grid(row=0, column=1, sticky=W)
    self.newpw1.grid(row=1, column=1, sticky=W)
    self.newpw2.grid(row=2, column=1, sticky=W)
    return self.oldpw

    def apply(self):
    opw  = self.oldpw.get()
    npw1 = self.newpw1.get()
    npw2 = self.newpw2.get()

    if not npw1 == npw2:
    tkMessageBox.showerror('Bad Password',
   'New Passwords do not match')
    else:
    # This is where we would set the new password...
    pass

root = Tk()
dialog = GetPassword(root)
-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


“Life is one damn thing after another."
 -- Mark Twain 





___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] memory error files over 100MB

2009-03-16 Thread Kent Johnson
On Mon, Mar 16, 2009 at 12:30 PM, A.T.Hofkamp  wrote:

> I don't know what code is executed in an assignment exactly, but
> **possibly**, first the 'read()' is executed (thus loading a very big string
> into memory), before assigning the value to the variable (which releases the
> previous value of the variable).
> That means that just after reading but before assigning, you **may** have
> two very big strings in memory that cannot be garbage collected.

No. Python variables are references to values, not containers for
values. Python assignment is *always* reference assignment, not
copying of a value. More here;
http://personalpages.tds.net/~kent37/kk/00012.html

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] memory error files over 100MB

2009-03-16 Thread A.T.Hofkamp

Cheetah1000 wrote:

I can't speak for Python 2.6, but using Jython 2.1 (Python 2.1 for Java),
the code only looks at the file you are trying to extract()/read().  Near
the end of the zip archive is a directory of all the files in the archive,
with the start position and length of each file.  Jython's zipfile (written
in python, naturally) only reads from the start position to the end of the
file.  More information on this can be found by searching for 'Central
Directory' of a zip archive.  Still doesn't explain the 100M problem though. 
I've having the same issue extracting 20MB from a 22MB zip.  It could be
Python; or it could be, in my case, a java issue.  


Zipped sizes are not really interesting.

Since you read the unzipped version into memory, how big is the data unzipped? 
That is the amount of storage that you need for just the file data.


To have a working program, you have to add the size of a running Python or 
Java program to that number.


I don't know what code is executed in an assignment exactly, but **possibly**, 
first the 'read()' is executed (thus loading a very big string into memory), 
before assigning the value to the variable (which releases the previous value 
of the variable).
That means that just after reading but before assigning, you **may** have two 
very big strings in memory that cannot be garbage collected.


All that data needs to be available in the memory of a single process at your 
machine.


As already discussed, the only proper way of dealing with such files is to 
split your read call into smaller blocks, so you can handle zip files up to 
disk capacity.



Sincerely,
Albert
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] memory error files over 100MB

2009-03-16 Thread Cheetah1000



Alan Gauld wrote:
> 
> 
> "Sander Sweers"  wrote
> 
>> ...  I would expect zf.read(zfilename) to only read the
>> requested file in the zipfile.
> 
> That's a dangerous assumption. You might be right but I'd want to
> do some tests first to see. But if even one zipped file was big the
> same would apply.
> 
> Alan G.
> 
> 

I can't speak for Python 2.6, but using Jython 2.1 (Python 2.1 for Java),
the code only looks at the file you are trying to extract()/read().  Near
the end of the zip archive is a directory of all the files in the archive,
with the start position and length of each file.  Jython's zipfile (written
in python, naturally) only reads from the start position to the end of the
file.  More information on this can be found by searching for 'Central
Directory' of a zip archive.  Still doesn't explain the 100M problem though. 
I've having the same issue extracting 20MB from a 22MB zip.  It could be
Python; or it could be, in my case, a java issue.  
-- 
View this message in context: 
http://www.nabble.com/memory-error-files-over-100MB-tp22437060p22539945.html
Sent from the Python - tutor mailing list archive at Nabble.com.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] 32-bit libaries on 64-bit Windows

2009-03-16 Thread Dinesh B Vadhia
Does anyone know if 32-bit Python libraries will work with 64-bit Python under 
64-bit Windows?  For example, will 32-bit Numpy or Scipy work under 64-bit 
Python?  Cheers ...

Dinesh


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] wxPython vs PyQt

2009-03-16 Thread Kent Johnson
2009/3/16 Elena of Valhalla :
> 2009/3/16 Neven Goršić :
>> I just would like to correct my incomplete PyQT pricing list from
>> above and mislead none.
>>
>> If you intent to write commercial programs you have to pay:
>>
>> 400 EURO   for PyQT     AND    3000 EURO  for QT !!!
>
> actually, QT is moving to LGPL, so in the near future you may be able
> not to pay anything even for writing some proprietary programs

Qt is available now under LGPL. PyQt is still GPL / Commercial AFAICT.

> anyway, you're still free to use the GPL version to play around with
> it and to develop free software apps

Yes, but be careful with the playing around - "Both the Qt and PyQt
Commercial Licenses prevent you from developing code using the GPL
versions and subsequently selling that code under the commercial
license. You must purchase a commercial license at the start of your
development. "
http://www.riverbankcomputing.co.uk/software/pyqt/license

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] wxPython vs PyQt

2009-03-16 Thread Elena of Valhalla
2009/3/16 Neven Goršić :
> I just would like to correct my incomplete PyQT pricing list from
> above and mislead none.
>
> If you intent to write commercial programs you have to pay:
>
> 400 EURO   for PyQT     AND    3000 EURO  for QT !!!

actually, QT is moving to LGPL, so in the near future you may be able
not to pay anything even for writing some proprietary programs

anyway, you're still free to use the GPL version to play around with
it and to develop free software apps

-- 
Elena ``of Valhalla''

email: elena.valha...@gmail.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] wxPython vs PyQt

2009-03-16 Thread Neven Goršić
I just would like to correct my incomplete PyQT pricing list from
above and mislead none.

If you intent to write commercial programs you have to pay:

400 EURO   for PyQT AND3000 EURO  for QT !!!

-

On Tue, Mar 10, 2009 at 2:27 PM, andré palma  wrote:
> Neven Goršić wrote:
>>
>> Thank you all. It was not easy to decide what to learn/use, so I "Google"
>> some more.
>>
>> I have found that PyQT is more stable, faster, more consistent and more
>> expensive :).
>> 400 EURO is too much for playing around with some GUI, but GPL licence
>> resolves that issue.
>> The cons are C++ oriented documentation, editor and some structures ...
>>
>> Neven
>>
>> ---
>>
>> On Thu, Mar 5, 2009 at 3:10 AM, johnf > > wrote:
>>
>>On Wednesday 04 March 2009 04:56:37 pm Alan Gauld wrote:
>>> "Kent Johnson" mailto:ken...@tds.net>> wrote
>>>
>>> > I've heard good things about Dabo, never tried it myself though.
>>> > http://dabodev.com/
>>>
>>> I looked at Dabo but decided not to try it since it was yet another
>>> framework. Although it's based on wxPython they have layered their
>>> own widgets on top which is what the GUI Builder uses. (PythonCard
>>> fell into the same hole)
>>
>>Yes, it's true that Dabo has wrapped (subclassed) most of the
>>controls. The
>>purpose of course was to provide developer ease of use.  If you
>>are building
>>a real business app then I doubt there is anything better in the
>>python
>>world.  I personally have used both VB and Delphi and see Dabo on
>>the same
>>level.  With one exception - we have a beta GUI builder.
>> Everything that has
>>been done in Dabo is the very same things that all developers would be
>>required to do if they access a database and associate fields to
>>controls.
>>BTW there is nothing stopping a Dabo developer from directly using wx
>>controls.  Dabo prevents nothing.
>>
>>So Alan, I don't see my work as falling into any hole.
>>>
>>> But the web pages and writeup looked good and the forum seemed
>>> to be active and not all negative.
>>>
>>> Alan G
>>
>
>>Hey, i've found your discussion interesting.
>>
> I'm developing my final course project and i'm using a toll called "Glade"
> to create my application. It has a IDE that let you to create your windows,
>  with text boxes, combo boxes ... everything! And the really good thing: it
> is totally open source =)
> It's quit simple to do applications with glade. You just have to create your
> GUI with it IDE and then you just need to link the "signals" to de functions
> that actually preform actions.
>
> GLADE:
> http://glade.gnome.org/
> http://www.pygtk.org/articles/pygtk-glade-gui/Creating_a_GUI_using_PyGTK_and_Glade.htm
>(examples how to use glade and pyGTK)
>
> and if you look for it in youtube there is a lot of a good video tutorials
>
>>
>>--
>>John Fabiani
>>___
>>Tutor maillist  -  Tutor@python.org 
>>http://mail.python.org/mailman/listinfo/tutor
>>
>>
>> 
>>
>> ___
>> Tutor maillist  -  Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] TypeError: dict objects are unhashable

2009-03-16 Thread A.T.Hofkamp

Lie Ryan wrote:

Emile van Sebille wrote:

Mark Tolonen wrote:

[dict(n) for n in set(tuple(n.items()) for n in l1)]


Anyone know if the ordered items for two different dicts where dicta 
== dictb is guaranteed the same?  I know the ordering is unspecified 
but you can depend on the sequence of keys matching data and I think 
it'll also match items.


but for all DA's and DB's below, is that true?



Considering how dictionary is implemented, I don't think so. The 
dictionary is internally implemented as a hash table, and two dictionary 
with identical items may have different sized hash table, the algorithm 
guarantees efficient usage of memory (it resizes when it's too small or 
too big). On a resize, the hashes are recalculated and the ordering 
rescrambled.


And a short demo to confirm:

Python 2.3.4 (#1, Jul 25 2008, 14:24:21)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> x = range(10)
>>> y = x[:]
>>> y.reverse()
>>> d1 = dict([(i*1000, i) for i in x])
>>> d2 = dict([(i*1000, i) for i in y])
>>> d1.items()
[(0, 0), (4000, 4), (1000, 1), (8000, 8), (6000, 6), (9000, 9), (2000, 2), 
(5000, 5), (7000, 7), (3000, 3)]

>>> d2.items()
[(8000, 8), (4000, 4), (2000, 2), (0, 0), (9000, 9), (6000, 6), (5000, 5), 
(3000, 3), (1000, 1), (7000, 7)]



Sincerely,
Albert

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] way of dictating leading zeros

2009-03-16 Thread Alan Gauld

"Patrick"  wrote


Is there an easy way to dictate how many digits a number will occupy
that also allows for leading zeros?


Andre showed you the way to do this using "String Formatting".
Search for that phrase in the docs for al lot more info.

If you are considering using Python v3 then that style is deprecated 
and

you may want to use the new String Formatter object. See the Python 3
string docs for more on that.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help With Rock, Paper Scissor Game

2009-03-16 Thread Alan Gauld


"Brendy Siguenza"  wrote

This is the template that we are suppose to use while doing the 
program, I
am a beginner to this programming language and really have no clue 
what I am

doing


We don;t do homework problems for you but we can try to point
you in the right direction.

First off, it looks like you don;t understand dictionaries?
Try reading about dictionaries in a tutorial somwhere
(eg mine - the Raw Materials topic has some info)


NOW THIS IS WHAT I HAVE SO FAR, AND THESE ARE ALL
JUMBLE AROUND BECAUSE I HAVE NO CLUE WHERE
THEY ARE SUPPOSE TO GO PLZ HELP


Randomly coding is never a good idea. Try to work out how
you would solve it in your head before charging into writing code.


import random



#table of winning plays
win_play_for = {'r':'p', 'p':'s', 's':'r'}


This is a dictionary but you call it like a function.
See my comments above

#scoring results

player_score = 0
mach_score = 0

You don't use these? What are they for and when should you set them?


#kepp track of users' last plays
#assume initially an even distribution
hist = ['r', 'p', 's', 'r', 'p', 's', 'r', 'p', 's']
next = 0 #index of where to put next user play


You set these here so dpnt need to set them again inside the while 
loop



while True:
hist = ['r', 'p', 's', 'r', 'p', 's', 'r', 'p', 's']
next = 0

don't need those two lines


guess = random_choice(hist)
len (hist)

The len() does nothing because you throw itr away.
Plus its always the same so no point in calculating it every
time round the loop.


#gets user's play
user_play = raw_input("What's your play (r|p|s)?")
hist[next] = user_play
next = next + 1
if next == len(hist):
next = 0


This bit is fine.

But where is the computers play?


user_play == win_play_for(mach_play)
mach_play == win_play_for(user_play)


These are dictionaries not function. See comment above

Also, where is the output? You never print anything?

Go think some more and come back to use with specific
questions about what you don't understand. Until you undersand
the basic structure of what you are trying to do there is not much
point in trying to fix the individual code issues. Try to describe
how it should work in English before describing it in Python. You
probably think better in English than you do in Python...


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor