Collate Module

2006-10-23 Thread Ron Adam
will 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. Class: Collate(option_string

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

2006-10-22 Thread Ron Adam
they succeed. There is also the view point of informal groups of individuals working separately but having a significant combined effect. This is probably the more common situation. But not as common as the viewpoint you've stated above unfortunately. Cheers, Ron Never thought having

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

2006-10-21 Thread Ron Adam
, 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: 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 it hard to capture the output for further analysis.) I

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 recent call last):

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++. This isn't

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 settings. Application can actually use something else and you will overwrite that. You can also affect

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 that. You can also affect (unexpectedly to the application

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 flags: self.txtable.append

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 how they get sorted. Then define options CAPS_FIRST

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 Thank you, Ron, for the input :) I'll examine also

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

2006-10-19 Thread Ron Adam
'[reverser] 'gfedcba' Ron -- http://mail.python.org/mailman/listinfo/python-list

Flexable Collating (feedback please)

2006-10-18 Thread Ron Adam
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 module. Collation can be modified

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

Re: [OT] a little about regex

2006-10-18 Thread Ron Adam
you know your filters are working as designed? Another approach would be to assign values for filtered, accepted, and undefined and set those accordingly instead of incrementing and decrementing a counter. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: How to convert this list to string?

2006-10-18 Thread Ron Adam
' 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: 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. ,,, def __call__(self, a, b): This allows

Re: Flexible Collating (feedback please)

2006-10-18 Thread Ron Adam
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_SPACE - Don't ignore

Re: Flexable Collating (feedback please)

2006-10-18 Thread Ron Adam
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 there. Cheers and thanks, Ron [EMAIL

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',

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. if self.flag CAPS_FIRST: s

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. Most examples of sorting usually sort on the ord() order of the character

Re: Need a strange sort method...

2006-10-17 Thread Ron Adam
: yield s return list(iterinner(sequence)) Cheers, Ron Adam -- http://mail.python.org/mailman/listinfo/python-list

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 obtaining it, such as the hackish sum([a[i::chunk_size] for i

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,

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 that is not always what you want. Check

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 with certain 1-3d elements oriented in 3d space with dashed

Re: 3D Vector Type Line-Drawing Program

2006-10-10 Thread Ron Adam
? 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 a look

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 =

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()) Don't

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 around

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 a CGI environment, and that's why cgi.parse() isn't working. Clearly. So what

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: But basically, you aren't providing a CGI environment, and that's why cgi.parse() isn't working

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) and see what

Re: OO on python real life tutorial?

2006-09-02 Thread Ron Adam
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

Easy Validators

2006-08-20 Thread Ron Adam
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 is not an Int % arg def IsFloat

Re: String.digits help!!!

2006-08-09 Thread Ron Adam
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
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: help a newbie with a IDE/book combination

2006-07-12 Thread Ron Rogers Jr.
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: first book about python

2006-07-12 Thread Ron Rogers Jr.
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: 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 approach

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: 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 enviromental variable LANG=en_US.utf-8, then ssh should transfer

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: I'm using an OS X terminal to ssh to a Linux machine. In theory it should work out of the box. OS X

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: Ron Garret wrote: I'm using an OS X terminal to ssh to a Linux machine. In theory

WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
u'\xbd' u'\xbd' print _ Traceback (most recent call last): File stdin, 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: 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 stdin, line 1, in ? UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in position 0: ordinal not in range(128

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. What can I say? I can. B) Don't do that. OK. What should I do instead? C) It's not relevant

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: I forgot to mention: sys.getdefaultencoding() 'utf-8' A) You shouldn't be able to do

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 from the combobox. At the bottom you will see a combobox title Character 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: In article [EMAIL PROTECTED], Robert Kern [EMAIL PROTECTED] wrote: Ron Garret wrote: I

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 to the Search for a Download area on the Download

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-4BFA122FA91Bdisplaylang=en does work. Can you please try this again: I'm

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 wait, I'm here too. ;-) -- http://mail.python.org

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 calling the funtion twice. e

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. I suspect

Appending Elements in Element Tree

2006-04-07 Thread Ron Adam
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: 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: Python Module for Determining CPU Freq. and Memory?

2006-04-06 Thread Ron Adam
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 tasks, but this might be better for your use. Cheers, Ron from ctypes import

Re: pre-PEP: The create statement

2006-04-06 Thread Ron Adam
be... name = object(): block 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

Re: good style guides for python-style documentation ?

2006-04-06 Thread Ron Adam
? /F 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 be nice. Cheers, Ron -- http://mail.python.org/mailman

xml element tree to html problem

2006-04-04 Thread Ron Adam
them up. The problem I have is finding a relatively painless way to do the actual translation. Thanks in advance for any advise. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: xml element tree to html problem

2006-04-04 Thread Ron Adam
!* :-) This is what I needed. Now I can play with finding the best data structure along with what elements to translate each tag to. This is for a rewrite of PyDoc.py. I'm hoping it will be as easy to write to other formats from the XML as it is to html. Cheers, Ron -- http

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

2006-04-01 Thread Ron Adam
(), 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: any() and all() on empty list?

2006-04-01 Thread Ron Adam
= {} 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 in talley(S): do_somthing() Works for me... ;-) Cheers, Ron -- http

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

2006-04-01 Thread Ron Adam
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
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't needed for this... if True in S: do_domething() That's

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 sequence. There is also 'None' which serves a similar purpose

Re: proposed proposal: set.values()

2006-03-31 Thread Ron Adam
... 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-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): do_release() Oops! Some empty bins showed up

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

2006-03-30 Thread Ron Adam
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
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
passing arguments. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

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... I don't see any contradiction. all([]) and none

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 those suggestions about not not S as being contorted

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

2006-03-29 Thread Ron Adam
. 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): do_release() Oops! Some empty bins showed up at the next assembly station. ;-) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

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

2006-03-28 Thread Ron Adam
. 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 makes the most sense? Cheers, Ron -- http://mail.python.org/mailman/listinfo

Re: Accessing func_name from inside a function

2006-03-26 Thread Ron Adam
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

Advice for Python and Web Server/Services?

2006-03-26 Thread Ron Davis
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
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 other popular language the keyword this means (a pointer/reference to) the instance variable

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 a few

Re: TaskQueue

2006-03-21 Thread Ron Adam
within python C code, and not by python source code. If you know how to make a generator, then you would know how to do simple threads. And maybe anything needing more than this would be better off being an external task anyway? I'm sure there are lots of um... issues. ;-) Cheers, Ron

Re: ** Operator

2006-03-20 Thread Ron Adam
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: Can I use a conditional in a variable declaration?

2006-03-19 Thread Ron Adam
= {'a':'b', 'b':'a'} # define outside loop while 1: v = values[v] # alternate between 'a' and 'b' ... There are limits to this, both the keys and the values need to be hashable. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Initializing a list of lists

2006-03-19 Thread Ron Adam
= [[value]*x for i in xrange(y)] Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there such an idiom?

2006-03-19 Thread Ron Adam
in linear-time? I'm not sure if it works in linear time, but if there are no duplicates in each list, sets would be the easiest way to do these with. s = set([1,2,3,4,5,6]) t = 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

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: My Generator Paradox!

2006-03-17 Thread Ron Adam
() method is called again. Although there are times when I wish it could run (as a thread) until it reaches a yield and then continue after the next() method is called until it reaches the next yield. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: My Generator Paradox!

2006-03-17 Thread Ron Adam
, in ? StopIteration This is the signal to indicate iteration is finished. You don't see it when you are using generators as iterators because it's usually caught by the object or statement using the generator. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: pretty print, tidy, reindent.py

2006-03-15 Thread Ron Adam
if there is a reformatter/pretty printer that like perl tidy that might help. I see i have tabnanny, but that only complains... i want something that fixes automagically. -kp8-- What you're looking for is in Python24/Tools/Scripts directory. Cheers, Ron -- http://mail.python.org/mailman

Re: Is this possible in Python?

2006-03-13 Thread Ron Garret
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: Hi I wonder if Python is capable of the following: define a function which returns its argument. I mean: def magic_function(arg): .. some magic code ... that behaves the following way: assert

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

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 would be one obvious place to put it. Yes

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

2006-03-12 Thread Ron Adam
, then the correct establishment for that is The Ministry of Silly Walks. ;) Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: sort one list using the values from another list

2006-02-28 Thread Ron Adam
[EMAIL PROTECTED] wrote: Following Ron Adam solution (and using [] instead of list() in the last line), this may be a possible solution of the problem, that is often quite fast: def psort16(s1, s2): try: d = dict(izip(s2, s1)) except TypeError: _indices = range

Re: sort one list using the values from another list

2006-02-27 Thread Ron Adam
Ron Adam wrote: Alex Martelli wrote: Ron Adam [EMAIL PROTECTED] wrote: ... Considering the number time I sort keys after getting them, It's the behavior I would prefer. Maybe a more dependable dict.sortedkeys() method would be nice. ;-) sorted(d) is guaranteed to do exactly the same

Re: sort one list using the values from another list

2006-02-27 Thread Ron Adam
Scott David Daniels wrote: Ron Adam wrote: Ron Adam wrote: This probably should be: def psort11(s1, s2): d = dict(zip(s2,s1)) assert len(d) == len(s1) s1[:] = list(d[v] for v in sorted(d)) You could do this to avoid all of those lookups: def psort_xx(s1, s2

<    1   2   3   4   5   6   7   8   9   10   >