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: 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: 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

"also" to balance "else" ?

2005-06-13 Thread Ron Adam
There seems to be a fair amount of discussion concerning flow control enhancements lately. with, do and dowhile, case, etc... So here's my flow control suggestion. ;-) 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

Re: "also" to balance "else" ?

2005-06-13 Thread Ron Adam
Eloff wrote: > My first reaction was that this is terrible, else clauses on loops are > confusing enough. But if I think about it more, I'm warming up to the > idea. Also/Else for loops is clear, symmetrical, and would be useful. > > Reversing the meanign of else will break code, but it's not used

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
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
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-14 Thread Ron Adam
Sion Arrowsmith wrote: > Fredrik Lundh <[EMAIL PROTECTED]> wrote: >>nope. else works in exactly the same way for all statements that >>support it: if the controlling expression is false, run the else suite >>and leave the statement. > > > For example, consider the behaviour of: > > condition =

Re: "also" to balance "else" ?

2005-06-14 Thread Ron Adam
Andrew Dalke wrote: > As someone else pointed out, that problem could be resolved in > some Python variant by using a different name, like "at end". > Too late for anything before P3K. It was pointed out to me the logic of the else is consistant with the if in reguard to the loop test it self, i

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-15 Thread Ron Adam
Terry Hancock wrote: > On Wednesday 15 June 2005 03:57 am, Fredrik Lundh wrote: > >>where your "abnormal behaviour" is, of course, the expected >>behaviour. if you insist on looking at things the wrong way, >>things will look reversed. > > Unfortunately, the converse is true, too: no matter how

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: Break up list into groups

2007-07-17 Thread Ron Adam
Matimus wrote: > I did some more experimenting and came up with the code below. It > shows several methods. When run, the script tests the robustness of > each method (roughly), and profiles it using timeit. The results from > running on my laptop are shown below the code. Try this one... def g

Re: Break up list into groups

2007-07-17 Thread Ron Adam
Matt McCredie wrote: > That certainly is fast, unfortunately it doesn't pass all of the tests. > I came up with those tests so I don't know how important they are to the > original poster. I modified it and came up with a generator and a > non-generator version based (roughly) on your algorith

Re: Break up list into groups

2007-07-20 Thread Ron Adam
Matimus wrote: > Excellent work! One more modification and I get below 10us/pass: > > def getgroups(seq): > groups = [] > push = groups.append > iseq = iter(xrange(len(seq))) > for start in iseq: > if seq[start] & 0x80: > for stop in iseq: >

Re: pydoc and imported modules

2007-04-25 Thread Ron Adam
[EMAIL PROTECTED] wrote: > When I "from foo import *" in my __init__.py, sometimes module foo's > docs will be expanded in the pydocs. It seems to depend in what > language foo was implemented. > > For example, if you "from math import *" in your __init__.py, you will > see math's members will app

Sorting attributes by catagory

2007-05-09 Thread Ron Adam
This is for a new version of pydoc if I can get the class attributes sorted out. The module level attributes aren't too difficult to categorize. (I might be just too tired to see the obvious.) The original pydoc did this a somewhat round about way, so I would like to find a more direct method

Re: PYDOC replacement. (Was:Sorting attributes by catagory)

2007-05-09 Thread Ron Adam
Nick Vatamaniuc wrote: > Ron, > > Consider using epydoc if you can. Epydoc will sort the methods and it > will also let you use custom CSS style sheets for the final HTML > output. Check out the documentation of my PyDBTable module. > http://www.psipy.com/PyDBTable > > -Nick Vatamaniuc Hi Nick

Re: PYDOC replacement. (Was:Sorting attributes by catagory)

2007-05-10 Thread Ron Adam
Nick Vatamaniuc wrote: > Thanks for the info, Ron. I had no idea pydoc was that powerful! > -Nick Change *was* to *will be*. It really needed to be re factored. ;-) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

webbrowser module bug?

2007-05-24 Thread Ron Adam
Is anyone else having problems with the webbrowser module? Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import webbrowser >>> webbrowser.open('http://www.python.o

Re: webbrowser module bug?

2007-05-25 Thread Ron Adam
[EMAIL PROTECTED] wrote: > On May 24, 5:03 pm, Ron Adam <[EMAIL PROTECTED]> wrote: >> Is anyone else having problems with the webbrowser module? >> >> Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25) >> [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 >>

Re: webbrowser module bug?

2007-05-25 Thread Ron Adam
Brian van den Broek wrote: > Ron Adam said unto the world upon 05/25/2007 12:28 PM: >> [EMAIL PROTECTED] wrote: >>> On May 24, 5:03 pm, Ron Adam <[EMAIL PROTECTED]> wrote: >>>> Is anyone else having problems with the webbrowser module? >>>> >>

Re: webbrowser module bug?

2007-05-25 Thread Ron Adam
Steve Holden wrote: > Ron Adam wrote: >> [EMAIL PROTECTED] wrote: >>> On May 24, 5:03 pm, Ron Adam <[EMAIL PROTECTED]> wrote: >>>> Is anyone else having problems with the webbrowser module? >>>> >>>> Python 2.5.1c1 (release25-maint, A

Re: webbrowser module bug?

2007-05-25 Thread Ron Adam
Paul Boddie wrote: > On 25 May, 00:03, Ron Adam <[EMAIL PROTECTED]> wrote: >> Is anyone else having problems with the webbrowser module? >> >> Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25) >> [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 >> Type &qu

Re: webbrowser module bug?

2007-05-25 Thread Ron Adam
Ron Adam wrote: > Paul Boddie wrote: >> On 25 May, 00:03, Ron Adam <[EMAIL PROTECTED]> wrote: >>> Is anyone else having problems with the webbrowser module? >>> >>> Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25) >>> [GCC 4.1.2 (Ubuntu 4.1

Re: webbrowser module bug?

2007-05-25 Thread Ron Adam
Ron Adam wrote: > Got it. > > It looks like the problem started when I told firefox to make itself > the default browser. That changed the way webbrowser.py figured out the > browser to use. So instead of trying them in order, it asked the gnome > configure too

Re: webbrowser module bug?

2007-05-26 Thread Ron Adam
Paul Boddie wrote: > Ron Adam wrote: >> Reseting the default browser with the gnome default application window >> confirmed this. The browser selection can either have the quotes around >> the args "%s" paremteter, or not depending on how and what sets it. >&g

Pydoc Rewrite Discussion at doc-sig list.

2007-04-13 Thread Ron Adam
an be submitted and a final discussion can take place on the python-dev list at a later date. Thanks and Regards, Ron Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Pydoc Rewrite Discussion at doc-sig list.

2007-04-14 Thread Ron Adam
Colin J. Williams wrote: > Ron Adam wrote: >> If anyone is interested in participating in discussing the details of the >> PyDoc rewrite/refactoring I've been working on, a discussion is being >> started on the doc-sig list. >> >> [EMAIL PROTECTED] >

Re: Python 3K or Python 2.9?

2007-09-21 Thread Ron Adam
TheFlyingDutchman wrote: > I am not talking about the way it does it, but rather, the way it > could do it or... could have done it. That requires no knowledge of > how the interpreter currently does it unless I am proposing something > that no interpreter in the world could ever do. Yes, there

Re: Python 3K or Python 2.9?

2007-09-21 Thread Ron Adam
Bruno Desthuilliers wrote: > Ron Adam a écrit : >> >> TheFlyingDutchman wrote: >> >>> I am not talking about the way it does it, but rather, the way it >>> could do it or... could have done it. That requires no knowledge of >>> how the int

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Ron Adam
Cristian wrote: > My hope is to subtly reinforce the notion that functions are data > and can be passed around. The current function declaration doesn't > help with this. Creating a function and assigning it to a name is > exactly what Python does, why not have it come out in the syntax? It's > n

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Ron Adam
Cristian wrote: > On Sep 21, 3:44 pm, Ron Adam <[EMAIL PROTECTED]> wrote: > >> I think key may be to discuss names and name binding with your friend. How >> a name is not the object it self, like a variable is in other languages. >> For example show him how an

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Ron Adam
Scott David Daniels wrote: > Cristian wrote: >> On Sep 21, 3:44 pm, Ron Adam <[EMAIL PROTECTED]> wrote: >> >>> I think key may be to discuss names and name binding with your friend. > > Here's an idea: > > import math > > def sin_inte

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Ron Adam
Scott David Daniels wrote: > Ron Adam wrote: >> >> Scott David Daniels wrote: >>> Cristian wrote: >>>> On Sep 21, 3:44 pm, Ron Adam <[EMAIL PROTECTED]> wrote: >>>> >>>>> I think key may be to discuss names and name binding

Re: Factory function with keyword arguments

2007-09-23 Thread Ron Adam
Steven D'Aprano wrote: > I'm writing a factory function that needs to use keywords in the produced > function, not the factory. Here's a toy example: > I thought of doing this: > > def factory(flag): > if flag: kw = 'spam' > else: kw = 'ham' > def foo(obj, arg): > kwargs =

Re: Factory function with keyword arguments

2007-09-23 Thread Ron Adam
Steven D'Aprano wrote: > On Sun, 23 Sep 2007 03:55:45 -0500, Ron Adam wrote: > >> Steven D'Aprano wrote: >>> I'm writing a factory function that needs to use keywords in the >>> produced function, not the factory. Here's a toy example: > >

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Ron Adam
Scott David Daniels wrote: > Ron Adam wrote: >> Scott David Daniels wrote: >>> Ron Adam wrote: >>>> How about this? >>>> def integrate(fn, x1, x2, n=100):... >>> The point was a pedagogic suggestion, ... >> I understood your point.

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-15 Thread Ron Adam
Calvin Spealman wrote: > On 1/15/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >> On Mon, 15 Jan 2007 17:50:56 -0500, Calvin Spealman wrote: >> >>> assert foo(0x10) == 0 # Assertions are much better tests than prints :-) >> I dispute that assertion (pun intended). > > Hah! > >> Firstly, print s

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-15 Thread Ron Adam
Steven D'Aprano wrote: > On Mon, 15 Jan 2007 21:01:35 -0600, Ron Adam wrote: > > >> There have been times where I would like assert to be a little more >> assertive >> than it is. :-) >> >> ie.. not being able to turn them off with the -0/-00 switc

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-16 Thread Ron Adam
Carl Banks wrote: > Ron Adam wrote: >> There have been times where I would like assert to be a little more assertive >> than it is. :-) >> >> ie.. not being able to turn them off with the -0/-00 switches, and having >> them >> generate a more verbose traceb

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-16 Thread Ron Adam
Neil Cerutti wrote: > On 2007-01-16, Ron Adam <[EMAIL PROTECTED]> wrote: >> I have to admit that part of why assert seems wrong to me is >> the meaning of the word implies something you shouldn't be able >> to ignore. While warnings seem like somet

Module name to filename and back?

2007-01-18 Thread Ron Adam
Is there a function to find a filename from a dotted module (or package) name without importing it? The imp function find_module() doesn't work with dotted file names. And it looks like it may import the file as it raises an ImportError error exception if it can't find the module. (Shouldn

Re: Module name to filename and back?

2007-01-18 Thread Ron Adam
Ron Adam wrote: > Is there a function to find a filename from a dotted module (or package) name > without importing it? > > The imp function find_module() doesn't work with dotted file names. And it > looks like it may import the file as it raises an ImportError error exc

from __future__ import absolute_import ?

2007-02-02 Thread Ron Adam
from __future__ import absolute_import Is there a way to check if this is working? I get the same results with or without it. Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win 32 _Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: from __future__ import absolute_import ?

2007-02-02 Thread Ron Adam
Peter Otten wrote: > Ron Adam wrote: > >> from __future__ import absolute_import >> >> Is there a way to check if this is working? I get the same results with >> or without it. >> >> Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) >> [MS

Re: from __future__ import absolute_import ?

2007-02-03 Thread Ron Adam
Peter Otten wrote: > Ron Adam wrote: > >> >> work >> | >> |- foo.py# print "foo not in bar" >> | >> `- bar >> | >> |- __init__.py >> | >> |- foo.py# print "foo in

Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Ron Adam
Stef Mientki wrote: >> Do you mean something like that? >> > import some_module >> Traceback (most recent call last): >> File "", line 1, in ? >> ImportError: No module named some_module > import sys > sys.path.append("..") > import some_module > Rob, > thank you very much, > that

Re: from __future__ import absolute_import ?

2007-02-09 Thread Ron Adam
Peter Otten wrote: > Ron Adam wrote: > >> Peter Otten wrote: >>> Ron Adam wrote: >>> >>>> work >>>> | >>>> |- foo.py# print "foo not in bar" >>>> | >>>> `- bar

Re: MS VC++ Toolkit 2003, where?

2006-04-24 Thread Ron Adam
Alex Martelli wrote: > "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > >> Alex Martelli wrote: >>> As suggested to me by David Rushby 10 hours ago, >>> >>> http://www.microsoft.com/downloads/details.aspx?FamilyId=272BE09D-40BB-4 >>> 9FD-9CB0-4BFA122FA91B&displaylang=en >>> >>> does work. >> Can you

Re: MS VC++ Toolkit 2003, where?

2006-04-25 Thread Ron Adam
Alex Martelli wrote: > Ron Adam <[EMAIL PROTECTED]> wrote: >... >> I still get the following with the tinyurl link: >> >> ~~~ >> The download you requested is unavailable. If you continue to see this >> message when trying to access this download, go

time.time or time.clock

2008-01-13 Thread Ron Adam
I'm having some cross platform issues with timing loops. It seems time.time is better for some computers/platforms and time.clock others, but it's not always clear which, so I came up with the following to try to determine which. import time # Determine if time.time is better than t

Re: time.time or time.clock

2008-01-13 Thread Ron Adam
John Machin wrote: > On Jan 14, 7:05 am, Ron Adam <[EMAIL PROTECTED]> wrote: >> I'm having some cross platform issues with timing loops. It seems >> time.time is better for some computers/platforms and time.clock others, but > > Care to explain why it seems

Re: time.time or time.clock

2008-01-13 Thread Ron Adam
Fredrik Lundh wrote: > John Machin wrote: > >> AFAICT that was enough indication for most people to use time.clock on >> all platforms ... > > which was unfortunate, given that time.clock() isn't even a proper clock > on most Unix systems; it's a low-resolution sample counter that can > happi

Re: Intra-package References?? (again)

2008-01-29 Thread Ron Adam
[EMAIL PROTECTED] wrote: > Hi Python list, > > I have been struggleling with this before, but have never been able to > find a good solution. > The thing I dont understand is, I follow the guide here: > http://docs.python.org/tut/node8.html#SECTION00842 > And have the same setup

Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Ron Adam
Fredrik Lundh wrote: > Tim Parkin wrote: >> Also 'Foundation' could be confused with 'beginners' or 'basic'. > > while "PSF" is completely incomprehensible for someone who doesn't > already know what it is... why even keep it on the front page ? Looks like a good place for a tool tip, PSF is o

Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Ron Adam
Fredrik Lundh wrote: > Ron Adam wrote: > >> I think the PSF is important enough to have a link on *every* page. It >> doesn't need a lot of space, but it should be easy to get to from >> anywhere on the web site. > > a copyright blurb at the bottom of the page

Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Ron Adam
[EMAIL PROTECTED] wrote: > richard wrote: > [snip] > Should the "Python Cheeseshop" have anything in it, though? Having a > stocked cheese shop in relation to Python is just silly! Cheese (or the lack of cheese) is never silly, Thus the slogan... "The power of cheese". Now if you want silliness

Re: pretty print, tidy, reindent.py

2006-03-15 Thread Ron Adam
kpp9c wrote: > What ever happened to reindent.py ? This used to be part of the > distribution. Does it still work with modern versions of python? > > A lot of the code i drag off here (even if i use "show original"!) > comes out all messed up and i end up having to clean a lot of it up. I > wonder

Re: My Generator Paradox!

2006-03-17 Thread Ron Adam
Robert Kern wrote: > vbgunz wrote: >> I believe I understand now. the yield keyword is sort of like a cousin >> to return. return will bring back an object I can work with and so does >> yield *but* yield's object will most likely support the .next() method. > > No, that's not really how it works.

Re: My Generator Paradox!

2006-03-17 Thread Ron Adam
vbgunz wrote: > OK. I hope my understanding of the yield keyword and generators in a > general sense are now better understood. When a generator function is > assigned to an identifier, no code is executed and a generator is > immediately returned. When the next() method is called on the new > gene

Re: strange math?

2006-03-18 Thread Ron Adam
[EMAIL PROTECTED] wrote: f(01) > 43 f(02) > 44 f(010) > 50 42+010 > 50 > > The first f(01) was a mistake. I accidentally forgot to delete the > zero, but to my suprise, it yielded the result I expected. So, I tried > it again, and viola, the right answer. So, I decided to r

Re: Can I use a conditional in a variable declaration?

2006-03-19 Thread Ron Adam
[EMAIL PROTECTED] wrote: > I've done this in Scheme, but I'm not sure I can in Python. > > I want the equivalent of this: > > if a == "yes": >answer = "go ahead" > else: >answer = "stop" > > in this more compact form: > > > a = (if a == "yes": "go ahead": "stop") > > > is there such

Re: Initializing a list of lists

2006-03-19 Thread Ron Adam
[EMAIL PROTECTED] wrote: > I want to create a list of lists, each of which is identical, but which > can be modified independently i.e: > x = [ [0], [0], [0] ] x[0].append(1) x > [[0, 1], [0], [0]] > > The above construct works if I have only few items, but if I have many, > I'd pr

Re: Is there such an idiom?

2006-03-19 Thread Ron Adam
Per wrote: > http://jaynes.colorado.edu/PythonIdioms.html > > """Use dictionaries for searching, not lists. To find items in common > between two lists, make the first into a dictionary and then look for > items in the second in it. Searching a list for an item is linear-time, > while searching a

Re: Is there such an idiom?

2006-03-19 Thread Ron Adam
Per wrote: > Thanks Ron, > surely set is the simplest way to understand the question, to see > whether there is a non-empty intersection. But I did the following > thing in a silly way, still not sure whether it is going to be linear > time. > def foo(): > l = [...] > s = [...] > dic =

Re: ** Operator

2006-03-20 Thread Ron Adam
Christoph Zwerschke wrote: > Alex Martelli wrote: >> Sathyaish wrote: >> >>> I tried it on the interpreter and it looks like it is the "to the power >>> of" operator symbol/function. Can you please point me to the formal >>> definition of this operator in the docs? >> >> http://docs.python.org/ref/

Re: TaskQueue

2006-03-21 Thread Ron Adam
Raymond Hettinger wrote: > I would like to get feedback on an idea I had for simplifying the use > of queues with daemon consumer threads > > Sometimes, I launch one or more consumer threads that wait for a task > to enter a queue and then work on the task. A recurring problem is that > I sometime

Re: Accessing func_name from inside a function

2006-03-26 Thread Ron Adam
Alex Martelli wrote: > Personally, I'd rather have a 3.0 keyword referring to "the current > object" (module for module toplevel code, class for classbody toplevel > code, function for code within a function) -- say for the sake of > argument the keyword is 'current'; this would allow current.__na

Re: Accessing func_name from inside a function

2006-03-26 Thread Ron Adam
Alex Martelli wrote: > Ron Adam <[EMAIL PROTECTED]> wrote: > >> A "Current" key word would fix this. Or possibly "This" which would be >> short for "This object". > > I think "This" would cause huge confusion, since in oth

Re: any() and all() on empty list?

2006-03-28 Thread Ron Adam
Paul McGuire wrote: > "Paul Rubin" wrote in message > news:[EMAIL PROTECTED] > To my mind, the *meaning* of all() is that every element in the list asserts > True. But this is with an initial assumption that all() is False, unless I > test every value and find them to b

Re: any() and all() on empty list?

2006-03-29 Thread Ron Adam
Paul Rubin wrote: > Ron Adam <[EMAIL PROTECTED]> writes: >> In this view and empty set can be True for all(). Is it posible >> 'all([])' is undefined? Here, none() and all() return contradicting >> values. So maybe the correct version may be... > >

Re: any() and all() on empty list?

2006-03-29 Thread Ron Adam
Paul Rubin wrote: > Ron Adam <[EMAIL PROTECTED]> writes: >> Just thinking about things. I really just want what is best for >> Python in the long term and am not trying to be difficult. > > I'm sorry, maybe it's the math geek in me, but I just see all tho

Re: any() and all() on empty list?

2006-03-29 Thread Ron Adam
Carl Banks wrote: > Steve R. Hastings wrote: >> I'm completely on board with the semantics for any(). But all() bothers >> me. If all() receives an empty list, it will return True, and I don't >> like that. To me, all() should be a more restrictive function than any(), >> and it bothers me to se

Re: any() and all() on empty list?

2006-03-30 Thread Ron Adam
Duncan Booth wrote: > Ron Adam wrote: > >> Where we are assembling widgets in a manufacturing plant. Where we don't >> want to go to the next step until *all* the sub parts are present. >> >> if all(part.status == 'present' for part in unit): >

Re: any() and all() on empty list?

2006-03-30 Thread Ron Adam
Steven D'Aprano wrote: > Paul Rubin wrote: > >> Steven D'Aprano <[EMAIL PROTECTED]> writes: >> >>> Think of it this way: if all(seq) is true, shouldn't it be the case >>> that you can point to a specific element in seq that is true? >> >> >> No, all(seq) is true if you can't point to a specific el

Re: any() and all() on empty list?

2006-03-30 Thread Ron Adam
Ron Adam wrote: > > hasall(S, True, lambda n: n=42) > That was suppose to be: hasall(S, True, lambda n: n==42) -- http://mail.python.org/mailman/listinfo/python-list

Re: any() and all() on empty list?

2006-03-30 Thread Ron Adam
Carl Banks wrote: > In Python, yes and no are the only possible answers. Probably the only > analogous thing you could do in Python would be for all() to raise > ValueError when passed an empty sequence. There is also 'None' which serves a similar purpose of indicating an invalid value when pas

Re: any() and all() on empty list?

2006-03-31 Thread Ron Adam
Carl Banks wrote: > Ron Adam wrote: >> Carl Banks wrote: >> >>> In Python, yes and no are the only possible answers. Probably the only >>> analogous thing you could do in Python would be for all() to raise >>> ValueError when passed an empty sequen

Re: proposed proposal: set.values()

2006-03-31 Thread Ron Adam
Paul Rubin wrote: > "Terry Reedy" <[EMAIL PROTECTED]> writes: >> 1. It is pure duplication that *adds* keystrokes. >> > Nobody says you shouldn't use list(s) if you know you're dealing with > a set. The idea of s.values() is so you can duck-type between dicts > and sets. You could just do the fol

Re: any() and all() on empty list?

2006-04-01 Thread Ron Adam
Steve R. Hastings wrote: > On Fri, 31 Mar 2006 16:29:00 -0800, Paul Rubin wrote: >> I think "S and all(S)" is the right way to express that, if that's >> what's intended. > > I still would like a standard function, because "S and all(S)" does not > work with iterators. I proposed one possible fun

Re: any() and all() on empty list?

2006-04-01 Thread Ron Adam
Steve R. Hastings wrote: > Here is a function called "tally()". It reduces a list to a dictionary > of counts, with one key for each value from the list. The value for > each key is the count of how many times it appeared in the list. > > > def tally(seq, d=None): > if d == None: >

Re: any() and all() on empty list?

2006-04-01 Thread Ron Adam
Steve R. Hastings wrote: > On Sat, 01 Apr 2006 14:35:58 -0300, Felipe Almeida Lessa wrote: >> Two changes: >> - Use "is None". >> - Use "try ... except" instead of "in" > > Yes. > > >> Maybe you don't like my version, and the gains aren't that much, but >> please use "is None" instead of "== N

Re: any() and all() on empty list?

2006-04-01 Thread Ron Adam
Ron Adam wrote: > Steve R. Hastings wrote: >> This neatly replaces truecount(), and you can use it for other things as >> well. > > if True in talley(S): do_somthing() > > Works for me... ;-) > > > Cheers, > Ron Actulley talley isn&#

xml element tree to html problem

2006-04-04 Thread Ron Adam
I'm new to element tree and haven't been able to find a simple solution to this problem yet. So maybe someone can point me in the right direction. I have an element tree structure of nested elements that I want to convert to html as nested definition and unordered lists in the following way.

Re: xml element tree to html problem

2006-04-04 Thread Ron Adam
Fredrik Lundh wrote: > here's one way to do it: > > import cElementTree as ET > > tree = ET.XML(""" > > ball > > red > large > > > """) > > MAP = { > "object": ("dl", "object"), > "name": ("dt", "name"

Re: Python Module for Determining CPU Freq. and Memory?

2006-04-06 Thread Ron Adam
efrat wrote: > Hello, > > I'd like to determine at runtime the computer's CPU frequency and memory. > > Is there a module for these types of queries? platform.platform returns > the computer's CPU name and type, but not its frequency; nor does it > report how much memory the computer has. I

Re: pre-PEP: The create statement

2006-04-06 Thread Ron Adam
> Abstract > > > This PEP proposes a generalization of the class-declaration syntax, > the ``create`` statement. The proposed syntax and semantics parallel > the syntax for class definition, and so:: > >create : > > > is translated into the assignment:: > > = ("", ,

Re: good style guides for python-style documentation ?

2006-04-06 Thread Ron Adam
> (reposted from doc-sig, which seems to be mostly dead > these days). > > over at the pytut wiki, "carndt" asked: > > Are there any guidelines about conventions concerning > punctuation, text styles and language style (e.g. how > to address the reader)? > > any suggestions from this

Appending Elements in Element Tree

2006-04-07 Thread Ron Adam
In my program I have a lot of statements that append elements, but sometimes I don't want to append the element so it requres an if statement to check it, and that requires assigning the returned element from a function to a name or calling the funtion twice. e = ET.Element('name') e

Re: how you know you're a programming nerd

2006-04-07 Thread Ron Adam
When you are working on your programming project on Friday night instead of going out. When you do go out, you look forward to getting home so you can work on your programming project some more. -- http://mail.python.org/mailman/listinfo/python-list

Re: how you know you're a programming nerd

2006-04-08 Thread Ron Adam
John Salerno wrote: > Ron Adam wrote: >> When you are working on your programming project on Friday night >> instead of going out. > > Ok, you win. :) > > Oh wait, it's Friday night and I'm typing this message...dang it! Yep, Hah Hah... No

Re: Appending Elements in Element Tree

2006-04-08 Thread Ron Adam
Ron Adam wrote: > > In my program I have a lot of statements that append elements, but > sometimes I don't want to append the element so it requres an if > statement to check it, and that requires assigning the returned element > from a function to a name or calli

Re: calculating system clock resolution

2006-04-08 Thread Ron Adam
Steven D'Aprano wrote: > On Fri, 07 Apr 2006 16:39:40 -0700, jUrner wrote: > >> Maybe it was not too clear what I was trying to point out. >> >> I have to calculate the time time.time() requires to return the next >> tick of the clock. >> Should be about 0.01ms but this may differ from os to os. >

Re: python admin abuse complaint

2010-02-06 Thread Ron Adam
Xah Lee wrote: For anyone reading this thread and interested in my opinions, i have written many essays related to this and netiquette. Many of which detail other similar incidences that i personally experienced, such as freenode's irc ban in #emacs channel. If you are interested, they can be

<    1   2   3   4