[Tutor] How to generate permutations of a given string

2006-11-27 Thread Asrarahmed Kadri
Hello folks, Can someone help me with a simple algorithm to generate permutations of a given string: Input string:>> 'abc' Output:--->> ['abc','acb','bac','bca','cab','cba'] Thanks. Regards, Asrarahmed Kadri - To HIM you shall return. _

[Tutor] Newbie question: join() string method

2006-11-27 Thread Moedeloos Overste
Hi, I'm trying to use the join() method on a list to be able to store the contents of that list in a file. Basically I want the contents of the list stored without the []. I've tried numerous ways of using the join() method, but they all return errors. I've tried using the tutorial and document

Re: [Tutor] Newbie question: join() string method

2006-11-27 Thread Andreas Kostyrka
",".join(str(x) for x in intList) Andreas _ Ursprüngliche Mitteilung _ Betreff:[Tutor] Newbie question: join() string method Autor: "Moedeloos Overste" <[EMAIL PROTECTED]> Datum: 27. November 2006 13:20:41 Hi, I'm trying to use the join() method on a list to be able to

Re: [Tutor] Newbie question: join() string method

2006-11-27 Thread jhl
Hi, I am not sure what 'random' does (what package is it from?), but list=['1','2','3'] slist=','.join(list) works, while list=[1,2,3] slist=','.join(list) does not. It appears 'join' only works on lists (and maybe tuples?) of string objects and the list must be passed in as an argument. Tr

Re: [Tutor] What are the issues in running Python script on another machine (developed on Windows but will be using on Linux)

2006-11-27 Thread Python
On Sun, 2006-11-26 at 15:14 +, Asrarahmed Kadri wrote: > > > Hi folks, > > I have a couple of programs that I want to test on a different > machine.. > > I have developed these on Win-XP platform, but I want to test them on > my college's machine, which is running Linux. > > Are there

Re: [Tutor] What are the issues in running Python script on another machine (developed on Windows but will be using on Linux)

2006-11-27 Thread Kent Johnson
Python wrote: > On Sun, 2006-11-26 at 15:14 +, Asrarahmed Kadri wrote: >> >> >> Hi folks, >> >> I have a couple of programs that I want to test on a different >> machine.. >> >> I have developed these on Win-XP platform, but I want to test them on >> my college's machine, which is runni

Re: [Tutor] Newbie question: join() string method

2006-11-27 Thread Moedeloos Overste
Ha! Thanx for all the input everybody. I finally got it to work. The contents of the list is now stored in the file without the []. The solution is in the code below. Next step in my learning process is reading the file contents and storing it in a dictionary. One question: When I run the prog

Re: [Tutor] How to generate permutations of a given string

2006-11-27 Thread Alan Gauld
"Asrarahmed Kadri" <[EMAIL PROTECTED]> wrote > Can someone help me with a simple algorithm to generate permutations > of a > given string: Try Googling for python string permutation. Several approaches came up including a cookbook page entry. Alan G. ___

Re: [Tutor] __init__.py for running a file from commandline?

2006-11-27 Thread Marcus Goldfish
On 11/11/06, Kent Johnson <[EMAIL PROTECTED]> wrote: Marcus Goldfish wrote: > Hoping someone can help with this... > > I have a logical python namespace using a directory tree and __init__.py > files. For example, PYTHONPATH points to ~pyroot, and I have the following: > > ~pyroot/ > ~pyroot/ut

[Tutor] e: moving from pack to grid in tkinter

2006-11-27 Thread Tony Cappellini
Date: Mon, 27 Nov 2006 18:07:33 +1300 From: "John Fouhy" <[EMAIL PROTECTED]> Subject: Re: [Tutor] moving from pack to grid in tkinter To: tutor-python Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1; format=flowed On 27/11/06, Tony Cappellini <[EMAIL PROTECTED]> wrot

Re: [Tutor] __init__.py for running a file from commandline?

2006-11-27 Thread Kent Johnson
Marcus Goldfish wrote: > > > On 11/11/06, *Kent Johnson* <[EMAIL PROTECTED] > > wrote: > > Marcus Goldfish wrote: > > Hoping someone can help with this... > > > > I have a logical python namespace using a directory tree and > __init__.py > >

Re: [Tutor] __init__.py for running a file from commandline?

2006-11-27 Thread Michael P. Reilly
Marcus, When you type something from the command-line, you are at the whims of the WinXP command shell. You have to follow its rules, not Python's. It would need to have "python" in %PATH%, and then it would need to have to run "python C:\path\to\pyroot\utils\commands\mygrep.py". The arguments

Re: [Tutor] Newbie question: join() string method

2006-11-27 Thread Alan Gauld
"Moedeloos Overste" <[EMAIL PROTECTED]> wrote > One question: When I run the program from IDLE it writes the data to > file > but when I run it from the command prompt(win32) it doesn't. why is > this? How do you know? Have you searched for the file? Or are you looking in the same file that ID

Re: [Tutor] moving from pack to grid in tkinter

2006-11-27 Thread Alan Gauld
"Tony Cappellini" <[EMAIL PROTECTED]> wrote >>> > But i'm trying to get away from pack() and use grid() There's no good reason not to use pack where it makes sense. You can mix n match provided you keep it consistent within a single container(usually a frame) Grid is best where the controls conf

[Tutor] AttributeError: 'list' object has no attribute 'copy'

2006-11-27 Thread Keith Troell
I'm a rank beginner. I am running Python 2.3.5 on the Terminal of Mac OSX. The Tutorial (5.1) mentions list.copy as a list method. When I run scores = [1, 2, 3] copy = scores.copy () I get: AttributeError: 'list' object has no attribute 'copy' However, I am able to use .copy for dictionaries

Re: [Tutor] AttributeError: 'list' object has no attribute 'copy'

2006-11-27 Thread Kent Johnson
Keith Troell wrote: > I'm a rank beginner. I am running Python 2.3.5 on the Terminal of Mac > OSX. > > The Tutorial (5.1) mentions list.copy as a list method. When I run Are you sure? I don't see it here: http://www.python.org/doc/2.3.5/tut/node7.html#SECTION00710 > > scores =

Re: [Tutor] ashamed

2006-11-27 Thread Moedeloos Overste
I shamefully bowe my head. How stupid of me not to think of that. I assumed that as the script is in a certain directory the output would also be in that directory. A very humbling learning experience Thank you for the pointer on file open/close outside of the loop. That should speed thing

Re: [Tutor] adjust key bindings

2006-11-27 Thread John CORRY
Luke, Thanks for the response. I am trying to help someone out on the Pygtk list. I forgot to enclose his reasons for wanting to assign the key press. They are below: It looks like he likes his keys set out in a certain way. I am happy with mine the way they are! I used "z" in isolation just

Re: [Tutor] e: moving from pack to grid in tkinter

2006-11-27 Thread John Fouhy
On 28/11/06, Tony Cappellini <[EMAIL PROTECTED]> wrote: > But i'm trying to get away from pack() and use grid() Why? Sometimes pack() is the right option. You can do things with pack that you can't do with grid. You can use both in your program -- just don't use both in the same frame. > Well

Re: [Tutor] Newbie question: join() string method

2006-11-27 Thread wesley chun
> strgOutput=",".join(str(i) for i in LotNumbers) #??converting list > to string to store it. note that here, you are *not* converting the list to a string to store it. you are converting each list member to a string and creating a new "list" (actually generator [expression]) for the st

Re: [Tutor] AttributeError: 'list' object has no attribute 'copy'

2006-11-27 Thread Keith Troell
On Nov 27, 2006, at 1:55 PM, Kent Johnson wrote: > Keith Troell wrote: >> I'm a rank beginner. I am running Python 2.3.5 on the Terminal of >> Mac OSX. >> The Tutorial (5.1) mentions list.copy as a list method. When I run > > Are you sure? I don't see it here: > http://www.python.org/doc/2.3.5

Re: [Tutor] How to generate permutations of a given string

2006-11-27 Thread Carroll, Barry
Hello, Asrarahmed > -Original Message- > Date: Mon, 27 Nov 2006 12:06:54 + > From: "Asrarahmed Kadri" <[EMAIL PROTECTED]> > Subject: [Tutor] How to generate permutations of a given string > To: tutor-python > Message-ID: > <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=

[Tutor] Convert string to file handle

2006-11-27 Thread Shitiz Bansal
Hi, i have a string abc. i need a file handle f pointing to a file which contains this string. is there any way i can achieve this without actually writing the contents to a file and then opening it? for performance reasons i want to run this entire process within the physical memory! Thanks, S

Re: [Tutor] Convert string to file handle

2006-11-27 Thread John Fouhy
On 28/11/06, Shitiz Bansal <[EMAIL PROTECTED]> wrote: > Hi, > i have a string abc. > i need a file handle f pointing to a file which contains this string. > is there any way i can achieve this without actually writing the contents to > a file and then opening it? for performance reasons i want to

Re: [Tutor] How to generate permutations of a given string

2006-11-27 Thread John Fouhy
On 28/11/06, Carroll, Barry <[EMAIL PROTECTED]> wrote: > I'm not sure these qualify as "simple", but they work. This was one of > my very first projects in Python, so it may be more complicated than > necessary. This is an alternative approach: http://mail.python.org/pipermail/tutor/2005-May/0380

Re: [Tutor] Convert string to file handle

2006-11-27 Thread Bob Gailer
Shitiz Bansal wrote: > Hi, > i have a string abc. > i need a file handle f pointing to a file which contains this string. For what? > is there any way i can achieve this without actually writing the > contents to a file and then opening it? for performance reasons i want > to run this entire pro

Re: [Tutor] Tutor Digest, Vol 33, Issue 100

2006-11-27 Thread Danny Yoo
> done=0 > fd = open("draw__output.txt",'r') > while not done: >line = fd.readline() >if line == '': >done = 1 >else: > for i in line: > d[i] = int(d[i])+ 1 Code simplification: you can do a loop directly across files. Files provide an "iterator" that allow us

Re: [Tutor] ashamed

2006-11-27 Thread Alan Gauld
"Moedeloos Overste" <[EMAIL PROTECTED]> wrote > d={1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0, 10:0, 11:0, 12:0, > 13:0, > 14:0, 15:0, >16:0, 17:0, 18:0, 19:0, 20:0, 21:0, 22:0, 23:0, 24:0, 25:0, 26:0, > 27:0, > 28:0, >29:0, 30:0, 31:0, 32:0, 33:0, 34:0, 35:0, 36:0, 37:0, 38:0, 39:0,

[Tutor] How to Automatically generate a synopsis for a Module

2006-11-27 Thread Tim Johnson
Hello: If I start the python interpreter, then import a file, and type help(module_name_here) Documentation about the module is displayed in detail. I would like to write a python script that Searches for all python scripts in a directory, and extracts (initially) the description for each scrip

Re: [Tutor] How to Automatically generate a synopsis for a Module

2006-11-27 Thread Tim Johnson
Amazing what google can do I think pydoc does it all... pydoc -p 1234 sets up the server what what I need. Never mind! :-) tim * Tim Johnson <[EMAIL PROTECTED]> [061127 17:24]: > Hello: > If I start the python interpreter, then import a file, and > type > help(module_name_here) > Documenta

Re: [Tutor] help with Tkinter, please

2006-11-27 Thread Dick Moores
At 08:55 PM 11/26/2006, you wrote: >On 27/11/06, Dick Moores <[EMAIL PROTECTED]> wrote: >>I have a question about the "EXIT" button's command, >>command=sys.exit. It fails to quit the program when I've entered too >>large an integer for factoring, or for prime testing, and I don't >>want to wait an

[Tutor] Rounding a float to n significant digits

2006-11-27 Thread Dick Moores
I just dug this Tim Smith creation out of the Tutor archive. def round_to_n(x, n): """ Rounds float x to n significant digits, in scientific notation. Written by Tim Peters. See his Tutor list post of 7/3/04 at http://mail.python.org/pipermail/tutor/2004-July/030324

Re: [Tutor] Please suggest a python book

2006-11-27 Thread wesley chun
> I am new to python. I have a vacation of 15 days. Please suggest me a python > book (or a website). > > I already know C language. I have heard much about Python. there was a long thread about this in the main newsgroup several months ago... i suppose these threads show up annually. anyway, it

Re: [Tutor] help with Tkinter, please

2006-11-27 Thread wesley chun
> >>I have a question about the "EXIT" button's command, > >>command=sys.exit. It fails to quit the program when I've entered too > >>large an integer for factoring, or for prime testing, and I don't > >>want to wait any more for the result. > > > >So, you can see why clicking your exit button won'