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

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 become, /aa/)

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 them.

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 +, 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 all cases. Imagine trying it on *really long* strings

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__(self):

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 those

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
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 are passed to a function that collects them with **kwds. class namespace(dict): def __getattr__(self, name): return self.__getitem__(name

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

Re: namespace dictionaries ok?

2005-10-25 Thread Ron Adam
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, adict): ... self.__dict__.update(adict) ... py n = namespace({'bob':1, 'carol':2, 'ted':3, 'alice

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... class

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: example snipped But it's not a dictionary anymore so you can't use it in the same places you would use a dictionary. foo(**n) Would raise an error. So I couldn't do: def foo

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 names

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 masked by the methods, so the values can't effect

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 the

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 what the

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 quite

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 hold binary

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,

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 do this? If any of the keys (which become attributes through

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 to slow down existing sorting cases

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 to. it

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 the

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 each button and

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 args? using

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 revision 41366. Committed revision 41366 ? You could then do... func, args

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

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

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 programming

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] numBumps: 57

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

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 way

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 dictionary of course. I believe this one is correct (but I have not checked in-depth

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 http://[EMAIL PROTECTED] 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 ([EMAIL PROTECTED] deleted ;-)

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 interested in

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: dcrespo [EMAIL PROTECTED] writes: hex(255)[2:] 'ff' '%x'%255 is preferable since the format of hex

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), but is handled more

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 really needs. Although the test to find

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Szabolcs Nagy wrote: with the current syntax L[i:i+1] returns [L[i]], with nxlist it returns L[i+1] if i0. L=range(10) L[1:2]==[L[1]]==[1] L[-2:-1]==[L[-2]]==[8] L=nxlist(range(10)) L[1:2]==[L[1]]==[1] L[-2:-1]==[L[-1]]==[9] # not [L[-2]] IMHO in this case current list slicing is

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Magnus Lycka wrote: Ron Adam wrote: Slicing is one of the best features of Python in my opinion, but when you try to use negative index's and or negative step increments it can be tricky and lead to unexpected results. Hm... Just as with positive indexes, you just need to understand

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Fredrik Lundh wrote: Steve Holden wrote: Yes, I've been surprised how this thread has gone on and on. it's of course a variation of You can lead an idiot to idioms, but you can't make him think ;-) as long as you have people that insist that their original

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Steve Holden wrote: It's a common misconception that all ideas should be explainable simply. This is not necessarily the case, of course. When a subject is difficult then all sorts of people bring their specific misconceptions to the topic, and suggest that if only a few changes were made

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Bengt Richter wrote: On Mon, 5 Sep 2005 18:09:51 +0200, Fredrik Lundh [EMAIL PROTECTED] wrote: OTOH, ISTM we must be careful not to label an alternate alpha-version way to model the real world as a misunderstanding just because it is alpha, and bugs are apparent ;-) Thanks! I couldn't

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Terry Reedy wrote: Ron Adam wrote: However, I would like the inverse selection of negative strides to be fixed if possible. If you could explain the current reason why it does not return the reverse order of the selected range. To repeat, the current reason is compatibility

Re: Possible improvement to slice opperations.

2005-09-06 Thread Ron Adam
Patrick Maupin wrote: I previously wrote (in response to a query from Ron Adam): In any case, you asked for a rationale. I'll give you mine: L = range(10) L[3:len(L):-1] == [L[i] for i in range(3,len(L),-1)] True After eating supper, I just realized that I could probably make my

Re: Possible improvement to slice opperations.

2005-09-06 Thread Ron Adam
Steve Holden wrote: Ron Adam wrote: Steve Holden wrote: What misconception do you think I have? This was not an ad hominem attack but a commentary on many attempts to improve the language. Ok, No problem. ;-) No one has yet explained the reasoning (vs the mechanics

Re: Possible improvement to slice opperations.

2005-09-06 Thread Ron Adam
Patrick Maupin wrote: Ron Adam wrote: This should never fail with an assertion error. You will note that it shows that, for non-negative start and end values, slicing behavior is _exactly_ like extended range behavior. Yes, and it passes for negative start and end values as well

Re: Possible improvement to slice opperations.

2005-09-06 Thread Ron Adam
Magnus Lycka wrote: Ron Adam wrote: Ok, lets see... This shows the problem with using the gap indexing model. L = range(10) [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] # elements 0 1 2 3 4 5 6 7 8 9 10 # index's L[3::1] - [3, 4, 5, 6, 7, 8, 9] 3rd index

Re: Possible improvement to slice opperations.

2005-09-07 Thread Ron Adam
Bengt Richter wrote: Then the question is, do we need sugar for reversed(x.[a:b]) or list(reversed(x.[a:b])) for the right hand side of a statement, and do we want to to use both kinds of intervals in slice assignment? (maybe and yes ;-) Yes, I think this is the better way to do it, as this

Re: Possible improvement to slice opperations.

2005-09-09 Thread Ron Adam
Michael Hudson wrote: Ron Adam [EMAIL PROTECTED] writes: With current slicing and a negative step... [ 1 2 3 4 5 6 7 8 9 ] -9 -8 -7 -6 -5 -4 -3 -2 -1 -0 r[-3:] - [7, 8, 9]# as expected r[-3::-1] - [7, 6, 5, 4, 3, 2, 1, 0] # surprise The seven is include

Re: encryption with python

2005-09-10 Thread Ron Adam
Kirk Job Sluder wrote: The only way to keep confidential stuff secure is to shred it, burn it, and grind the ashes. I think the fundamental problem is that that most customers don't want actual security. They want to be able to get their information by calling a phone number and saying

Re: encryption with python

2005-09-10 Thread Ron Adam
James Stroud wrote: On Saturday 10 September 2005 15:02, Ron Adam wrote: Kirk Job Sluder wrote: I would think that any n digit random number not already in the data base would work for an id along with a randomly generated password that the student can change if they want. The service provider

Re: encryption with python

2005-09-11 Thread Ron Adam
Kirk Job Sluder wrote: Ron Adam [EMAIL PROTECTED] writes: I would think that any n digit random number not already in the data base would work for an id along with a randomly generated password that the student can change if they want. The service provider has full access to the data

Re: Software bugs aren't inevitable

2005-09-16 Thread Ron Adam
Paul Rubin wrote: Steven D'Aprano [EMAIL PROTECTED] writes: But there is a difference: writing assembly is *hard*, which is why we prefer not to do it. Are you suggesting that functional programming is significantly easier to do than declarative? I think you mean imperative. Yes, there is

Re: Software bugs aren't inevitable

2005-09-16 Thread Ron Adam
Terry Reedy wrote: You cannot tell whether a function object will act recursive or not just by looking at its code body. Trivial examples: I was thinking last night that maybe it would be useful to be able to define a function explicitly as a recursive object where it's frame is reused on

inspect getsource() minor fix?

2005-09-19 Thread Ron Adam
While playing around with the inspect module I found that the Blockfinder doesn't recognize single line function definitions. Adding the following two lines to it fixes it, but I'm not sure if it causes any problems anywhere else. elif self.indent == 0: raise EndOfBlock,

Re: inspect getsource() minor fix?

2005-09-19 Thread Ron Adam
Delaney, Timothy (Tim) wrote: Ron Adam wrote: While playing around with the inspect module I found that the Blockfinder doesn't recognize single line function definitions. Adding the following two lines to it fixes it, but I'm not sure if it causes any problems anywhere else. elif

Re: Question About Logic In Python

2005-09-19 Thread Ron Adam
Steven D'Aprano wrote: On Mon, 19 Sep 2005 12:16:15 +0200, sven wrote: to make sure that an operation yields a boolean value wrap a bool() around an expression. None, 0 and objects which's len is 0 yield False. so you can also do stuff like that: Are there actually any usage cases for

Re: Organising a python project

2005-09-20 Thread Ron Adam
[EMAIL PROTECTED] wrote: Dear all, Can anyone point me to a resource that describes the best way of organising a python project? My project (gausssum.sf.net) is based around a class, and has a GUI that allows 'easy-access' to the methods of the class. What is the best or typical directory

Re: Question About Logic In Python

2005-09-21 Thread Ron Adam
Steven D'Aprano wrote: Ah, that's a good example, thanks, except I notice you didn't actually cast to bool in them, eg: (min value max) * value It wasn't needed in these particular examples. But it could be needed if several comparisons with 'and' between them are used. It just seems odd

Re: Finding where to store application data portably

2005-09-21 Thread Ron Adam
Steven D'Aprano wrote: On Wed, 21 Sep 2005 20:07:54 +0100, Tony Houghton wrote: I wish the Linux Standard Base folks would specify that settings files should all go into a subdirectory like ~/settings rather than filling up the home directory with cruft. That was acceptable in the days

Re: Finding where to store application data portably

2005-09-21 Thread Ron Adam
Tony Houghton wrote: I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use ~/.bombz, in Windows something like C:\Documents And Settings\user\Applicacation Data\Bombz. There are plenty of messages in

Re: Question About Logic In Python

2005-09-22 Thread Ron Adam
Steve Holden wrote: Ron Adam wrote: 2. Expressions that will be used in a calculation or another expression. By which you appear to mean expressions in which Boolean values are used as numbers. Or compared to other types, which is common. This matters because if you aren't

Re: Finding where to store application data portably

2005-09-22 Thread Ron Adam
Steve Holden wrote: Ron Adam wrote: Tony Houghton wrote: I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use ~/.bombz, in Windows something like C:\Documents And Settings\user\Applicacation Data

Re: Finding where to store application data portably

2005-09-22 Thread Ron Adam
Tony Houghton wrote: This works on Win XP. Not sure if it will work on Linux. import os parent = os.path.split(os.path.abspath(os.sys.argv[0]))[0] file = parent + os.sep + '.bombz' Ooh, no, I don't want saved data to go in the installation directory. In general that

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? Why not return 42? Why not return a picture of a banana? My question still stands. Could it be helpful

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

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 emails back to

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) I thought that I might have missed something there. Is there a paper on how

Re: Finding where to store application data portably

2005-09-23 Thread Ron Adam
. 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 class.

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

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 complexity.)

Re: Dynamically adding and removing methods

2005-09-27 Thread Ron Adam
Steven D'Aprano wrote: On Sun, 25 Sep 2005 14:52:56 +, Ron Adam wrote: 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

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 http://www.python.org/peps/pep-0350.html. Thanks! How about an

Re: Dynamically adding and removing methods

2005-09-28 Thread Ron Adam
Steven D'Aprano wrote: On Tue, 27 Sep 2005 16:42:21 +, Ron Adam wrote: def beacon(self, x): ...print beacon + %s % x ... Did you mean bacon? *wink* Of course... remembering arbitrary word letter sequences is probably my worst skill. ;-) That, and I think for some reason

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? When it is referenced via the class. Ok, that's what I suspected

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? That is, what would happen with

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 settled, I wonder if further discussion

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 to self.q. ---self.q Cheers, Ron -- http

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 braking

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 the OP's remark

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 braking either too early or too late. Result: a new crater on Mars, named after the NASA

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 do... def few(x,y): a = 'a' b = 'b' i

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 simply do, say from somewhere import debugdecorator

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 sys, os

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

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

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 with tracebacks. Cheers

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 the

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 special cell objects (rather than direct object references), and the compiler

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 must be

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 byte

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 i can find what's

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. I want to something roughly similar to ... class shape(object

  1   2   3   4   5   6   >