Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Terry--gmail
Thanks Japhy Bartlett! [[0] for i in range(5)] Works! I converted to fit into my routine as: lens = [[] for i in range(len(catalog2[0]))] << the new statement for row in catalog2: for col, item in enumerate(row): lens[col].append(len(item)) lens = [max(col) for col in lens]

Re: [Tutor] Parsing txt file

2014-08-20 Thread Cameron Simpson
On 20Aug2014 16:35, Dima Kulik wrote: Hi to all. I have a problem with parsing file. I have txt file exported from AD and it has such structure: DistinguishedName : CN=*** ,OU=*** ,OU=*** ,DC=*** ,DC=***,DC=*** GroupCategory : Distribution GroupScope    : Universal Name  : *

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Japhy Bartlett
this forms a list of integers >>> [0]*5 [0, 0, 0, 0, 0] what I think you want is something like: >>> [[0] for i in range(5)] [[0], [0], [0], [0], [0]] (a list of lists) >>> foo = [[0] for i in range(5)] >>> foo[3].append('bar') >>> foo [[0], [0], [0], [0, 'bar'], [0]] On Wed, Aug 20, 2014 a

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Alan Gauld
On 20/08/14 20:06, Terry--gmail wrote: We are not quite out of the woods on this last example lens = [0] * len(catalog2[0]) This is what happens when you don't test code. My apologies, the initialisation is all wrong. Try this instead: lens = [ [] for n in catalog2[0] ] That adds an empt

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Danny Yoo
> > lens = [0] * len(catalog2[0]) Ah. Read the following closely: https://docs.python.org/2/faq/programming.html#how-do-i-create-a-multidimensional-list If you have any questions, please feel free to ask further. See if that clears up the mistake that's in your code. ___

Re: [Tutor] Parsing txt file

2014-08-20 Thread Danny Yoo
> i need to export to file all stings which start from "Name" > > I've tried to make little parser: > > keywords = ['Name', 'Name:'] > input_file=open("Mail_Groups.txt","r").readlines() > output_file=open("Out.txt","w") > for line in input_file: > for word in line.split(): > if word in

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Terry--gmail
Hi Marc Tompkins! You are absolutely right that lens = [0] * len(catalog2[0]) Just creates a list of integers! Here is what happened, my original method of finding the maximum element sizes in the 9 x ? block of data held in catalog2, only needed a final list of integers to contain it. Howe

Re: [Tutor] Parsing txt file

2014-08-20 Thread Dave Angel
Dima Kulik Wrote in message: Please post in text mode. The html mode you used can cause multiple problems. Please specify your Python version and os version in any new thread.It sometimes makes a big difference in the solution. Your primary problem is that you don't close the files. But yo

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Peter Otten
Terry--gmail wrote: > Marc, my understanding is, is that: > > lens[col].append(len(item)) > > -should be building a mirror image of my list of lists called catalog2, > which currently has 9 columns by x number of rows, and that we are > plugging into these positions, the sizes of all the el

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Marc Tompkins
On Wed, Aug 20, 2014 at 1:38 PM, Terry--gmail wrote: > Marc, my understanding is, is that: > > lens[col].append(len(item)) > > -should be building a mirror image of my list of lists called catalog2, > which currently has 9 columns by x number of rows, and that we are plugging > into these posi

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Terry--gmail
Marc, my understanding is, is that: lens[col].append(len(item)) -should be building a mirror image of my list of lists called catalog2, which currently has 9 columns by x number of rows, and that we are plugging into these positions, the sizes of all the elements in that block of data.

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Marc Tompkins
On Aug 20, 2014 12:07 PM, "Terry--gmail" wrote: > > Alan Gauld > > Hi! > We are not quite out of the woods on this last example you gave me. It now seems to be complaining > that it doesn't want to append an integer to the list or that this isn't the place to use '.append' -- I am probably interp

Re: [Tutor] Fwd: Embedding resources

2014-08-20 Thread Danny Yoo
On Wed, Aug 20, 2014 at 6:45 AM, diliup gabadamudalige wrote: > Hi Danny! > > The routine works fine and so does this one. > > http://www.pygame.org/pcr/zipshow/index.php > > The only problem with all these are that that the time taken to read these > files and to either make a list or send to scr

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Terry--gmail
Alan Gauld Hi! We are not quite out of the woods on this last example you gave me. It now seems to be complaining that it doesn't want to append an integer to the list or that this isn't the place to use '.append' -- I am probably interpreting it's complaint wrong: Python 3.3 If I run this

Re: [Tutor] How to end this program

2014-08-20 Thread Joel Goldstick
On Wed, Aug 20, 2014 at 2:40 PM, Joel Goldstick wrote: > On Wed, Aug 20, 2014 at 2:34 PM, Joel Goldstick > wrote: >> On Wed, Aug 20, 2014 at 7:00 AM, abid saied wrote: >>> >>> # OK, I'm stuck on setting up an instruction that ends the program once >>> you >>> # say either 'yes' or 'no'.

Re: [Tutor] How to end this program

2014-08-20 Thread Joel Goldstick
On Wed, Aug 20, 2014 at 2:34 PM, Joel Goldstick wrote: > On Wed, Aug 20, 2014 at 7:00 AM, abid saied wrote: >> >> # OK, I'm stuck on setting up an instruction that ends the program once >> you >> # say either 'yes' or 'no'. And if you don't say 'yes' or 'no', and you >> reach >> # t

Re: [Tutor] How to end this program

2014-08-20 Thread Joel Goldstick
On Wed, Aug 20, 2014 at 7:00 AM, abid saied wrote: > > # OK, I'm stuck on setting up an instruction that ends the program once > you > # say either 'yes' or 'no'. And if you don't say 'yes' or 'no', and you > reach > # the end, the program comes to an end. Please remember I'm a newbi

[Tutor] Parsing txt file

2014-08-20 Thread Dima Kulik
Hi to all. I have a problem with parsing file. I have txt file exported from AD and it has such structure: DistinguishedName : CN=*** ,OU=*** ,OU=*** ,DC=*** ,DC=***,DC=*** GroupCategory : Distribution GroupScope    : Universal Name  : ObjectClass   : group ObjectGUI

[Tutor] Fwd: Embedding resources

2014-08-20 Thread diliup gabadamudalige
Hi Danny! The routine works fine and so does this one. http://www.pygame.org/pcr/zipshow/index.php The only problem with all these are that that the time taken to read these files and to either make a list or send to screen is WAY TOO LONG. The only one that works without much delay is in the fi

[Tutor] How to end this program

2014-08-20 Thread abid saied
# OK, I'm stuck on setting up an instruction that ends the program once you # say either 'yes' or 'no'. And if you don't say 'yes' or 'no', and you reach # the end, the program comes to an end. Please remember I'm a newbie and would # appreciate any advise in plain simple

[Tutor] Embedding resources

2014-08-20 Thread Danny Yoo
On Aug 19, 2014 11:53 PM, "diliup gabadamudalige" wrote: > > Hi all! > > Is there any way I can bundle all my graphics only using Python and Pygame so that the user may not be able to read them out of the program? (Changing subject line to more descriptive title) Would something like http://www.