Re: Basic Boost.Python Question

2006-08-14 Thread Pierre Barbier de Reuille
Hoop wrote: > Hi, > > I have been working in getting Boost.Python running on my PC, seems to > work now. > I have what I believe is somewhat of basic question here. > I am starting on an application that will developed in VS2005, probably > using C++/CLI. > I want to be able to exchange data in b

Re: Nested if and expected an indent block

2006-08-14 Thread Pierre Barbier de Reuille
[EMAIL PROTECTED] wrote: > Simon Forman wrote: >>> I got rid of the triple quote string at the start of the function, and >>> that cleared up the problem, though I don't know why. >>> >> Ah, yes. The docstring for a function (or at least its first >> triple-quote) must be indented to the same degre

Re: do people really complain about significant whitespace?

2006-08-09 Thread Pierre Barbier de Reuille
Carl Banks wrote: > Michiel Sikma wrote: >> Op 8-aug-2006, om 1:49 heeft Ben Finney het volgende geschreven: >> >>> As others have pointed out, these people really do exist, and they >>> each believe their preconception -- that significant whitespace is >>> intrinsically wrong -- is valid, and auto

Re: How do you implement this Python idiom in C++

2006-07-30 Thread Pierre Barbier de Reuille
[EMAIL PROTECTED] wrote: > Pierre Barbier de Reuille wrote: [...] > > I thank you for your response. The equivalent of your solution is > posted hereunder: > class cA(object): > count=0 > def __init__(self): > self.__class__.count +=

Re: Using iterators to write in the structure being iterated through?

2006-07-28 Thread Pierre Barbier de Reuille
Pierre Thibault wrote: > On Wed, 26 Jul 2006 18:54:39 +0200, Peter Otten wrote: > >> Pierre Thibault wrote: >> [...] > > Now, I want to do simple math operations on the data in C. Doing a loop > from 0 to 49 would loop twice through the actual data. In this > context, an iterator is perfect since

Re: How do you implement this Python idiom in C++

2006-07-28 Thread Pierre Barbier de Reuille
[EMAIL PROTECTED] wrote: > Rob Williscroft wrote: > >> If this is more than idle curiosity I strongly suggest you post >> a version of the python code you need to translate to C++. > > For the moment this is just healthy curiosity but i will still post the > code i would like to see translated: >

Re: How do you implement this Python idiom in C++

2006-07-27 Thread Pierre Barbier de Reuille
[EMAIL PROTECTED] wrote: > Hello, > > I have the need to write the equivalent of Python class methods in C++. > > Chuck Allison proposes the following > (http://www.artima.com/cppsource/simple.html): > #include > using namespace std; > > // A base class that provides counting > template class C

Re: Trying to generate a list of the subclasses of C

2006-01-16 Thread Pierre Barbier de Reuille
Charles Krug a écrit : > List: > > I have this: > > # classC.py > > class C(object): pass > > class D(C): pass > > class E(C): pass > > def CSubclasses(): > for name in dir(): pass > > I'm trying to create a list of all of C's subclasses: > > import classC > > print C > aList = [] > fo

Re: boost.python on Debian

2006-01-16 Thread Pierre Barbier de Reuille
Joe bloggs a écrit : > Can anyone tell me how to get boost.python to work on Debian Sarge? > When I try to build the tutorial hello world example bjam reports: > > /usr/share/doc/libboost-doc/examples/libs/python/example/boost-build.jam > attempted to load the build system by invoking > >

Re: Inheritance problem?

2006-01-06 Thread Pierre Barbier de Reuille
KraftDiner a écrit : > So ok I've written a piece of code that demonstrates the problem. > Can you suggest how I change the Square class init? > > class Shape(object): > def __init__(self): > print 'MyBaseClass __init__' > > class Rectangle(Shape): > def __init__(self):

Re: Inheritance problem?

2006-01-06 Thread Pierre Barbier de Reuille
Xavier Morel a écrit : > Pierre Barbier de Reuille wrote: > >> Well, I would even add : don't use super ! >> Just call the superclass method : >> >> MyClass.__init__(self) >> >> >> >> Simon Percivall a écrit : >> >>> Don

Re: Inheritance problem?

2006-01-06 Thread Pierre Barbier de Reuille
Well, I would even add : don't use super ! Just call the superclass method : MyClass.__init__(self) Simon Percivall a écrit : > Don't use self.__class__, use the name of the class. > -- http://mail.python.org/mailman/listinfo/python-list

Re: Proposal for adding symbols within Python

2005-11-16 Thread Pierre Barbier de Reuille
Rocco Moretti a écrit : [...] > > > I did, but I still don't see why it is an argument against using > strings. The point you may not appreciate is that (C)Python already uses > strings to represent names, as an important part of its introspective > abilities. > Well, I'm well aware of that, bu

Re: Not enough arguments for format string

2005-11-14 Thread Pierre Barbier de Reuille
Kevin Walzer a écrit : > I'm getting an error in a Python script I'm writing: "not enough > arguments for format string." The error comes at the end of the > os.system command, referenced below. Any ideas? > > --- > > import EasyDialogs > import os > import sys > > > password = EasyDialogs.AskP

Re: Proposal for adding symbols within Python

2005-11-14 Thread Pierre Barbier de Reuille
Ben Finney a écrit : > Michael <[EMAIL PROTECTED]> wrote: > >>Ben Finney wrote: >> >>>I've yet to see a convincing argument against simply assigning >>>values to names, then using those names. >> >>If you have a name, you can redefine a name, therefore the value a >>name refers to is mutable. > >

Re: Proposal for adding symbols within Python

2005-11-13 Thread Pierre Barbier de Reuille
Björn Lindström a écrit : > Ben Finney <[EMAIL PROTECTED]> writes: > > >>I've yet to see a convincing argument against simply assigning values >>to names, then using those names. > > > The problem with that is that you can't pass around the names of objects > that are used for other things. Obv

Re: Proposal for adding symbols within Python

2005-11-13 Thread Pierre Barbier de Reuille
Steven D'Aprano a écrit : > On Sun, 13 Nov 2005 12:33:48 +0100, Pierre Barbier de Reuille wrote: > > >>Steven D'Aprano a écrit : >>[...] > > > If you want to be technical, Python doesn't have variables. It has names > and objects. > > If

Re: Proposal for adding symbols within Python

2005-11-13 Thread Pierre Barbier de Reuille
Ben Finney a écrit : > Pierre Barbier de Reuille <[EMAIL PROTECTED]> wrote: > >>Mike Meyer a écrit : >> >>>Hmm. You know, $symbol$ doesn't seem nearly as bad as $symbol. It >>>tickles TeX, not P***. I could live with that. >> >>Yep,

Re: Proposal for adding symbols within Python

2005-11-13 Thread Pierre Barbier de Reuille
Steven D'Aprano a écrit : > On Sun, 13 Nov 2005 10:11:04 +0100, Pierre Barbier de Reuille wrote: > > >>The problem, IMHO, is that way you need to declare "symbols" >>beforehands, that's what I was trying to avoid by requiring a new syntax. > > &g

Re: Proposal for adding symbols within Python

2005-11-13 Thread Pierre Barbier de Reuille
Mike Meyer a écrit : > Pierre Barbier de Reuille <[EMAIL PROTECTED]> writes: > >>>While you don't make it clear, it seems obvious that you intend that >>>if $open occurs twice in the same scope, it should refer to the same >>>symbol. So you're usi

Re: Proposal for adding symbols within Python

2005-11-13 Thread Pierre Barbier de Reuille
Mike Meyer a écrit : > Pierre Barbier de Reuille <[EMAIL PROTECTED]> writes: > >>Please, note that I am entirely open for every points on this proposal >>(which I do not dare yet to call PEP). >> >>Abstract >> >> [...] > > >>

Re: Proposal for adding symbols within Python

2005-11-13 Thread Pierre Barbier de Reuille
Ben Finney a écrit : > Pierre Barbier de Reuille <[EMAIL PROTECTED]> wrote: > >>This proposal suggests to add symbols into Python. > > > I still don't think "symbol" is particularly descriptive as a name; > there are too many other things already

Proposal for adding symbols within Python

2005-11-12 Thread Pierre Barbier de Reuille
Please, note that I am entirely open for every points on this proposal (which I do not dare yet to call PEP). Abstract This proposal suggests to add symbols into Python. Symbols are objects whose representation within the code is more important than their actual value. Two symbols needs

Re: What do you use as symbols for Python ?

2005-11-10 Thread Pierre Barbier de Reuille
Well, thank you all ! I still feel it could be good for Python to have some kind of symbols built in, and I will try to expose that to the python-dev list, to see their reaction. But in the different solutions proposed, the one I prefer is probably the definitions of contants in a class to group

What do you use as symbols for Python ?

2005-11-09 Thread Pierre Barbier de Reuille
When you need some symbols in your program, what do you use in Python ? For example, an object get a state. This state is more readable if expressed as a symbols, for example "opened", "closed", "error". Typically, in C or C++, I would use an enum for that: enum OBJECT_STATE { opened, closed, er

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

2005-10-06 Thread Pierre Barbier de Reuille
Mike Meyer a écrit : > Antoon Pardon <[EMAIL PROTECTED]> writes: > >>Op 2005-10-03, Steven D'Aprano schreef <[EMAIL PROTECTED]>: >> >>>On Mon, 03 Oct 2005 13:58:33 +, Antoon Pardon wrote: >> >>Declarations also allow easier writable closures. Since the declaration >>happens at a certain scope,

Re: how to debug when "Segmentation fault"

2005-10-05 Thread Pierre Barbier de Reuille
Maksim Kasimov a écrit : > > yes, to generete core dump is the best way, > > but the command "$ ulimit -c 50" don't make python to generete core > dump in the time of crush. > > I would like to know how to run python script so if it crushes than core > dump will be genereted. > > Thanks >

Re: how to debug when "Segmentation fault"

2005-10-04 Thread Pierre Barbier de Reuille
Maksim Kasimov a écrit : > > Hello, > > my programm sometime gives "Segmentation fault" message (no matter how > long the programm had run (1 day or 2 weeks). And there is nothing in > log-files that can points the problem. > My question is how it possible to find out where is the problem in the

Re: User-defined augmented assignment

2005-09-29 Thread Pierre Barbier de Reuille
Reinhold Birkenfeld a écrit : > Pierre Barbier de Reuille wrote: > > >>So, what I would suggest is to drop the user-defined augmented >>assignment and to ensure this equivalence : >> >>a X= b <=> a = a X b >> >>with 'X' begin one of th

User-defined augmented assignment

2005-09-29 Thread Pierre Barbier de Reuille
Hello, a discussion began on python-dev about this. It began by a bug report, but is shifted and it now belongs to this discussion group. The problem I find with augmented assignment is it's too complex, it's badly explained, it's error-prone. And most of all, I don't see any use-case for it ! T

Re: Parametric Polymorphism

2005-09-26 Thread Pierre Barbier de Reuille
Kay Schluehr a écrit : > Catalin Marinas wrote: > >>Hi, >> >>Sorry if this was previously discussed but it's something I miss in >>Python. I get around this using isinstance() but it would be cleaner >>to have separate functions with the same name but different argument >>types. I think the idea g

Re: Brute force sudoku cracker

2005-09-17 Thread Pierre Barbier de Reuille
Tom Anderson a écrit : > On Fri, 16 Sep 2005, Bas wrote: > >> -any ideas how to easily incorporate advanced solving strategies? >> solve(problem1) and solve(problem2) give solutions, but >> solve(problem3) gets stuck... > > > the only way to solve arbitrary sudoku problems is to guess. Well, th

Re: which is more 'pythonic' / 'better' ?

2005-09-12 Thread Pierre Barbier de Reuille
Will McGugan a écrit : > gabor wrote: > >> hi, >> >> there are 2 versions of a simple code. >> which is preferred? >> >> >> === >> if len(line) >= (n+1): >> text = line[n] >> else: >> text = 'nothing' >> === >> >> >> === >> try: >> text = line[n] >> except IndexError: >> text = 'no

Re: GIL, threads and scheduling - performance cost

2005-08-29 Thread Pierre Barbier de Reuille
[EMAIL PROTECTED] a écrit : > Merci Pierre, > > Yes I agree and plan to move more to C/C++ and releasing the GIL when > entering C/C++. > > I also need to understand my original question re GIL and rescheduling. > I fear that lock/unlock too often is also causing delays due to context > switching

Re: GIL, threads and scheduling - performance cost

2005-08-29 Thread Pierre Barbier de Reuille
[EMAIL PROTECTED] a écrit : > Hi all, > > Wondering if a GIL lock/unlock causes a re-schedule/contect swap when > embedding Python in a multi-threaded C/C++ app on Unix ? > > If so, do I have any control or influence on this re-scheduling ? > > The app suffers from serious performance degradatio

Re: using common lisp with python.

2005-08-29 Thread Pierre Barbier de Reuille
[EMAIL PROTECTED] a écrit : > is there a way to embed common lisp programs in python? > It depends on what you call "embedding" ... can you be more specifiv about what you want ? -- http://mail.python.org/mailman/listinfo/python-list

Re: can I delete one of *.py *.pyc *.pyo in /usr/lib/python2.3 ?

2005-08-20 Thread Pierre Barbier de Reuille
Lucas Raab a écrit : > Miernik wrote: > [...] > > You can delete any two of the three and you shouldn't run into any > problems. However, the .py files are the source code and .pyc and .pyo > are compiled Python files. The .pyc and .pyo files will load faster > because they are compiled. Also, if

Re: can I delete one of *.py *.pyc *.pyo in /usr/lib/python2.3 ?

2005-08-20 Thread Pierre Barbier de Reuille
Miernik a écrit : > On my Debian GNU/Linux system I have Python 2.3 installed in [...] > > I noticed that all those files come in three "flavours": > *.py *.pyc *.pyo > > Is it possible that only one "flavour" of these files is needed, and I can > delete the remaining two, any my Python installat

Re: Multi Threading embedded python

2005-06-30 Thread Pierre Barbier de Reuille
Well, depends on what you want to achieve :) First, I don't think you can call Py_Initialize on many threads. You have special function to initialise different interpreters on per-thread basis. However, the main problem is: do you want to share data across your threads ? If the answer is 'no' the

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Pierre Barbier de Reuille
Ivan Van Laningham a écrit : Hi All-- Maybe I'm not getting it, but I'd think a better name for count would be add. As in d.add(key) d.add(key,-1) d.add(key,399) etc. > [...] There is no existing add() method for dictionaries. Given the name change, I'd like to see it. Metta, Ivan I don't think "

Re: GIL release

2005-03-18 Thread Pierre Barbier de Reuille
Do you mean in Python or in C ? In C this is described in details in the documentation. In Python, I don't think there is a way ! If you want to do so you'll want to use a micro sleep ... Pierre Alastair Basden a écrit : Hi, Does anyone know whether there is a way for a python thread to release

Re: parameter name conflict. How to solve?

2005-03-08 Thread Pierre Barbier de Reuille
Bo Peng a écrit : Dear list, If you ask: why do you choose these names? The answer is: they need to be conformable with other functions, parameter names. I have a function that pretty much like: def output(output=''): print output and now in another function, I need to call output function, wit

Re: python -i (interactive environment)

2005-03-06 Thread Pierre Barbier de Reuille
Very simple is you're on UNIX ... You juste have to put at the beginnin of your file : #!/usr/bin/python -i And it juste does what you want :) Pierre Joe a écrit : When you run "python -i scriptname.py" after the script completes you left at the interactive command prompt. Is there a way to have

Re: Controlling Pc From Server?

2005-02-27 Thread Pierre Barbier de Reuille
[EMAIL PROTECTED] a écrit : Hello Kartic & NG, Thank you for your prompt answer. In effect, I'm trying to work on a NT network of 6 PC (plus the server). Sorry to not have been clearer. Ideally, I'm trying to monitor the Internet activity of each client (PC) on this network (but I'm not a boss

Re: is there a safe marshaler?

2005-02-10 Thread Pierre Barbier de Reuille
Irmen de Jong a écrit : Pickle and marshal are not safe. They can do harmful things if fed maliciously constructed data. That is a pity, because marshal is fast. I need a fast and safe (secure) marshaler. Is xdrlib the only option? I would expect that it is fast and safe because it (the xdr spec) h

Re: convert list of tuples into several lists

2005-02-09 Thread Pierre Barbier de Reuille
Oliver Eichler a écrit : Diez B. Roggisch wrote: zip(*[(1,4),(2,5),(3,6)]) Thanks :) I knew it must be simple. The asterics - thing was new to me. By the way: What is faster? this: z = [(1,4),(2,5),(3,6) a,b = zip(*[(x[0], x[0]-x[1]) for x in z]) or: a = [] b = [] for x in z: a.append(x[0])

Re: multi threading in multi processor (computer)

2005-02-09 Thread Pierre Barbier de Reuille
[EMAIL PROTECTED] a écrit : Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours, Pujo There's just no way you can use Python in a multi-processor environment, bec

Re: IDLE history, Python IDE, and Interactive Python with Vim

2005-02-03 Thread Pierre Barbier de Reuille
Fuzzyman a écrit : If you use IPython for your interactive mode stuff, you'll have a nice history... Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml Best event : if your "EDITOR" system variable in "vim", using the "ed" command in ipython will bring "vim" with (eventually) the code y

Re: Redirecting stdout/err under win32 platform

2005-02-02 Thread Pierre Barbier de Reuille
David Douard a écrit : Alan, I did search Google for this problem (not enough, thou). In fact, I found some kind of solution (by myself, not that much on Google), but it is not really satisfactory. I have used win32 pipes to do so (win32api.CreatePipe). I can redirect stdout/stderr to it from my py

Re: Is this a contradiction in the docs ?

2005-02-02 Thread Pierre Barbier de Reuille
Fuzzyman a écrit : Yes.. but that would mean that eval could only run code objects that "consist[s] of a single expression".. which I doubt is the reality or the intention. Regards, Fuzzyman http://www.voidspace.org.uk/python/index.shtml [Sorry, I deleted the commented lines because they were comp

Re: type of simple object

2005-02-02 Thread Pierre Barbier de Reuille
Steve Holden a écrit : Pierre Barbier de Reuille wrote: [EMAIL PROTECTED] a écrit : Thank you guys. My function should multiply every element of a list, for example "something" and "something" can be an integer or another list. If it deals with integer than it is ok, but I

Re: Is this a contradiction in the docs ?

2005-02-02 Thread Pierre Barbier de Reuille
Fuzzyman a écrit : The following two passages from the python documentation *appear* to contradict each other. Equally possible (or more likely !) is that I misunderstand it : eval : This function can also be used to execute arbitrary code objects (such as those created by compile()). In this case

Re: type of simple object

2005-02-01 Thread Pierre Barbier de Reuille
[EMAIL PROTECTED] a écrit : Thank you guys. My function should multiply every element of a list, for example "something" and "something" can be an integer or another list. If it deals with integer than it is ok, but If it deals with list than it become false for example list*2 = listlist, and what

Re: Help with Threading

2005-01-24 Thread Pierre Barbier de Reuille
Philip Smith a écrit : Hi I am fairly new to Python threading and my needs are simple(!) I want to establish a number of threads each of which work on the same computationally intensive problem in different ways. I am using the thread module rather than the threading module. My problem is I can't

Re: map in Python

2005-01-21 Thread Pierre Barbier de Reuille
You have three ways to do what you want : First wayt is to use lambda. Then, you want to write : >>> map(lambda x: re.sub("[a-z]", "", x), test) Second is to use regular named function : >>> def remove_letters( s ): ... re.sub("[a-z]", "", s) >>> map(remove_letters, test) A third way would be to

Re: extension module, thread safety?

2005-01-19 Thread Pierre Barbier de Reuille
David Bolen a écrit : Nick Coghlan <[EMAIL PROTECTED]> writes: And even before that it was certainly possible to call into the Python interpreter from a native thread using existing functions, albeit the newer functions are more convenient (and perhaps more robust, I don't know). My earliest intera

Re: extension module, thread safety?

2005-01-18 Thread Pierre Barbier de Reuille
Nick Coghlan a écrit : The Python 2.4 docs claim the functions were added in Python 2.3, even though they aren't documented in the 2.3.4 docs. The 2.3 release PEP (PEP 283) confirms that PEP 311 (which added these functions) went in. Indeed, I just tested it and now it works fine :) Thanks a lot

Re: extension module, thread safety?

2005-01-18 Thread Pierre Barbier de Reuille
Nick Coghlan a écrit : Pierre Barbier de Reuille wrote: With the current CPython, it's very hard to mix Python and C in a multithreading application (with C-threads, not Python-threads). In fact I never really succeeded in that task because of that GIL ! I have a multi-thread applicatio

Re: extension module, thread safety?

2005-01-17 Thread Pierre Barbier de Reuille
David Bolen a écrit : If the threads under discussion are all Python threads, then by default yes, the extension module C functions will appear to be atomic from the perspective of the Python code. When the Python code calls into the extension module, the GIL (global interpreter lock) is still bei

Re: Unclear On Class Variables

2005-01-14 Thread Pierre Barbier de Reuille
Pierre Barbier de Reuille a écrit : Antoon Pardon a écrit : Well I find this a confusing behaviour on python's part. The fact that instance.field can mean something different, depending on where in a statement you find it, makes the behaviour inconsistent. I know people in general here are ag

Re: Unclear On Class Variables

2005-01-13 Thread Pierre Barbier de Reuille
Antoon Pardon a écrit : Well I find this a confusing behaviour on python's part. The fact that instance.field can mean something different, depending on where in a statement you find it, makes the behaviour inconsistent. I know people in general here are against declarations, but declarations could

Re: how to visualize symbol table?

2005-01-12 Thread Pierre Barbier de Reuille
Thomas Korimort a écrit : Hi, how can i visualize the content of the symbol table in Python? Sometimes i want to know which symbols are imported from apackage and such kind of things Greetings, THomas Korimort Do you mean something like : dir(module) ??? Pierre -- http://mail.python.org/mailman/l

Re: Suggestion for "syntax error": ++i, --i

2004-12-13 Thread Pierre Barbier de Reuille
Christian Ergh a écrit : Hmm, i never liked the i++ syntax, because there is a value asignment behind it and it does not show - except the case you are already used to it. >>> i = 1 >>> i +=1 >>> i 2 I like this one better, because you see the assignment at once, it is easy to read and inuit

Re: Qt String Question

2004-12-13 Thread Pierre Barbier de Reuille
Michael McGarry wrote: Michael McGarry wrote: Hi, How do I convert from a qt.QString to a Python string? Michael Apparently the ascii() method of QString does this. (I answered my own question). sorry for wasting newsgroup space. Depending on the kind of string you have, latin1() may be a better

Re: Semaphore or what should I use?

2004-12-06 Thread Pierre Barbier de Reuille
Sergei Organov a ecrit : Pierre Barbier de Reuille <[EMAIL PROTECTED]> writes: Ville Vainio a ecrit : "Bastian" == Bastian Hammer <[EMAIL PROTECTED]> writes: Bastian> Now I have to make sure, that both threads are Bastian> synchronal, 1 thread edits something

Re: Semaphore or what should I use?

2004-12-02 Thread Pierre Barbier de Reuille
Ville Vainio a écrit : "Bastian" == Bastian Hammer <[EMAIL PROTECTED]> writes: Bastian> Now I have to make sure, that both threads are Bastian> synchronal, 1 thread edits something and the other is Bastian> blocked until the first thread is ready. Bastian> Isn´t it a good idea to d

Re: non blocking read()

2004-12-02 Thread Pierre Barbier de Reuille
Steve Holden a écrit : Donn Cave wrote: In article <[EMAIL PROTECTED]>, Gustavo Córdova Avila <[EMAIL PROTECTED]> wrote: David Bolen wrote: Jp Calderone <[EMAIL PROTECTED]> writes: def nonBlockingReadAll(fileObj): bytes = [] while True: b = fileObj.read(1024)

Re: documentation for PyArg_ParseTupleAndKeywords

2004-11-30 Thread Pierre Barbier de Reuille
Steven Bethard a écrit : I'm just starting to play around with the Python source. (Specifically, I'm looking at adding a key argument to max/min like sorted has.) Can anyone direct me to the documentation on how PyArg_ParseTupleAndKeywords, etc. work? In particular, I can't figure out how th