Re: [unittest] Run setUp only once

2008-07-29 Thread Jean-Paul Calderone
On Tue, 29 Jul 2008 20:12:14 +0200, Nikolaus Rath <[EMAIL PROTECTED]> wrote: Jean-Paul Calderone <[EMAIL PROTECTED]> writes: On Tue, 29 Jul 2008 19:26:09 +0200, Nikolaus Rath <[EMAIL PROTECTED]> wrote: Jean-Paul Calderone <[EMAIL PROTECTED]> writes: On Tue, 29 Jul 2008 16:35:55 +0200, Nikolaus

Python / PAMIE - scriptWrite Function

2008-07-29 Thread frankrentef
In using PAMIE 2.0 specifically the "scripWrite" function I'm getting the following error... File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 489, in _getattr_ further states... raise AttributeError, "%s.%s" % (self._username_, attr) Help... :) -- http://mail.python.org/m

Re: Python / PAMIE - scriptWrite Function

2008-07-29 Thread frankrentef
On Jul 29, 1:26 pm, frankrentef <[EMAIL PROTECTED]> wrote: > In using PAMIE 2.0 specifically the "scripWrite" function I'm getting > the following error... > > File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line > 489, in _getattr_ > > further states... > > raise AttributeError, "

Re: iterating "by twos"

2008-07-29 Thread giltay
On Jul 29, 1:36 pm, kj <[EMAIL PROTECTED]> wrote: > Is there a special pythonic idiom for iterating over a list (or > tuple) two elements at a time? I use this one a lot: for x, y in zip(a, a[1:]): frob(x, y) Geoff G-T -- http://mail.python.org/mailman/listinfo/python-list

Python: SPREE HELP (willing to pay someone)

2008-07-29 Thread TGD101
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. -- http://mail.python.org/mailman/listinfo/pyt

Re: block/lambda

2008-07-29 Thread Terry Reedy
iu2 wrote: On Jul 29, 9:36 am, Duncan Booth <[EMAIL PROTECTED]> wrote: Your example becomes: def dotimes(n, callable): for i in range(n): callable(i) def block(i): for j in range(i): print j, print dotimes(5, block) 0 0 1 0 1 2 0 1 2 3 The on

Re: like py2exe, but on a mac

2008-07-29 Thread Russell E. Owen
In article <[EMAIL PROTECTED]>, William McBrine <[EMAIL PROTECTED]> wrote: > On Sun, 13 Jul 2008 00:58:59 +0200, Python.Arno wrote: > > > http://undefined.org/python/py2app.html > > py2app bundles Python itself into the app, right? I wonder, is there no > way to create an app bundle that relie

Re: Attack a sacred Python Cow

2008-07-29 Thread Terry Reedy
Nikolaus Rath wrote: Bruno Desthuilliers <[EMAIL PROTECTED]> writes: Nikolaus Rath a écrit : Thats true. But out of curiosity: why is changing the interpreter such a bad thing? (If we suppose for now that the change itself is a good idea). Because it would very seriously break a *lot* of c

Re: like py2exe, but on a mac

2008-07-29 Thread Russell E. Owen
In article <[EMAIL PROTECTED]>, Tommy Nordgren <[EMAIL PROTECTED]> wrote: > On 28 jul 2008, at 03.59, William McBrine wrote: > > > On Sun, 13 Jul 2008 00:58:59 +0200, Python.Arno wrote: > > > >> http://undefined.org/python/py2app.html > > > > py2app bundles Python itself into the app, right? I w

Re: Where is the documentation for psycopg2?

2008-07-29 Thread Matthew Woodcraft
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 dbapi, which is described in http://www.python.org/dev/peps/pep-0249/ Additi

Re: Swap memory in Python ? - three questions

2008-07-29 Thread Terry Reedy
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) This returns a mem

Re: iterating "by twos"

2008-07-29 Thread william tanksley
kj <[EMAIL PROTECTED]> wrote: > Is there a special pythonic idiom for iterating over a list (or > tuple) two elements at a time? I don't know of one, and I shouldn't be answering, but the following should work: def gulp_two(items): for i,j in zip(items[0::2], items[1::2]): yield (i,j) Let'

Re: iterating "by twos"

2008-07-29 Thread giltay
On Jul 29, 2:36 pm, [EMAIL PROTECTED] wrote: > On Jul 29, 1:36 pm, kj <[EMAIL PROTECTED]> wrote: > > > Is there a special pythonic idiom for iterating over a list (or > > tuple) two elements at a time? > >      I use this one a lot: > > for x, y in zip(a, a[1:]): >     frob(x, y) > > Geoff G-T

Re: Python Written in C?

2008-07-29 Thread Warren Myers
The OO overheads for C++ are almost non-existent. http://www.informit.com/articles/article.aspx?p=1192024&ns=15058 On Mon, Jul 21, 2008 at 2:05 PM, Dan Upton <[EMAIL PROTECTED]> wrote: > On Mon, Jul 21, 2008 at 1:21 PM, Marc 'BlackJack' Rintsch > <[EMAIL PROTECTED]> wrote: >> On Mon, 21 Jul 2008 1

Re: Windows Interpreter

2008-07-29 Thread Terry Reedy
Tim Golden wrote: Victor Subervi wrote: 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 against him?\par' for char in chars: c = '(?<=' + char +

Re: Questions on 64 bit versions of Python

2008-07-29 Thread Fuzzyman
On Jul 26, 8:02 pm, Rob Williscroft <[EMAIL PROTECTED]> wrote: > Martin v. Löwis wrote innews:[EMAIL PROTECTED] > comp.lang.python: > > >> I just tested, I built a default C# forms app using the "AnyCPU" > >> option and it ran as a 64 bit app (no *32 in Task Manager), this is > >> on XP64. > > >> I

Re: Build tool for Python

2008-07-29 Thread Terry Reedy
Hussein B wrote: Hi. Apache Ant is the de facto building tool for Java (whether JSE, JEE and JME) application. With Ant you can do what ever you want: compile, generate docs, generate code, packing, deploy, connecting to remote servers and every thing. Do we have such a tool for Python projects

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

2008-07-29 Thread Erik Max Francis
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 the fact that explicit comparisons always hamper polymorphism I'm not going to tak

Re: iterating "by twos"

2008-07-29 Thread Erik Max Francis
[EMAIL PROTECTED] wrote: On Jul 29, 1:36 pm, kj <[EMAIL PROTECTED]> wrote: Is there a special pythonic idiom for iterating over a list (or tuple) two elements at a time? I use this one a lot: for x, y in zip(a, a[1:]): frob(x, y) It doesn't work: >>> a = range(10) >>> [(x, y) for

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

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

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: 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 [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

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

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

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

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

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

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: 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 [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: 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: 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: 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: [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: 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

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

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

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:

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

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

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

<    1   2   3   >