List permutations?


How would you go about doing list permutations in python I've seen permutations in C++, C, and Java. but I wanna see what it looks like in python
Posted On: Tuesday 27th of November 2012 01:10:58 AM Total Views:  48
View Complete with Replies

RELATED TOPICS OF Python Programming PROGRAMMING LANGUAGE




Re: Misuse of list comprehensions?

On Tue, May 27, 2008 at 7:09 PM, Delaney, Timothy (Tim) wrote: > Ian Kelly wrote: > >> It sounds like the wasteful list creation is the biggest objection to >> using a list comprehension. I'm curious what people ...
VIEWS ON THIS POST

53

Posted on:

Sunday 25th November 2012
View Replies!

getting dir(x), but not as list of strings?

I want to iterate over members of a module, something like: for i in dir(x): if type(i) == types.FunctionType: ... but of course dir() returns a list of strings. If x is a module, how can I get the list ...
VIEWS ON THIS POST

48

Posted on:

Sunday 25th November 2012
View Replies!

list index out of range

I am a relatively new python user. I am writing an economic simulation of acard-game. The simulation runs fine for a few iteration but then it gives an error of "list index out of range." The strange thing is that ...
VIEWS ON THIS POST

45

Posted on:

Sunday 25th November 2012
View Replies!

??: how to remove \n in the list

> lines[:] = [line.rstrip('\n') for line in lines] why not just: lines = [line.rstrip('\n') for line in lines] what's the difference between lines[:] and lines here
VIEWS ON THIS POST

100

Posted on:

Sunday 25th November 2012
View Replies!

Sorting Directories from files in a os.listdir??

I'd like to read the filenames in a directory, but not the subdirectories, os.listdir() gives me everything... how do I separate the directory names from the filenames Is there another way of doing this
VIEWS ON THIS POST

92

Posted on:

Sunday 25th November 2012
View Replies!

list.sort(): heaviest item?

If I have a list of items of mixed type, can I put something into it such that after a list.sort(), is guaranteed to be at the end of the list Looking at http://www.python.org/doc/2.3.5/ref/comparisons.html "Most other types compare unequal unless ...
VIEWS ON THIS POST

47

Posted on:

Sunday 25th November 2012
View Replies!

append to a sublist - please help

I must be blind but I don't see what's going wrong with G=[[]]*2 G[0].append('A') G[1].append('B') print G[0] gives ['A', 'B'] as well as print G[1] I was expecting ['A'] and ['B'] respectively. Many
VIEWS ON THIS POST

80

Posted on:

Sunday 25th November 2012
View Replies!

wxPython listctrl

I was wondering if there is a way to extract an icon from a file (executable) and then add it in a listctrl. I also 'd like to know if i can shorten the icon in order to fit in ...
VIEWS ON THIS POST

40

Posted on:

Sunday 25th November 2012
View Replies!

Re: Why does python behave so? (removing list items)

On Wed, 2008-03-26 at 23:04 +0100, Micha\t Bentkowski wrote: > Why does python create a reference here, not just copy the variable Python, like most other oo languages, will always make references for =, unless you work on native types ...
VIEWS ON THIS POST

117

Posted on:

Sunday 25th November 2012
View Replies!

Why does python behave so? (removing list items)

Why does python create a reference here, not just copy the variable >>> j=range(0,6) >>> k=j >>> del j[0] >>> j [1, 2, 3, 4, 5] >>> k [1, 2, 3, 4, 5] Shouldn't k remain the same -- Micha ...
VIEWS ON THIS POST

96

Posted on:

Sunday 25th November 2012
View Replies!

lists v. tuples

What are the considerations in choosing between: return [a, b, c] and return (a, b, c) # or return a, b, c Why is the immutable form the default...
VIEWS ON THIS POST

47

Posted on:

Sunday 25th November 2012
View Replies!

changing names of items in a list

hi i am trying to rename extension of files in a directory..as an initial step i made a method in class ConvertFiles: def __init__(self,infldr,outfldr): self.infldr=infldr self.outfldr=outfldr self.origlist=os.listdir(infldr) ..... def renamefiles(self,extn): for x in self.origlist: x=x+"."+extn .... later when i print ...
VIEWS ON THIS POST

46

Posted on:

Sunday 25th November 2012
View Replies!

comparing two lists, ndiff performance

Hi all. I'm working on a tool for localizers. I have two Lists with Entities/Strings/Comments (each L10n file is built of those three elements). So I have sth like: l10nObject = [] l10nObject.append(Comment('foo')) l10nObject.append("string") l10nObject.append(Entity('name', 'value')) etc. I can have ...
VIEWS ON THIS POST

34

Posted on:

Sunday 25th November 2012
View Replies!

Converting a bidimensional list in a bidimensional array

Hi First of all, I must apologize for my poor english I'm starting with python and pygame and for testing (and learning) purposes I wrote an small "Map Editor" for a small game project I'm going to start next month. ...
VIEWS ON THIS POST

31

Posted on:

Sunday 25th November 2012
View Replies!

list property fires get on append

I've created a class that has a property which points at a private list. When I try to use the append() function on this list property, the fget method is fired rather than the fset method. If I directly set ...
VIEWS ON THIS POST

63

Posted on:

Monday 26th November 2012
View Replies!

list in a tuple

Recently, I got into a debate on programming.reddit.com about what should happen in the following case: >>> a = ([1], 2) >>> a[0] += [3] Currently, Python raises an error *and* changes the first element of the tuple. Now, this ...
VIEWS ON THIS POST

31

Posted on:

Monday 26th November 2012
View Replies!

Re: arrays in lists

Rafael Sachetto wrote: > No problem here too. > Using python 2.5 on Ubuntu Gutsy and the newest NumPy Okay, I just checked with Travis and we do allow 1-element arrays to have a truth value because it is unambiguous ...
VIEWS ON THIS POST

49

Posted on:

Monday 26th November 2012
View Replies!

Writing event handler for dropdown list in python

I am new to python, Can someone help me with writing event handler for a dropdown list in python. i have one function to create dropdown list in a file def dropdown_options(self,title,options,name,value = None): ret = "\n
VIEWS ON THIS POST

47

Posted on:

Monday 26th November 2012
View Replies!

simple question on persisting variable values in a list

I am an unabashed noob. I am trying to build a list to store values that are generated through a loop. However, every time I append the variable to the list, I'd like to reset the variable, but have ...
VIEWS ON THIS POST

34

Posted on:

Monday 26th November 2012
View Replies!

lists indexes - beginner

Every C I know, which predates C89, handles the offset automatically by multiplying by type size. Admittedly, I've only been using it since 1980.
VIEWS ON THIS POST

67

Posted on:

Tuesday 27th November 2012
View Replies!