Re: all possible combinations

2005-07-13 Thread Duncan Smith
rbt wrote: > On Wed, 2005-07-13 at 11:09 -0400, rbt wrote: > >>On Wed, 2005-07-13 at 10:21 -0400, rbt wrote: >> >>>Say I have a list that has 3 letters in it: >>> >>>['a', 'b', 'c'] >>> >>>I want to print all the possible 4 digit combinations of those 3 >>>letters: >>> >>>4^3 = 64 >>> >>> >>>a

Re: all possible combinations

2005-07-13 Thread Duncan Smith
Jack Diederich wrote: > On Wed, Jul 13, 2005 at 05:07:33PM +0100, Duncan Smith wrote: > >>rbt wrote: >> >>>On Wed, 2005-07-13 at 11:09 -0400, rbt wrote: >>> >>> >>>>On Wed, 2005-07-13 at 10:21 -0400, rbt wrote: >>>> >>&

Re: How would you program this?

2005-03-03 Thread Duncan Smith
"engsol" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > There is a number puzzle which appears in the daily paper. > Because I'm between Python projects, I thought it might be > fun to write a program to solve it20 minute job, max. > > On closer inspection, it became apparent th

Re: Optimizing list processing

2013-12-11 Thread duncan smith
On 11/12/13 23:54, Steven D'Aprano wrote: I have some code which produces a list from an iterable using at least one temporary list, using a Decorate-Sort-Undecorate idiom. The algorithm looks something like this (simplified): table = sorted([(x, i) for i,x in enumerate(iterable)]) table = [i fo

Re: numpy.where() and multiple comparisons

2014-01-17 Thread duncan smith
On 18/01/14 01:51, John Ladasky wrote: Hi folks, I am awaiting my approval to join the numpy-discussion mailing list, at scipy.org. I realize that would be the best place to ask my question. However, numpy is so widely used, I figure that someone here would be able to help. I like to use n

counting unique numpy subarrays

2015-12-04 Thread duncan smith
Hello, I'm trying to find a computationally efficient way of identifying unique subarrays, counting them and returning an array containing only the unique subarrays and a corresponding 1D array of counts. The following code works, but is a bit slow. ### from collections import C

Re: counting unique numpy subarrays

2015-12-04 Thread duncan smith
On 04/12/15 22:36, Albert-Jan Roskam wrote: > Hi > > (Sorry for topposting) > > numpy.ravel is faster than numpy.flatten (no copy) > numpy.empty is faster than numpy.zeros > numpy.fromiter might be useful to avoid the loop (just a hunch) > > Albert-Jan > Thanks, I'd forgotten the difference be

Re: counting unique numpy subarrays

2015-12-04 Thread duncan smith
On 04/12/15 23:06, Peter Otten wrote: > duncan smith wrote: > >> Hello, >> I'm trying to find a computationally efficient way of identifying >> unique subarrays, counting them and returning an array containing only >> the unique subarrays and a co

Re: Catogorising strings into random versus non-random

2015-12-21 Thread duncan smith
On 21/12/15 03:01, Steven D'Aprano wrote: > I have a large number of strings (originally file names) which tend to fall > into two groups. Some are human-meaningful, but not necessarily dictionary > words e.g.: > > > baby lions at play > saturday_morning12 > Fukushima > ImpossibleFork > > > (no

Re: Catogorising strings into random versus non-random

2015-12-21 Thread duncan smith
On 21/12/15 16:49, Ian Kelly wrote: > On Mon, Dec 21, 2015 at 9:40 AM, duncan smith wrote: >> Finite state machine / transition matrix. Learn from some English text >> source. Then process your strings by lower casing, replacing underscores >> with spaces, removing trailing n

rdflib subclass problem

2016-03-01 Thread duncan smith
Hello, I'm just getting to grips with RDF and rdflib, and I've hit something I can't figure out. I have a graph with information on two people. (I haven't shown the imports below because they're scattered around my interactive session and I might reconstruct them incorrectly. Anyone familiar

Re: rdflib subclass problem

2016-03-02 Thread duncan smith
On 02/03/16 08:16, dieter wrote: > duncan smith writes: > >> I'm just getting to grips with RDF and rdflib, and I've hit >> something I can't figure out. >> >> I have a graph with information on two people. (I haven't shown the &g

__index__

2014-11-01 Thread duncan smith
Hello, I have a Bloom filter class and want to (partially) serialize instances using hex() or oct(). Instances are mutable, so I can't inherit from long. I thought I'd found the answer when I came across __index__, https://docs.python.org/2/reference/datamodel.html#object.__index__. But it do

Re: __index__

2014-11-01 Thread duncan smith
On 01/11/14 16:56, duncan smith wrote: [snip] Sorry, forgot to add that I'm using Python 2.7.6 on Ubuntu 14.04. Cheers. Duncan -- https://mail.python.org/mailman/listinfo/python-list

Re: __index__

2014-11-01 Thread duncan smith
On 01/11/14 18:29, Ethan Furman wrote: > On 11/01/2014 10:11 AM, Ned Batchelder wrote: >> On 11/1/14 12:56 PM, duncan smith wrote: >>> >>>I have a Bloom filter class and want to (partially) serialize >>> instances using hex() or oct(). Instances are

Re: Using Python for date calculations

2014-11-21 Thread duncan smith
On 21/11/14 08:35, Steve Hayes wrote: > I've finally found a use for Python. > > When, in the course of my genealogy research, I look at census or burial > records, I often want to work out a person's date of birth from their age. > It's a simple matter of mental arithmetic, but I sometimes get i

Re: Algorithm for Creating Supersets of Smaller Sets Based on Common Elements

2015-02-22 Thread duncan smith
On 21/02/15 19:46, TommyVee wrote: > Start off with sets of elements as follows: > > 1. A,B,E,F > 2. G,H,L,P,Q > 3. C,D,E,F > 4. E,X,Z > 5. L,M,R > 6. O,M,Y > > Note that sets 1, 3 and 4 all have the element 'E' in common, therefore > they are "related" and form the following superset: > > A,B,C

Re: random.sample with large weighted sample-sets?

2014-02-16 Thread duncan smith
On 16/02/14 05:08, Ben Finney wrote: Tim Chase writes: I'm not coming up with the right keywords to find what I'm hunting. I'd like to randomly sample a modestly compact list with weighted distributions, so I might have data = ( ("apple", 20), ("orange", 50), ("grape", 30),

Re: random.sample with large weighted sample-sets?

2014-02-16 Thread duncan smith
On 16/02/14 16:35, Charles Allen wrote: How efficient does this thing need to be? You can always just turn it into a two-dimensional sampling problem by thinking of the data as a function f(x=item), generating a random x=xr in [0,x], then generating a random y in [0,max(f(x))]. The xr is accept

Re: The possibility integration in Python without an equation, just an array-like file

2014-05-16 Thread duncan smith
On 16/05/14 13:57, Enlong Liu wrote: Sorry for this inconvenience. Since my file is a little large, I think it will be more difficult for fellows to check. I will now paste the attachment below. The file for T(E) consists of two columns, the first is E and the second is T(E). What I want is to

Re: The possibility integration in Python without an equation, just an array-like file

2014-05-16 Thread duncan smith
On 16/05/14 16:01, Johannes Schneider wrote: If you do not have a closed form for T(E) you cannot calculate the exact value of I(V). Anyway. Assuming T is integrable you can approximate I(V). 1. Way to do: interpolate T(E) by a polynomial P and integrate P. For this you need the equation (coeff

Re: PEP 450 Adding a statistics module to Python

2013-08-11 Thread duncan smith
On 11/08/13 15:02, Roy Smith wrote: In article , Skip Montanaro wrote: See the Rationale of PEP 450 for more reasons why “install NumPy� is not a feasible solution for many use cases, and why having ‘statistics’ as a pure-Python, standard-library package is desirable. I read that b

Re: many constructors in a class?

2013-08-14 Thread duncan smith
On 14/08/13 15:16, climb65 wrote: Hello, here is a small basic question : Is it possible to have more than one constructor (__init__ function) in a class? For instance, to create an object with 2 different ways? If my memory is good, I think that with C++ it is possible. Thanks for your answer

Re: Bug in floating point multiplication

2015-07-02 Thread duncan smith
On 02/07/15 15:52, Steven D'Aprano wrote: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version of > Python and your operating system. Printing sys.version will probably do. > >

Re: How to Calculate NPV?

2015-07-29 Thread duncan smith
On 29/07/15 15:27, ryguy7272 wrote: > On Wednesday, July 29, 2015 at 10:21:35 AM UTC-4, ryguy7272 wrote: >> On Wednesday, July 29, 2015 at 9:59:10 AM UTC-4, ryguy7272 wrote: >>> I am using Spyder Python 2.7. I'm running this sample code. >>> >>> import scipy as sp >>> cashflows=[50,40,20,10,50] >>

Re: Generating a vector from successive multiplications of another vector from an initial value

2015-10-01 Thread duncan smith
On 01/10/15 21:45, Paulo da Silva wrote: > Hi all. > > What is the fastest way to do the following: > > I have an initial value V and a vector vec of (financial) indexes. > I want to generate a new vector nvec as > > V, V*vec[0], V*vec[0]*vec[1], V*vec[0]*vec[1]*vec[2], ... > > A numpy vectoriz

Re: [OT] spelling colour / color was Re: Toggle

2014-10-09 Thread duncan smith
On 09/10/14 18:43, mm0fmf wrote: > On 09/10/2014 02:29, Steven D'Aprano wrote: >> Apart from the horrible spelling of colour :-) > > I've always spelt colour as "color" when programming and as "colour" > when writing language including documentation about software. > > colour in a programme doesn

Re: [OT] spelling colour / color was Re: Toggle

2014-10-11 Thread duncan smith
On 11/10/14 12:45, mm0fmf wrote: > On 11/10/2014 10:37, Christian Gollwitzer wrote: >> Being a non-native English speaker/writer, I myself stick to the >> recommendations of the Oxford dictionary. >> >> Christian > > But you do realise the Oxford dictionary is different to English usage > and

Re: [OT] spelling colour / color was Re: Toggle

2014-10-11 Thread duncan smith
On 11/10/14 20:55, William Ray Wing wrote: > On Oct 11, 2014, at 3:20 PM, Dennis Lee Bieber wrote: > >> On Sat, 11 Oct 2014 16:26:43 +0100, duncan smith >> declaimed the following: >> >> >>> The media have their own quirks when it comes to English. The B

Re: Graph editor

2011-10-14 Thread duncan smith
On 14/10/11 08:45, Libra wrote: Hi, I would like to build a simple graph editor, allowing me to add nodes and edges via the mouse, along with the possibility to edit it (delete/ move nodes and edges, double click on object to pop-up a form where I can insert object related info, and so forth) and

Re: Assign values from list to list of instances

2011-11-01 Thread duncan smith
On 01/11/11 15:05, Gnarlodious wrote: I want to assign a list of variables: locus=[-2, 21, -10, 2, 12, -11, 0, 3] updating a list of objects each value to its respective instance: for order in range(len(Orders)): Orders[order].locus=locus[order] This works, even though it reads like do

Re: Is there a graphical GUI builder?

2013-02-19 Thread duncan smith
On 19/02/13 22:19, Rex Macey wrote: I'm new to Python and only a hobbyist programmer. A long time ago I used Microsoft's Visual Basic which had a nice (graphical) facility for creating GUIs which was part of the development environment. I'm wondering if there's a utility for Python to build

Re: list comprehension misbehaving

2013-03-28 Thread duncan smith
On 28/03/13 15:25, Wolfgang Maier wrote: Dear all, with a=list(range(1,11)) why (in Python 2.7 and 3.3) is this explicit for loop working: for i in a[:-1]: a.pop() and a giving: [1, 2, 3, 4, 5, 6, 7, 8, 9] [1, 2, 3, 4, 5, 6, 7, 8] [1, 2, 3, 4, 5, 6, 7] [1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5] [1

Re: Red Black Tree implementation?

2013-05-01 Thread duncan smith
On 02/05/13 00:11, Dan Stromberg wrote: What's the best Red Black Tree implementation for Python with an opensource license? I started out looking at http://newcenturycomputers.net/projects/rbtree.html because it was pretty high in Google and had the operators I wanted, but it gets very slow at

Re: deal or no deal

2005-12-25 Thread Duncan Smith
Rocco Moretti wrote: > rbt wrote: > >> The TV show on NBC in the USA running this week during primetime (Deal >> or No Deal). I figure there are roughly 10, maybe 15 contestants. They >> pick a briefcase that has between 1 penny and 1 million bucks and then >> play this silly game where NBC tries

Re: deal or no deal

2005-12-28 Thread Duncan Smith
Chip Turner wrote: > On 2005-12-26 15:05:21 -0500, [EMAIL PROTECTED] said: > >> I believe not; the Monty Hall problem is biased by the fact that the >> presenter knows where the prize is, and eliminates one box accordingly. >> Where boxes are eliminated at random, it's impossible for any given >>

Re: Can't get around "IndexError: list index out of range"

2006-10-07 Thread Duncan Smith
MonkeeSage wrote: > On Oct 7, 12:37 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > >>for what? > > > key in self.keys() > [snip] No. The above constructs a list of keys and searches the list for the key, O(n). "key in somedict" is a lookup, O(1). Duncan -- http://mail.python.org/mailman

Re: Can't get around "IndexError: list index out of range"

2006-10-07 Thread Duncan Smith
MonkeeSage wrote: > > On Oct 7, 7:14 pm, Duncan Smith <[EMAIL PROTECTED]> wrote: > >>No. The above constructs a list of keys and searches the list for the >>key, O(n). "key in somedict" is a lookup, O(1). > > > My point wasn't in

Re: What's the best IDE?

2006-10-25 Thread Duncan Smith
[EMAIL PROTECTED] wrote: > After researching Komodo, I found it's not free. The only funds I have > are a college fund, and I can't start diping into that until I'm going > to college. Any free AND good IDEs? > http://wiki.python.org/moin/IntegratedDevelopmentEnvironments Duncan -- http://mail.

Re: itertools.count() as built-in

2006-05-29 Thread Duncan Smith
[EMAIL PROTECTED] wrote: > Zipping an xrange? I'm having trouble visualizing how you do that to > avoid x*i+y. > > -Janto > Something like, >>> lis = ['a', 'b', 'c', 'd'] >>> y = 3 >>> i = 7 >>> for n, item in zip(xrange(y, len(lis)*i+y, i), lis): print n, item 3 a 10 b 17 c

Re: after del list , when I use it again, prompt 'not defined'.how could i delete its element,but not itself?

2006-06-02 Thread Duncan Smith
python wrote: [snip] > > How could I keep the list1 not to change when remove list2's elements? > You can't when the names list1 and list2 refer to the same list. Try making list2 a copy of list1, list2 = list(list1) Duncan -- http://mail.python.org/mailman/listinfo/python-list

Re: Sampling a population

2006-06-02 Thread Duncan Smith
Brian Quinlan wrote: > This is less a Python question and more a optimization/probability > question. Imaging that you have a list of objects and there frequency in > a population e.g. > > lst = [(a, 0.01), (b, 0.05), (c, 0.50), (d, 0.30), (e, 0.04), (f, 0.10)] > > and you want to drawn n items f

Re: fonction in python

2006-07-04 Thread Duncan Smith
Steven D'Aprano wrote: > On Tue, 04 Jul 2006 03:06:37 -0700, aliassaf wrote: > > >>Hello, >> >>If we write = x^2 and if I give to the program the values of x, it will >>going to calculate the values of y, and also for x. >> >>But it is possible ? that is if I give to the program the values

Re: Poisson Distribution (for a newbie)

2006-02-15 Thread Duncan Smith
[EMAIL PROTECTED] wrote: > I am simulating an event where users come into the pool randomly > starting at time T=0, i.e. For Example, 2 users came at T= 0 into the > the pool, 3 users came at T= 1 into the the pool, 5 users came at T=2 > ,..,54 users came at T=45 etc. As cumulative number o

Re: skip next item in list

2007-06-11 Thread Duncan Smith
ahlongxp wrote: > list=('a','d','c','d') > for a in list: > if a=='a' : > #skip the letter affer 'a' > > what am I supposed to do? > Maybe, >>> it = iter(['a','d','c','d']) >>> for item in it: print item if item == 'a': x = it.next()

Re: Sorting dict keys

2007-07-20 Thread Duncan Smith
[EMAIL PROTECTED] wrote: > Consider the following: > a = {1:2, 3:4, 2:5} > > > Say that i want to get the keys of a, sorted. First thing I tried: > > b = a.keys().sort() print b > > None > > Doesn't work. Probably because I am actually trying to sort the keys > of the dictionary

numpy migration (also posted to numpy-discussion)

2007-04-23 Thread Duncan Smith
Hello, Since moving to numpy I've had a few problems with my existing code. It basically revolves around the numpy scalar types. e.g. >>> import Numeric as N >>> a = N.array([[0,1],[2,3]]) >>> a array([[0, 1], [2, 3]]) >>> i = a[0,0] >>

Re: numpy migration (also posted to numpy-discussion)

2007-04-23 Thread Duncan Smith
Travis E. Oliphant wrote: > Duncan Smith wrote: > >> Hello, >> Since moving to numpy I've had a few problems with my existing >> code. It basically revolves around the numpy scalar types. e.g. >> > > You will probably get more help on the num

Re: numpy migration (also posted to numpy-discussion)

2007-04-24 Thread Duncan Smith
Travis E. Oliphant wrote: > Duncan Smith wrote: > >> Hello, >> Since moving to numpy I've had a few problems with my existing >> code. It basically revolves around the numpy scalar types. e.g. >> > > You will probably get more help on the num

Re: Syntax Question - list multiplication

2007-08-19 Thread Duncan Smith
Roel Schroeven wrote: > Pablo Torres schreef: > >> Hi guys! >> >> I am working on Conway's Game of Life right now and I've run into a >> little problem. >> I represent dead cells with 0s and live ones with 1s. Check this out: >> >> >>> grid = [[0] * 3] * 3 >> >>> grid >> [[0, 0, 0], [0

Re: confused about why i get a type error when i call an object's method

2007-08-21 Thread Duncan Smith
[EMAIL PROTECTED] wrote: > I'm confused about why i get a type error when i call an object's > method. Here's the example code: > class Foo: > > def __init__(self): > self.foo = [] > def foo(self): > print "in foo!" > > > f = Foo() dir(f) >

Re: Problem with extremely small real number

2007-09-03 Thread Duncan Smith
Andrea wrote: > Hi, > I need to calculate this probability P!/{n \choose p}, varying both n > and p, n takes values in this range [512:1024] and p in [2:12]. > So i write this code in python: > > def factorial(n): > result=1 > if n==0: return 1 > for i in xrange(1, abs(n)+1): >

Re: number generator

2007-03-13 Thread Duncan Smith
Hendrik van Rooyen wrote: > "Nick Craig-Wood" <[EMAIL PROTECTED]> wrote: > > >>Paul Rubin wrote: >> >>> The fencepost method still seems to be simplest: >>> >>> t = sorted(random.sample(xrange(1,50), 4)) >>> print [(j-i) for i,j in zip([0]+t, t+[50])] >> >>Mmm, nice. >> >>Here is anothe

Re: number generator

2007-03-13 Thread Duncan Smith
greg wrote: > Gabriel Genellina wrote: > >> The 5th number is not "random". > > > More precisely, the fifth number is not *independent* > of the others. You can't have five independent random > numbers that sum to 50; only four independent numbers > plus a dependent one. > > -- > Greg In the

Re: number generator

2007-03-14 Thread Duncan Smith
Duncan Smith wrote: > greg wrote: > >>Gabriel Genellina wrote: >> >> >>>The 5th number is not "random". >> >> >>More precisely, the fifth number is not *independent* >>of the others. You can't have five independent random &g

Re: number generator

2007-03-14 Thread Duncan Smith
Hendrik van Rooyen wrote: > "Duncan Smith" <[EMAIL PROTECTED]> wrote: > > > >>Yes, if the generating processes yield numbers from different >>probability mass functions. You could simply look at the likelihood >>ratio. Otherwise, the likelihood

reverse engineering Excel spreadsheet

2007-04-01 Thread Duncan Smith
Hello, I am currently implementing (mainly in Python) 'models' that come to me as Excel spreadsheets, with little additional information. I am expected to use these models in a web application. Some contain many worksheets and various macros. What I'd like to do is extract the data and busi

Re: reverse engineering Excel spreadsheet

2007-04-01 Thread Duncan Smith
John Machin wrote: > On Apr 2, 1:59 am, Duncan Smith <[EMAIL PROTECTED]> wrote: > >>Hello, >> I am currently implementing (mainly in Python) 'models' that come >>to me as Excel spreadsheets, with little additional information. I am >>expected t

Re: writing to lists within a dictionary

2007-09-20 Thread Duncan Smith
[EMAIL PROTECTED] wrote: > I am trying to write a basic anagram system, that takes a text file > line by line and by sorting the string into its alphabetical form > compares it to keys within a dictionary. > > If it matches a key I want to add it (in its unordered form) to a list > for that key. >

Re: Using arrays in Python - problems.

2007-10-23 Thread Duncan Smith
[EMAIL PROTECTED] wrote: > attackwarningred napisa (a): > > >>The array F(n) is dynamically allocated earlier on and is sized with >>reference to shotcount, the number of iterations the model performs. The >>problem is I can't get something like this to run in Python using numpy, >>and for the si

Python web app. (advice sought)

2007-01-14 Thread Duncan Smith
Hello, I find myself in the, for me, unusual (and at the moment unique) position of having to write a web application. I have quite a lot of existing Python code that will form part of the business logic. This relies on 3rd party libraries (such as numpy) which would make porting to e.g. Iro

Re: Python web app. (advice sought)

2007-01-15 Thread Duncan Smith
Thanks all. It's looking like Turbogears at the moment (unless my boss makes an executive decision). Cheers. Duncan -- http://mail.python.org/mailman/listinfo/python-list

set update in 2.5

2007-01-27 Thread Duncan Smith
Hello, In moving from 2.4 to 2.5 I find that some of my unit tests are now failing. I've worked out that the problem relates to the set update method. In 2.4 I could update a set with an iterable type derived from dict as the argument. I now find that the set is updated with the hash values

Re: set update in 2.5

2007-01-29 Thread Duncan Smith
Peter Otten wrote: > Duncan Smith wrote: > > >> In moving from 2.4 to 2.5 I find that some of my unit tests are now >>failing. I've worked out that the problem relates to the set update >>method. In 2.4 I could update a set with an iterable type derived fro

Re: Generating pdf files in epydoc on Windows

2007-02-11 Thread Duncan Smith
Don Taylor wrote: > Does anyone know what is needed to install to get epydoc to generate pdf > files on Windows. Besides epydoc itself of course. > > Maybe there is a more appropriate forum to ask newbie questions about > epydoc? > As I remember, LaTeX and ghostscript. Duncan -- http://mail.p

Re: What is the best queue implemetation in Python?

2007-02-22 Thread Duncan Smith
John wrote: > I want to write a code for Breadth First Traveral for Graph, which needs a > queue to implement. > > I wonder that for such a powerful language as Python, whether there is a > better and simpler implementation for a traditional FIFO queue? > For a BFS I coded up a while back iterat

Re: implement random selection in Python

2007-11-16 Thread duncan smith
Bruza wrote: > I need to implement a "random selection" algorithm which takes a list > of [(obj, prob),...] as input. Each of the (obj, prob) represents how > likely an object, "obj", should be selected based on its probability > of > "prob".To simplify the problem, assuming "prob" are integers, an

Re: implement random selection in Python

2007-11-16 Thread duncan smith
Bruza wrote: > On Nov 16, 4:47 pm, Bruza <[EMAIL PROTECTED]> wrote: >> On Nov 16, 6:58 am, duncan smith <[EMAIL PROTECTED]> >> wrote: >> >> >> >>> Bruza wrote: >>>> I need to implement a "random selection" algorithm w

Re: Python keywords vs. English grammar

2006-05-24 Thread Duncan Smith
Roy Smith wrote: > I noticed something interesting today. In C++, you write: > > try { >throw foo; > } catch { > } > > and all three keywords are verbs, so when you describe the code, you can > use the same English words as in the program source, "You try to execute > some code, but it thr

Re: how to clear up a List in python?

2006-05-26 Thread Duncan Smith
[EMAIL PROTECTED] wrote: > The original post only mentions deleting the values in the list, not > the list itself. Given that you want to keep the list and just ditch > the values it contains I'd go with: > > list1 = [] > > -Linnorm > Which rebinds list1 to a new (empty) list. It doesn't clea

Re: OLAP and pivot tables

2006-05-26 Thread Duncan Smith
George Sakkis wrote: > After a brief search, I didn't find any python package related to OLAP > and pivot tables. Did I miss anything ? To be more precise, I'm not so > interested in a full-blown OLAP server with an RDBMS backend, but > rather a pythonic API for constructing datacubes in memory, sl

Re: how to clear up a List in python?

2006-05-26 Thread Duncan Smith
chris brat wrote: > Doesnt this do what the original poster is try accomplish? > Not what the OP asked for, no. Clearing a list implies that list1 should still be bound to the same list (which might be important if there are other names bound to the same list). If it wasn't important that it be

Re: TopSort in Python?

2008-01-19 Thread duncan smith
Carl Banks wrote: > On Jan 18, 7:01 pm, Paddy <[EMAIL PROTECTED]> wrote: >> On Jan 18, 9:47 pm, [EMAIL PROTECTED] wrote:> Tim, >> >>> Thanks for the topsort code. It would be useful in a project I'm >>> working on. Can I use the code for free under public domain? Thanks! >> When I needed one I d

Re: List as FIFO in for loop

2008-03-08 Thread duncan smith
malkarouri wrote: > Hi everyone, > > I have an algorithm in which I need to use a loop over a queue on > which I push values within the loop, sort of: > > while not(q.empty()): > x = q.get() > #process x to get zero or more y's > #for each y: > q.put(y) > > The easiest thing I ca

Re: Sorting a list

2008-10-28 Thread duncan smith
RC wrote: > unsortedList = list(["XYZ","ABC"]) > > sortedList = unsortedList.sort() > print sortedList > > > Why this return None? Because the sort method sorts the list in place (and returns None). > How do I get return as ["ABC", "XYZ"]? >>> unsortedList = ["XYZ","ABC"] >>> unsortedList.sor

Re: Misuse of list comprehensions?

2008-05-23 Thread duncan smith
Simon Forman wrote: On May 21, 4:36 am, Bruno Desthuilliers wrote: Simon Forman a écrit : On May 20, 8:58 am, Paul McGuire <[EMAIL PROTECTED]> wrote: On May 20, 10:50 am, [EMAIL PROTECTED] wrote: You don't need all those conditionals. A set differs from a list precisely in the fact that e

Re: boolian logic

2008-06-13 Thread duncan smith
marc wyburn wrote: HI all, I'm a bit stuck with how to work out boolian logic. I'd like to say if A is not equal to B, C or D: do something. I've tried if not var == A or B or C: and various permutations but can't seem to get my head around it. I'm pretty sure I need to know what is calula

Re: Multiprecision arithmetic library question.

2008-06-19 Thread duncan smith
Michael Press wrote: In article <[EMAIL PROTECTED]>, Mark Wooding <[EMAIL PROTECTED]> wrote: Michael Press <[EMAIL PROTECTED]> wrote: I already compiled and installed the GNU multiprecision library on Mac OS X, and link to it in C programs. How do I link to the library from Python? You kn

Re: Preferred method for "Assignment by value"

2008-04-15 Thread duncan smith
[EMAIL PROTECTED] wrote: > Thank you both, the assigning using slicing works perfectly (as I'm > sure you knew it would)... It just didn't occur to me because it > seemed a little nonintuitive... The specific application was > > def dicttolist (inputdict): > finallist=[] > for k, v in inpu

Re: Most pythonic way of weighted random selection

2008-08-30 Thread duncan smith
Manuel Ebert wrote: > Dear list, > > who's got aesthetic advice for the following problem? I've got some > joint probabilities of two distinct events Pr(X=x, Y=y), stored in a > list of lists of floats, where every row represents a possible outcome > of X and every float in a row a possible outcom

Re: style guideline for naming variables?

2006-03-17 Thread Duncan Smith
John Salerno wrote: > After reading the PEP, I'm still not quite sure if there is a > recommended (or widely preferred) method of naming variables. Here are > the relevant bits: > >> Global Variable Names >> >> (Let's hope that these variables are meant for use inside one >> module >>

Re: tips for this exercise?

2006-03-28 Thread Duncan Smith
John Salerno wrote: > I'm working on another exercise now about generating random numbers for > the lottery. What I want to do is write a function that picks 5 random > numbers from 1-53 and returns them. Here's what I have so far: > > numbers = range(1, 54) > > def genNumbers(): > for x in r

Re: Programming Tutorial for absolute beginners

2006-04-08 Thread Duncan Smith
James wrote: > Perhaps use the phrase "whole number" there and mention that in > programming they're called integers. Having a glossary with > definitions for things like integer, float etc etc. would be good if > when you talked about integers it linked to the glossary. And > similarly use "decima

Re: Programming Tutorial for absolute beginners

2006-04-08 Thread Duncan Smith
Clodoaldo Pinto wrote: > Duncan Smith wrote: > >>James wrote: >> >>>Perhaps use the phrase "whole number" there and mention that in >>>programming they're called integers. Having a glossary with >>>definitions for things like integ

Re: list.clear() missing?!?

2006-04-11 Thread Duncan Smith
John Salerno wrote: > Steven Bethard wrote: > > >> lst[:] = [] >> lst = [] > > > What's the difference here? >>> lst = [1,2,3] >>> lst2 = lst >>> lst[:] = [] >>> lst2 [] >>> lst = [1,2,3] >>> lst2 = lst >>> lst = [] >>> lst2 [1, 2, 3] >>> Duncan -- http://mail.python.org/mailman/list

max / min / smallest float value on Python 2.5

2010-02-06 Thread duncan smith
Hello, I'm trying to find a clean and reliable way of uncovering information about 'extremal' values for floats on versions of Python earlier than 2.6 (just 2.5 actually). I don't want to add a dependence on 3rd party modules just for this purpose. e.g. For the smallest positive float

Re: max / min / smallest float value on Python 2.5

2010-02-06 Thread duncan smith
Christian Heimes wrote: duncan smith wrote: Hello, I'm trying to find a clean and reliable way of uncovering information about 'extremal' values for floats on versions of Python earlier than 2.6 (just 2.5 actually). I don't want to add a dependence on 3rd party m

Re: max / min / smallest float value on Python 2.5

2010-02-07 Thread duncan smith
Steven D'Aprano wrote: On Sun, 07 Feb 2010 03:02:05 +0000, duncan smith wrote: The precise issue is that I'm supplying a default value of 2.2250738585072014e-308 for a parameter (finishing temperature for a simulated annealing algorithm) in an application. I develop on Ubuntu64,

Re: Help (I can't think of a better title)

2010-05-23 Thread duncan smith
Alex Hall wrote: On 5/22/10, MRAB wrote: Lanny wrote: The answer may be right infront of me but I really can't figure this out. I'm trying to build a interactive fiction kind of game, silly I know but I am a fan of the genre. I'm trying to build up an index of all the rooms in the game from an

Re: Pick items from list with probability based upon property of list member ?

2010-06-20 Thread duncan smith
southof40 wrote: I have list of of N Vehicle objects - the only possible vehicles are cars, bikes, trucks. I want to select an object from the list with a probability of : cars 0.7, bikes 0.3, trucks 0.1. I've currently implemented this by creating another list in which each car object from the

Re: Pick items from list with probability based upon property of list member ?

2010-06-20 Thread duncan smith
duncan smith wrote: southof40 wrote: I have list of of N Vehicle objects - the only possible vehicles are cars, bikes, trucks. I want to select an object from the list with a probability of : cars 0.7, bikes 0.3, trucks 0.1. I've currently implemented this by creating another list in

Re: Find slope of function given empirical data.

2010-06-29 Thread duncan smith
Thomas wrote: Hello all. Trying to find slope of function using numpy. Getting close, but results are a bit off. Hope someone out here can help. [snip] Why are you generating y-coordinates from the x-coordinates [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4]? If you're going to use the x-coordina

IDLE / Python 2.5 under Jaunty

2009-06-23 Thread duncan smith
A little off-topic perhaps, but I can't think of anywhere more likely to contain people with answers. I've just upgraded to Jaunty Jackalope where Python 2.6 is the default Python version. I'm still developing under 2.5, but IDLE now refuses to respond to left click events (for code editing, menu

Re: IDLE / Python 2.5 under Jaunty

2009-06-24 Thread duncan smith
Michiel Overtoom wrote: > > Duncan Smith wrote: > >> IDLE now refuses to >> respond to left click events (for code editing, menus etc. respond as >> expected). If I right click, then left click I can move the cursor, but >> that's not ideal. >> >

Re: Is Psyco good for Python 2.6.1?

2009-07-03 Thread duncan smith
Russ P. wrote: > I need to speed up some Python code, and I discovered Psyco. However, > the Psyco web page has not been updated since December 2007. Before I > go to the trouble of installing it, does anyone know if it is still > good for Python 2.6.1? Thanks. If you look at http://psyco.sourcefo

Re: Very simple finite automaton (?)

2009-09-23 Thread duncan smith
kpp9c wrote: > Very simple finite automaton (?) > > I am not sure if this is and example of Finite Automaton or a Finite > State Machine or perhaps it is related to a transition table or markov > process. I am not a math person so i am not sure what it is called. I > googled around and got lots of

Re: Create ordering of points

2017-02-15 Thread duncan smith
On 15/02/17 13:27, spiess.benja...@googlemail.com wrote: > Hello !:) > I've got a problem which I would really like to solve. > I got a cloud of points (in the simplest example its a 2-dimensional cloud of > points). > First, I want to set one of the points as the initial (or middle) point. > S

Re: Surprised by the lack of constant folding

2017-03-24 Thread duncan smith
On 24/03/17 19:35, Tim Chase wrote: > Playing around, I came across the following > > $ python3 > Python 3.4.2 (default, Oct 8 2014, 10:45:20) > [GCC 4.9.1] on linux > Type "help", "copyright", "credits" or "license" for more information. from dis import dis def f(x): > ... return

table class - inheritance, delegation?

2017-03-31 Thread duncan smith
Hello, I need to code up a table class, which will be based on numpy arrays. Essentially it needs to behave like a numpy array, but with a variable associated with each array dimension. It must (at least partially) satisfy the API of an existing class. The main reason for the new class is to

Re: Printing dict value for possibly undefined key

2023-11-25 Thread duncan smith via Python-list
On 24/11/2023 14:31, Loris Bennett wrote: Hi, I want to print some records from a database table where one of the fields contains a JSON string which is read into a dict. I am doing something like print(f"{id} {d['foo']} {d['bar']}") However, the dict does not always have the same keys, so

<    1   2   3   >