Re: What is class method?

2008-08-26 Thread Matthew Fitzgibbons
Medardo Rodriguez (Merchise Group) wrote: On Tue, Aug 26, 2008 at 4:10 PM, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: In Python, there's *no* relationship between classmethods and metaclasses. In OOP the concept of meta-class has everything to do with class methods, regardless if is in Pyt

Re: Identifying the start of good data in a list

2008-08-26 Thread Matthew Fitzgibbons
[EMAIL PROTECTED] wrote: I have a list that starts with zeros, has sporadic data, and then has good data. I define the point at which the data turns good to be the first index with a non-zero entry that is followed by at least 4 consecutive non-zero data items (i.e. a week's worth of non-zero da

Re: Programmatically exit the REPL

2008-08-26 Thread Matthew Fitzgibbons
Matthew Fitzgibbons wrote: I've got a pretty complex interactive command line program. Instead of writing my own REPL, I'm using the Python interpreter (an infinitely better solution). This program has two threads, a background thread and the REPL thread. When you call quit() or sys

Re: Programmatically exit the REPL

2008-08-26 Thread Matthew Fitzgibbons
008/8/26 Matthew Fitzgibbons <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> Alexander Schmolck wrote: Without reading your post properly or having tried to do the same thing myself: I think you might want to have a look at ipython; it gives a better

Re: Programmatically exit the REPL

2008-08-26 Thread Matthew Fitzgibbons
Alexander Schmolck wrote: Without reading your post properly or having tried to do the same thing myself: I think you might want to have a look at ipython; it gives a better REPL and "embedding ipython" should give you plenty of hits as well. Thanks for the tip; I hadn't heard of ipython befor

Programmatically exit the REPL

2008-08-25 Thread Matthew Fitzgibbons
I've got a pretty complex interactive command line program. Instead of writing my own REPL, I'm using the Python interpreter (an infinitely better solution). This program has two threads, a background thread and the REPL thread. When you call quit() or sys.exit() in the REPL thread, everything

Re: Good python equivalent to C goto

2008-08-18 Thread Matthew Fitzgibbons
Paul McGuire wrote: On Aug 17, 1:09 pm, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next;

Re: Good python equivalent to C goto

2008-08-17 Thread Matthew Fitzgibbons
as mentioned 'in complex code the goto statement is still the easiest to code and understand'. The examples are very small and do not require that at all. I agree it's ugly. Just to show a way to do it. A very few functions where I use goto in C or C# are a few hundred lines of code, difficult t

Re: Good python equivalent to C goto

2008-08-17 Thread Matthew Fitzgibbons
[EMAIL PROTECTED] wrote: On Aug 17, 8:09 pm, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) got

Re: Good python equivalent to C goto

2008-08-17 Thread Matthew Fitzgibbons
Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next; if (condition3) goto next; stmt1; stmt2; next: stmt3; stmt4; }

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-08-01 Thread Matthew Fitzgibbons
Carl Banks wrote: On Aug 1, 8:49 am, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: Carl Banks wrote: On Jul 31, 11:44 pm, Carl Banks <[EMAIL PROTECTED]> wrote: [snip excellent explanation of why it's hard to for "if x" to be extensively polymorphic] By the way, on

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-08-01 Thread Matthew Fitzgibbons
Matthew Fitzgibbons wrote: 'if x' strikes me as better for this case because you might want to accept a non-empty list (or some other objects) but reject non-empty lists. 'if x is None' would not work. It still may be susceptible to the empty iterator problem, depending on

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-08-01 Thread Matthew Fitzgibbons
Carl Banks wrote: On Jul 31, 11:44 pm, Carl Banks <[EMAIL PROTECTED]> wrote: [snip excellent explanation of why it's hard to for "if x" to be extensively polymorphic] By the way, one thing I forgot to mention is Matt Fitzgibbons' filter example. As I said, it's hard to write code that works fo

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-08-01 Thread Matthew Fitzgibbons
Antoon Pardon wrote: On 2008-08-01, Erik Max Francis <[EMAIL PROTECTED]> wrote: Antoon Pardon wrote: I now have the following question for people who argue that "if x" is more polymorphic. I could subclass list, so that instances of this new sequence would always behave as true, even if they a

Re: Hobbyist - Python vs. other languages

2008-07-31 Thread Matthew Fitzgibbons
fprintf wrote: I have been playing with computers since I first learned to program moving shapes on an Atari 800XL in BASIC. After many years of dabbling in programming languages as a hobbyist (I am not a computer scientist or other IT professional), I have never found a way to stick with a langu

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Matthew Fitzgibbons
Matthew Fitzgibbons wrote: Steven D'Aprano wrote: On Wed, 30 Jul 2008 09:23:05 -0600, Matthew Fitzgibbons wrote: If you're expecting a list (and only a list) then your point makes sense. 'if x' can get you into trouble if you _don't_ want its polymorphism. "

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Matthew Fitzgibbons
Steven D'Aprano wrote: On Wed, 30 Jul 2008 09:23:05 -0600, Matthew Fitzgibbons wrote: If you're expecting a list (and only a list) then your point makes sense. 'if x' can get you into trouble if you _don't_ want its polymorphism. "if x" is hardly unique

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Matthew Fitzgibbons
Steven D'Aprano wrote: On Wed, 30 Jul 2008 09:23:05 -0600, Matthew Fitzgibbons wrote: If you're expecting a list (and only a list) then your point makes sense. 'if x' can get you into trouble if you _don't_ want its polymorphism. "if x" is hardly unique

Re: Reasoning behind 'self' parameter in classes?

2008-07-30 Thread Matthew Fitzgibbons
Robert Dailey wrote: Hi, I want to point out first of all that I'm not as familiar with Python as I should be, and for that reason I question a lot of things because I'm mainly a C++ programmer and I'm used to certain conveniences. Having said that... I've always been curious (more so than

Re: Is there a such Python module ?

2008-07-30 Thread Matthew Fitzgibbons
Johny wrote: Is there a Python module that can help with reading SMS message from a mobile phone? Or is there an example how to read SMS message using a program written in Python,C, or any other language? Thank you very much for help L. -- http://mail.python.org/mailman/listinfo/python-list Th

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Matthew Fitzgibbons
Carl Banks wrote: On Jul 29, 6:42 pm, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: Carl Banks wrote: Much like in Steven D'Aprano's example, still the only actual code snippet I've seen, it seems that this can easily be done with a simple explicit test by having all no-a

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Matthew Fitzgibbons
Russ P. wrote: On Jul 30, 12:03 am, Heiko Wundram <[EMAIL PROTECTED]> wrote: Am Mittwoch, 30. Juli 2008 08:30:48 schrieb Russ P.: On Jul 29, 11:09 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: I'm getting this sneaking suspicion that you guys are all putting us on. As I said in an earlier

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Matthew Fitzgibbons
Carl Banks wrote: On Jul 30, 1:58 am, "Russ P." <[EMAIL PROTECTED]> wrote: On Jul 29, 10:33 pm, Carl Banks <[EMAIL PROTECTED]> wrote: On Jul 30, 1:15 am, "Russ P." <[EMAIL PROTECTED]> wrote: Having said that, it would sure be nice to be able to write if myList is not empty: instead of if len(

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Matthew Fitzgibbons
Carl Banks wrote: On Jul 29, 11:12 am, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: Carl Banks wrote: On Jul 28, 8:15 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: On Mon, 28 Jul 2008 13:22:37 -0700, Carl Banks wrote: On Jul 28, 10:00 am, Steven

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Matthew Fitzgibbons
Carl Banks wrote: On Jul 28, 8:15 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: On Mon, 28 Jul 2008 13:22:37 -0700, Carl Banks wrote: On Jul 28, 10:00 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: Cutting to the crux of the discussion... On Sun, 27 Jul 2

Re: Attack a sacred Python Cow

2008-07-25 Thread Matthew Fitzgibbons
Jordan wrote: Well this discussion is chugging along merrily now under its own steam, but as the OP I should probably clarify a few things about my own views since people continue to respond to them (and are in some cases misunderstanding me.) I *like* explicit self for instance variable access.

Re: 2d graphics - what module to use?

2008-07-25 Thread Matthew Fitzgibbons
sturlamolden wrote: On Jul 25, 8:13 am, Pierre Dagenais <[EMAIL PROTECTED]> wrote: What is the easiest way to draw to a window? I'd like to draw something like sine waves from a mathematical equation. Newbie to python. For mathematica equations, NumPy and matplotlib is probably the best opti

Re: Execution speed question

2008-07-25 Thread Matthew Fitzgibbons
Iain King wrote: On Jul 25, 4:22 pm, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: It seems like the probability calculation applies to all three equally, and can therefore be ignored for the simulations. The probability affects (1) more. My reasoning for this being: as probabilit

Re: Execution speed question

2008-07-25 Thread Matthew Fitzgibbons
Suresh Pillai wrote: That's a good comparison for the general question I posed. Thanks. Although I do believe lists are less than ideal here and a different data structure should be used. To be more specific to my case: As mentioned in my original post, I also have the specific condition tha

Re: sending input to an embedded application

2008-07-21 Thread Matthew Fitzgibbons
mefyl wrote: Uwe Schmitt wrote: On 12 Jul., 09:08, George Oliver <[EMAIL PROTECTED]> wrote: What I would like to do is take a program and embed it or put it within a Python-run GUI, using the GUI just to capture and send input to the application, and display the ouput. Which interface does you

Re: Python Written in C?

2008-07-21 Thread Matthew Fitzgibbons
Martin P. Hellwig wrote: I disagree he has upper management written all over him. In any case, the OP should remember that programming languages are all theoretically the same: if you can do it in one language, then you can theoretically do it any other. When choosing a language, you just ne

Re: Unit Testing Techniques

2008-07-11 Thread Matthew Fitzgibbons
I'm by no means a testing expert, but I'll take a crack at it. Casey McGinty wrote: I'm familiar with the unittest module in Python, however I'm hoping someone can point me to some examples of more advanced usages of the framework. For example: 1. Using the framework to test a package with ne

Re: Singleton implementation problems

2008-07-04 Thread Matthew Fitzgibbons
Ben Finney wrote: Peter Otten <[EMAIL PROTECTED]> writes: The problem is the structure of your program. The myset module is imported twice by Python, once as "myset" and once as "__main__". Yes, this is the problem. Each module imports the other. Therefore you get two distinct MySet classes

Re: Singleton implementation problems

2008-07-03 Thread Matthew Fitzgibbons
Urizev wrote: Hi everyone I have developed the singleton implementation. However I have found a strange behaviour when using from different files. The code is attached. Executing main new MySet object No singleton instance New singleton: <__main__.Singleton instance at 0x2b98be474a70> new MySet

Re: Testing for an empty list

2008-07-03 Thread Matthew Fitzgibbons
Alexnb wrote: Okay this is a simple question I just don't know how. If I have a list, say: funList = [] and after a while something possible should have been appended to it, but wasn't. How can I test if that list is empty. if not funList: do_something() -Matt -- http://mail.python.o

Re: Write a file - beginner's question

2008-07-03 Thread Matthew Fitzgibbons
Callie Bertsche wrote: I have a closely related note. How do I write to a relative path with python? Example, source = open('/../../directory/subdirectory/file.extension') What am I missing? -- http://mail.python.org/mailman/listinfo/python-list Leave off the beginning slash. -Matt -- http:/