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

2008-07-29 Thread Carl Banks
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 >

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

2008-07-29 Thread Carl Banks
On Jul 30, 2:06 am, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Perhaps in the particular use case you're thinking of (numeric types vs. > container types), there aren't any good examples. But who cares? You don't have to. I am trying to set the record straight on just how much polymophism "if

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

2008-07-29 Thread Russ P.
On Jul 29, 11:36 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Russ P. wrote: > > Come to think of it, shouldn't the list type have an "isempty" method? > > Or does it? > > Yes. It's written: > > if not aList: > ... As you know, that is not quite exactly the same thing. An

Re: interpreter vs. compiled

2008-07-29 Thread castironpi
I note that IronPython and Python's pickle.dumps do not return the same value. Perhaps this relates to the absence of interpreter loop. >>> p.dumps( { 'a': True, 'b': set( ) } ) IPy: '(dp0\nVb\np1\nc__builtin__\nset\np3\n((lp4\ntp5\nRp2\nsVa \np6\nI01\ns.' CPy: "(dp0\nS'a'\np1\nI01\nsS'b'\np2\nc_

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

2008-07-29 Thread Russ P.
On Jul 29, 11:36 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Russ P. wrote: > > 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 post, I realize that this would only w

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

2008-07-29 Thread Erik Max Francis
Russ P. wrote: Come to think of it, shouldn't the list type have an "isempty" method? Or does it? Yes. It's written: if not aList: ... -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfranci

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

2008-07-29 Thread Erik Max Francis
Russ P. wrote: 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 post, I realize that this would only work if there were only one copy of "empty" (as there is only one copy of "Non

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

2008-07-29 Thread Russ P.
On Jul 29, 11:16 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Russ P. 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 e

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

2008-07-29 Thread 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 post, I realize that this would only work if there were only one copy of "empty" (as there is only one copy of "None"). I don't know

Re: elementtree and rounding questions

2008-07-29 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > > > > > > > > > > > >name="Courier">text > >

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

2008-07-29 Thread Erik Max Francis
Russ P. 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(myList) != 0: I can agree with this. But I guess that co

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

2008-07-29 Thread Erik Max Francis
Carl Banks wrote: On Jul 30, 1:15 am, "Russ P." <[EMAIL PROTECTED]> wrote: All this discussion about "if x" has me wondering. I use it all the time because a fully explicit test just seems redundant. But maybe it does have some value in terms of readability and type checking. After all, it is p

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

2008-07-29 Thread Erik Max Francis
Russ P. wrote: All this discussion about "if x" has me wondering. I use it all the time because a fully explicit test just seems redundant. But maybe it does have some value in terms of readability and type checking. After all, it is possible to forget whether something is a number or a list. H

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

2008-07-29 Thread Erik Max Francis
Carl Banks wrote: Bull. This is a request, that, if satisfied, would prove that "if x" is more polymorphic than a simple explicit test. I posed the question precisely to see if anyone could come up with a use case that shows this benefit of "if x". Except you're the only one who's not convin

Re: Overloaded Functions

2008-07-29 Thread Daniel da Silva
With a little hacking, you might be able to do something like this: @overload("f", (int, int, str)) def f1(x, y, z): pass @overload("f", (str, str)) def f2(x, y): pass The way I would typically do method overloading would be as follows (this has been tested): class Person: def __in

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

2008-07-29 Thread Russ P.
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(myList) != 0: > > I can agree with this. But I guess th

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

2008-07-29 Thread Carl Banks
On Jul 30, 1:15 am, "Russ P." <[EMAIL PROTECTED]> wrote: > All this discussion about "if x" has me wondering. I use it all the > time because a fully explicit test just seems redundant. But maybe it > does have some value in terms of readability and type checking. After > all, it is possible to for

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

2008-07-29 Thread Carl Banks
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-advance filters return None and

Re: elementtree and rounding questions

2008-07-29 Thread Gabriel Genellina
En Wed, 30 Jul 2008 00:56:55 -0300, <[EMAIL PROTECTED]> escribi�: One other question I had was about rounding floats. I was first looking at this syntax to round out to 6 decimal places if needed: f = '508.5' x = '%.6f' % (float(f)/72) x '7.062500' However, in this instance I don't want t

Re: Dynamically adding methods to a class...

2008-07-29 Thread arsyed
On Tue, Jul 29, 2008 at 12:17 AM, Piyush Anonymous <[EMAIL PROTECTED]> wrote: > class MyObject: >def __init__(self, name): > self.name = name > >def do_this_default(self): > print "default do_this implementation for %s" % self.name > > def custom_do_this(): #method to be added >

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

2008-07-29 Thread Russ P.
On Jul 29, 9:52 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Jul 29, 11:17 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > > > > > Carl Banks wrote: > > >> As I wrote in the second reply email I sent, check out my integer set > > >> recipe on ASPN (and to save you the search: > > >> http://code.ac

RE: interpreter vs. compiled

2008-07-29 Thread Dino Viehland
IronPython doesn't have an interpreter loop and therefore has no POP / TOP / etc... Instead what IronPython has is a method call Int32Ops.Add which looks like: public static object Add(Int32 x, Int32 y) { long result = (long) x + y; if (Int32.MinValue <= result

Re: Dynamically adding methods to a class...

2008-07-29 Thread Gabriel Genellina
En Tue, 29 Jul 2008 01:17:13 -0300, Piyush Anonymous <[EMAIL PROTECTED]> escribi�: class MyObject: def __init__(self, name): self.name = name def do_this_default(self): print "default do_this implementation for %s" % self.name def custom_do_this(): #method to be added pri

Re: iterating "by twos"

2008-07-29 Thread Daniel da Silva
The following method is similar to the others provided, but yields an index value as well (similar to the enumerate(iterable) function). This is useful in some (but not all) situations. If the iterable object's iterator returns an even number of items then you're fine; otherwise it will throw away

Re: Defunct when using subprocess.Popen

2008-07-29 Thread Gabriel Genellina
En Tue, 29 Jul 2008 10:04:46 -0300, Gordon Maria <[EMAIL PROTECTED]> escribi�: I'm running a GUI in python which is able to launch a separate python process that will run forever. In rare cases I will want to kill the launched process. Every time I do so, I end up with the process as defunc

Re: interpreter vs. compiled

2008-07-29 Thread castironpi
On Jul 29, 1:46 am, Tim Roberts <[EMAIL PROTECTED]> wrote: > castironpi <[EMAIL PROTECTED]> wrote: > > >In CPython yes.  In IronPython yes:  the parts that are compiled into > >machine code are the interpreter, *not user's code*. > > WRONG!  You are WRONG.  At "compile" time, the Python code is com

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

2008-07-29 Thread Carl Banks
On Jul 29, 11:17 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > >> As I wrote in the second reply email I sent, check out my integer set > >> recipe on ASPN (and to save you the search: > >> http://code.activestate.com/recipes/466286/). > > > Couple points: > > > 1. Any containe

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

2008-07-29 Thread Carl Banks
On Jul 30, 12:22 am, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > That's not what I was asking for. I was asking for a use case for "if > > x" that can't be replaced by a simple explicit test. Your example > > didn't satisfy that. > > It's a completely artificial request.

Re: Windows Interpreter

2008-07-29 Thread Gabriel Genellina
En Tue, 29 Jul 2008 17:00:40 -0300, Terry Reedy <[EMAIL PROTECTED]> escribi�: I just found the QuickEdit option. While in an administrator account (if Python is installed for all users), bring up the menu as specified above, select Properties instead, then the Options tab, then select Qu

Re: Attack a sacred Python Cow

2008-07-29 Thread Russ P.
On Jul 29, 2:27 am, Iain King <[EMAIL PROTECTED]> wrote: > On Jul 29, 5:33 am, "Russ P." <[EMAIL PROTECTED]> wrote: > > > > > On Jul 28, 8:44 pm, alex23 <[EMAIL PROTECTED]> wrote: > > > > On Jul 29, 4:46 am, "Russ P." <[EMAIL PROTECTED]> wrote: > > > > > As I said, I could write a pre-processor mys

Re: RTF Parsing

2008-07-29 Thread Gabriel Genellina
En Tue, 29 Jul 2008 10:08:21 -0300, Victor Subervi <[EMAIL PROTECTED]> escribi�: Hi; I have this code: def a(): chars = ['\\i0', '\\u0', '\\qc', '\\b0', '\\ql', '\\i', '\\u', '\\b', '\\yz'] rtf_markup = 'viewkind4\uc1\pard\nowidctlpar\qc\i\f0\fs36 Who is like the Beast? Who can wage war agains

Re: Native Code vs. Python code for modules

2008-07-29 Thread alex23
On Jul 30, 1:56 pm, koblas <[EMAIL PROTECTED]> wrote: > Ruby has been getting pummeled for the last year or more on the > performance subject.  They've been working hard at improving it.  From > my arm chair perspective Python is sitting on it's laurels and not > taking this as seriously as it prob

Re: static variables in Python?

2008-07-29 Thread Daniel da Silva
This is the solution I suggest. It is fairly trivial, and works by introducing the "self.static" namespace for a class's static variables, in contrast to "self" for the class's instance variables. --- class Static(object): pass personStatic = Static() class Pers

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

2008-07-29 Thread Carl Banks
On Jul 29, 7:30 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Tue, 29 Jul 2008 10:30:43 -0700, Carl Banks wrote: > > On Jul 29, 5:15 am, Heiko Wundram <[EMAIL PROTECTED]> wrote: > >> I can't dig up a simple example from code I wrote quickly, but because > >> of the fact tha

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

2008-07-29 Thread Erik Max Francis
Carl Banks wrote: That's not what I was asking for. I was asking for a use case for "if x" that can't be replaced by a simple explicit test. Your example didn't satisfy that. It's a completely artificial request. "if x" _is_ a completely simple test. Simpler, in fact, than the ones you we

Re: interpreter vs. compiled

2008-07-29 Thread castironpi
On Jul 29, 7:39 am, alex23 <[EMAIL PROTECTED]> wrote: > On Jul 29, 2:21 pm, castironpi <[EMAIL PROTECTED]> wrote: > > > On Jul 28, 5:58 pm, Fuzzyman <[EMAIL PROTECTED]> wrote: > > > Well - in IronPython user code gets compiled to in memory assemblies > > > which can be JIT'ed. > > > I don't believe

Re: proxy class and __add__ method

2008-07-29 Thread Gabriel Genellina
En Tue, 29 Jul 2008 13:13:51 -0300, Magnus Schuster <[EMAIL PROTECTED]> escribi�: Hello, I have written the following small proxy class which I expect to pass all function calls to the 'original' object: --- BEGIN --- class proxy(object): def __init__( self, subject ): self.__subj

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

2008-07-29 Thread Carl Banks
On Jul 29, 10:23 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > Bzzt. "if len(x)!=0" is a simple explicit that would work for this > > class and all built-in containers. (Or should--Steven D'Aprano's > > objections notwithstanding, any reasonable container type should > >

Re: Is it allowed to use function results as default arguments ?

2008-07-29 Thread Ben Finney
"fred.haab" <[EMAIL PROTECTED]> writes: > Well, others have answered the question, but I thought I'd throw in > that it would be more pythonic to do something like: > > def Get_Relative_Path(target, base = None): > if base is None: > base = os.curdir > ... Even more Pythonic woul

Re: method decorators and more on decorators

2008-07-29 Thread Gabriel Genellina
En Tue, 29 Jul 2008 08:45:02 -0300, Themis Bourdenas <[EMAIL PROTECTED]> escribi�: On Mon, Jul 28, 2008 at 11:12 AM, Gabriel Genellina <[EMAIL PROTECTED]>wrote: En Sun, 27 Jul 2008 15:26:39 -0300, Themistoklis Bourdenas < [EMAIL PROTECTED]> escribió: > On a related note, as the actual insta

Native Code vs. Python code for modules

2008-07-29 Thread koblas
Ruby has been getting pummeled for the last year or more on the performance subject. They've been working hard at improving it. From my arm chair perspective Python is sitting on it's laurels and not taking this as seriously as it probably should. In general it's possible to make many comments t

elementtree and rounding questions

2008-07-29 Thread jyoung79
Hi, Hoping that some of you won't mind taking a peek at my code and sharing your thoughts. I just started using the elementtree module yesterday to work with xml files. Here's an example of some xml code I might be parsing:

Re: Is it allowed to use function results as default arguments ?

2008-07-29 Thread fred.haab
Well, others have answered the question, but I thought I'd throw in that it would be more pythonic to do something like: def Get_Relative_Path(target, base = None): if base is None: base = os.curdir ... -- http://mail.python.org/mailman/listinfo/python-list

Re: static variables in Python?

2008-07-29 Thread castironpi
On Jul 29, 8:38 pm, pigmartian <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > kj: > >> OK, I guess that in Python the only way to do what I want to do > >> is with objects... > > > There are other ways, like assigning the value out of the function, > > because Python functions too are ob

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

2008-07-29 Thread Terry Reedy
Carl Banks wrote: As I wrote in the second reply email I sent, check out my integer set recipe on ASPN (and to save you the search: http://code.activestate.com/recipes/466286/). Couple points: 1. Any container type that returns a length that isn't exactly the number of elements in it is b

Re: I CAN connect socket to any localhost port but I shouldn't be able to

2008-07-29 Thread Gabriel Genellina
En Tue, 29 Jul 2008 14:56:08 -0300, qvx <[EMAIL PROTECTED]> escribi�: I don't have server listening on port 8084 but I can open socket to it (and to many other ports, tested for all<8000) Your example fails -as expected- on my PC running Python 2.5.2 + Windows XP SP2. It may be something spe

Re: Parsing VHDL with python, where to start.

2008-07-29 Thread Henrique Dante de Almeida
On Jul 29, 11:23 pm, Henrique Dante de Almeida <[EMAIL PROTECTED]> wrote: > On Jul 28, 6:49 pm, Svenn Are Bjerkem <[EMAIL PROTECTED]> > wrote: > > > > > Hi again, > > > when I get far enough to parse the VHDL (which is not currently the > > fact, but I have to look at the work coming up downstream)

Re: Parsing VHDL with python, where to start.

2008-07-29 Thread Henrique Dante de Almeida
On Jul 28, 6:49 pm, Svenn Are Bjerkem <[EMAIL PROTECTED]> wrote: > Hi again, > > when I get far enough to parse the VHDL (which is not currently the > fact, but I have to look at the work coming up downstream) I will have > to put it into an internal data structure and then write some classes > to

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

2008-07-29 Thread Erik Max Francis
Carl Banks wrote: Bzzt. "if len(x)!=0" is a simple explicit that would work for this class and all built-in containers. (Or should--Steven D'Aprano's objections notwithstanding, any reasonable container type should support this invariant. From a language design standpoint, an "empty" builtin c

Re: static variables in Python?

2008-07-29 Thread John Machin
On Jul 30, 11:57 am, "Russ P." <[EMAIL PROTECTED]> wrote: > On Jul 29, 6:33 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > > > > > On Jul 29, 1:40 pm, kj <[EMAIL PROTECTED]> wrote: > > > > Yet another noob question... > > > > Is there a way to mimic C's static variables in Python? Or something > > > l

Re: How can I check nbr of cores of computer?

2008-07-29 Thread [EMAIL PROTECTED]
On Jul 29, 7:44 pm, Mensanator <[EMAIL PROTECTED]> wrote: > On Jul 29, 5:53 pm, defn noob <[EMAIL PROTECTED]> wrote: > > > How can I check how many cores my computer has? > > Is it possible to do this in a Python-app? > > If you're using Windows, get PyWin32: > > win32api.GetSystemInfo > tuple = Ge

Re: static variables in Python?

2008-07-29 Thread Russ P.
On Jul 29, 6:33 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > On Jul 29, 1:40 pm, kj <[EMAIL PROTECTED]> wrote: > > > > > Yet another noob question... > > > Is there a way to mimic C's static variables in Python? Or something > > like it? The idea is to equip a given function with a set of > > const

Re: Boolean tests

2008-07-29 Thread Matthew Woodcraft
Steven D'Aprano <[EMAIL PROTECTED]> wrote: >Anders wrote: >> "But then you decide to name the method "__nonzero__", instead of some >> nice descriptive name?" > That suggests to me that Anders imagined that __nonzero__ is something I > just made up, instead of a standard Python method. What do

Re: static variables in Python?

2008-07-29 Thread pigmartian
[EMAIL PROTECTED] wrote: kj: OK, I guess that in Python the only way to do what I want to do is with objects... There are other ways, like assigning the value out of the function, because Python functions too are objects: ... But I suggest you to use a class in this situation, it's often th

Re: static variables in Python?

2008-07-29 Thread Russ P.
On Jul 29, 1:40 pm, kj <[EMAIL PROTECTED]> wrote: > Yet another noob question... > > Is there a way to mimic C's static variables in Python? Or something > like it? The idea is to equip a given function with a set of > constants that belong only to it, so as not to clutter the global > namespace

lolaaaxwe

2008-07-29 Thread babacity2
http://www.google.com/notebook/public/16705304140696498535/BDQxBQwoQm_aljLcj http://www.google.com/notebook/public/12366932363888735542/BDQV_QgoQlOK7jLcj http://www.google.com/notebook/public/02454303184762488307/BDRE-QwoQoaWWjLcj http://www.google.com/notebook/public/16705304140696498535/BDR96QgoQ

Re: static variables in Python?

2008-07-29 Thread Bruce Frederiksen
On Tue, 29 Jul 2008 21:31:01 +, kj wrote: > In <[EMAIL PROTECTED]> Larry Bates <[EMAIL PROTECTED]> writes: > > [snip] > > Maybe it's easier to see what I mean with JavaScript: > > function foo() { > if (foo.x === undefined) foo.x = expensive_call(); > return do_stuff_with(foo.x); > } de

Re: [unittest] Run setUp only once

2008-07-29 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Nikolaus Rath <[EMAIL PROTECTED]> wrote: > But at least this variation doesn't work, because unittest apparently > also creates two separate TwoTests instances for the two tests. Isn't > there some way to convince unittest to reuse the same instance instead > of tr

Re: How can I check nbr of cores of computer?

2008-07-29 Thread Mensanator
On Jul 29, 5:53 pm, defn noob <[EMAIL PROTECTED]> wrote: > How can I check how many cores my computer has? > Is it possible to do this in a Python-app? If you're using Windows, get PyWin32: win32api.GetSystemInfo tuple = GetSystemInfo() Retrieves information about the current system. Win32 API

Re: How can I check nbr of cores of computer?

2008-07-29 Thread gbs
On Tue, 29 Jul 2008 15:53:47 -0700, defn noob wrote: > How can I check how many cores my computer has? Is it possible to do > this in a Python-app? Well you can try the functions in the 'platform' module, although in my box(debian) nothing useful comes out. I don't think there's a simple & port

Re: POP3 - Using poplib only shows the first few hundred messages in the mailbox

2008-07-29 Thread SteveC
On Jul 25, 6:07 pm, MRAB <[EMAIL PROTECTED]> wrote: > On Jul 25, 1:18 pm, SteveC <[EMAIL PROTECTED]> wrote: > > > Hello, > > > I am trying to use POP3_SSL class of thepoplibmodule to read email > > from my gmail account.  I can connect just fine using the example > > herehttp://www.python.org/doc/

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

2008-07-29 Thread Steven D'Aprano
On Tue, 29 Jul 2008 13:53:07 -0700, Carl Banks wrote: > Bzzt. "if len(x)!=0" is a simple explicit that would work for this > class and all built-in containers. (Or should--Steven D'Aprano's > objections notwithstanding, any reasonable container type should support > this invariant. What's the le

Re: Python parsing iTunes XML/COM

2008-07-29 Thread John Machin
On Jul 30, 3:53 am, william tanksley <[EMAIL PROTECTED]> wrote: > To ask another way: how do I convert from a file:// URL to a local > path in a standard way, so that filepaths from two different sources > will work the same way in a dictionary? > > Right now I'm using the following source: > > tra

Re: Boolean tests

2008-07-29 Thread Ethan Furman
Matthew Woodcraft wrote: Ben Finney <[EMAIL PROTECTED]> wrote: No, he retracted the *insult* and restated the *advice* as a distinct statement. I think it's quite worthwhile to help people see the difference. Ben, it was quite clear from Anders' post that he knows about __nonzero__ . That's

Re: Boolean tests

2008-07-29 Thread Steven D'Aprano
On Tue, 29 Jul 2008 21:25:44 +0100, Matthew Woodcraft wrote: > Ben Finney <[EMAIL PROTECTED]> wrote: >> No, he retracted the *insult* and restated the *advice* as a distinct >> statement. I think it's quite worthwhile to help people see the >> difference. > > Ben, it was quite clear from Anders'

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

2008-07-29 Thread Steven D'Aprano
On Tue, 29 Jul 2008 21:15:12 +0100, Matthew Woodcraft wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: >> "if x" is completely type agnostic. You can pass an object of any type >> to it, and it will work. (Excluding objects with buggy methods, >> naturally.) > > There are many circumstances w

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

2008-07-29 Thread Steven D'Aprano
On Tue, 29 Jul 2008 10:42:50 -0700, Carl Banks wrote: > On Jul 29, 11:12 am, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: ... >> My use case involves a DAG of filters that pass data (of a variety of >> types--filters just pass on data types they don't understand) between >> them. I can also drop

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

2008-07-29 Thread Steven D'Aprano
On Tue, 29 Jul 2008 10:30:43 -0700, Carl Banks wrote: > On Jul 29, 5:15 am, Heiko Wundram <[EMAIL PROTECTED]> wrote: >> I can't dig up a simple example from code I wrote quickly, but because >> of the fact that explicit comparisons always hamper polymorphism > > I'm not going to take your word fo

Re: static variables in Python?

2008-07-29 Thread Ben Finney
kj <[EMAIL PROTECTED]> writes: > Is there a way to mimic C's static variables in Python? Or something > like it? A "static variable" in C is one that has access limited to the scope in which it is declared. Python approaches the same issue through namespaces: a name binding made at a class or mo

Re: DB access without object-relation mapping?

2008-07-29 Thread Ben Finney
kj <[EMAIL PROTECTED]> writes: > The word on the street is to use something like SQLAlchemy for > database access in Python, but my experience in the past with > packages that perform automated SQL generation has been awful, so I > always return to lighter-weight solutions that allow me to write m

Re: static variables in Python?

2008-07-29 Thread bearophileHUGS
kj: > OK, I guess that in Python the only way to do what I want to do > is with objects... There are other ways, like assigning the value out of the function, because Python functions too are objects: def iamslow(): return 100 def foo(x): return x + foo.y foo.y = iamslow() # slow computat

Re: How can I check nbr of cores of computer?

2008-07-29 Thread Casey McGinty
On Tue, Jul 29, 2008 at 12:53 PM, defn noob <[EMAIL PROTECTED]> wrote: > How can I check how many cores my computer has? > Is it possible to do this in a Python-app? > -- > http://mail.python.org/mailman/listinfo/python-list > You can use the HAL interface from the DBUS module. See also the gnome

How can I check nbr of cores of computer?

2008-07-29 Thread defn noob
How can I check how many cores my computer has? Is it possible to do this in a Python-app? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python COM

2008-07-29 Thread Larry Bates
[EMAIL PROTECTED] wrote: I have implemented a COM in C++,buy i don't know how to use this COM in python. For example: the COM's ProgID is "MyCOM1.AdvMethod".this COM have two interfaces,the default interface's name is IAdvMethod,the second interface's name is IBasicMethod. How do i use those inte

Re: Python: SPREE HELP (willing to pay someone)

2008-07-29 Thread Diez B. Roggisch
I cannot help but wonder if this is spam meant to drive traffic to the site. If yes, you just managed to increase its visibility by quoting the whole post including the post. Diez -- http://mail.python.org/mailman/listinfo/python-list

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 D'Aprano <[EMAIL PROTECTE

Re: Python COM

2008-07-29 Thread Michel Claveau - NoSpam SVP ; merci
Re! Pywin32 can use dynamic COM server (without tlb). Therefore, I prefer to wait the return from birdprince... @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: static variables in Python?

2008-07-29 Thread Colin J. Williams
kj wrote: In <[EMAIL PROTECTED]> Larry Bates <[EMAIL PROTECTED]> writes: kj wrote: Yet another noob question... Is there a way to mimic C's static variables in Python? Or something like it? The idea is to equip a given function with a set of constants that belong only to it, so as not to cl

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

2008-07-29 Thread Heiko Wundram
Also, just a couple of points: Am 29.07.2008, 22:27 Uhr, schrieb Carl Banks <[EMAIL PROTECTED]>: 1. Any container type that returns a length that isn't exactly the number of elements in it is broken. I agree, but how do you ever expect to return an infinite element count? The direction I too

Re: Swap memory in Python ? - three questions

2008-07-29 Thread Robert Kern
Terry Reedy wrote: Robert LaMarca wrote: Hi, I am using numpy and wish to create very large arrays. My system is AMD 64 x 2 Ubuntu 8.04. Ubuntu should be 64 bit. I have 3gb RAM and a 15 GB swap drive. The command I have been trying to use is; g=numpy.ones([1000,1000,1000],numpy.int32)

Re: Continuous integration for Python projects

2008-07-29 Thread Erik Ramfelt
Hi all Hudson supports arbitrary ant/shell/batch commands so it basically supports any development environment (as long as it can run java). I use(d) it to build, test, package, pylint my XBMC python script (http://hudson.ramfelt.se/job/XBMC%20TV). If you would like a guide on how to get going, c

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

2008-07-29 Thread giltay
On Jul 29, 1:30 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Jul 29, 5:15 am, Heiko Wundram <[EMAIL PROTECTED]> wrote: > > > I can't dig up a simple example from code I wrote quickly, but because of > > the > > fact that explicit comparisons always hamper polymorphism > > I'm not going to take y

Re: iterating "by twos"

2008-07-29 Thread kj
In <[EMAIL PROTECTED]> Terry Reedy <[EMAIL PROTECTED]> writes: >kj wrote: >> Is there a special pythonic idiom for iterating over a list (or >> tuple) two elements at a time? >> >> I mean, other than >> >> for i in range(0, len(a), 2): >> frobnicate(a[i], a[i+1]) >There have been request

Re: Parsing VHDL with python, where to start.

2008-07-29 Thread Paddy
On Jul 21, 12:09 pm, Svenn Are Bjerkem <[EMAIL PROTECTED]> wrote: > Hi, > I am in the need to write an application for PyQt to visualise the > structure of a VHDL project I am working on. Looking for a sensible > way to parse VHDL files and putting them into a data structure that > PyQt can represe

Re: static variables in Python?

2008-07-29 Thread kj
In <[EMAIL PROTECTED]> Larry Bates <[EMAIL PROTECTED]> writes: >kj wrote: >> Yet another noob question... >> >> Is there a way to mimic C's static variables in Python? Or something >> like it? The idea is to equip a given function with a set of >> constants that belong only to it, so as not to

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

2008-07-29 Thread Carl Banks
On Jul 29, 3:43 pm, "Heiko Wundram" <[EMAIL PROTECTED]> wrote: > Am 29.07.2008, 18:30 Uhr, schrieb Carl Banks <[EMAIL PROTECTED]>: > > > On Jul 29, 5:15 am, Heiko Wundram <[EMAIL PROTECTED]> wrote: > >> I can't dig up a simple example from code I wrote quickly, but because > >> of the > >> fact tha

RE: Execution speed question

2008-07-29 Thread Delaney, Timothy (Tim)
Diez B. Roggisch wrote: >> For sets, I presume they are built on top of or like dicts, and >> there is nothing crazy in the low level implementation so that I can >> be guaranteed that if I don't alter the set, then the order, >> although arbitrary, will be maintained in successive iterations over

Re: Where is the documentation for psycopg2?

2008-07-29 Thread kj
In <[EMAIL PROTECTED]> Matthew Woodcraft <[EMAIL PROTECTED]> writes: >kj <[EMAIL PROTECTED]> wrote: >> Hi. I can't find any documentation for psycopg2. >> >> I'm a noob, so I'm sure I'm just not looking in the right place... >> >> Anybody know where it is? >For basic use, psycopg2 follows the

Re: static variables in Python?

2008-07-29 Thread Larry Bates
kj wrote: Yet another noob question... Is there a way to mimic C's static variables in Python? Or something like it? The idea is to equip a given function with a set of constants that belong only to it, so as not to clutter the global namespace with variables that are not needed elsewhere. Fo

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

2008-07-29 Thread Carl Banks
On Jul 29, 4:08 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > On Jul 29, 1:30 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > >> On Jul 29, 5:15 am, Heiko Wundram <[EMAIL PROTECTED]> wrote: > > >>> I can't dig up a simple example from code I wrote quickly, but because of > >>

Re: Build tool for Python

2008-07-29 Thread Matthew Woodcraft
Paul Boddie <[EMAIL PROTECTED]> wrote: > I do understand that it can be awkward to work out which object files > need recompiling due to changes in source files, for example, and > that one doesn't want to see the logic involved reproduced all over > the place, but I do wonder whether the machiner

Re: Python: SPREE HELP (willing to pay someone)

2008-07-29 Thread Terry Reedy
TGD101 wrote: I need someone who is able to install SPREE an open source program see: http://www.askspree.de/ HOWEVER, here is the catch: It is on WINDOWS, but my server has PYTHON..is there a miracle out there? If so please let me know what I can do? Thank you. Since the site's 'Open Sou

static variables in Python?

2008-07-29 Thread kj
Yet another noob question... Is there a way to mimic C's static variables in Python? Or something like it? The idea is to equip a given function with a set of constants that belong only to it, so as not to clutter the global namespace with variables that are not needed elsewhere. For example,

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

2008-07-29 Thread Heiko Wundram
Am 29.07.2008, 18:30 Uhr, schrieb Carl Banks <[EMAIL PROTECTED]>: On Jul 29, 5:15 am, Heiko Wundram <[EMAIL PROTECTED]> wrote: I can't dig up a simple example from code I wrote quickly, but because of the fact that explicit comparisons always hamper polymorphism I'm not going to take your w

Re: iterating "by twos"

2008-07-29 Thread Terry Reedy
kj wrote: Is there a special pythonic idiom for iterating over a list (or tuple) two elements at a time? I mean, other than for i in range(0, len(a), 2): frobnicate(a[i], a[i+1]) There have been requests to add a grouper function to itertools, but its author has resisted because there

Re: Boolean tests

2008-07-29 Thread Matthew Woodcraft
Ben Finney <[EMAIL PROTECTED]> wrote: > No, he retracted the *insult* and restated the *advice* as a distinct > statement. I think it's quite worthwhile to help people see the > difference. Ben, it was quite clear from Anders' post that he knows about __nonzero__ . That's why the so-called advice

Re: SWIG and char* newb questions :)

2008-07-29 Thread Stefan Behnel
code_berzerker wrote: > Hi i'm relatively new to Python and my C/C++ knowledge is near to > None. Having said that I feel justified to ask stupid questions :) Have you considered using Cython? It's almost Python, but it compiles to C code for a Python extension module and even lets you call C func

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

2008-07-29 Thread Matthew Woodcraft
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > "if x" is completely type agnostic. You can pass an object of any type to > it, and it will work. (Excluding objects with buggy methods, naturally.) There are many circumstances where if a parameter is None I'd rather get an exception than have the co

Re: iterating "by twos"

2008-07-29 Thread kj
Thanks for all the replies. I learned a lot! kynn -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should be discarded. -- http://mail.python.org/mailman/listinfo/python-list

Re: iterating "by twos"

2008-07-29 Thread Erik Max Francis
[EMAIL PROTECTED] wrote: Whoops, I misread the original post. That would be: for x, y in zip(a[::2], a[1::2]): frob(x, y) ... which I don't use a lot. Sorry, posted before I saw your reply. Still, you're building three sublists in order to just iterate over them. -- Erik Max Fr

  1   2   3   >