Re: Efficiently Split A List of Tuples

2005-07-18 Thread Ron Adam
Raymond Hettinger wrote: > [Ron Adam] > >>Currently we can implicitly unpack a tuple or list by using an >>assignment. How is that any different than passing arguments to a >>function? Does it use a different mechanism? > > > It is the same mechanism, so it

Re: Ordering Products

2005-07-18 Thread Ron Adam
Kay Schluehr wrote: > > Ron Adam wrote: > >>Kay Schluehr wrote: >>On a more general note, I think a constrained sort algorithm is a good >>idea and may have more general uses as well. >> >>Something I was thinking of is a sort where instead of giving a

Re: Efficiently Split A List of Tuples

2005-07-17 Thread Ron Adam
',) # trailing comma is needed here. # This is an error opportunity IMO Choice of symbols aside, packing and unpacking are a very big part of Python, it just seems (to me) like having an explicit way to express it might be a good thing. It doesn't do anything that can't already be done, of course. I think it might make some code easier to read, and possibly avoid some errors. Would there be any (other) advantages to it beside the syntax sugar? Is it a horrible idea for some unknown reason I'm not seeing. (Other than the symbol choices breaking current code. Maybe other symbols would work just as well?) Regards, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Ordering Products

2005-07-17 Thread Ron Adam
Overall it's about 10 times slower than pythons built in sort for large lists, but that's better than expected considering it's written in python and not C. Cheers, Ron # Quick Sort def qsort(x): if len(x)<2: return x# Nothing to sort.

Re: extend for loop syntax with if expr like listcomp&genexp ?

2005-07-11 Thread Ron Adam
: yell_for_help() else: leave() else: leave() Interesting idea, but I think it might make reading other peoples code more difficult. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: decorators as generalized pre-binding hooks

2005-07-10 Thread Ron Adam
Bengt Richter wrote: > On Sun, 10 Jul 2005 05:35:01 GMT, Ron Adam <[EMAIL PROTECTED]> wrote: >>So far they are fairly equivalent. So there's not really any advantage >>over the equivalent inline function. But I think I see what you are >>going towards. Decora

Re: Should I use "if" or "try" (as a matter of speed)?

2005-07-10 Thread Ron Adam
mputers, some of them may be fairly old. It might be worth slowing your computer down and then optimizing the parts that need it. When it's run on faster computers, those optimizations would be a bonus. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Use cases for del

2005-07-10 Thread Ron Adam
Reinhold Birkenfeld wrote: > Ron Adam wrote: > > >>>>>> 'abc' is 'abcd'[:3] >>>False >> >>Well of course it will be false... your testing two different strings! >>And the resulting slice creates a third. >&g

Re: decorators as generalized pre-binding hooks

2005-07-09 Thread Ron Adam
concepts that have been floating around into one tool. I like the place holders because I think they make the code much more explicit and they are more flexible because you can put them where you need them. > orthogonal-musing-ly ;-) "Orthogonal is an unusual computer language in which your program flow can go sideways. In actuality in can go in just about any direction you could want." http://www.muppetlabs.com/~breadbox/orth/ ;-) Cheers, Ron > Regards, > Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list

Re: Use cases for del

2005-07-09 Thread Ron Adam
Scott David Daniels wrote: > Ron Adam wrote: > >> George Sakkis wrote: >> >>> I get: >>> >>> None: 0.54952316 >>> String: 0.498000144958 >>> is None: 0.45047684 >> >> >> >> What do yo get for "na

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Ron Adam
2,3] mylist(*"abc") -> ['a','b','c'] mylist(1,2,3) -> [1,2,3] mylist([1],[2]) -> [[1],[2]] mylist('hello','world') -> ['hello','world'] Works for me. ;-) I always thought list([1,2,3]) -> [1,2,3] was kind of silly. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Ron Adam
st() > > list('a','b','c') "abc".splitchrs() There's already a str.split() to create a list of words, and a str.splitline() to get a list of lines, so it would group related methods together. I don't thin adding sting methods to lists is a good idea. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Use cases for del

2005-07-08 Thread Ron Adam
r than "if True/ if False" expressions. But the actual different is so small as to be negligible. I'm just kind of curious why testing is objects isn't just as fast as testing is string? Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Use cases for del

2005-07-08 Thread Ron Adam
as a serious idea quite a while ago and said so in several posts. From two days ago... in this same thread ... I said. >>Yes, I agree using None as an alternative to delete currently is >>unacceptable. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Use cases for del

2005-07-07 Thread Ron Adam
Steven D'Aprano wrote: > Ron Adam wrote: >> def count_records(record_obj, start=0, end=len(record_obj)): > > > That would work really well, except that it doesn't work at all. Yep, and I have to stop trying to post on too little sleep. Ok, how about... ?

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-07 Thread Ron Adam
Erik Max Francis wrote: > Ron Adam wrote: > >> Well in my previous explanation I *mean* it to be empty parenthesis. >> >> Does that help? > > > Maybe it might be beneficial to learn a little more of the language > before proposing such wide-reaching

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-07 Thread Ron Adam
Erik Max Francis wrote: > Ron Adam wrote: > >> It's not an empty tuple, it's an empty parenthesis. Using tuples it >> would be. >> >> (a,) == (,) >> >> which would be the same as: >> >> (,) == (,) > > > &

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-07 Thread Ron Adam
[list_comp] is a nice distinction. Maybe a {dictionary_comp} would make it a complete set. ;-) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Use cases for del

2005-07-07 Thread Ron Adam
Steven D'Aprano wrote: > Ron Adam wrote: > >> Why would you want to use None as an integer value? >> >> If a value isn't established yet, then do you need the name defined? >> Wouldn't it be better to wait until you need the name then give it a >

Re: Use cases for del

2005-07-07 Thread Ron Adam
Grant Edwards wrote: > On 2005-07-07, Ron Adam <[EMAIL PROTECTED]> wrote: >>>>>>It would be a way to set an argument as being optional without >>>>>>actually assigning a value to it. >> >>So it would still work like you expect even tho

Re: Why anonymity? [was Re: map/filter/reduce/lambda opinions and background unscientific mini-survey]

2005-07-07 Thread Ron Adam
#x27;)) def func_x(x): return someother_func_x(x,'value') There's both nearly identical, but the def is understandable to beginners and advanced python programs. Cheers, Ron > Am I just weird? Aren't we all? ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-07 Thread Ron Adam
Reinhold Birkenfeld wrote: > Ron Adam wrote: > > >>Given the statement: >> >>a = None >> >>And the following are all true: >> >> a == None > > > Okay. > > >>(a) == (None) > > > Okay. > > >>(a) =

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Ron Adam
Mike Meyer wrote: > Ron Adam <[EMAIL PROTECTED]> writes: > >>So doing this would give an error for functions that require an argument. >> >> def foo(x): >> return x >> >> a = None >> b = foo(a)# error because a dissap

Re: Use cases for del

2005-07-06 Thread Ron Adam
Grant Edwards wrote: > On 2005-07-07, Ron Adam <[EMAIL PROTECTED]> wrote: > >>Grant Edwards wrote: >> >> >>>On 2005-07-06, Ron Adam <[EMAIL PROTECTED]> wrote: >>> >>> >>> >>>>It would be a way to set an argument

Re: flatten(), [was Re: map/filter/reduce/lambda opinions ...]

2005-07-06 Thread Ron Adam
d just barely winning out in the very deep catagory. But they're all respectable times so everyone wins. ;-) And here's the source code. Cheers, :-) Ron # --- import sys import time TIMERS = {"win32": time.clock} timer = TIMERS.get(sy

Re: Use cases for del

2005-07-06 Thread Ron Adam
Grant Edwards wrote: > On 2005-07-06, Ron Adam <[EMAIL PROTECTED]> wrote: > > >>It would be a way to set an argument as being optional without actually >>assigning a value to it. The conflict would be if there where a global >>with the name baz as well. Pro

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Ron Adam
Benji York wrote: > Ron Adam wrote: > >> "if extraargs:" would evaluate to "if None:", which would evaluate to >> "if:" which would give you an error. > > > In what way is "if None:" equivalent to "if:"? > -- >

Re: Use cases for del

2005-07-06 Thread Ron Adam
Reinhold Birkenfeld wrote: > Ron Adam wrote: > >>Ron Adam wrote: >> >> >>>And accessing an undefined name returned None instead of a NameError? >> >>I retract this. ;-) >> >>It's not a good idea. But assigning to None as a way

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Ron Adam
Stian Søiland wrote: > On 2005-07-06 16:33:47, Ron Adam wrote: > > >>*No more NamesError exceptions! >> print value >> >> None > > > So you could do lot's of funny things like: > > def my_fun(extra_args=None): >

Re: Use cases for del

2005-07-06 Thread Ron Adam
Ron Adam wrote: > And accessing an undefined name returned None instead of a NameError? I retract this. ;-) It's not a good idea. But assigning to None as a way to unbind a name may still be an option. -- http://mail.python.org/mailman/listinfo/python-list

Re: Avoiding NameError by defaulting to None

2005-07-06 Thread Ron Adam
Scott David Daniels wrote: > Ron Adam wrote: > >> Dan Sommers wrote: >> >>> Lots more hard-to-find errors from code like this: >>> filehandle = open( 'somefile' ) >>> do_something_with_an_open_file( file_handle ) >>> fil

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Ron Adam
# error 10 while undefined==None: Possible loop till defined behavior. Ok... and undefined var returning None is a bad idea, but using None to del names could still work. And (undefined==None) could be a special case for checking if a variable is defined. Otherwise using an undefined name should give an error as it currently does. Cheers, Ron > Regards, > Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Ron Adam
he reduce-lambda expressions are a lot harder to read than a properly named function. And a function will often work faster than the reduce-lambda version as well. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Use cases for del

2005-07-06 Thread Ron Adam
. $ cat mymodule2.py # define some temporary names a, b, c, d, e, f = 1, 2, 3, 4, 5, 6 # do some work result = a+b+c+d*e**f # delete the temp variables a = b = c = d = e = f = None# possibly unbind names This would work if None unbound names. > It is bad enough that from module import *

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Ron Adam
Dan Sommers wrote: > On Wed, 06 Jul 2005 14:33:47 GMT, > Ron Adam <[EMAIL PROTECTED]> wrote: > > >>Since this is a Python 3k item... What would be the consequence of >>making None the default value of an undefined name? And then assigning >>

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Ron Adam
: something = value *And of course one less keyword! Any drawbacks? Cheers, Ron PS... not much sleep last night, so this may not be well thought out. -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-05 Thread Ron Adam
Robert Kern wrote: > Dan Bishop wrote: > >> There's also the issue of having to rewrite old code. > > > It's Python 3000. You will have to rewrite old code regardless if reduce > stays. > And from what I understand Python 2.x will still be maintained and supported. It will probably be more

Re: map/filter/reduce/lambda opinions and background unscientificmini-survey

2005-07-05 Thread Ron Adam
d the 'orif' would act just like the 'elif'. Actually this is a completely differnt subject reguarding flow testing verses value testing. Else and also would be the coorisponding end pair, but it seemed nobody really liked that idea when I suggested it a while back. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientificmini-survey

2005-07-05 Thread Ron Adam
s let, they both begin with 'L', and then the colon should be read as return. So lambda x,y: x+y should be read as: let x,y return x+y I'm in the group that hadn't heard about lambda as a function before Python even after > twenty years of computer tech experience. I

Re: flatten(), [was Re: map/filter/reduce/lambda opinions and background unscientific mini-survey]

2005-07-05 Thread Ron Adam
Tom Anderson wrote: > > We really ought to do this benchmark with a bigger list as input - a few > thousand elements, at least. But that would mean writing a function to > generate random nested lists, and that would mean specifying parameters > for the geometry of its nestedness, and that wou

Re: flatten(), [was Re: map/filter/reduce/lambda opinions ...]

2005-07-05 Thread Ron Adam
> Ok... How about a non-recursive flatten in place? ;-) > > def flatten(seq): > i = 0 > while i!=len(seq): > while isinstance(seq[i],list): > seq.__setslice__(i,i+1,seq[i]) > i+=1 > return seq > > seq = [[1,2],[3],[],[4,[5,6]]] > print flatten(seq) > > I

flatten(), [was Re: map/filter/reduce/lambda opinions and background unscientific mini-survey]

2005-07-05 Thread Ron Adam
--- The results on Python 2.3.5: (maybe someone can try it on 2.4) recursive flatten: 23.6332723852 flatten in place-non recursive: 22.1817641628 recursive-no copies: 30.909762833 smallest recursive: 35.2678756658 non-recursive flatten in place without copies: 7.8551944451 A 300% improvement!!! This shows the value of avoiding copies, recursion, and extra function calls. Cheers, Ron Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-04 Thread Ron Adam
; > >>>>flatten(seq) > > [1, 2, 3, 4, 5, 6] > > > George > How about this for a non recursive flatten. def flatten(seq): s = [] while seq: while isinstance(seq[0],list): seq = seq[0]+seq[1:] s.append(seq.pop(0))

Re: Folding in vim

2005-07-03 Thread Ron Adam
Terry Hancock wrote: > On Saturday 02 July 2005 10:35 pm, Terry Hancock wrote: > >>I tried to load a couple of different scripts to >>automatically fold Python code in vim, but none of them >>seems to do a good job. >> >>I've tried: >>python_fold.vim by Jorrit Wiersma >>http://www.vim.org/sc

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-03 Thread Ron Adam
Erik Max Francis wrote: > Ron Adam wrote: > >> Each item needs to stand on it's own. It's a much stronger argument >> for removing something because something else fulfills it's need and >> is easier or faster to use than just saying we need x becaus

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-03 Thread Ron Adam
Steven D'Aprano wrote: > On Sun, 03 Jul 2005 19:31:02 +0000, Ron Adam wrote: > > >>First on removing reduce: >> >>1. There is no reason why reduce can't be put in a functional module > > > Don't disagree with that. > > >>or >

Re: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-03 Thread Ron Adam
Bengt Richter wrote: > What if parameter name syntax were expanded to allow dotted names as binding > targets in the local scope for the argument or default values? E.g., > > def foometh(self, self.x=0, self.y=0): pass > > would have the same effect as > > def foometh(self, self.y=0, se

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-03 Thread Ron Adam
Erik Max Francis wrote: > Ron Adam wrote: >> I'm just estimating, but I think that is the gist of adding those two >> in exchange for reduce. Not that they will replace all of reduce use >> cases, but that sum and product cover most situations and can be >> i

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-02 Thread Ron Adam
at sum and product cover most situations and can be implemented more efficiently than using reduce or a for loop to do the same thing. The other situations can easily be done using for loops, so it's really not much of a loss. Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Folding in vim

2005-07-02 Thread Ron Adam
ding more now that I've played with it a bit. I like Vim-Cream, but I still haven't gotten the script right for executing the current file in the shell. And a second script for executing the current file in the shell and capturing the output in a pane. I think some of it may be windows path conflicts. Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-02 Thread Ron Adam
'angle_proxies':None, 'dihedral_proxies':None, 'chirality_proxies':None, 'planarity_proxies':None, 'plain_pairs_radius':None } defaults.update(args) self.data = defaults # real code Regards, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-01 Thread Ron Adam
Terry Hancock wrote: > On Friday 01 July 2005 03:36 pm, Ron Adam wrote: > >>I find map too limiting, so won't miss it. I'm +0 on removing lambda >>only because I'm unsure that there's always a better alternative. > > > Seems like some new

custom Tkinter ListBox selectMode

2005-07-01 Thread Ron Provost
tion set after the built-in hander has had a chance to do its thing, but that seems like such a kludge to me. Any suggestions on how I can implement a custom selectMode? Thanks for your input. Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-01 Thread Ron Adam
lways a better alternative. So what would be a good example of a lambda that couldn't be replaced? Cheers, Ron BTW... I'm striving to be Pythonic. ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-30 Thread Ron Adam
expr from { 'a':expr0, 'b':expr1, 'c':expr3 } else: expr4 Reads nice, but can't put expressions in a dictionary or list without them being evaluated first, and the [] and {} look like block brackets which might raise a few complaints. Can't help thinking of what if's. ;-) Cheer's Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Boss wants me to program

2005-06-28 Thread Ron Adam
em if they have any used computers for sale. I was able to get a Dell Pentium 3 for $45 dollars last year for a second computer to put Linux on. I just asked him if he had any old computers for really cheep that booted, and that's what he found in the back. I just needed to add ram an

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-28 Thread Ron Adam
Mike Meyer wrote: > Riccardo Galli <[EMAIL PROTECTED]> writes: > > >>On Fri, 24 Jun 2005 09:00:04 -0500, D H wrote: >> >> Bo Peng wrote: >I need to pass a bunch of parameters conditionally. In C/C++, I can >do func(cond1?a:b,cond2?c:d,.) > >Is there an easier way

Re: Thoughts on Guido's ITC audio interview

2005-06-27 Thread Ron Adam
quot;name constraints" been discussed or considered previously? Regards, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Favorite non-python language trick?

2005-06-24 Thread Ron Adam
() will never have arguments as it's meant to reference it's variables as locals and probably will be replaced directly with names's byte code contents at compile time. Defer could be shortened to def I suppose, but I think defer would be clearer. Anyway, it's only a wish list item for now. Regards, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 343, second look

2005-06-22 Thread Ron Adam
Paul Rubin wrote: > Ron Adam <[EMAIL PROTECTED]> writes: > >>>A new statement is proposed with the syntax: >>>with EXPR as VAR: >>>BLOCK >>>Here, 'with' and 'as' are new keywords; EXPR is an arbitrar

PEP 343, second look

2005-06-22 Thread Ron Adam
f.close() with with_gen(opening, "testfile", "w") as f: f.write("test file") This seems (to me) to be an easier to understand alternative to the decorator version. The class could also be used as a base class for constructing other 'with' class's as well as the with_template decorator. Will this work or am I missing something? Any suggestions for a different (better) name for the with_gen function? Regards, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: getting an object name

2005-06-22 Thread Ron Adam
data_type(data): data.data_type() # don't need the name here data_type(list_a) # prints 'This is a data1 object' data_type(list_b) # prints 'This is a data2 object' You can also store a name with the list in a list if you don't want to use class's. alis

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-20 Thread Ron Adam
Ron Adam wrote: > You might be able to use a dictionary of tuples. > > call_obj = {(type_obj1,0):obj1a, > (type_obj1,0):obj1b, > (type_boj2,1):obj2a, > (type_obj2,1):obj2b, > etc... } > call_obj[(type_of_obj,order)]() &g

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-19 Thread Ron Adam
,0):obj1a, (type_obj1,0):obj1b, (type_boj2,1):obj2a, (type_obj2,1):obj2b, etc... } call_obj[(type_of_obj,order)]() Regards, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Loop until condition is true

2005-06-18 Thread Ron Adam
te or block But I doubt it would be significantly faster than an if statement with a break. So the only benefit I see is you don't have to use the break keyword, and the exit conditions will stand out in blocks with a lot of if statements in them. Regards, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: "also" to balance "else" ?

2005-06-15 Thread Ron Adam
Nicolas Fleury wrote: > Ron Adam wrote: > >> It occurred to me (a few weeks ago while trying to find the best way >> to form a if-elif-else block, that on a very general level, an 'also' >> statement might be useful. So I was wondering what others would thin

Re: "also" to balance "else" ?

2005-06-15 Thread Ron Adam
ink these are sufficiently explicit as to avoid being non-intuitive. The endloop might be generalized into a endblock or endsuite statement possibly. I'm not sure if that would have any uses's in the proposed "with" statements or not. (?) Regards, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: "also" to balance "else" ?

2005-06-15 Thread Ron Adam
Fredrik Lundh wrote: > Ron Adam wrote: > > >>So the (my) confusion comes from the tendency to look at it in terms of >>overall program flow rather than in terms of the specific conditional >>logic. >> >>In a for loop the normal, as in terminating normally

Re: "also" to balance "else" ?

2005-06-14 Thread Ron Adam
w load and return it. module = imp.load_module(modname, None, modname, \ ('', '', type)) return 0, module, { } # not found # return None None of these are big or dramatic changes of the sort that I couldn't live without. Finding examples in the library is more difficult than I expected, so while this seems like a good idea... I'm not convinced yet either. But that is why I posted is to find out what other thought. Regurds, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: "also" to balance "else" ?

2005-06-14 Thread Ron Adam
or counter behavior is when a break statement executes. Thus the 'else' block is the normal result, and the skipping the 'else' block becomes the abnormal counter behavior. So while the logic is consistent, the expected context is reversed. Why is e

Re: "also" to balance "else" ?

2005-06-13 Thread Ron Adam
Terry Hancock wrote: > On Monday 13 June 2005 11:09 pm, Ron Adam wrote: >>My suggestion is to use, also as the keyword to mean "on normal exit" >>'also' do this. > > > Unfortunately, "also" is also a bad keyword to use for this, IMHO. &

Re: "also" to balance "else" ?

2005-06-13 Thread Ron Adam
Andrew Dalke wrote: > Ron Adam wrote: > >>It occurred to me (a few weeks ago while trying to find the best way to >>form a if-elif-else block, that on a very general level, an 'also' >>statement might be useful. So I was wondering what others woul

Re: "also" to balance "else" ?

2005-06-13 Thread Ron Adam
John Roth wrote: > > "Ron Adam" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> Currently the else block in a for loop gets executed if the loop is >> completed, which seems backwards to me. I would expect the else to >> compl

Re: "also" to balance "else" ?

2005-06-13 Thread Ron Adam
k of having an also. I was parsing and formatting doc strings at the time, and also would allow it to become. if : BLOCK1 elif : BLOCK2 also: BLOCK3 Which is much easier to read. Ron -- http://mail.python.org/mailman/listinfo/python-list

"also" to balance "else" ?

2005-06-13 Thread Ron Adam
fore.) Changing the for-else is probably a problem... This might be a 3.0 wish list item because of that. Is alif too simular to elif? On the plus side, I think this contributes to the pseudocode character of Python very well. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Scope

2005-06-04 Thread Ron Adam
Elliot Temple wrote: > I want to write a function, foo, so the following works: > > def main(): > n = 4 > foo(n) > print n > > #it prints 7 > > if foo needs to take different arguments, that'd be alright. > > Is this possible? It is possible if you pass mutable objects to foo such

Re: The need to put "self" in every method

2005-06-03 Thread Ron Adam
Fernando M. wrote: > Hi, > > i was just wondering about the need to put "self" as the first > parameter in every method a class has because, if it's always needed, > why the obligation to write it? couldn't it be implicit? > > Or is it a special reason for this being this way? > > Thanks. Here'

Re: Sorting x lists based on one list ... maybe an example would make sense:

2005-05-18 Thread Ron Adam
Steven Bethard wrote: > Ron Adam wrote: >>grades.sort(lambda x,y: cmp(students[x[1]][0], students[y[1]][0])) > Assuming that students[x[1]][0] is what you want to sort on, this may > also be written as: > > grades.sort(key=lambda x: students[x[1]][0])

Re: Sorting x lists based on one list ... maybe an example would make sense:

2005-05-18 Thread Ron Adam
Philippe C. Martin wrote: >>Another way would be to merge the three lists into one of 3-tuples, sort, >>and unmerge, similarly to the DSU pattern -- which raises the question: >>why are you using three lists in the first place? > > > :-) Thanks, the lists will evolve and are also stored in 'csv'

Re: Quick Reference from module doc strings.

2005-05-17 Thread Ron Adam
Michele Simionato wrote: > Ron Adam: > >>Thats part of what I'm trying to resolve, the doc strings a lot of > > time > >>isn't enough by itself or is missing. So I'm trying to build up a >>complete enough record so if there is no doc string, at

Re: Representing ambiguity in datetime?

2005-05-17 Thread Ron Adam
John Machin wrote: > On Tue, 17 May 2005 17:38:30 -0500, Terry Hancock > <[EMAIL PROTECTED]> wrote: > > >>What do you do when a date or time is >>incompletely specified? ISTM, that as it is, there is no >>formal way to store this --- you have to guess, and there's >>no way to indicate that the

Re: Quick Reference from module doc strings.

2005-05-17 Thread Ron Adam
Scott David Daniels wrote: > Ron Adam wrote: > >> ...What would be the advantage of using StringIO over list.append with >> ''.join()? > > The advantage is more in using a function that prints as it goes > rather than building up a large string to print.

Re: Quick Reference from module doc strings.

2005-05-17 Thread Ron Adam
Michele Simionato wrote: > Ron Adam: > > >>Sound great! Adding a command line parser, I'm going to add a brief ^---^ That part should have been deleted, I meant your whole program sounded good, not just that part. :-) >>

Re: Quick Reference from module doc strings.

2005-05-17 Thread Ron Adam
Michele Simionato wrote: >>Do you have any feature suggestions, additional information that > > could > >>go in, something that would extend the content in some way and make > > it > >>more useful? > > > I have written something similar which I use all the time. It generates > ReST > output w

Re: Quick Reference from module doc strings.

2005-05-16 Thread Ron Adam
Scott David Daniels wrote: > Ron Adam wrote: > >>Do you have any feature suggestions, additional information that could >>go in, something that would extend the content in some way and make it >>more useful? >> >>As it stands now, it could be just a module,

Re: Quick Reference from module doc strings.

2005-05-15 Thread Ron Adam
Scott David Daniels wrote: > Althought object is a horrible name for your own value (there is a builtin > object which you use for defining new-style classes), you probably want: Good point, I agree. It's a bad habit to start, sooner or later it would cause a problem. I'll find something else

Re: Precision?

2005-05-15 Thread Ron Adam
Ron Adam wrote: > tiissa wrote: > >>Steffen Glückselig wrote: >> >> >>>>>>1.0 + 3.0 + 4.6 >>> >>>8.5996 >>> >>>Ehm, how could I get the intuitively 'correct' result of - say - 8.6

Re: Quick Reference from module doc strings.

2005-05-15 Thread Ron Adam
John Machin wrote: > Ron Adam wrote: > >>Does anyone have suggestions on how to improve this further? > > > Not functionally (from me, yet). However if you can bear a stylistic > comment, do read on :-) > > >> elif (isinstance(object,str) >>

Re: Quick Reference from module doc strings.

2005-05-15 Thread Ron Adam
I think this deserves a little more of a description than I gave it initially. The routine in the previous message does a little more than just print out __doc__ strings. It outputs a formatted alphabetical list of objects in a module with each objects, name, class or type, and then tries to

Re: Precision?

2005-05-15 Thread Ron Adam
tiissa wrote: > Steffen Glückselig wrote: > >1.0 + 3.0 + 4.6 >> >>8.5996 >> >>Ehm, how could I get the intuitively 'correct' result of - say - 8.6? >>;-) > > > You may find annex B of the python tutorial an interesting read: > http://docs.python.org/tut/node16.html In addition t

Re: Exception question

2005-05-15 Thread Ron Adam
Steven Bethard wrote: > Ron Adam wrote: > >>Do exceptions that take place get stored in a stack or list someplace? > > [snip] > >>I know I can catch the error and store it myself with, >> >>except Exception, exc: >> >>or possibly, >

Exception question

2005-05-14 Thread Ron Adam
I'm trying to understand exception handling better and have a question I haven't been able to find an answer too. Which probably means It won't work, but... Do exceptions that take place get stored in a stack or list someplace? For example in: try: try: try: riskyf

Quick Reference from module doc strings.

2005-05-14 Thread Ron Adam
Does anyone have suggestions on how to improve this further? Cheers, Ron_Adam def getobjs(object, dlist=[], lvl=0, maxlevel=1): """ Retrieve a list of sub objects from an object. """ if object not in dlist: dlist.append(object) if lvl200: s = object[0:

Re: Python 2.4 & BLT ?

2005-05-14 Thread Ron Adam
StepH wrote: >> >> A little googling found the following which may give you a clue or >> ideas of further searches. Also run a virus scanner on the file >> before hand. >> >> http://www.noteworthysoftware.com/composer/faq/90.htm > > > Argg... I always find me stupid when i don't have find my

Re: Python Documentation (should be better?)

2005-05-13 Thread Ron Adam
Steven Bethard wrote: > Ron Adam wrote: > >>What I would like to see is something like the following for each item: >> >>0. reference @ sequence code >>2. "Builtin" | "import " >>3. Type/class: Name/Syntax >>4. Description with ex

Re: Python Documentation (should be better?)

2005-05-12 Thread Ron Adam
Steven Bethard wrote: > Skip Montanaro wrote: > >>Mike> Given that Python hides the difference between user-defined >>Mike> objects and built-in objects, it's not clear to me that anything >>Mike> other than the current system, with all the classes/types in one >>Mike> place, make

Re: Python 2.4 & BLT ?

2005-05-12 Thread Ron Adam
StepH wrote: > Ron Adam a écrit : > >>StepH wrote: >> >> >>>Ron Adam a écrit : >>> >>> >>>>StepH wrote: >>>> >>>> >>>> >>>>>Hi, >>>>> >>>>>I'm

Re: Python 2.4 & BLT ?

2005-05-11 Thread Ron Adam
StepH wrote: > Ron Adam a écrit : > >>StepH wrote: >> >> >>>Hi, >>> >>>I'm not able to install BLT on my Python 2.4 (upgraded to 2.4.1) >>>distibution... >>> >>>I'v try to download btlz-for-8.3.exe, but when

Re: Python Graphing Utilities.

2005-05-10 Thread Ron Adam
Kenneth Miller wrote: > Hello All, > > I am new to Python and i was wondering what graphing utlities would be > available to me. I have already tried BLT and after weeks of unsuccesful > installs i'd like to find something else. Anything someone would recommend? > > Regards, > Ken BLT does

Re: Python 2.4 & BLT ?

2005-05-10 Thread Ron Adam
StepH wrote: > Hi, > > I'm not able to install BLT on my Python 2.4 (upgraded to 2.4.1) > distibution... > > I'v try to download btlz-for-8.3.exe, but when i try to install it, i've > a msgbox saying to the file is corrupt... > > Any idea ? > > Thanks. > > StepH. Have you tried blt2.4z-for-

<    2   3   4   5   6   7   8   >