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: 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: 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: 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: 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
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
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
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: 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-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: 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: 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: 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: 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: 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: 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: 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
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: 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: 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-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: 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: 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: 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: 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-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: 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: 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: 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: 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: 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-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-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: Efficiently Split A List of Tuples

2005-07-18 Thread Ron Adam
7;m tried to reinvent the wheel yet again. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Ordering Products

2005-07-18 Thread Ron Adam
eeds some better logic to merge adjacent like groups. I think the reverse sorting my be a side effect of the nesting that takes place when the expressions are built. Having the digits first might be an advantage as you can use a for loop to add or multiply them until you get to a not digit. Anyway, interesting stuff. ;-) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Ordering Products

2005-07-19 Thread Ron Adam
Kay Schluehr wrote: > Hi Ron, > > I really don't want to discourage you in doing your own CAS but the > stuff I'm working on is already a bit more advanced than my > mono-operational multiplicative algebra ;) I figured it was, but you offered a puzzle: "Here

Re: Ordering Products

2005-07-20 Thread Ron Adam
Kay Schluehr wrote: > Ron Adam wrote: > >> Kay Schluehr wrote: >> BTW.. Usually when people say "I don't want to discourage...", They >> really want or mean the exact oppisite. > > Yes, but taken some renitence into account they will provoke the &g

Re: [path-PEP] Path inherits from basestring again

2005-07-25 Thread Ron Adam
o be: > >scripts = userfolder.joinpath(scriptfolder) >scriptpath = scripts.joinpath(self.config['system']['commandfile']) > > Even so I'm only +0 on it. > > -Peter I think the '+' is used as a join for both strings and lists, so i

Re: [path-PEP] Path inherits from basestring again

2005-07-27 Thread Ron Adam
ct or modify the original? p = path('C://somedir//somefile') p+='.zip' what would this do? p[-1]+='.zip' Or this? Cheer's Ron. -- http://mail.python.org/mailman/listinfo/python-list

Re: [path-PEP] Path inherits from basestring again

2005-07-27 Thread Ron Adam
Michael Hoffman wrote: > Ron Adam wrote: > >> In all current cases, (that I know of), of differing types, '+' raises >> an error. > > > Not quite: > > >>> "hello " + u"world" > u'hello world' > >>

Re: [path-PEP] Path inherits from basestring again

2005-07-27 Thread Ron Adam
Peter Hansen wrote: > Ron Adam wrote: > >> Michael Hoffman wrote: >> >>> Ron Adam wrote: >>> >>>> In all current cases, (that I know of), of differing types, '+' >>>> raises an error. >>> >>> >>>

Re: Friend wants to learn python

2005-07-29 Thread Ron Stephens
rials and books might be best for newbies to Python, depending on their background. It can be reached at http://www.awaretek.com/python/index.html Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP on path module for standard library

2005-07-30 Thread Ron Adam
en done. apath.close() etc... With this you can iterate a file system as well as it's files. ;-) (Add more or less methods as needed of course.) apath = device(dev_obj).path(some_path_sting) apath.open().write(data).close() or if you like... device(dev_obj).append(path_sting).open().write(data).close() Just a few thoughts, Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: [path-PEP] Path inherits from basestring again

2005-08-01 Thread Ron Adam
;/' will be considered a wart by many and a boon by others. If I'm right, there will be endless discussions over it if it's implemented. I'd rather not see that, so I'm still -1 concerning '/' for that reason among others. Cheers, Ron PS. Could someone repost

Path as a dictionary tree key? (was Re: PEP on path module for standard library)

2005-08-01 Thread Ron Adam
x27;b') item = D_tree[path] or item = D_tree[Path('a','b')] That would be in place of.. item = D[path[0]][path[1]] -> item = D['a']['b'] This give a more general purpose for path objects. Working out ways to retriev

Re: Path as a dictionary tree key? (was Re: PEP on path module for standard library)

2005-08-01 Thread Ron Adam
Brian Beck wrote: > Ron Adam wrote: > >> This give a more general purpose for path objects. Working out ways >> to retrieve path objects from a dictionary_tree also would be useful I >> think. I think a Tree class would also be a useful addition as well. >> >

Re: Path as a dictionary tree key? (was Re: PEP on path module for standard library)

2005-08-01 Thread Ron Adam
t all if anyone posted improvements. (hint hint) ;-) Cheers, Ron Adam + output -- Define paths: path1 = ['hello', 'world'] path2 = ['hello', 'there', 'world'] path3 = ['hello', 'there', 'wide', &#x

Re: finding sublist

2005-08-02 Thread Ron Adam
n None. So you don't need to return 'no'. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-09 Thread Ron Adam
uld just increment a reference counter, and it wouldn't be removed from shared until it reaches zero again. Using 'share' twice with the same name in the same function should cause an error. Using 'shared' with a name that is not in shared name space would cause an error. Just a few thoughts. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] implementation of copy standard lib

2005-08-16 Thread Ron Adam
r is it just me? I use copy.deepcopy() sometimes, and more often [:] with lists. Dictionary objects have a copy method. All non mutable objects are copies. I too have wondered why copy isn't a builtin, and yet some builtin objects do make copies. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-16 Thread Ron Adam
in a module you wouldn't be able to access any builtin functions or class's without declaring them as global (or importing them) in every function or class that uses them. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] implementation of copy standard lib

2005-08-17 Thread Ron Adam
he alternative would be to use a flag and shallow copies in all the methods that altered the object. copy.deepcopy() was a lot easier as it's only needed in the method that initiates the result calculation. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: pythonXX.dll size: please split CJK codecs out

2005-08-21 Thread Ron Adam
there may be a lot of differing opinions on just what those minimum Python programs should be. But that is where the PEP process comes in. Regards, Ron > Regards, > Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: pythonXX.dll size: please split CJK codecs out

2005-08-21 Thread Ron Adam
Martin v. Löwis wrote: > Ron Adam wrote: > >>I would put the starting minimum boundary as: >> >> 1. "The minimum required to start the python interpreter with no >>additional required files." >> >>Currently python 2.4 (on windows) does not

Re: variable hell

2005-08-25 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Benji York <[EMAIL PROTECTED]> wrote: > Peter Maas wrote: > > >>> suffix = 'var' > > >>> vars()['a%s' % suffix] = 45 > > >>> avar > > 45 > > Quoting from http://docs.python.org/lib/built-in-funcs.html#l2h-76 about > the "vars" built in: > > The returned dicti

Re: variable hell

2005-08-25 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Robert Kern <[EMAIL PROTECTED]> wrote: > In the > bowels of my modules, I may not know what the contents are at code-time, Then how do you write your code? rg -- http://mail.python.org/mailman/listinfo/python-list

Re: variable hell

2005-08-25 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> wrote: > rafi wrote: > > Reinhold Birkenfeld wrote: > > > > > exec(eval("'a%s=%s' % (count, value)")) > >>> > >>>why using the eval? > >>> > >>>exec ('a%s=%s' % (count, value)) > >>> > >>>should be fine > >> > >>And this demo

Re: py to exe: suggestions?

2005-08-28 Thread Ron Adam
m a single exe file that's very professional. Most users won't need to know or care what language you developed your application with as long as it works. Hope that helps, Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

2005-08-31 Thread Ron Adam
t; -1, but about an easy way to get the last value. > > But I like your idea. I just think there should be two differnt ways > to index. maybe use braces in one case. > > seq{i} would be pure indexing, that throws exceptions if you > are out of bound > > seq[i

Re: Bug in string.find

2005-09-01 Thread Ron Adam
Fredrik Lundh wrote: > Ron Adam wrote: > > >>The problem with negative index's are that positive index's are zero >>based, but negative index's are 1 based. Which leads to a non >>symmetrical situations. > > > indices point to the "gap&q

Re: Bug in string.find

2005-09-02 Thread Ron Adam
Terry Reedy wrote: > "Ron Adam" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Fredrik Lundh wrote: >> >>>Ron Adam wrote: >>> >>>>The problem with negative index's are that positive index'

Re: Bug in string.find

2005-09-03 Thread Ron Adam
Terry Reedy wrote: >>b[-1:] = ['Z']# replaces last item >>b[-1:-0] = ['Z'] # this doesn't work >> >>If you are using negative index slices, you need to check for end >>conditions because you can't address the end of the slice in a >>sequential/numerical way. > > OK, now I understand

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

2005-09-03 Thread Ron Adam
Bengt Richter wrote: > IMO the problem is that the index sign is doing two jobs, which for zero-based > reverse indexing have to be separate: i.e., to show direction _and_ a _signed_ > offset which needs to be realtive to the direction and base position. Yes, that's definitely part of it. > A l

Possible improvement to slice opperations.

2005-09-04 Thread Ron Adam
y, it would be nice to get a few opinions at this point. So blast away... or hopefully tell me what you like about it instead. ;-) (Any suggestions or contributions to make it better would be appreciated.) Cheers, Ron Adam """ IMPROVED SLICING Slicing is one

Re: Possible improvement to slice opperations.

2005-09-04 Thread Ron Adam
Terry Reedy wrote: > "Ron Adam" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Slicing is one of the best features of Python in my opinion, but >>when you try to use negative index's and or negative step increments >>it can be

Re: Possible improvement to slice opperations.

2005-09-04 Thread Ron Adam
fear you might need a similar helper function for > similar issues with your change. I just don't know what those are > without more thought. > > Regards, > Pat Thanks for the feedback, it was helpful. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Scott David Daniels wrote: > Magnus Lycka wrote: > >> Ron Adam wrote: >> >>> ONES BASED NEGATIVE INDEXING > > > I think Ron's idea is taking off from my observation that if one's > complement, rather than negation, was used to specify measure

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
m right The symmetry is easier to see when using the '~' values. LL=list(range(10)) Lx=nxlist(range(10)) LL[ 1: 2]==[LL[ 1]]==[1] Lx[~2:~1]==[Lx[~1]]==[8] Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Magnus Lycka wrote: > Ron Adam wrote: > >> Slicing is one of the best features of Python in my opinion, but >> when you try to use negative index's and or negative step increments >> it can be tricky and lead to unexpected results. > > > Hm... Just as w

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
selection of negative strides to be fixed if possible. If you could explain the current reason why it does not return the reverse order of the selected range. I would appreciated it. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
) however would require a lot of small changes in index's. Mostly changing.. L[:-1] to L[:~1] or to L[:-2]. So no, I don't expect one's based indexing to be added any time soon. It could be useful as a function or object in it's own. > "Professor Einstein, could you tell our readers how general relativity > works?" Actually I can, but it would be off topic for this news group. Cheers, Ron > regards > Steve -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
slice of a slice object r.range_sub(d,3) # subtract 3 from items in range d Or more flexible ... r.range_modify(d, add(), 5) Using your suggestion that would be... r = range(100) d = [10:10] r.range_add(d,5) d = d[5:] -> [15:5] # interesting symmetry. r.range_sub(d,3) Of course adding and subtracting slice objects could also be possible. d = [10:20] e = [15:25] f = d + e-> [10:25] or ... d = [10:10] e = [15:10] f = d + e-> [10:15] Cheers, Ron > Regards, > Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Terry Reedy wrote: >>Ron Adam wrote: >> >> >>>However, I would like the inverse selection of negative strides to be >>>fixed if possible. If you could explain the current reason why it does >>>not return the reverse order of the selected ra

Re: Possible improvement to slice opperations.

2005-09-06 Thread Ron Adam
Patrick Maupin wrote: > I previously wrote (in response to a query from Ron Adam): > > >>In any case, you asked for a rationale. I'll give you mine: >> >> >>>>>L = range(10) >>>>>L[3:len(L):-1] == [L[i] for i in range(3,len(L),-1)]

Re: Possible improvement to slice opperations.

2005-09-06 Thread Ron Adam
Steve Holden wrote: > Ron Adam wrote: > >> Steve Holden wrote: >> >> What misconception do you think I have? >> > This was not an ad hominem attack but a commentary on many attempts to > "improve" the language. Ok, No problem. ;-) >> No o

Re: Possible improvement to slice opperations.

2005-09-06 Thread Ron Adam
Patrick Maupin wrote: > Ron Adam wrote: > > >>>This should never fail with an assertion error. You will note that it >>>shows that, for non-negative start and end values, slicing behavior is >>>_exactly_ like extended range behavior. > > >>Yes,

Re: Possible improvement to slice opperations.

2005-09-06 Thread Ron Adam
Magnus Lycka wrote: > Ron Adam wrote: > >> Ok, lets see... This shows the problem with using the gap indexing >> model. >> >> L = range(10) >> >> [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] # elements >> 0 1 2 3 4 5 6 7 8 9

Re: Possible improvement to slice opperations.

2005-09-07 Thread Ron Adam
x27;ll deal with the subsetting another time ... No hurry, this isn't a hack it out because "the boss wants it on his desk Monday" situation. ;-) > Regards, > Bengt Richter Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible improvement to slice opperations.

2005-09-09 Thread Ron Adam
Michael Hudson wrote: > Ron Adam <[EMAIL PROTECTED]> writes: >>With current slicing and a negative step... >> >>[ 1 2 3 4 5 6 7 8 9 ] >> -9 -8 -7 -6 -5 -4 -3 -2 -1 -0 >> >>r[-3:] -> [7, 8, 9]# as expected >&

Re: encryption with python

2005-09-10 Thread Ron Adam
and get another randomly generated password. Or am I missing something? Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: encryption with python

2005-09-10 Thread Ron Adam
James Stroud wrote: > On Saturday 10 September 2005 15:02, Ron Adam wrote: > >>Kirk Job Sluder wrote: >>I would think that any n digit random number not already in the data >>base would work for an id along with a randomly generated password that >>the student

Re: encryption with python

2005-09-11 Thread Ron Adam
Kirk Job Sluder wrote: > Ron Adam <[EMAIL PROTECTED]> writes: >>I would think that any n digit random number not already in the data >>base would work for an id along with a randomly generated password >>that the student can change if they want. The service provid

Re: Software bugs aren't inevitable

2005-09-16 Thread Ron Adam
ferent versions of a program on several different platforms simultaneously and use only the results that have a majority agreement. Or to put it another way; risk management by ... "keep it simple", "don't have too many cooks", "get second opinions", and "don't put all your eggs in one basket". Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Software bugs aren't inevitable

2005-09-16 Thread Ron Adam
reused on successive calls, but then I realized that it's nearly identical to a loop in that context, so why not just write it as a loop to start with. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Synchronous/Asynchrnous Audio play with pymedia

2005-09-18 Thread Ron Provost
Hello, I'm developing a piece of software to assist illiteraate adults to learn to read. I'm trying to figure out how, if possible, to make audio playback asynchrnous but still controllable. I'm using python 2.4 with pymedia on XP. I started out with the example in the tutorials section of t

inspect getsource() minor fix?

2005-09-19 Thread Ron Adam
EndOfBlock, self.last Cheers, Ron C:\Python24\Lib>diff.py inspect.py inspect_.py *** inspect.py Tue Mar 15 13:22:02 2005 --- inspect_.py Mon Sep 19 14:26:26 2005 *** *** 531,536 --- 531,538 raise EndOfBlock, self.last elif type == tokenize.NAME

Re: inspect getsource() minor fix?

2005-09-19 Thread Ron Adam
Delaney, Timothy (Tim) wrote: > Ron Adam wrote: > > >>While playing around with the inspect module I found that the >>Blockfinder doesn't recognize single line function definitions. >> >>Adding the following two lines to it fixes it, but I'm not sur

Re: Question About Logic In Python

2005-09-19 Thread Ron Adam
rue, but not equal. bool(1 and 2) == bool(2 and 1) (1 and 2) * value != (2 and 1) * value # except if value is False. bool(1 and 2) * value == bool(2 and 1) * value So.. bool(a and b) * value Would return value or zero, which is usually what I want when I do this type of expression. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Organising a python project

2005-09-20 Thread Ron Adam
projectname2 <- next version... ... # copy the previous version to start. ... Below is my basic py2exe script. You'll need to change it to suite your own needs of course. The rmtree is my own module to remove directories and contents. The newest version of

Re: Question About Logic In Python

2005-09-21 Thread Ron Adam
on bools to bools first. But it would be easier IMO if bool operations gave bool results so I wouldn't need to do: bool_result = a and bool(b) or bool_result = bool(a and b) On one hand these seem like little things, but little things is sometimes what will bite you the hardest as they are more likely to get by your guard. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Question About Logic In Python

2005-09-21 Thread Ron Adam
ra, the simplest one. Strictly > speaking, Booleans aren't limited to two values. See > http://en.wikipedia.org/wiki/Boolean_algebra for more detail. I look at those earlier and was surprised at how complex some Boolean algebra concepts were. Interesting though, and I'll probably go back and study it a bit more. > Python's bools aren't Booleans. They are merely aliases for 0 and 1. Yes, and according to the PEP they were introduced to help reduce errors. ;-) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding where to store application data portably

2005-09-21 Thread Ron Adam
extensions) is definitely not the answer. Personally I think hidden files do more harm than good. It's not a substitute for good file management, and it not an acceptable alternative to good security either. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding where to store application data portably

2005-09-21 Thread Ron Adam
ke RISC OS (it may not have pygame but > it definitely has python). Surely this is something that's crying out > for an official function in os or sys. This works on Win XP. Not sure if it will work on Linux. import os parent = os.path.split(os.path.abspath(os.sys.argv[0]))[0] file =

Re: Question About Logic In Python

2005-09-22 Thread Ron Adam
Steve Holden wrote: > Ron Adam wrote: >> >> 2. Expressions that will be used in a calculation or another >> expression. >> > By which you appear to mean "expressions in which Boolean values are > used as numbers". Or compared to other types, wh

Re: Finding where to store application data portably

2005-09-22 Thread Ron Adam
Steve Holden wrote: > Ron Adam wrote: > >> Tony Houghton wrote: >> >>> I'm using pygame to write a game called Bombz which needs to save some >>> data in a directory associated with it. In Unix/Linux I'd probably use >>> "~/.bomb

Re: Finding where to store application data portably

2005-09-22 Thread Ron Adam
e would be as you suggested, but maybe doing it this way would be better. import os user = os.path.join( os.environ["USERPROFILE"], 'Application Data', 'Bombz' ) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: supress creation of .pyc files

2005-02-16 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Thomas Guettler <[EMAIL PROTECTED]> wrote: > Hi, > > Is there a way to import a file without creating > a .pyc file? > > Of course you can delete the pyc in my script after > the import statement, but maybe there is a switch > that I have not found yet. > > The

Re: __getitem__ method on (meta)classes

2005-03-14 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Leif K-Brooks <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Why doesn't this work? > > > > > def foo(lst): > > > > ... class baz(object): > > ... def __getitem__(cls, idx): return cls.lst[idx] > > ... __getitem__=classmethod(__getitem__

Re: __getitem__ method on (meta)classes

2005-03-14 Thread Ron Garret
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Bengt Richter) wrote: > On 14 Mar 2005 17:43:53 -0800, [EMAIL PROTECTED] wrote: > > > > >Why doesn't this work? > > > def foo(lst): > >... class baz(object): > >... def __getitem__(cls, idx): return cls.lst[idx] > >... __getitem__

Re: __getitem__ method on (meta)classes

2005-03-14 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Ron Garret <[EMAIL PROTECTED]> wrote: Wow, this is really cool: > What I'm really trying to do is to create enumerated types... And the code I ended up with is: # Inheriting from type, not object, is the key: class enum_metaclass(type):

<    1   2   3   4   5   6   7   8   >