Danny Yoo | 1 Oct 2006 04:54
Picon

Re: Monte Carlo method modules & references

> I am searching for monte carlo and two- person game, also monte carlo
> statistical ampling distribution. Thanks.

Hi William,

Ok... so what do you need help in?

If you're asking how to do research on those subjects, we're probably not 
the best people to ask.  This group is dedicated to helping with general 
programming in Python, with a slant toward beginners.  If you have a 
programming question, that's something we can really sink our teeth into. 
Otherwise, we won't claim any special expertise on simulation methods.

Have you done a few Google searches with the term "monte carlo"?  There's 
a whole bunch of useful material that can be found with a good search 
engine.  You may also want to look at a resource like the Wikipedia, which 
has quite a lot of material on monte carlo methods.
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Liam Clarke | 1 Oct 2006 13:53
Picon

difflib - restoring from a unified diff?

Hi all,

I'm writing a wiki at the moment, and I want to store unified diffs to 
allow easy reverting between versions of a document. It appears that 
difflib.restore() can only generate original text from diffs returned 
from ndiff() or compare() which store the full text of both versions.

As this offers no efficiency in storage space over storing the actual 
text, it doesn't much serve my purpose - does anyone know of a 3rd party 
module that, given a text and a unified diff, can return the altered 
text? I can probably write one myself if I sweat a bit, but I'd much 
rather use any pre-existing modules.

Regards,

Liam Clarke
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Dick Moores | 1 Oct 2006 15:03

Re: Puzzled by print lst.sort()

At 01:37 PM 9/30/2006, Shantanoo Mahajan wrote:
>Maybe following is helpful:
>
> >>> a=[3,2,1]
> >>> b=a[:]
> >>> b.sort()
> >>> c=sorted(a)
> >>> print a,b,c
> >>> [3, 2, 1] [1, 2, 3] [1, 2, 3]
> >>>
>
>Shantanoo

Sorry to be dense, but I don't see what showing what happens to a 
copy of list a adds to the explanation:
 >>> a = [3,2,1]
 >>> b = a[:]
 >>> b.sort()
 >>> b
[1, 2, 3]
 >>>

given that:

 >>> a = [3,2,1]
 >>> a.sort()
 >>> a
[1, 2, 3]
 >>>

(Continue reading)

Liam Clarke | 1 Oct 2006 15:15
Picon

Re: Puzzled by print lst.sort()

Dick Moores wrote:
> At 01:37 PM 9/30/2006, Shantanoo Mahajan wrote:
>   
>> Maybe following is helpful:
>>
>>     
>>>>> a=[3,2,1]
>>>>> b=a[:]
>>>>> b.sort()
>>>>> c=sorted(a)
>>>>> print a,b,c
>>>>> [3, 2, 1] [1, 2, 3] [1, 2, 3]
>>>>>
>>>>>           
>> Shantanoo
>>     
>
> Sorry to be dense, but I don't see what showing what happens to a 
> copy of list a adds to the explanation:
>  >>> a = [3,2,1]
>  >>> b = a[:]
>  >>> b.sort()
>  >>> b
> [1, 2, 3]
>  >>>
>
> given that:
>
>  >>> a = [3,2,1]
>  >>> a.sort()
(Continue reading)

mike viceano | 1 Oct 2006 15:17
Picon
Favicon

error message

hello i wrote a litle program ware you pick a number and the computer
guesses it and i recently decided to make it so it dosint reguess
numbers but now i get a error message

here is the program

def number(number):
   from random import randrange
   guess=randrange(number*2)
   print guess
   guessed.append(guess)
   guesses=1
   guessed=[]
   while guess !=number:
       guess=randrage(number*2)
       if guess not in guessed:
           guessed.append(guess) #here is ware the problem is
           guesses=guesses+1
   print"i got the number",number,"number","in",guesses,"guesses"

and here is the error

Traceback (most recent call last):
File "<pyshell#17>", line 1, in -toplevel-
   guess.number(10)
File 
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/guess.py",
line 5, in number
   guessed.append(guess)
UnboundLocalError: local variable 'guessed' referenced before assignment
(Continue reading)

Kent Johnson | 1 Oct 2006 15:50
Gravatar

Re: difflib - restoring from a unified diff?

Liam Clarke wrote:
> Hi all,
> 
> I'm writing a wiki at the moment, and I want to store unified diffs to 
> allow easy reverting between versions of a document. It appears that 
> difflib.restore() can only generate original text from diffs returned 
> from ndiff() or compare() which store the full text of both versions.
> 
> As this offers no efficiency in storage space over storing the actual 
> text, it doesn't much serve my purpose - does anyone know of a 3rd party 
> module that, given a text and a unified diff, can return the altered 
> text? I can probably write one myself if I sweat a bit, but I'd much 
> rather use any pre-existing modules.

I don't see a python module for this but you could use os.system() to 
invoke patch.

Kent

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Kent Johnson | 1 Oct 2006 15:56
Gravatar

Re: error message

mike viceano wrote:
> hello i wrote a litle program ware you pick a number and the computer
> guesses it and i recently decided to make it so it dosint reguess
> numbers but now i get a error message
> 
> here is the program
> 
> def number(number):
>    from random import randrange
>    guess=randrange(number*2)
>    print guess
>    guessed.append(guess)
>    guesses=1
>    guessed=[]
>    while guess !=number:
>        guess=randrage(number*2)
>        if guess not in guessed:
>            guessed.append(guess) #here is ware the problem is
>            guesses=guesses+1
>    print"i got the number",number,"number","in",guesses,"guesses"
> 
> and here is the error
> 
> Traceback (most recent call last):
> File "<pyshell#17>", line 1, in -toplevel-
>    guess.number(10)
> File 
> "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/guess.py",
> line 5, in number
>    guessed.append(guess)
(Continue reading)

Andrew Robert | 1 Oct 2006 17:52
Picon

Python code to split and reassemble files


Hi guys,

Awhile back, I believe I saw a cookbook recipe for splitting and
reassembling text/binary files.

Does anyone know where this or something similar can be found?

I am working on a file transfer mechanism via MQSeries and breaking
large files to smaller chunks would improve efficiency.

--
Thank you,
Andrew Robert
Senior MQ Engineer
Information Technologies
MFS Investment Management
Phone:   617-954-5882

E-mail:  arobert <at> mfs.com
Linux User Number: #201204
Andrew Robert | 1 Oct 2006 18:11
Picon

Re: Python code to split and reassemble files


Never mind.. :)

found it at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/224800

However, if someone has something better, I would be very interested.

Andrew Robert wrote:
> Hi guys,
> 
> Awhile back, I believe I saw a cookbook recipe for splitting and
> reassembling text/binary files.
> 
> Does anyone know where this or something similar can be found?
> 
> I am working on a file transfer mechanism via MQSeries and breaking
> large files to smaller chunks would improve efficiency.
> 
Kent Johnson | 1 Oct 2006 18:18
Gravatar

Re: Python code to split and reassemble files

Andrew Robert wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi guys,
> 
> Awhile back, I believe I saw a cookbook recipe for splitting and
> reassembling text/binary files.
> 
> Does anyone know where this or something similar can be found?

Searching the cookbook for 'split file' finds this:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/224800

Kent

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor


Gmane