Re: NYLUG meeting: The Python Object Model with Alex Martelli & Google(open bar and food!)

2005-10-14 Thread Ron Guerin
Gregory Piñero wrote: > A reasonable question ... Sure is. ;) October 26, 2005 6:00pm - 10:00pm - Ron -- http://mail.python.org/mailman/listinfo/python-list

object inheritance and default values

2005-10-14 Thread Ron Adam
t I want to be able to have all the objects access alike? Hmmm.. I think maybe if if don't ever access shape (or Shape) directly in my data structure, then __new__ would work? So my first default object should be an instance of shape with a __new__ method to create more? Ok, off to try

Re: object inheritance and default values

2005-10-14 Thread Ron Adam
George Sakkis wrote: > "Ron Adam" <[EMAIL PROTECTED]> wrote: > > >>I'm trying to implement simple svg style colored complex objects in >>tkinter and want to be able to inherit default values from other >>previously defined objects. >> >&

tkinter drawing

2005-10-15 Thread Ron Adam
et me know what you think? Some of the things I want to add, but aren't exactly sure how at this time: Nested groups Use tags to be able to change sub items later Have items get attribues from the group if it doesn't have them Hope this isn't too long. Cheers, Ron

Re: dis.dis question

2005-10-16 Thread Ron Adam
Bengt Richter wrote: > On Sun, 09 Oct 2005 12:10:46 GMT, Ron Adam <[EMAIL PROTECTED]> wrote: >>Ron Adam wrote: >>It seems I've found a bug in dis.py, or maybe a expected non feature. >>When running dis from a program it fails to find the last traceback >>

Re: dis.dis question

2005-10-16 Thread Ron Adam
8 RETURN_VALUE > > Skip Thanks Skip, I had figured it out, but I like your example. >>> import dis >>> dis.dis('d\x01\x00GHd\x00\x00S') 0 LOAD_CONST 1 (1) 3 PRINT_ITEM 4 PRINT_NEWLINE

Re: Comparing lists

2005-10-16 Thread Ron Adam
k most programmers can switch styles to some degree if they need to. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing lists

2005-10-16 Thread Ron Adam
Christian Stapfer wrote: > "Ron Adam" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Christian Stapfer wrote: >> >> >>>This discussion begins to sound like the recurring >>>arguments one hears between theoretica

Re: Comparing lists - somewhat OT, but still ...

2005-10-16 Thread Ron Adam
mes incomplete as there are often other influences that will effect the outcome. So the you could say: don't *depend* on the completeness of your theoretical information, try to *verify* the validity of your results with experiments. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing lists

2005-10-16 Thread Ron Adam
Christian Stapfer wrote: > "Ron Adam" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Christian Stapfer wrote: >> >>>"Ron Adam" <[EMAIL PROTECTED]> wrote in message >>>news:[EMAIL PROTECTED] >>>

NYLUG meeting: 10/26 The Python Object Model with Alex Martelli & Google (open bar and food!)

2005-10-17 Thread Ron Guerin
picking up the tab for an hour and a half of open bar and food. Additionally, if you're looking for a job as a Python developer, bring your resume. Please RSVP at http://rsvp.nylug.org to attend, as seating is limited. PS: You may wish to bring ID and a GPG fingerprint for keysigning. - Ron

ordered keywords?

2005-10-17 Thread Ron Adam
comes close to the same pattern used in SVG and other formats where you have definitions before expressions. If I use keywords only, It won't keep the order, and if I use args before keywords, I have to pre-assign temporary 'None' values to the argumen

Re: ordered keywords?

2005-10-17 Thread Ron Adam
Diez B. Roggisch wrote: > Ron Adam wrote: > >> >> Is there a way to preserve or capture the order which keywords are given? >> >> >>> def foo(**kwds): >> ...print kwds >> ... >> >>> foo(one=1, two=2, three=3) >> {&#

Re: ordered keywords?

2005-10-17 Thread Ron Adam
Ron Adam wrote: > > def lamb(args): > for v in args: print v > > def feedlamb(): > print locals() > y = 20 > lamb( (lambda x=10: (x,y,x+y))() ) > print locals() > > feedlamb() > > {} > 10 > 20 > 30 > {'y': 20} &g

Re: ordered keywords?

2005-10-17 Thread Ron Adam
Kent Johnson wrote: > Ron Adam wrote: > >> drawshapes( triangle=3, square=4, color=red, >> polygon(triangle, color), >> polygon(square, color) ) >> >> This comes close to the same pattern used in SVG and other formats >> whe

Re: Vim capable IDE?

2005-10-18 Thread Ron Adam
still needs a little fine tuning. This is on windows, but it should work on linux with some minor changes. Cheers, Ron Add this to your python.vim file in your ftplugin directory. " Run a python script and get the output into a window. set switchbuf=useopen function! RunPython(rmode)

Tkinter or Python issue?

2005-10-18 Thread Ron Provost
'TBU', font=f2 ) In rerunning the code, I see each bit of text now styled differently. This is the behavior that I both expect and want. Does anybody know why the two bits of code result in different behavior? Is it a Python thing or a Tkinter thing? Thanks for your feedback. Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: question about timestamp and MySQLdb

2005-10-19 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Sean Berry" <[EMAIL PROTECTED]> wrote: > I am using MySQLdb to connect to a database and retrieve a timestamp from a > table. The problem is I want the timestamp as a long, unformatted and all. > > In the table I have a timestamp like this > 20051019111617 > >

multi-property groups?

2005-10-19 Thread Ron Adam
y to do it. So is there a better way? Is there a way to use properties to do this same thing? I'd also like a way to override the dictionary methods __getitem__, __setitem__, and __delitem__. (Or an equivalent) Cheers, Ron class Pobject(object): """ an ob

Re: multi-property groups?

2005-10-19 Thread Ron Adam
This is what I like about Python, there's almost always a way to do it. ;-) Here's an updated version that I think works, but it could use some review. Any way to make this better? Should grouped properties share references to objects? Cheers, Ron """ Group

Re: destroy your self????

2005-10-19 Thread Ron Adam
> foo Traceback (most recent call last): File "", line 1, in ? NameError: name 'foo' is not defined Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: destroy your self????

2005-10-20 Thread Ron Adam
James wrote: > Doesn't work for classes because self has no global reference. True. To make it work one would need to track instances and names and do comparisons... and so on. So it's not worth it. ;-) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: classmethods, class variables and subclassing

2005-10-21 Thread Ron Adam
self.states[1] = val def get_s2(self): return self.states[1] It keeps the states because the list isn't ever reassigned after it's created, so the values in it can change and all instances and subclasses can see the changed values. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to replace first word in string?

2005-10-22 Thread Ron Adam
Steven D'Aprano wrote: > def replace_word(source, newword): > """Replace the first word of source with newword.""" > return newword + " " + "".join(source.split(None, 1)[1:]) > > import time > def test(): > t = time.time() > for i in range(1): > s = replace_word("aa to

Re: Question about inheritance...

2005-10-22 Thread Ron Adam
has references to them. Could you explain a little better what you are doing. Since I'm working on the same (or similar) thing maybe we can share our results, (or efforts). Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to replace first word in string?

2005-10-22 Thread Ron Adam
Steven D'Aprano wrote: > On Sat, 22 Oct 2005 21:41:58 +0000, Ron Adam wrote: > > >>Don't forget a string can be sliced. In this case testing before you >>leap is a win. ;-) > > > Not much of a win: only a factor of two, and unlikely to hold in a

Re: Question about inheritance...

2005-10-22 Thread Ron Adam
exactly like it, but the closer it is to the way the SVG standard works, the better. That would make it easier to use some 'simple' existing SVG images, and easier to create SVG files as well, as it closes the gap between the canvas object and the VGA standard. Anyway, I'm more th

Re: best way to replace first word in string?

2005-10-22 Thread Ron Adam
[EMAIL PROTECTED] wrote: > interesting. seems that "if ' ' in source:" is a highly optimized code > as it is even faster than "if str.find(' ') != -1:' when I assume they > end up in the same C loops ? The 'in' version doesn't call a function and has a simpler compare. I would think both of th

namespace dictionaries ok?

2005-10-24 Thread Ron Adam
;, etc..) It just seems awkward to have to use "string keys" in this situation. This is easy and still retains the dictionary so it can be modified and passed to another function or method as kwds again. Any thoughts? Any better way to do this? Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: namespace dictionaries ok?

2005-10-24 Thread Ron Adam
) kwds.bob = 3 kwds.alice = 5 ... bar(**kwds) #<--- do something with changed items Ron > On Monday 24 October 2005 19:06, Ron Adam wrote: > >>Hi, I found the following to be a useful way to access arguments after >>they

Re: namespace dictionaries ok?

2005-10-24 Thread Ron Adam
gt; > > This is looking like foo should be a method of Context now, > but in my situation foo is already a method of another class. > > Simon. I didn't see what you were referring to at first. But yes, I see the similarity. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: namespace dictionaries ok?

2005-10-24 Thread Ron Adam
nstead of creating a new object? Cheers, Ron > On Monday 24 October 2005 19:53, Ron Adam wrote: > >>James Stroud wrote: >> >>>Here it goes with a little less overhead: >>> >>> >>>py> class namespace: >>>... def __init__(self,

Re: namespace dictionaries ok?

2005-10-25 Thread Ron Adam
;alice':4}) > py> n.bob > 1 > py> n.ted > 3 > > James How about... class namespace(dict): __getattr__ = dict.__getitem__ __setattr__ = dict.__setitem__ __delattr__ = dict.__delitem__ This seems to work, and eliminates the indirect method calls. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: namespace dictionaries ok?

2005-10-25 Thread Ron Adam
Duncan Booth wrote: > Ron Adam wrote: > >>James Stroud wrote: >> >>>Here it goes with a little less overhead: >>> >>> > > > >>But it's not a dictionary anymore so you can't use it in the same places >>you would

Re: Missing modules '_ssl', 'ext.IsDOMString', 'ext.SplitQName'

2005-10-25 Thread Ron Adam
x27;t the same as any of the module names you are using. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: namespace dictionaries ok?

2005-10-25 Thread Ron Adam
Bengt Richter wrote: > On Tue, 25 Oct 2005 16:20:21 GMT, Ron Adam <[EMAIL PROTECTED]> wrote: >>Or worse, the dictionary would become not functional depending on what >>methods were masked. >> >> >>And this approach reverses that, The dict values will be

Re: Setting Class Attributes

2005-10-25 Thread Ron Adam
the __init__ it is when the class is called after an instance object is created. When instances are created they share any class objects that were bound to names when the class was defined. They don't share any objects that get bound to instance attribute names in methods later. Does thi

Re: Top-quoting defined [was: namespace dictionaries ok?]

2005-10-26 Thread Ron Adam
uch point in rehashing the arguments. Probably I > should have equally lambasted Ron for the heinous crime of bottom-quoting. I usually try to keep things in reasonable context and or order. I tend to bottom quote only when either the message is short enough to fit on a single page, or wh

Re: Would there be support for a more general cmp/__cmp__

2005-10-26 Thread Ron Adam
de is already broken. Adding complexity to cmp may not break code, but it could probably slow down sorting in general. So I would think what ever improvements or alternatives needs to be careful not to slow down existing sorting cases. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Missing modules '_ssl', 'ext.IsDOMString', 'ext.SplitQName'

2005-10-26 Thread Ron Adam
f nothing else to rule out file path problems like these. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: How best to reference parameters.

2005-10-26 Thread Ron Adam
can then do... c_y = C_Y(pumplist) print c_y.p1.name --> 'p1' print c_y.p1.status --> 0 print c_y.p1.ptype--> 'ob1' print c_y.p1.number --> 0 c_y.p1.status = 1 # p1 on c_y.p1.status = 0 # p1 off print c_y.p2.status --> 0 print c_y.p2.ptype--> 'ob1' print c_y.p2.number --> 1 etc... print c_y.showall() Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: How best to reference parameters.

2005-10-26 Thread Ron Adam
David Poundall wrote: > Sadly Ron, c_y can only see index and showall in your example. Well, don't give up! The approach is sound and I did say it was untested. Here's a tested version with a few corrections. :-) Cheers, Ron class Pump(object): def __init__(self

Re: namespace dictionaries ok?

2005-10-26 Thread Ron Adam
Alex Martelli wrote: > Ron Adam <[EMAIL PROTECTED]> wrote: >... > >> class namespace(dict): >> def __getattr__(self, name): >> return self.__getitem__(name) > >... > >>Any thoughts? Any better way to d

Re: Would there be support for a more general cmp/__cmp__

2005-10-28 Thread Ron Adam
Antoon Pardon wrote: > Op 2005-10-26, Ron Adam schreef <[EMAIL PROTECTED]>: > >>Adding complexity to cmp may not break code, but it could probably slow >>down sorting in general. So I would think what ever improvements or >>alternatives needs to be careful not

Re: tkinter blues (greens, reds, ...)

2005-10-28 Thread Ron Adam
ing the focus. Another place to look is where you may be adding or converting rgb color values. This function convert decimal rgb values to a hex rgb string that tkinter expects. def rgb(red, green, blue): """ Convert RGB value of 0 to 255 to hex Tkinter color string. """ return '#%02x%02x%02x' % (red, green, blue) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: tkinter blues (greens, reds, ...)

2005-10-28 Thread Ron Adam
eace Hmm... It worked fine for me. I'm using python 2.4.1 on windows XP. I didn't see anything particularly wrong with the program that might cause the problem you are referring to. So I'm afraid I can't help much. Maybe someone with 2.3 can reproduce it? BTW, Nice puzzle, much harder than it looks. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Arguments for button command via Tkinter?

2005-10-31 Thread Ron Adam
on( frame, text=button, command=self.command(button) ) ... The button label is used as the id above, but a number or code could also be used. def command(self, id): """ Assign a command to an item. The id is the value to be

Re: dictionary that have functions with arguments

2005-11-02 Thread Ron Adam
':(func1, args)} You could then do... func, args = execfunc['key1'] func(**args) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: dictionary that have functions with arguments

2005-11-02 Thread Ron Adam
Neal Norwitz wrote: > Ron Adam wrote: > >>Eval or exec aren't needed. Normally you would just do... >> >>execfunc['key1'](**args) >> >>If your arguments are stored ahead of time with your function... >> >>Committed re

Re: Tkinter- Building a message box

2005-11-07 Thread Ron Adam
tly I use a function to pass and sometimes modify the values to the dialog and then return the dialog.result value after it's closed. Something like... def domydialog(*args, **kwds): # # Check and modify args or kwds here if needed. # mydialog(*args, **kwds) return mydi

Re: Tkinter- Building a message box

2005-11-07 Thread Ron Adam
been ... def domydialog(*args, **kwds): # # check or change args or kwds # d = mydialog(*args, **kwds) return d.result I left out the returned object name 'd'. Which is needed to get the result from the dialog instance. Cheers, Ron -- http://mail.pyt

Re: when and how do you use Self?

2005-11-07 Thread Ron Adam
st argument. 'self' becomes the new name for bar within foo. self.c = a + b# same as -> bar.c = a + b This should be enough to visualize the basic relationship. Hope it helped. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Alert: Help me store constants pythonically

2005-11-07 Thread Ron Adam
s = [] for p in tranversePlanes: self.transversePlanes.append(Plane(**p)) mod1 = Model(**models.M1) This may be good to use until you decide how else to do it. You can easily write the dictionaries to a text file in the chosen format later and that will t

Re: overloading *something

2005-11-07 Thread Ron Adam
(*myobj) > > I've looked at getitem, getslice, and iter. What is it if not one of these? > > And, how about the "**something" operator? > > James A dictionary would be pretty much the same except subclassed from a dictionary of course. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Returning a value from a Tk dialog

2005-11-07 Thread Ron Adam
dialog, and then the show() method is called and it returns the value. The return line above is the same as... cc = Chooser(**options) color = cc.show() return color The other dialogs work in same way. They are all based on tkCommonDialog, so look in tkCommonDialog.py to see e

Re: overloading *something

2005-11-07 Thread Ron Adam
Alex Martelli wrote: > Ron Adam <[EMAIL PROTECTED]> wrote: > > >>James Stroud wrote: >>>And, how about the "**something" operator? >>> >>>James >> >>A dictionary would be pretty much the same except subclassed from a >

Re: How to convert a number to hex number?

2005-11-08 Thread Ron Adam
or should be for it, but iterating a string is faster than converting to int and back. I doubt I can make these significantly faster at this point. Using dictionary lookups really helped a lot going both ways. Cheers, Ron import string BaseDigits = sorted(list(string.digits + str

Re: which feature of python do you like most?

2005-11-08 Thread Ron Adam
[EMAIL PROTECTED] wrote: > which feature of python do you like most? > > I've heard from people that python is very useful. > Many people switch from perl to python because they like it more. > > I am quite familiar with perl, I've don't lots of code in perl. > Now, I was curious and intereste

Re: How to convert a number to hex number?

2005-11-09 Thread Ron Adam
Bengt Richter wrote: > On Wed, 09 Nov 2005 00:42:45 GMT, Ron Adam <[EMAIL PROTECTED]> wrote: > > >> >>Bengt Richter wrote: >> >>>On 08 Nov 2005 08:07:34 -0800, Paul Rubin <http://[EMAIL PROTECTED]> wrote: >>> >>> >>

Re: help make it faster please

2005-11-13 Thread Ron Adam
ed. Surprisingly a standard Python word iterator works just as well, and is easier to understand than the re version. Which one is faster depends on the average word length and number of ignored characters. Cheers, Ron Character count: 10 Word count: 16477 Average word size: 6.0

Re: help make it faster please

2005-11-13 Thread Ron Adam
Fredrik Lundh wrote: > Ron Adam wrote: > > >>The \w does make a small difference, but not as much as I expected. > > > that's probably because your benchmark has a lot of dubious overhead: I think it does what the OP described, but that may not be what he rea

apply()?

2005-12-05 Thread Ron Griswold
doesn’t appear to be the case. Can someone point me in the right direction?   Thanks,   Ron Griswold Character TD R!OT Pictures [EMAIL PROTECTED]   -- http://mail.python.org/mailman/listinfo/python-list

RE: apply()?

2005-12-05 Thread Ron Griswold
Just the ticket. Thank you! Ron Griswold Character TD R!OT Pictures [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fredrik Lundh Sent: Monday, December 05, 2005 3:58 PM To: python-list@python.org Subject: Re: apply()? Ron Griswold

Re: Python! Is! Truly! Amazing!

2005-01-02 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Erik Bethke" <[EMAIL PROTECTED]> wrote: > > I have NEVER experienced this kind of programming joy. Just wait until you discover Lisp! ;-) rg -- http://mail.python.org/mailman/listinfo/python-list

Rebinding stdout (was: Re: Python! Is! Truly! Amazing!)

2005-01-02 Thread Ron Garret
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Aahz) wrote: > In article <[EMAIL PROTECTED]>, > Roy Smith <[EMAIL PROTECTED]> wrote: > >In article <[EMAIL PROTECTED]>, > > Ron Garret <[EMAIL PROTECTED]> wrote: > >> In article &l

Re: Rebinding stdout

2005-01-02 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Mark McEahern <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > > But this topic does bring up a legitimate question: I have a bunch of > > code that generates HTML using PRINT statements. I need to convert > > all thi

Re: Rebinding stdout (was: Re: Python! Is! Truly! Amazing!)

2005-01-03 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Just <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Simo Melenius <[EMAIL PROTECTED]> wrote: > > > I've sometimes replaced sys.stdout (and/or sys.stderr) to > > capture/redirect debugging information in existing code that has > > unwisely just "pr

Re: Python! Is! Truly! Amazing!

2005-01-03 Thread Ron Garret
In article <[EMAIL PROTECTED]>, jfj <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > "Erik Bethke" <[EMAIL PROTECTED]> wrote: > > > > > >>I have NEVER experienced this ki

Re: Loop until condition is true

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

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

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

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

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

Re: getting an object name

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

PEP 343, second look

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

Re: PEP 343, second look

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

Re: Favorite non-python language trick?

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

Re: Thoughts on Guido's ITC audio interview

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

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

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

Re: Boss wants me to program

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

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

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

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

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

custom Tkinter ListBox selectMode

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

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

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

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

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

Re: Folding in vim

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

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

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

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

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

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

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

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

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

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

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

Re: Folding in vim

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Re: Use cases for del

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

<    1   2   3   4   5   6   7   8   >