Re: Question About Logic In Python

2005-09-22 Thread Ron Adam
Terry Hancock wrote: > On Thursday 22 September 2005 12:26 pm, Ron Adam wrote: > >>Steve Holden wrote: >> >>>Ron Adam wrote: >>> >>>> >>> True * True >>>>1 # Why not return True here as well? >>>>

Re: Anyone else getting posts back as email undeliverable bounces?

2005-09-22 Thread Ron Adam
Bengt Richter wrote: > It seems lately all my posts have been coming back to me as bounced emails, > and I haven't emailed them ;-( > > I've been getting bounce messages like (excerpt): > ... Yes, I get them too. Plugging http://deimos.liage.net/ into a browser get: This domain is parked

Re: What is "self"?

2005-09-22 Thread Ron Adam
Wayne Sutton wrote: > OK, I'm a newbie... > I'm trying to learn Python & have had fun with it so far. But I'm having > trouble following the many code examples with the object "self." Can > someone explain this usage in plain english? > > Thanks, > Wayne I'll give it a try.. When you have

Re: Anyone else getting posts back as email undeliverable bounces?

2005-09-22 Thread Ron Adam
Terry Reedy wrote: > "Bengt Richter" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>It seems lately all my posts have been coming back to me as bounced >>emails, >>and I haven't emailed them ;-( > > > They are gatewayed to the general python email list. But bouncing list

Re: What is "self"?

2005-09-23 Thread Ron Adam
Erik Max Francis wrote: > Ron Adam wrote: > >> When you call a method of an instance, Python translates it to... >> >> leader.set_name(leader, "John") > > > It actually translates it to > > Person.set_name(leader, "John")

Re: Finding where to store application data portably

2005-09-23 Thread Ron Adam
g. Every user account would be a complete unit which can be backed up and restored independently of the OS. If something went wrong you could always find out which user (or application developer) was responsible. Anyway... just wishful thinking. I'm sure there are a lot of problems that would need to be worked out. ;-) Cheers, Ron Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamically adding and removing methods

2005-09-25 Thread Ron Adam
Steven D'Aprano wrote: > Or you could put the method in the class and have all instances recognise > it: > > py> C.eggs = new.instancemethod(eggs, None, C) > py> C().eggs(3) > eggs * 3 Why not just add it to the class directly? You just have to be sure it's a class and not an instance of a cl

Re: What is "self"?

2005-09-25 Thread Ron Adam
Michael Spencer wrote: > All is explained at: > http://users.rcn.com/python/download/Descriptor.htm#functions-and-methods > and further at: > http://www.python.org/pycon/2005/papers/36/pyc05_bla_dp.pdf > > "For objects, the machinery is in object.__getattribute__ which > transforms b.x into type

Re: What is "self"?

2005-09-27 Thread Ron Adam
Diez B. Roggisch wrote: >> This still seems not quite right to me... Or more likely seems to be >> missing something still. >> >> (But it could be this migraine I've had the last couple of days >> preventing me from being able to concentrate on things with more than >> a few levels of complexit

Re: Dynamically adding and removing methods

2005-09-27 Thread Ron Adam
Steven D'Aprano wrote: > On Sun, 25 Sep 2005 14:52:56 +0000, Ron Adam wrote: > > >>Steven D'Aprano wrote: >> >> >> >>>Or you could put the method in the class and have all instances recognise >>>it: >>> >>>py> C.eg

Re: PEP 350: Codetags

2005-09-28 Thread Ron Adam
Micah Elliott wrote: > Please read/comment/vote. This circulated as a pre-PEP proposal > submitted to c.l.py on August 10, but has changed quite a bit since > then. I'm reposting this since it is now "Open (under consideration)" > at . > > Thanks! How a

Re: Dynamically adding and removing methods

2005-09-28 Thread Ron Adam
Steven D'Aprano wrote: > On Tue, 27 Sep 2005 16:42:21 +0000, Ron Adam wrote: > > >>>>>>>def beacon(self, x): >>>> >>>>...print "beacon + %s" % x >>>>... >>> >>> >>>Did you me

Re: Dynamically adding and removing methods

2005-09-29 Thread Ron Adam
Terry Reedy wrote: > "Ron Adam" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Actually I think I'm getting more confused. At some point the function >>is wrapped. Is it when it's assigned, referenced, or called? > > &g

Re: [Info] PEP 308 accepted - new conditional expressions

2005-09-30 Thread Ron Adam
Reinhold Birkenfeld wrote: > Rocco Moretti wrote: > >>Reinhold Birkenfeld wrote: >> >>>Hi, >>> >>>after Guido's pronouncement yesterday, in one of the next versions of Python >>>there will be a conditional expression with the following syntax: >>> >>>X if C else Y >> >>Any word on chaining? >> >>

Re: [Info] PEP 308 accepted - new conditional expressions

2005-10-01 Thread Ron Adam
Reinhold Birkenfeld wrote: > Ron Adam >>I think I'm going to make it a habit to put parentheses around these >>things just as if they were required. > Yes, that's the best way to make it readable and understandable. > > Reinhold Now that the syntax is settl

Re: Class Help

2005-10-01 Thread Ron Adam
Ivan Shevanski wrote: > To continue with my previous problems, now I'm trying out classes. But > I have a problem (which I bet is easily solveable) that I really don't > get. The numerous tutorials I've looked at just confsed me.For intance: > class Xyz: > > ... def y(self): > ...

Re: Class Help

2005-10-01 Thread Ron Adam
Ron Adam wrote: > Also, > > In your example 'q' is assigned the value 2, but as soon as the method > 'y' exits, it is lost. To keep it around you want to assign it to self.y. Ooops, That should say ... "To keep it around you want to assign it

Re: "no variable or argument declarations are necessary."

2005-10-03 Thread Ron Adam
Steven D'Aprano wrote: > On Mon, 03 Oct 2005 06:59:04 +, Antoon Pardon wrote: > > x = 12.0 # feet > # three pages of code > y = 15.0 # metres > # three more pages of code > distance = x + y > if distance < 27: > fire_retro_rockets() > > And lo, one multi-billion dollar Mars lander starts

Re: "no variable or argument declarations are necessary."

2005-10-04 Thread Ron Adam
Antoon Pardon wrote: > Op 2005-10-03, Steven D'Aprano schreef <[EMAIL PROTECTED]>: > >>On Mon, 03 Oct 2005 06:59:04 +, Antoon Pardon wrote: >> >> >>>Well I'm a bit getting sick of those references to standard idioms. >>>There are moments those standard idioms don't work, while the >>>gist of t

Re: "no variable or argument declarations are necessary."

2005-10-05 Thread Ron Adam
Antoon Pardon wrote: > Op 2005-10-04, Ron Adam schreef <[EMAIL PROTECTED]>: > >>Antoon Pardon wrote: >> >>>Op 2005-10-03, Steven D'Aprano schreef <[EMAIL PROTECTED]>: >>> >>>>And lo, one multi-billion dollar Mars lander starts braki

Re: "no variable or argument declarations are necessary."

2005-10-06 Thread Ron Adam
Bengt Richter wrote: > On Wed, 05 Oct 2005 11:10:58 GMT, Ron Adam <[EMAIL PROTECTED]> wrote: >>Looking at it from a different direction, how about adding a keyword to >>say, "from this point on, in this local name space, disallow new >>names". Then you can

Re: "no variable or argument declarations are necessary."

2005-10-06 Thread Ron Adam
Fredrik Lundh wrote: > Ron Adam wrote: > > >>Is there a way to conditionally decorate? For example if __debug__ is >>True, but not if it's False? I think I've asked this question before. (?) > > > the decorator is a callable, so you can simpl

Re: Why do I get an import error on this?

2005-10-07 Thread Ron Adam
Steve wrote: > I'm trying to run a Python program on Unix and I'm encountering some > behavior I don't understand. I'm a Unix newbie, and I'm wondering if > someone can help. > > I have a simple program: > > > #! /home/fergs/python/bin/python > import

dis.dis question

2005-10-08 Thread Ron Adam
Can anyone show me an example of of using dis() with a traceback? Examples of using disassemble_string() and distb() separately if possible would be nice also. I'm experimenting with modifying the dis module so that it returns it's results instead of using 'print' it as it goes. I want to ma

Re: Weighted "random" selection from list of lists

2005-10-08 Thread Ron Adam
Jesse Noller wrote: > 60% from list 1 (main_list[0]) > 30% from list 2 (main_list[1]) > 10% from list 3 (main_list[2]) > > I know how to pull a random sequence (using random()) from the lists, > but I'm not sure how to pick it with the desired percentages. > > Any help is appreciated, thanks >

Re: dis.dis question

2005-10-09 Thread Ron Adam
Ron Adam wrote: > > Can anyone show me an example of of using dis() with a traceback? > > Examples of using disassemble_string() and distb() separately if > possible would be nice also. [cliped] > But I still need to rewrite disassemble_string() and need to test it

Re: Function decorator that caches function results

2005-10-09 Thread Ron Adam
Steven D'Aprano wrote: > On Sat, 08 Oct 2005 15:20:12 +0200, Lasse Vågsæther Karlsen wrote: > > >>Ok, so I thought, how about creating a decorator that caches the >>function results and retrieves them from cache if possible, otherwise it >>calls the function and store the value in the cache for

Re: Function decorator that caches function results

2005-10-09 Thread Ron Adam
Fredrik Lundh wrote: > Ron Adam wrote: > > >>In effect, 'cache' and 'fn' are replaced by the objects they reference >>before the cached_result function is returned. > > > not really; accesses to "free variables" always go via specia

Re: non descriptive error

2005-10-09 Thread Ron Adam
Timothy Smith wrote: > i have reproduced the error in this code block > > #save values in edit > self.FinaliseTill.SaveEditControlValue() > if > Decimal(self.parent.TillDetails[self.TillSelection.GetStringSelection()]['ChangeTinBalance'])) > > == Decimal('0'): > #box

Re: Python's Performance

2005-10-09 Thread Ron Adam
Steven D'Aprano wrote: > For what it is worth, Python is compiled AND interpreted -- it compiles > byte-code which is interpreted in a virtual machine. That makes it an > compiling interpreter, or maybe an interpreting compiler, in my book. Good points, and in addition to this, the individual byt

Re: non descriptive error

2005-10-12 Thread Ron Adam
Steven D'Aprano wrote: > Timothy Smith wrote: > i have NO idea what in there could be making it have such a strange error. it just says "error" when you try run it. there nothing terribly strange being done. > > >> i am still coming across this error it's driving me nuts. usually

object inheritance and default values

2005-10-14 Thread Ron Adam
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. I want to something roughly similar to ... class shape(object): def __init__(self, **kwds): # set a bunch

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
I want to be able to easily create reusable shapes in Tkinter and be able to use them in mid level dialogs. So after some experimenting I've managed to get something to work. The following does pretty much what I need, but I think it can be improved on. So could anyone take a look and let me

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
[EMAIL PROTECTED] wrote: > >> I'm still looking for info on how to use disassemble_string(). > > How about this? > > >>> import dis > >>> def f(): > ... print "hello world" > ... > >>> f.func_code.co_code > 'd\x01\x00GHd\x00\x00S' > >>> dis.disassemble_string(f

Re: Comparing lists

2005-10-16 Thread Ron Adam
Christian Stapfer wrote: > This discussion begins to sound like the recurring > arguments one hears between theoretical and > experimental physicists. Experimentalists tend > to overrate the importance of experimental data > (setting up a useful experiment, how to interpret > the experimental data

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
Christian Stapfer wrote: > It turned out that the VAX compiler had been > clever enough to hoist his simple-minded test > code out of the driving loop. In fact, our VAX > calculated the body of the loop only *once* > and thus *immediately* announced that it had finished > the whole test - the

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

ordered keywords?

2005-10-17 Thread Ron Adam
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) {'three': 3, 'two': 2, 'one': 1} I would love to reverse the *args, and **kwds as well so I can use kwds to set defaults and initiate values an

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
Chris Lasher wrote: > Thanks for your responses, guys. I can't get the PIDA page to come up > for me; server timeout error. I'll have to look into Eclipse more, but > I've been warned that it's resource greedy and that the VI plugin > doesn't provide very much functionality. Still, that's hearsay,

multi-property groups?

2005-10-19 Thread Ron Adam
I was trying to see if I can implement property groups so I can set and pass arguemts as dictionaries. I think this will simplify interfacing to multiple objects and funtions that use a lot of keywords as arguments. But so far, the the following seems like it's not the most efficient way to

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 """ Grouped properties: This need pr

Re: destroy your self????

2005-10-19 Thread Ron Adam
KraftDiner wrote: > if I create an object like... > > obj = None > ... > obj = anObject() > > can obj set itself to none in some method of the class? > Do you mean like this? >>> def foo(): ... global foo ... del foo ... >>> foo() >>> foo Traceback (most recent call last): File "",

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
Andrew Jaffe wrote: > Hi, > > I have a class with various class-level variables which are used to > store global state information for all instances of a class. These are > set by a classmethod as in the following (in reality the setcvar method > is more complicated than this!): > > class sup

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
KraftDiner wrote: > I have a base class called Shape > And then classes like Circle, Square, Triangle etc, that inherit from > Shape: > > My quesiton is can a method of the Shape class call a method in Circle, > or Square etc...? This looks familiar. :-) Yes, it can if it has references to the

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
KraftDiner wrote: > Well here is a rough sketch of my code... > This is giving my two problems. > > 1) TypeError: super() argument 1 must be type, not classobj > 2) I want to be sure the the draw code calls the inherited classes > outline and not its own... > > class Shape: > def __init__(

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
Hi, I found the following to be a useful way to access arguments after they are passed to a function that collects them with **kwds. class namespace(dict): def __getattr__(self, name): return self.__getitem__(name) def __setattr__(self, name, value):

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
Simon Burton wrote: > Yes! > > I do this a lot when i have deeply nested function calls > a->b->c->d->e > and need to pass args to the deep function without changing the > middle functions. Yes, :-) Which is something like what I'm doing also. Get the dictionary, modify it or validate it som

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
James Stroud wrote: > Here it goes with a little less overhead: > > > py> class namespace: > ... def __init__(self, adict): > ... self.__dict__.update(adict) > ... > py> n = namespace({'bob':1, 'carol':2, 'ted':3, 'alice':4}) > py> n.bob > 1 > py> n.ted > 3 > > James How about... cl

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
[EMAIL PROTECTED] wrote: > Hi, > > unfortunately the result from py2exe won't run eventhough the original > script runs without problems. The trouble is I'm at a loss as to where > to start looking! > > Martin. Just a guess, Make sure any your file names aren't the same as any of the module na

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.theorist wrote: > So that it'll be easier to remember the next time I find myself in the > same situation on a different task, I'll extend the discussion > somewhat. > > Coming from C, I had expected that I'd get a new empty dict every time > the __init__ function ran. Guido (or some other

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

2005-10-26 Thread Ron Adam
Duncan Booth wrote: > No, I didn't think it was malice which is why I just added what I > considered to be a polite request at the end of my message. I assumed that > most people either knew the phrase or could find out in a few seconds using > Google so there wasn't much point in rehashing t

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

2005-10-26 Thread Ron Adam
Antoon Pardon wrote: > Op 2005-10-25, Steven D'Aprano schreef <[EMAIL PROTECTED]>: >>Can somebody remind me, what is the problem Antoon is trying to solve here? > > > Well there are two issues. One about correct behaviour and one about > practicallity. > > The first problem is cmp. This is w

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

2005-10-26 Thread Ron Adam
[EMAIL PROTECTED] wrote: > Hi, > > which file names do you mean? > > -Martin. I've ran across a case where I copied a module from the python libs folder to my source directory, it would work fine before I built with py2exe, but afterwards it would give a file not found error. I haven't q

Re: How best to reference parameters.

2005-10-26 Thread Ron Adam
David Poundall wrote: > However, what I really would like is something like... > > class c_y: > def __init__(self): > self.P1 = [0, 'OB1', 0 ] > self.P2 = [0, 'OB1', 1 ] > self.P3 = [0, 'OB1', 2 ] > self.P4 = [0, 'OB1', 3 ] > > Because that way I can also hol

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, name, ptype, n

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
Steve Holden wrote: > Sean McIlroy wrote: > >> hi all >> >> i recently wrote a script that implements a puzzle. the interface >> mostly consists of a bunch of colored disks on a tkinter canvas. the >> problem is that the disks change their colors in ways other than the >> way they're supposed t

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

2005-10-28 Thread Ron Adam
Sean McIlroy wrote: > i'm using the canned colors ("pink", "orange", etc). should i try > changing to explicit color specifications to see if that makes a > difference? i'm not sure what the other guy meant by a "soft toy", but > i take it the idea is to try and construct a correctness proof for

Re: Arguments for button command via Tkinter?

2005-10-31 Thread Ron Adam
Steve Holden wrote: > Francesco Bochicchio wrote: > >> Il Mon, 31 Oct 2005 06:23:12 -0800, [EMAIL PROTECTED] ha scritto: >> >> >>> And yet the stupidity continues, right after I post this I finnally >>> find an answer in a google search, It appears the way I seen it is to >>> create a class for

Re: dictionary that have functions with arguments

2005-11-02 Thread Ron Adam
[EMAIL PROTECTED] wrote: > hi > i have a dictionary defined as > > execfunc = { 'key1' : func1 } > > to call func1, i simply have to write execfunc[key1] . > but if i have several arguments to func1 , like > > execfunc = { 'key1' : func1(**args) } > > how can i execute func1 with variable ar

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
Tuvas wrote: > I've been trying to build a fairly simple message box in tkinter, that > when a button is pushed, will pop up a box, that has a line of text, an > entry widget, and a button, that when the button is pushed, will return > the value in the line of text. However, while I can read the v

Re: Tkinter- Building a message box

2005-11-07 Thread Ron Adam
Tuvas wrote: > Do you have any info on dialogs? I've been trying to find some, without > alot of success... > Be sure and look at the examples in python24/lib/lib-tk. The Dialog.py file there does pretty much what you want. In the dialog caller example I gave, it should have been ... def do

Re: when and how do you use Self?

2005-11-07 Thread Ron Adam
Tieche Bruce A MSgt USMTM/AFD wrote: > I am new to python, > > Could someone explain (in English) how and when to use self? > > I have been reading, and haven't found a good example/explanation > > > Bruce Tieche ([EMAIL PROTECTED]) Hi, Sometimes it's hard to get a simple answer to progra

Re: Newbie Alert: Help me store constants pythonically

2005-11-07 Thread Ron Adam
Brendan wrote: >>How many is LOOONG? Ten? Twenty? One hundred? > > > About 50 per Model > > >>If it is closer to 100 than to 10, I would suggest >>putting your constants into something like an INI file: >> >>[MODEL1] # or something more meaningful >>numBumps: 1 >>sizeOfBumps: 99 >> >>[MODEL2

Re: overloading *something

2005-11-07 Thread Ron Adam
James Stroud wrote: > Hello All, > > How does one make an arbitrary class (e.g. class myclass(object)) behave like > a list in method calls with the "*something" operator? What I mean is: You need to base myclass on a list if I understand your question. class myclass(list): def __init__

Re: Returning a value from a Tk dialog

2005-11-07 Thread Ron Adam
Gordon Airporte wrote: > The dialogs in tkColorChooser, tkFileDialog, etc. return useful values > from their creation somehow, so I can do stuff like this: > > filename = tkFileDialog.askopenfilename( master=self ) > > I would like to make a Yes/No/Cancel dialog that can be used the same > wa

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
Bengt Richter wrote: > On 08 Nov 2005 08:07:34 -0800, Paul Rubin wrote: > > >>"dcrespo" <[EMAIL PROTECTED]> writes: >> >>hex(255)[2:] >>> >>>'ff' >> >>'%x'%255 is preferable since the format of hex() output can vary. Try >>hex(33**33). > > > Not to mention ([E

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
Fredrik Lundh wrote: > Lonnie Princehouse wrote: > > >>"[a-z0-9_]" means "match a single character from the set {a through z, >>0 through 9, underscore}". > > > "\w" should be a bit faster; it's equivalent to "[a-zA-Z0-9_]" (unless you > specify otherwise using the locale or unicode flags), b

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

Re: Loop until condition is true

2005-06-18 Thread Ron Adam
Joseph Garvin wrote: > Peter Otten wrote: > >> I found 136 occurrences of "do {" versus 754 of "while (" and 1224 of >> "for >> (" in the Python 2.4 source, so using these rough estimates do-while >> still >> qualifies as "rarely used". >> >> Peter >> >> >> > That's 136 times you'd have to use

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

2005-06-19 Thread Ron Adam
Bo Peng wrote: > Roy Smith wrote: > >> Can you give us some idea of what it is that you're trying to do? It >> pretty unusual to see a requirement like that. > > > def func(type_of_obj1, type_of_obj2, .): > callfunc( [ > type_of_obj1 and obj1a() or obj1b(), > type_of_obj2 and obj

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
David Bear wrote: > Let's say I have a list called, alist. If I pass alist to a function, > how can I get the name of it? > > alist = range(10) > > def afunction(list): > listName = list.__name__ (fails for a list object) > Using an object's name as data isn't a good idea because it will g

PEP 343, second look

2005-06-22 Thread Ron Adam
After taking a break from following PEP 343 and it's associated PEPs, I wanted to look at it again because it still seemed a bit hard to get my mind around. http://www.python.org/peps/pep-0343.html > A new statement is proposed with the syntax: > > with EXPR as VAR: >

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
George Sakkis wrote: > "Joseph Garvin" wrote: > > >>I'm curious -- what is everyone's favorite trick from a non-python >>language? And -- why isn't it in Python? > > > Although it's an optimization rather than language trick, I like the > inline functions/methods in C++. There has been a thread

Re: Thoughts on Guido's ITC audio interview

2005-06-27 Thread Ron Adam
Dave Benjamin wrote: > Guido gave a good, long interview, available at IT Conversations, as was > recently announced by Dr. Dobb's Python-URL! The audio clips are available > here: > > http://www.itconversations.com/shows/detail545.html > http://www.itconversations.com/shows/detail559.html Than

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
[EMAIL PROTECTED] wrote: > Ok, sorry to throw perhaps unrelated stuff in here, but I want everyone > to know what we have right now in the office. We started with an > electric typewriter and file cabinets. We were given an old 386 with a > 20 mb hard drive about 5 years ago, and we moved everythi

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

2005-06-30 Thread Ron Adam
Antoon Pardon wrote: > Op 2005-06-29, Scott David Daniels schreef <[EMAIL PROTECTED]>: > >>Roy Smith wrote: >> >>>Andrew Durdin <[EMAIL PROTECTED]> wrote: >>> Corrected version: result = [(lambda: expr0), lambda: expr1][bool(cond)]() >> >>Sorry, I thought cond was a standard boolean. >>

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

2005-07-01 Thread Ron Adam
Tom Anderson wrote: > So, if you're a pythonista who loves map and lambda, and disagrees with > Guido, what's your background? Functional or not? 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. So what woul

  1   2   3   4   >