Re: Py3K idea: why not drop the colon?

2006-11-13 Thread Ron Adam
Michael Hobbs wrote: > Ron Adam wrote: >> [EMAIL PROTECTED] wrote: >> >>> >>>>> I'm not sure why '\'s are required to do multi-line before the >>> colon. >>> >>>> Special cases aren't special en

Re: Py3K idea: why not drop the colon?

2006-11-13 Thread Ron Adam
Michael Hobbs wrote: > Ron Adam wrote: >> LOL, of course it would. I would expect that too after a suitable amount >> of >> 'brain washing', oops, I mean training and conditioning. ;-) >> > Trust me, my brain is quite filthy and doesn't wash ea

Re: Py3K idea: why not drop the colon?

2006-11-11 Thread Ron Adam
>>> A bit of a circular answer. > >>> > >>> Why the rule? -> So not to break the rule? > >> > >> You proposed to allow leaving off line continuation '\' only in the > >> "if", "for&qu

Re: Py3K idea: why not drop the colon?

2006-11-11 Thread Ron Adam
Georg Brandl wrote: > Ron Adam wrote: >> Georg Brandl wrote: >>> Ron Adam wrote: >>>> Michael Hobbs wrote: >>>> >>>>> The same problem that is solved by not having to type parens around the >>>>> 'if' condition

Re: Py3K idea: why not drop the colon?

2006-11-11 Thread Ron Adam
Georg Brandl wrote: > Ron Adam wrote: >> Michael Hobbs wrote: >> >>> The same problem that is solved by not having to type parens around the >>> 'if' conditional, a la C and its derivatives. That is, it's unnecessary >>> typing to

Re: Py3K idea: why not drop the colon?

2006-11-11 Thread Ron Adam
Steven D'Aprano wrote: > On Sat, 11 Nov 2006 01:13:03 -0600, Ron Adam wrote: > >> Steven D'Aprano wrote: >>> On Fri, 10 Nov 2006 21:24:50 +0100, Bjoern Schliessmann wrote: >>> >>>> Marc 'BlackJack' Rintsch wrote: >>>> >&

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Ron Adam
Paul Boddie wrote: > Ron Adam wrote: >> PS. Rather than shav of on character her and ther in pythons programing >> languag, Lets remov all the silent leters from the english languag. That will >> sav thousands mor kestroks over a few yers. > > How about changing Pyt

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Ron Adam
t; x == blue or x == red or x == yellow Maybe it should have been expressed as: x == (blue or red or yellow) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Ron Adam
Michael Hobbs wrote: > Ron Adam wrote: >> It is also an outline form that frequently used in written languages. >> Something >> python tries to do, is to be readable as if it were written in plain >> language >> where it is practical to do so. So the c

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Ron Adam
Michael Hobbs wrote: > Ron Adam wrote: >> The faq also pointed out a technical reason for requiring the colon. It >> makes >> the underlying parser much easier to write and maintain. This shouldn't be >> taken to lightly in my opinion, because a simpler easer t

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Ron Adam
re reliable python parser means development time can be spent improving the language in other areas instead of fixing parsing problems every time a new feature is added that might be used in a conditional expression. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Style for modules with lots of constants

2006-11-01 Thread Ron Adam
rted or initialized. It avoids having to type namespace prefixes such as thismod.textmode, or myclass.textmode or importing a bunch of values into global name space. Strings comparisons in python are very fast. The disadvantage is an invalid flag may pass silently unless you do some sort of validation which may slow things down a bit. Ron -- http://mail.python.org/mailman/listinfo/python-list

Collate Module

2006-10-23 Thread Ron Adam
ll be appreciated. Any minor improvements to wording, spelling, etc.. are also welcome. Many thanks for all the terrific feed back and suggestions! Cheers, Ron ---start--- """ Collate.py - Sorts lists of strings in various ways depending options and locale.

Re: PSF Infrastructure has chosen Roundup as the issue tracker for Python development

2006-10-22 Thread Ron Adam
t. This is probably the more common situation. But not as common as the viewpoint you've stated above unfortunately. Cheers, Ron > Never thought having a small philosophical conversion with Margaret > Mead beyond time and space. So many thanks to great Google and its > devotees. > > Kay -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't this work?

2006-10-21 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Larry Bates <[EMAIL PROTECTED]> wrote: > Because datetime is a new-style class: Ah. > The Constructor __new__ > > If you are like me, then you probably always thought of the __init__ method > as > the Python equivalent of what is called a constructor in C++. Th

Why doesn't this work?

2006-10-21 Thread Ron Garret
Python 2.3.5 (#1, Jan 30 2006, 13:30:29) [GCC 3.3 20030304 (Apple Computer, Inc. build 1819)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from datetime import datetime >>> class ts(datetime): ... def __init__(self): pass ... >>> ts() Traceback (most rece

Re: invert or reverse a string... warning this is a rant

2006-10-21 Thread Ron Adam
Steven D'Aprano wrote: > On Sat, 21 Oct 2006 01:58:33 -0500, Ron Adam wrote: > >> [You said from an earlier post...] >> >>> (That's a complaint I have about the dis module -- it prints its results, >>> instead of returning them as a string. That makes

Re: invert or reverse a string... warning this is a rant

2006-10-21 Thread Ron Adam
to account some newer 2.5 features and the tests will need to be updated so they retrieve dis's output instead of redirecting stdout. If you'd like to finish it up and submit it as a patch, I can forward it to you. It would be good to have a second set of eyes look at it also. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Flexible Collating (feedback please)

2006-10-20 Thread Ron Adam
Leo Kislov wrote: > Ron Adam wrote: >> Leo Kislov wrote: >>> Ron Adam wrote: >>> >>>> locale.setlocale(locale.LC_ALL, '') # use current locale settings >>> It's not current locale settings, it's user's locale setting

Re: invert or reverse a string... warning this is a rant

2006-10-19 Thread Ron Adam
>>> reverser = slice(None, None, -1) >>> >>> 'abcdefg'[reverser] 'gfedcba' Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: [OT] a little about regex

2006-10-19 Thread Ron Adam
Fulvio wrote: > *** > Your mail has been scanned by InterScan MSS. > *** > > > On Wednesday 18 October 2006 15:32, Ron Adam wrote: > >> |Instead of using two separate if's, Use an if - elif and be sure to test > > T

Re: Flexable Collating (feedback please)

2006-10-19 Thread Ron Adam
Gabriel Genellina wrote: > At Wednesday 18/10/2006 21:36, Ron Adam wrote: >> Maybe changing the CAPS_FIRST to REVERSE_CAPS_ORDER would do? > > At least it's a more accurate name. > There is an indirect way: test locale.strcoll("A","a") and see

Re: Flexible Collating (feedback please)

2006-10-19 Thread Ron Adam
[EMAIL PROTECTED] wrote: > Ron Adam: > > Insted of: > > def __init__(self, flags=[]): > self.flags = flags > self.numrex = re.compile(r'([\d\.]*|\D*)', re.LOCALE) > self.txtable = [] > if HYPHEN_AS_SPACE in flag

Re: Flexible Collating (feedback please)

2006-10-19 Thread Ron Adam
Leo Kislov wrote: > Ron Adam wrote: > >> locale.setlocale(locale.LC_ALL, '') # use current locale settings > > It's not current locale settings, it's user's locale settings. > Application can actually use something else and you will overwrite &g

Re: Flexable Collating (feedback please)

2006-10-18 Thread Ron Adam
Gabriel Genellina wrote: > At Wednesday 18/10/2006 03:42, Ron Adam wrote: > >> I put together the following module today and would like some feedback >> on any >> obvious problems. Or even opinions of weather or not it is a good >> approach. >>

Re: Flexable Collating (feedback please)

2006-10-18 Thread Ron Adam
This is how I changed it... (I edited out the test and imports for posting here.) locale.setlocale(locale.LC_ALL, '') # use current locale settings class Collate(object): """ A general purpose and configurable collator class. """ options = [ 'CAPS_FIRST', 'NUMERICAL', 'HYPHEN

Re: Flexable Collating (feedback please)

2006-10-18 Thread Ron Adam
ntage of the list is it can be iterated without splitting first. But that's a minor thing. self.options = options.lower().split(' ') fixes that easily. Once I'm sure it's not going to get any major changes I'll post this as a recipe. I think it's almost ther

Re: Flexible Collating (feedback please)

2006-10-18 Thread Ron Adam
rings and tests were made. Any feedback is welcome. Cheers, Ron """ Collate.py A general purpose configurable collate module. Collation can be modified with the following keywords: CAPS_FIRST -> Aaa, aaa, Bbb, bbb HYPHEN_AS

Re: Flexable Collating (feedback please)

2006-10-18 Thread Ron Adam
[EMAIL PROTECTED] wrote: > > On Oct 18, 2:42 am, Ron Adam <[EMAIL PROTECTED]> wrote: >> I put together the following module today and would like some feedback on any >> obvious problems. Or even opinions of weather or not it is a good approach. > ,,, >

Re: How to convert this list to string?

2006-10-18 Thread Ron Adam
anks Just to be different from the other suggestions... >>> a = [1, 2, 3] >>> str(a[1:]).strip('[]').replace(',', '') '2 3' By the way. It's a good idea to try not to use 'list' or other built-in names for your own objects. Best to start with good habits so that you avoid odd hard to find bugs later. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: [OT] a little about regex

2006-10-18 Thread Ron Adam
hem in the correct order) That way it will skip the more general filter and not increment cnt twice. It's not exactly clear on what output you are seeking. If you want 0 for not filtered and 1 for filtered, then look to Freds Hint. Or are you writing a test at the moment, a

Re: Flexable Collating (feedback please)

2006-10-18 Thread Ron Adam
always find a few obvious glitches right after I post something. ;-) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Flexable Collating (feedback please)

2006-10-17 Thread Ron Adam
ed this in *anything* yet, so don't plug it into production code of any type. I also haven't done any performance testing. See the doc tests below for examples of how it's used. Cheers, Ron Adam """ Collate.py A general purpose configurable collate

Re: Need a strange sort method...

2006-10-17 Thread Ron Adam
Ron Adam wrote: > Neil Cerutti wrote: >> On 2006-10-16, Tim Chase <[EMAIL PROTECTED]> wrote: >>> If you need it in a flat list, rather than as a list of >>> chunk_size lists (which are handy for iterating over in many >>> cases), there are ways of obtain

Re: Need a strange sort method...

2006-10-17 Thread Ron Adam
sequence as a list. """ def iterinner(seq): for s in seq: if hasattr(s, '__iter__'): for i in iterinner(s): yield i else: yield s return list(iterinner(sequence)) Cheers, Ron Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Alphabetical sorts

2006-10-17 Thread Ron Adam
Neil Cerutti wrote: > On 2006-10-17, Ron Adam <[EMAIL PROTECTED]> wrote: >> Neil Cerutti wrote: >>> On 2006-10-16, Ron Adam <[EMAIL PROTECTED]> wrote: >>>> I have several applications where I want to sort lists in >>>> alphabetical order.

Re: Alphabetical sorts

2006-10-16 Thread Ron Adam
Neil Cerutti wrote: > On 2006-10-16, Ron Adam <[EMAIL PROTECTED]> wrote: >> I have several applications where I want to sort lists in >> alphabetical order. Most examples of sorting usually sort on >> the ord() order of the character set as an approximation. But >

Alphabetical sorts

2006-10-16 Thread Ron Adam
I have several applications where I want to sort lists in alphabetical order. Most examples of sorting usually sort on the ord() order of the character set as an approximation. But that is not always what you want. The solution of converting everything to lowercase or uppercase is closer, but

Re: 3D Vector Type Line-Drawing Program

2006-10-12 Thread Ron Adam
Scott David Daniels wrote: > Ron Adam wrote: >> Scott David Daniels wrote: >>> James Stroud wrote: >>>>> I'm looking for a program to do line-drawings in 3d, with output to >>>>> postscript or svg or pdf, etc. I would like to describe a scene

Re: 3D Vector Type Line-Drawing Program

2006-10-10 Thread Ron Adam
way to have the display show a wire frame image instead of shaded shapes? And with or without hidden line removal? Is there an easy way to convert a display to something that can be printed? Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Painless way to do 3D visualization

2006-10-08 Thread Ron Adam
Peter Beattie wrote: > Hey folks, > > I need to do the following relatively simple 3D programming: > > I want to convert data from four-item tuples into 3D co-ordinates in a > regular tetrahedron. Co-ordinates come in sequences of 10 to 20, and the > individual dots in the tetrahedron need to be

Re: BaseHTTPServer weirdness

2006-09-12 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> wrote: > I wouldn't necessarily say you are wrong here, It's just that the cgi > module has sort of "just growed", so it isn't conveniently factyored for > reusability in other contexts. Several people (including me) have taken >

Re: BaseHTTPServer weirdness

2006-09-11 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Damjan <[EMAIL PROTECTED]> wrote: > >> But basically, you aren't providing a CGI environment, and that's why > >> cgi.parse() isn't working. > > > > Clearly. So what should I be doing? > > Probably you'll need to read the source of cgi.parse_qs (like Steve did)

Re: BaseHTTPServer weirdness

2006-09-11 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Kent Johnson <[EMAIL PROTECTED]> wrote: > Steve Holden wrote: > > Ron Garret wrote: > >> In article <[EMAIL PROTECTED]>, > >> Steve Holden <[EMAIL PROTECTED]> wrote: > >> > >> > &

Re: BaseHTTPServer weirdness

2006-09-11 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > Steve Holden <[EMAIL PROTECTED]> wrote: > > > > > >>But basically, you aren't providing

Re: BaseHTTPServer weirdness

2006-09-11 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> wrote: > But basically, you aren't providing a CGI environment, and that's why > cgi.parse() isn't working. Clearly. So what should I be doing? Surely I'm not the first person to have this problem? I have managed to work aroun

Re: BaseHTTPServer weirdness

2006-09-11 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> wrote: > The normal way is > > s = cgi.parse() > > since the CGI script sees the client network socket (after consumption > of HTTP headers) as its standard input. Doesn't work. (I even tried sys.stdin=r.rfile; s=cgi.parse())

BaseHTTPServer weirdness

2006-09-11 Thread Ron Garret
I'm trying to figure out how to use BaseHTTPServer. Here's my little test app: = #!/usr/bin/python from BaseHTTPServer import * import cgi class myHandler(BaseHTTPRequestHandler): def do_GET(r): s = '' try: s = cgi.parse_qs(r.rfile.read(int(r.

Re: OO on python real life tutorial?

2006-09-02 Thread Ron Adam
and not a simulation where you would use OO to actually model the objects which can also work, but is much harder to do. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Parsing form input in a BaseHTTPServer

2006-09-01 Thread Ron Garret
I'm write a web server using BaseHTTPServer. It can't be a CGI because it has to do some weird server-push stuff as database updates come in. But I still need to process form inputs as if it were a CGI. But the cgi module only works in a CGI environment. Is there something with the equivale

Easy Validators

2006-08-20 Thread Ron Adam
xamples at the end) Cheers, Ron # - Some Simple Validators. def Any(arg): pass def IsNumber(arg): assert type(arg) in (int, long, float), \ "%r is not a number" % arg def IsInt(arg): assert type(arg) in (int, long), \ "%r

Re: String.digits help!!!

2006-08-09 Thread Ron Adam
ctions. It probably should be an attribute of the class. These are just guide lines of course, but by keeping them in mind, I do think it has helped me to abstain from writing cluttered class's. Maybe there are other guidelines like these that are helpful? Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Fastest Way To Loop Through Every Pixel

2006-07-29 Thread Ron Adam
ed to look at an image library that uses compiled C (or assembly) code to do the brute force work. It may also be possible to access your platforms directX or opengl library routines directly to do it. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: first book about python

2006-07-12 Thread Ron Rogers Jr.
e Python tutorials: I've got the Python version of How to Think Like a Computer Scientist: http://www.ibiblio.org/obp/thinkCSpy/ And Dive into Python (available online as well as paper): http://diveintopython.org/ Hope this helps. CronoCloud (Ron Rogers Jr.) -- http://mail.python.org/mailman/listinfo/python-list

Re: help a newbie with a IDE/book combination

2006-07-12 Thread Ron Rogers Jr.
probably a way to do that from within vim or emacs) As some suggested, as a beginner you don't need much of a super powered IDE. If I wasn't using IDLE, I'd be using vim or gvim. CronoCloud (Ron Rogers Jr.) -- http://mail.python.org/mailman/listinfo/python-list

Re: What is Expressiveness in a Computer Language

2006-06-19 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Marshall" <[EMAIL PROTECTED]> wrote: > The conversation I would *really* like to have is the one where we > discuss what all the differences are, functionally, between the two, > and what the implications of those differences are, without trying > to address which

Re: Python 411.

2006-06-13 Thread Ron Stephens
Steve, thanks for the note. The name Python411 comes from me copying my good friend Rob Walch, who named his podcast Podcast411, which is a popular show on which he interviews other podcasters like Adam Curry etc. He also has a book just published about podcasting. Ron Stephens -- http

Re: WTF? Printing unicode strings

2006-05-19 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Serge Orlov wrote: > > Ron Garret wrote: > > > In article <[EMAIL PROTECTED]>, > > > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > >

Re: WTF? Printing unicode strings

2006-05-19 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > > > Ron Garret wrote: > > >

Re: WTF? Printing unicode strings

2006-05-19 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > > > I'm using an OS X terminal to ssh to a Linux machine. > > > > > > In theory it should work out of the box. OS X terminal should set &

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > > > Ron Garret wrote: > > &g

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Robert Kern <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > > I'm using an OS X terminal to ssh to a Linux machine. > > Click on the "Terminal" menu, then "Window Settings...". Choose "Display&qu

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > Robert Kern <[EMAIL PROTECTED]> wrote: > > > > > Ron Garret wrote: > > &

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Robert Kern <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > > I forgot to mention: > > > >>>>sys.getdefaultencoding() > > > > 'utf-8' > > A) You shouldn't be able to do that. Wha

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > >>>> u'\xbd' > > u'\xbd' > >>>> print _ > > Traceback (most recent call last): > > File "", line

WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
>>> u'\xbd' u'\xbd' >>> print _ Traceback (most recent call last): File "", line 1, in ? UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in position 0: ordinal not in range(128) >>> -- http://mail.python.org/mailman/listinfo/python-list

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

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

Appending Elements in Element Tree

2006-04-07 Thread Ron Adam
ould wrap the append and do it this way... def eappend(e1, e2): if e2 is None: return e1 e1.append(e2) return e1 Then do... e = eappend(e, get_element(obj)) # Append if not None. But maybe there's a better way? Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: good style guides for python-style documentation ?

2006-04-06 Thread Ron Adam
reader)? > > any suggestions from this list ? > > Well there's: PEP 8 -- Style Guide for Python Code http://www.python.org/dev/peps/pep-0008/ But I presume you already know that one. It covers doc strings some, but not general documentation. A how-to on documenting would b

Re: pre-PEP: The create statement

2006-04-06 Thread Ron Adam
.. name = object(): This is a bigger change than adding the create keyword, (definitely not a pre-P3k item), and I'm not sure if it fits your use case, but it does allow for a larger variety of types without adding additional keywords. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

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

2006-04-06 Thread Ron Adam
t For looking at memory on windows you might be able to make improvements to this class I wrote. I was going to add memget() methods for getting individual items, but it wasn't as useful as I was hoping it would be in checking my python memory use. For that I need info on individual ta

Re: xml element tree to html problem

2006-04-04 Thread Ron Adam
uot;size": ("li", "size"), > } > > for elem in tree.getiterator(): > elem.tag, klass = MAP[elem.tag] > if klass: > elem.set("class", klass) > > print ET.tostring(tree) Thanks a *LOT!* :-) This is w

xml element tree to html problem

2006-04-04 Thread Ron Adam
t html tag. 'object' is always mapped to , 'name' is always mapped to . etc... So I will probably have a dictionary to look them up. The problem I have is finding a relatively painless way to do the actual translation. Thanks in advance for any advise. Cheers, R

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&#

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

2006-04-01 Thread Ron Adam
comments. > > Ideally there should be an official tally() function in some module in > Python, and then we can just use it and not worry about how to write it. :-) And it's a good candidate to be written in C as well. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

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

2006-04-01 Thread Ron Adam
d=None): > if d == None: > d = {} > > for x in seq: > if x in d: > d[x] += 1 > else: > d[x] = 1 > return d > > > This neatly replaces truecount(), and you can use it for other things as > well. if True

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

2006-04-01 Thread Ron Adam
ions for a better name. How about: countall(S, value=True) Considering len() is used to get a length, and countall() is related to all(), but it's explicit about what it's counting and would not return True on an empty set. I think it would be useful. true_count, count = countall(S), len(S) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: proposed proposal: set.values()

2006-03-31 Thread Ron Adam
etween dicts > and sets. You could just do the following... >>> class vset(set): ... values = set.copy ... >>> s = vset([1,2,3]) >>> s.values() vset([1, 2, 3]) >>> for x in s.values(): ... x ... 1 2 3 Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

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: any() and all() on empty list?

2006-03-30 Thread Ron Adam
invalid value when passing arguments. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

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
hasall(S, value, test=None) hasall(S, True) # Test for actual "True" values or 1. hasall(S, True, bool) # test for true values, not zero or False. hasall(S, 'ok') hasall(S, True, lambda n: n=42) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

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-29 Thread Ron Adam
()'. if not any(bug.status == 'open' for bug in bugs_filed): do_release() So to give a counter example... 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 == &#x

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
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-28 Thread Ron Adam
'all([])' is undefined? Here, none() and all() return contradicting values. So maybe the correct version may be... def all(S): if S == []: return False for x in S: if x return True return False I think a few valid actual use case examples could clear it up. What

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

Advice for Python and Web Server/Services?

2006-03-26 Thread Ron Davis
m so straight Python would be great if I can get it working. Thanks for any advice you can give. -- Ron Davis -- Ron Davis -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessing func_name from inside a function

2006-03-26 Thread Ron Adam
is" which would be short for "This object". This may also relate to suggestions to reduce the need for having self in the argument list of methods. So if a keyword "This" could mean this method or function, then "Self" could mean this class. Hmmm, methods that use "Self" in this way might run into problems, but I havn't had enough coffee to think it though. ;-) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: __slots__

2006-03-25 Thread Ron Garret
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Alex Martelli) wrote: > > One other question I did not get answered: is there any > > simple example of a Pythonic use of __slots__ that does NOT > > involve the creation of **many** instances. > > Since the only benefit of __slots__ is saving

Re: TaskQueue

2006-03-21 Thread Ron Adam
eing an external task anyway? I'm sure there are lots of um... issues. ;-) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: ** Operator

2006-03-20 Thread Ron Adam
". If it's hard to read and understand, then that can and should be fixed. It probably should be moved to a position before the library reference manual and after the tutorial. Looking over the language reference manual will help in understanding the library reference manual I think. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

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 = [...] >

Re: Is there such an idiom?

2006-03-19 Thread Ron Adam
= set([4,5,6,7,8,9]) >>> s.intersection(t) set([4, 5, 6]) >>> len(s.intersection(t)) 3 Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   7   8   >