synchronized enumerate

2005-12-19 Thread smichr
I see that there is a thread of a similar topic that was posted recently ( enumerate with a start index ) but thought I would start a new thread since what I am suggesting is a little different. I posted a very similar item to python-dev, but they said to post it here. Tutor also said that if any

step argument for count

2005-12-19 Thread smichr
Does anyone know why a step argument was left off of count? There must be something that I am missing in why this is the case. For example, I read that the negative start and step were left off of islice because iterables can be of "infinite length" so you won't know apriori where the end is. But h

Re: How to get the type of an object?

2005-12-21 Thread smichr
You can use the type() function: ### >>> s='hello' >>> type(s) >>> type(s)==str True >>> n=1 >>> type(n) >>> type(n)==int True ### You can do the same with list, too. So you could write, if type(x)==list: #do list action /c -- http://mail.python.org/mailman/listinfo/python-list

indentation preservation/restoration

2006-01-02 Thread smichr
I have (inadvertently) wiped out the functionality of my personal python snippets by eliminating leading space. I have also just visited http://www.python.org/tim_one/000419.html and saw a piece of code with the indentation gone. Python code is fragile in this regard. One solution that occurs to me

Re: indentation preservation/restoration

2006-01-02 Thread smichr
Steven D'Aprano wrote: > With a little bit of work, this could be expanded to add redundancy for > not just indentation and numeric literals, but also string literals, > keywords, operators, and anything else. When I copy and assign to variable 'post' the reply posted here on c.l.p. starting with

Re: indentation preservation/restoration

2006-01-03 Thread smichr
I can't believe I forgot that trick :-| Thanks for the helpful reminder. /c -- http://mail.python.org/mailman/listinfo/python-list

slice's indices() method

2006-10-30 Thread smichr
It seems to me that the indices() method for slices is could be improved. Right now it gives back concrete indices for a range of length n. That is, it does not return any None values. Using an example from clpy about this the indices for a 'None, None, -2' slice for a range of length 10 are given

Re: slice's indices() method

2006-10-30 Thread smichr
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > Is there any reason not to change the behavior of the indices() method > > so it gives indices that can be used in range (to give indices > > corresponding to elements that would be extracted by a given slice) > > *and* used as arguments for sl

Re: Modifying the value of a float-like object

2009-04-30 Thread smichr
On Apr 18, 4:21 pm, eric.le.bi...@spectro.jussieu.fr wrote: > On Apr 15, 5:33 pm, Arnaud Delobelle wrote: > > I adjusted your code in a few ways, and put the result > athttp://code.activestate.com/recipes/576721/(with due credit): > > 1) There was a strange behavior, which is fixed (by performing

Re: Modifying the value of a float-like object

2009-05-01 Thread smichr
On May 1, 11:13 am, smichr wrote: > Also, this approach is limited in that only variables can be arguments > to functions, not node expressions. If x and d are variables, x/d > becomes an expression and you cannot compute sin(x/d). Or am I missing > something? > Note to self