Re: Python to Julia code generator?

2018-02-21 Thread Etienne Robillard



Le 2018-02-21 à 05:27, Chris Angelico a écrit :


"""If you find that your production code is too slow because you’re
using mutual recursion between nine different languages, blame Dan Luu
for this terrible idea."""

I have... NEVER gone as far as nine. That takes the cake. In fact, I
don't recall ever going beyond three. At least, not in production...

ChrisA


Dude that is advanced stuff... :-)

Etienne

--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python to Julia code generator?

2018-02-21 Thread Chris Angelico
On Wed, Feb 21, 2018 at 9:04 PM, Steven D'Aprano
 wrote:
> On Wed, 21 Feb 2018 04:13:56 -0500, Etienne Robillard wrote:
>
>> Hi,
>>
>> Would it be possible to build a Python to Julia code generator??
>>
>> i'm interested to learn Julia and would love to have the capacity to
>> embed or run native Python code in Julia..
>
> http://blog.leahhanson.us/post/julia/julia-calling-python.html
>

"""If you find that your production code is too slow because you’re
using mutual recursion between nine different languages, blame Dan Luu
for this terrible idea."""

I have... NEVER gone as far as nine. That takes the cake. In fact, I
don't recall ever going beyond three. At least, not in production...

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python to Julia code generator?

2018-02-21 Thread Etienne Robillard

I found this: https://github.com/JuliaPy/PyCall.jl

Looks pretty awesome already! :-)

Thx

E

Le 2018-02-21 à 05:04, Steven D'Aprano a écrit :

On Wed, 21 Feb 2018 04:13:56 -0500, Etienne Robillard wrote:


Hi,

Would it be possible to build a Python to Julia code generator??

i'm interested to learn Julia and would love to have the capacity to
embed or run native Python code in Julia..

http://blog.leahhanson.us/post/julia/julia-calling-python.html






--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python to Julia code generator?

2018-02-21 Thread Steven D'Aprano
On Wed, 21 Feb 2018 04:13:56 -0500, Etienne Robillard wrote:

> Hi,
> 
> Would it be possible to build a Python to Julia code generator??
> 
> i'm interested to learn Julia and would love to have the capacity to
> embed or run native Python code in Julia..

http://blog.leahhanson.us/post/julia/julia-calling-python.html




-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


Python to Julia code generator?

2018-02-21 Thread Etienne Robillard

Hi,

Would it be possible to build a Python to Julia code generator??

i'm interested to learn Julia and would love to have the capacity to 
embed or run native Python code in Julia..


Thx

Etienne

--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

--
https://mail.python.org/mailman/listinfo/python-list


Re: c code generator from python

2018-02-19 Thread Stefan Behnel
bhattacharya.kush...@gmail.com schrieb am 17.01.2018 um 12:03:
> Is there any python framework or any tool as  which can generate C code from 
> python code as it is .

http://cython.org/

Stefan

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-23 Thread Steven D'Aprano
On Tue, 23 Jan 2018 17:43:18 +, bartc wrote:

> It wouldn't be a satisfactory way of writing C programs. So, although
> I'm not that big a fan of C syntax, it might be better to write C as C,
> and Python as Python, to avoid confusion.)

This.

The fundamental reality is that `a + b` means different things in C and 
Python. Even if you limit yourself to integers and not arbitrary values 
(fractions, lists, strings, etc) the semantics are different:

- in C, ints have a fixed number of bits and any addition which
  ends up out of range is undefined behaviour[1];

- while Python uses BigInts, overflow is impossible, and the
  only possible error is that you run out of memory and an
  exception is raised (although the addition can take an 
  indefinite long amount of time).


Often the difference doesn't matter... but when it does matter, it 
*really* matters.




[1] If anyone thinks that it is addition with overflow, you are wrong. 
Some C compilers *may* use overflow, but the language strictly defines it 
as undefined behaviour, so the compiler can equally choose to set your 
computer on fire[2] if it prefers.

https://blog.regehr.org/archives/213



[2] http://www.catb.org/jargon/html/H/HCF.html


-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-23 Thread bartc

On 23/01/2018 13:34, bartc wrote:
Perhaps you simply want to use Python syntax to write C code? That would  > be a different kind of translator. And a simpler one, as 'a=b+c' > 

translates to 'a+b+c;' in C.
Or rather, 'a=b+c;'

(I've written source to source translators, some of which could target 
C, but not Python to C.


It would be feasible to write C code in a syntax that looks rather like 
Python, but it won't be real Python, and you can't run it as Python.


It wouldn't be a satisfactory way of writing C programs. So, although 
I'm not that big a fan of C syntax, it might be better to write C as C, 
and Python as Python, to avoid confusion.)


--
bartc

--
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-23 Thread Chris Angelico
On Wed, Jan 24, 2018 at 1:45 AM,   wrote:
> Hey Ally,
>
> Cython adds a big chunk of complexity to simple things. That's the problem.

That's like saying "Unicode adds a big chunk of complexity to the
simple task of translating a word from Japanese into Russian". No, it
doesn't; the complexity is inherent in the problem. You cannot
translate Python code into C code without either (a) reimplementing
all of Python's semantics, as Cython does; or (b) drastically changing
the semantics, such that even the very simplest of code might behave
quite differently; or (c) manually reading through the code and
writing equivalent C, which is what you might call "porting" or
"rewriting". (Or possibly "prototyping", if the intention was always
to transform it into C.) There is fundamentally NO easy way to
translate code from one language into another and get readable,
idiomatic code at the other end.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-23 Thread theodore . leblanc

Hey Ally,

Cython adds a big chunk of complexity to simple things. That's the problem.

Greetings.

On 01/23/2018 01:54 PM, ally.m...@bankmail.host wrote:

Have you tried cython ?

On 01/23/2018 01:25 PM, kushal bhattacharya wrote:
On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal 
bhattacharya wrote:

Hi,
Is there any python framework or any tool as  which can generate C 
code from python code as it is .


Thanks,
Kushal


hi,
I have found nuitka as asuitable candidate but it seems that nuitka 
doesnt generate a simple C code which could be included as a C file in 
another program.Is there any alternative easier way regarding this?


Thanks


--
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-23 Thread kushal bhattacharya
On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya 
wrote:
> Hi,
> Is there any python framework or any tool as  which can generate C code from 
> python code as it is .
> 
> Thanks,
> Kushal

ok so which python tool would be the best one which can be included and 
parameters can be passed to from another C code file
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-23 Thread Andrew Z
Id go this way too. Basic C is straightforward.  I usually consider
learning a new "thing " if the time to support potwntially combersome
solution using existing methods  justifies the effort.

On Jan 23, 2018 09:01, "Ned Batchelder"  wrote:

> On 1/23/18 8:48 AM, kushal bhattacharya wrote:
>
>> On Tuesday, January 23, 2018 at 7:05:02 PM UTC+5:30, bartc wrote:
>>
>>> On 23/01/2018 13:23, kushal bhattacharya wrote:
>>>
 On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal
 bhattacharya wrote:

> Hi,
> Is there any python framework or any tool as  which can generate C
> code from python code as it is .
>
> Thanks,
> Kushal
>
 yes i have but it generates a complex C code with python dependencies.I
 want to call the generated function from another C code but i Cant figure
 out how to do that

>>> Because the translation isn't simply defined.
>>>
>>> I've just tried nuitka on the Python code 'a=b+c', and it generates 2400
>>> lines of C. The main purpose seems to be to generate a self-contained
>>> executable corresponding to the Python, but generating first a C
>>> equivalent then using a C compiler and linker.
>>>
>>> This equivalent code may just contain all the bits in CPython needed to
>>> do the job, but bypassing all the stuff to do with executing actual
>>> byte-code. But it also seems to do some optimisations (in the generated
>>> C before it uses C compiler optimisations), so that if static types can
>>> be inferred it might make use of that info.
>>>
>>> Perhaps you simply want to use Python syntax to write C code? That would
>>> be a different kind of translator. And a simpler one, as 'a=b+c'
>>> translates to 'a+b+c;' in C.
>>>
>>> --
>>> bartc
>>>
>>
>> This is exactly what i meant to say.My goal is to translate the python
>> code into its C equivalent with function name as it is.
>>
>
> The best way to do that is to read the Python code, understand what it
> does, and re-write it in C.  You won't find an automatic tool that can do
> the job you want.  The semantics of Python and C are too different.
>
> --Ned.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-23 Thread Kirill Balunov
You can look at SymPy code generator
http://docs.sympy.org/latest/modules/utilities/codegen.html
Perhaps this is exactly what you need.

With kind regards,
-gdg

2018-01-23 17:00 GMT+03:00 Ned Batchelder :

> On 1/23/18 8:48 AM, kushal bhattacharya wrote:
>
>> On Tuesday, January 23, 2018 at 7:05:02 PM UTC+5:30, bartc wrote:
>>
>>> On 23/01/2018 13:23, kushal bhattacharya wrote:
>>>
>>>> On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal
>>>> bhattacharya wrote:
>>>>
>>>>> Hi,
>>>>> Is there any python framework or any tool as  which can generate C
>>>>> code from python code as it is .
>>>>>
>>>>> Thanks,
>>>>> Kushal
>>>>>
>>>> yes i have but it generates a complex C code with python dependencies.I
>>>> want to call the generated function from another C code but i Cant figure
>>>> out how to do that
>>>>
>>> Because the translation isn't simply defined.
>>>
>>> I've just tried nuitka on the Python code 'a=b+c', and it generates 2400
>>> lines of C. The main purpose seems to be to generate a self-contained
>>> executable corresponding to the Python, but generating first a C
>>> equivalent then using a C compiler and linker.
>>>
>>> This equivalent code may just contain all the bits in CPython needed to
>>> do the job, but bypassing all the stuff to do with executing actual
>>> byte-code. But it also seems to do some optimisations (in the generated
>>> C before it uses C compiler optimisations), so that if static types can
>>> be inferred it might make use of that info.
>>>
>>> Perhaps you simply want to use Python syntax to write C code? That would
>>> be a different kind of translator. And a simpler one, as 'a=b+c'
>>> translates to 'a+b+c;' in C.
>>>
>>> --
>>> bartc
>>>
>>
>> This is exactly what i meant to say.My goal is to translate the python
>> code into its C equivalent with function name as it is.
>>
>
> The best way to do that is to read the Python code, understand what it
> does, and re-write it in C.  You won't find an automatic tool that can do
> the job you want.  The semantics of Python and C are too different.
>
> --Ned.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-23 Thread Ned Batchelder

On 1/23/18 8:48 AM, kushal bhattacharya wrote:

On Tuesday, January 23, 2018 at 7:05:02 PM UTC+5:30, bartc wrote:

On 23/01/2018 13:23, kushal bhattacharya wrote:

On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya 
wrote:

Hi,
Is there any python framework or any tool as  which can generate C code from 
python code as it is .

Thanks,
Kushal

yes i have but it generates a complex C code with python dependencies.I want to 
call the generated function from another C code but i Cant figure out how to do 
that

Because the translation isn't simply defined.

I've just tried nuitka on the Python code 'a=b+c', and it generates 2400
lines of C. The main purpose seems to be to generate a self-contained
executable corresponding to the Python, but generating first a C
equivalent then using a C compiler and linker.

This equivalent code may just contain all the bits in CPython needed to
do the job, but bypassing all the stuff to do with executing actual
byte-code. But it also seems to do some optimisations (in the generated
C before it uses C compiler optimisations), so that if static types can
be inferred it might make use of that info.

Perhaps you simply want to use Python syntax to write C code? That would
be a different kind of translator. And a simpler one, as 'a=b+c'
translates to 'a+b+c;' in C.

--
bartc


This is exactly what i meant to say.My goal is to translate the python code 
into its C equivalent with function name as it is.


The best way to do that is to read the Python code, understand what it 
does, and re-write it in C.  You won't find an automatic tool that can 
do the job you want.  The semantics of Python and C are too different.


--Ned.
--
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-23 Thread kushal bhattacharya
On Tuesday, January 23, 2018 at 7:05:02 PM UTC+5:30, bartc wrote:
> On 23/01/2018 13:23, kushal bhattacharya wrote:
> > On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya 
> > wrote:
> >> Hi,
> >> Is there any python framework or any tool as  which can generate C code 
> >> from python code as it is .
> >>
> >> Thanks,
> >> Kushal
> > 
> > yes i have but it generates a complex C code with python dependencies.I 
> > want to call the generated function from another C code but i Cant figure 
> > out how to do that
> 
> Because the translation isn't simply defined.
> 
> I've just tried nuitka on the Python code 'a=b+c', and it generates 2400 
> lines of C. The main purpose seems to be to generate a self-contained 
> executable corresponding to the Python, but generating first a C 
> equivalent then using a C compiler and linker.
> 
> This equivalent code may just contain all the bits in CPython needed to 
> do the job, but bypassing all the stuff to do with executing actual 
> byte-code. But it also seems to do some optimisations (in the generated 
> C before it uses C compiler optimisations), so that if static types can 
> be inferred it might make use of that info.
> 
> Perhaps you simply want to use Python syntax to write C code? That would 
> be a different kind of translator. And a simpler one, as 'a=b+c' 
> translates to 'a+b+c;' in C.
> 
> -- 
> bartc


This is exactly what i meant to say.My goal is to translate the python code 
into its C equivalent with function name as it is.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-23 Thread bartc

On 23/01/2018 13:23, kushal bhattacharya wrote:

On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya 
wrote:

Hi,
Is there any python framework or any tool as  which can generate C code from 
python code as it is .

Thanks,
Kushal


yes i have but it generates a complex C code with python dependencies.I want to 
call the generated function from another C code but i Cant figure out how to do 
that


Because the translation isn't simply defined.

I've just tried nuitka on the Python code 'a=b+c', and it generates 2400 
lines of C. The main purpose seems to be to generate a self-contained 
executable corresponding to the Python, but generating first a C 
equivalent then using a C compiler and linker.


This equivalent code may just contain all the bits in CPython needed to 
do the job, but bypassing all the stuff to do with executing actual 
byte-code. But it also seems to do some optimisations (in the generated 
C before it uses C compiler optimisations), so that if static types can 
be inferred it might make use of that info.


Perhaps you simply want to use Python syntax to write C code? That would 
be a different kind of translator. And a simpler one, as 'a=b+c' 
translates to 'a+b+c;' in C.


--
bartc

--
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-23 Thread kushal bhattacharya
On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya 
wrote:
> Hi,
> Is there any python framework or any tool as  which can generate C code from 
> python code as it is .
> 
> Thanks,
> Kushal

yes i have but it generates a complex C code with python dependencies.I want to 
call the generated function from another C code but i Cant figure out how to do 
that
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-23 Thread paulina . zuniga

What about Cython?

On 01/23/2018 01:25 PM, kushal bhattacharya wrote:

On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya 
wrote:

Hi,
Is there any python framework or any tool as  which can generate C code from 
python code as it is .

Thanks,
Kushal


hi,
I have found nuitka as asuitable candidate but it seems that nuitka doesnt 
generate a simple C code which could be included as a C file in another 
program.Is there any alternative easier way regarding this?

Thanks


--
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-23 Thread kushal bhattacharya
On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya 
wrote:
> Hi,
> Is there any python framework or any tool as  which can generate C code from 
> python code as it is .
> 
> Thanks,
> Kushal

hi,
I have found nuitka as asuitable candidate but it seems that nuitka doesnt 
generate a simple C code which could be included as a C file in another 
program.Is there any alternative easier way regarding this?

Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-17 Thread bartc

On 17/01/2018 11:04, kushal bhattacharya wrote:

Hi,
Is there any python framework or any tool as  which can generate C code from 
python code as it is .


What C code would you expect to see from this line of Python:

   a = b + c

?

--
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-17 Thread David Palao
Hi,
Have a look at Cython.

Best

2018-01-17 12:04 GMT+01:00 kushal bhattacharya :
> Hi,
> Is there any python framework or any tool as  which can generate C code from 
> python code as it is .
>
> Thanks,
> Kushal
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


python to C code generator

2018-01-17 Thread kushal bhattacharya
Hi,
Is there any python framework or any tool as  which can generate C code from 
python code as it is .

Thanks,
Kushal
-- 
https://mail.python.org/mailman/listinfo/python-list


c code generator from python

2018-01-17 Thread bhattacharya . kushal4
Hi,
Is there any python framework or any tool as  which can generate C code from 
python code as it is .

Thanks,
Kushal
-- 
https://mail.python.org/mailman/listinfo/python-list


how to write code generator for Isabelle by using pygments?

2016-05-28 Thread meInvent bbird
how to write code generator for Isabelle by using pygments?

i am thinking to write a machine learning code to generate code 
by learning example from Isabelle code

however, after google, not much information about this.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-18 Thread Mick Krippendorf
Mark Lawrence wrote:
> On 17/07/2010 20:38, Mick Krippendorf wrote:
>>
>> If Java were *really* a multiple dispatch language, it wouldn't be
>> necessary to repeat the accept-code for every subclass. Instead a single
>> accept method in the base class would suffice. In fact, with true
>> multiple dispatch VP wouldn't even be needed.
> 
> Boilerplate, boilerplate everywhere, but not a beer to drink.

That's Java for ya.



class ASTNode:
def accept(self, visitor):
getattr(visitor, self.__class__.__name__)(self)

class IfNode(ASTNode):
... # inherits generic accept method

class ElseNode(ASTNode):
... # inherits generic accept method

class PrettyPrinter:
def IfNode(self, node):
...
def ElseNode(self, node):
...



Regards,
Mick.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-17 Thread Mark Lawrence

On 17/07/2010 20:38, Mick Krippendorf wrote:

Karsten Wutzke wrote:

The visitor pattern uses single-dispatch, that is, it determines
which method to call be the type of object passed in.


Say, in Python, I have an object o and want to call one of it's methods,
say m. Then which of possibly many methods m to call is determined by
the type of o, and nothing else (at least without further magic) -
hence, it is single dispatch. The VP uses two single dispatch calls (one
being a callback) to accomplish double dispatching.

Java has a form of multiple dispatch through function overloading. In
fact, it's still single dispatch, because which of the targets
overloaded methods gets called is determined at compile time by the
staticly known types of the methods parameters, AKA the formal parameter
types.

Anyway. Although VP *uses* double dispatch, it does not necessarily rely
on function overloading. In Java the VP is most often implemented like this:



interface IASTNode {
 void accept(IASTVisitor);
}

class IfNode implements IASTNode {
 void accept(IASTVisitor visitor) {
 visitor.visit(this);
 }
}

class ElseNode implements IASTNode {
 void accept(IASTVisitor visitor) {
 visitor.visit(this);
 }
}

interface IASTVisitor {
 void visit(IfNode node);
 void visit(ElseNode node);
 ...
}
class PrettyPrinter implements IASTVisitor {
 public void visit(IfNode n) {
 ...
 }
 public void visit(ElseNode n) {
 ...
 }
}



but it could as well be implemented like this:



interface IASTNode {
 void accept(IASTVisitor);
}

class IfNode implements IASTNode {
 void accept(IASTVisitor visitor) {
 visitor.visitIfNode(this);
 }
}

class ElseNode implements IASTNode {
 void accept(IASTVisitor visitor) {
 visitor.visitElseNode(this);
 }
}

interface IASTVisitor {
 void visitIfNode(IfNode node);
 void visitElseNode(ElseNode node);
 ...
}
class PrettyPrinter implements IASTVisitor {
 public void visitIfNode(IfNode n) {
 ...
 }
 public void visitElseNode(ElseNode n) {
 ...
 }
}



If Java were *really* a multiple dispatch language, it wouldn't be
necessary to repeat the accept-code for every subclass. Instead a single
accept method in the base class would suffice. In fact, with true
multiple dispatch VP wouldn't even be needed.


Regards,
Mick.


Boilerplate, boilerplate everywhere, but not a beer to drink.

Hope everyone at EuroPython is having a good time.

Kindest regards.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-17 Thread Mick Krippendorf
Hello,

Am 16.07.2010 09:52, Michele Simionato wrote:
> [os.path.walk vs os.walk]
> There is a big conceptual difference between os.path.walk and os.walk.
> The first works like a framework: you pass a function to it and
> os.path.walk is in charging of calling it when needed. The second works
> like a library: os.walk flattens the hierarchical structure and then
> you are in charge of doing everything you wish with it.
> 
> os.walk is the Pythonic way, and you suggested to follow that
> approach; for instance elementTree and lxml (libraries for parsing XML 
> data) work exactly that way. Actually one of the motivating examples for
> the introduction of generators in Python was their use in flattening
> data structure, i.e. exactly the pattern used by os.walk.

The Visitor Pattern isn't about traversing, so they could as well have
had an os.walk() that took a visitor object. Instead, it's about the
untangling of unrelated stuff. Not the traversing vs. everything else -
that's what iterators are for, like you said. But if you want to be able
to add new types of operations without ever touching the code of the
objects on which to apply those operations, then the VP is an easy way
to accomplish things:



class IfNode:
def apply(self, operation):
operation.handleIfNode(self)
...

class ElseNode:
def apply(self, operation):
operation.handleElseNode(self)
...

class PrettyPrinter:
def handleIfNode(self, if_node):
# print if_node pretty
def handleElseNode(self, else_node):
# print else_node pretty
...

class Interpreter:
def handleIfNode(self, if_node):
# interpret if_node
def handleElseNode(self, else_node):
# interpret else_node
...

class AST:
def apply(self, operation):
# apply operation to all nodes
...

some_ast = ...
some_ast.apply(PrettyPrinter())
some_ast.apply(Interpreter())



The traversing in AST.apply() is not really part of the pattern, it
could also be done in the client code. The VP lives in the relation
between the ...Node and the operation classes. It Encapsulates What
Varies and helps to uphold the Open/Closed Principle, because to add new
operations one does not need to touch the ...Node classes. It implements
double dispatching in a single dispatch language.


Regards,
Mick.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-17 Thread Mick Krippendorf
Karsten Wutzke wrote:
> The visitor pattern uses single-dispatch, that is, it determines 
> which method to call be the type of object passed in.

Say, in Python, I have an object o and want to call one of it's methods,
say m. Then which of possibly many methods m to call is determined by
the type of o, and nothing else (at least without further magic) -
hence, it is single dispatch. The VP uses two single dispatch calls (one
being a callback) to accomplish double dispatching.

Java has a form of multiple dispatch through function overloading. In
fact, it's still single dispatch, because which of the targets
overloaded methods gets called is determined at compile time by the
staticly known types of the methods parameters, AKA the formal parameter
types.

Anyway. Although VP *uses* double dispatch, it does not necessarily rely
on function overloading. In Java the VP is most often implemented like this:



interface IASTNode {
void accept(IASTVisitor);
}

class IfNode implements IASTNode {
void accept(IASTVisitor visitor) {
visitor.visit(this);
}
}

class ElseNode implements IASTNode {
void accept(IASTVisitor visitor) {
visitor.visit(this);
}
}

interface IASTVisitor {
void visit(IfNode node);
void visit(ElseNode node);
...
}
class PrettyPrinter implements IASTVisitor {
public void visit(IfNode n) {
...
}
public void visit(ElseNode n) {
...
}
}



but it could as well be implemented like this:



interface IASTNode {
void accept(IASTVisitor);
}

class IfNode implements IASTNode {
void accept(IASTVisitor visitor) {
visitor.visitIfNode(this);
}
}

class ElseNode implements IASTNode {
void accept(IASTVisitor visitor) {
visitor.visitElseNode(this);
}
}

interface IASTVisitor {
void visitIfNode(IfNode node);
void visitElseNode(ElseNode node);
...
}
class PrettyPrinter implements IASTVisitor {
public void visitIfNode(IfNode n) {
...
}
public void visitElseNode(ElseNode n) {
...
}
}



If Java were *really* a multiple dispatch language, it wouldn't be
necessary to repeat the accept-code for every subclass. Instead a single
accept method in the base class would suffice. In fact, with true
multiple dispatch VP wouldn't even be needed.


Regards,
Mick.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-16 Thread Thomas Jollans
On 07/16/2010 11:00 AM, Jean-Michel Pichavant wrote:
> Karsten Wutzke wrote:
>>> Yes, typo, I meant strictly.
>>>
>>> 
>>
>> Damn, I mean strongly. At least not for identifying which methods to
>> call depending on the type/s.
>>
>> Karsten
>>   
> Stringly is the perfect combination of strictly and strongly. Nice one :)

stringly typed sounds like "everything is a string" - doesn't Tcl do
that ? ^^

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-16 Thread Jean-Michel Pichavant

Karsten Wutzke wrote:

Yes, typo, I meant strictly.




Damn, I mean strongly. At least not for identifying which methods to
call depending on the type/s.

Karsten
  

Stringly is the perfect combination of strictly and strongly. Nice one :)

JM
--
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-16 Thread Stefan Behnel

Carl Banks, 16.07.2010 07:50:

On Jul 15, 8:33 pm, Stefan Behnel wrote:

The code I referenced is from the Cython compiler, and we use it to "do
stuff" with the AST. The visitor pattern is actually a pretty common way to
bind code in a single place that does a certain thing to different parts of
a data structure. Without it, if you kept that code *inside* of the data
structure, you'd have to spill the type specific parts all over your code.


Ahh, so this aspect oriented programming is it.


Never thought about it that way, but you have a point there. It's pretty 
much the same idea as AOP, but without any of those huge and feature 
drooling code injection frameworks.


Stefan

--
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-16 Thread Michele Simionato
On Jul 15, 7:58 pm, Karsten Wutzke  wrote:
> Hello,
>
> this is obviously a Python OO question:
>
> Since Python isn't stringly typed, single-dispatch isn't available per
> se. So is the "double-dispatch" Visitor pattern, which is usually used
> in OO systems to implement code generators. So, what is the de facto
> method in Python to handle source code generation?
>
> Karsten

You ask about code generation and you already had answers in that
area, but let me talk a bit about a simpler topic, traversing a
hierarchical file system. I think this is relevant (even if not
answering your question) if you want to get familiar with the Python
way. In the old days, the way to traverse a file system was through
the os.path.walk function. Here is what the docs say (from
http://docs.python.org/library/os.path.html):

"""
os.path.walk(path, visit, arg)

Calls the function visit with arguments (arg, dirname, names) for each
directory in the directory tree rooted at path (including path itself,
if it is a directory). The argument dirname specifies the visited
directory, the argument names lists the files in the directory (gotten
from os.listdir(dirname)). The visit function may modify names to
influence the set of directories visited below dirname, e.g. to avoid
visiting certain parts of the tree. (The object referred to by names
must be modified in place, using del or slice assignment.)
"""

As you see the documentation make explicit reference to the visitor
pattern.
However a note below says:

"""
This function is deprecated and has been removed in 3.0 in favor of
os.walk().
"""

In other word, the visitor pattern is *not* the Pythonic way to solve
this
problem. The Pythonic way is to use os.walk, which converts the nested
structure in a flat structure. From the docs
(http://docs.python.org/library/os.html):

"""
This example displays the number of bytes taken by non-directory files
in each directory under the starting directory, except that it doesn’t
look under any CVS subdirectory:

import os
from os.path import join, getsize
for root, dirs, files in os.walk('python/Lib/email'):
print root, "consumes",
print sum(getsize(join(root, name)) for name in files),
print "bytes in", len(files), "non-directory files"
if 'CVS' in dirs:
dirs.remove('CVS')  # don't visit CVS directories
"""

There is a big conceptual difference between os.path.walk and os.walk.
The first works like a framework: you pass a function to it and
os.path.walk
is in charging of calling it when needed. The second works like a
library:
os.walk flattens the hierarchical structure and then you are in charge
of
doing everything you wish with it.

os.walk is the Pythonic way, and you suggested to follow that
approach;
for instance elementTree and lxml (libraries for parsing XML data)
work
exactly that way. Actually one of the motivating examples for the
introduction of generators in Python was their use in flattening
data structure, i.e. exactly the pattern used by os.walk.

The message is stop thinking like in Java and start using idiomatic
Python. We are here to help.

 Michele Simionato
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Carl Banks
On Jul 15, 8:33 pm, Stefan Behnel  wrote:
> Carl Banks, 16.07.2010 01:14:
>
>
>
>
>
> > Around these parts, we consider the main use of most Design Patterns
> > to be to work around limitations of other languages.  Visitor Pattern
> > is probably the worst example of it.
>
> > In Python it's completely unnecessary (at least in its boilerplate-
> > heavy incarnation as used in C++), and the fact that Python isn't
> > strongly typed, as you put it, is exactly the reason why.
>
> > Say you have a bunch of unrelated types that define a calculate
> > method, you have a variable x that could be any of these types.
> > Here's how you would do that in Python:
>
> >      x.calculate()
>
> > Bam, that's it.  Visitor Pattern in Python.  You don't have to create
> > a bunch of homemade dispatching boilerplate like you do in C++.
>
> Well, you can do that in every OO language. It's not what the visitor
> pattern is there for, though.
>
> The code I referenced is from the Cython compiler, and we use it to "do
> stuff" with the AST. The visitor pattern is actually a pretty common way to
> bind code in a single place that does a certain thing to different parts of
> a data structure. Without it, if you kept that code *inside* of the data
> structure, you'd have to spill the type specific parts all over your code.

Ahh, so this aspect oriented programming is it.

I see your point, Visitor Pattern isn't necessary to work around the
"can't easily polymorph unrelated types" limitation, but could still
be necessary to work around "can't easily dispatch on methods not part
of the class" limitation.  So, ok, Visitor Pattern maybe isn't the
worst one.  My bad


Carl Banks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Paul Rubin
Karsten Wutzke  writes:
> Since Python isn't stringly typed, single-dispatch isn't available per
> se. So is the "double-dispatch" Visitor pattern, which is usually used
> in OO systems to implement code generators. So, what is the de facto
> method in Python to handle source code generation?

A minute of web surfing found this:

http://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Stefan Behnel

Carl Banks, 16.07.2010 01:14:

Around these parts, we consider the main use of most Design Patterns
to be to work around limitations of other languages.  Visitor Pattern
is probably the worst example of it.

In Python it's completely unnecessary (at least in its boilerplate-
heavy incarnation as used in C++), and the fact that Python isn't
strongly typed, as you put it, is exactly the reason why.

Say you have a bunch of unrelated types that define a calculate
method, you have a variable x that could be any of these types.
Here's how you would do that in Python:

 x.calculate()

Bam, that's it.  Visitor Pattern in Python.  You don't have to create
a bunch of homemade dispatching boilerplate like you do in C++.


Well, you can do that in every OO language. It's not what the visitor 
pattern is there for, though.


The code I referenced is from the Cython compiler, and we use it to "do 
stuff" with the AST. The visitor pattern is actually a pretty common way to 
bind code in a single place that does a certain thing to different parts of 
a data structure. Without it, if you kept that code *inside* of the data 
structure, you'd have to spill the type specific parts all over your code.


Stefan

--
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Carl Banks
On Jul 15, 11:45 am, Karsten Wutzke  wrote:
> On 15 Jul., 20:28, Thomas Jollans  wrote:
>
> > On 07/15/2010 07:58 PM, Karsten Wutzke wrote:
>
> > > Hello,
>
> > > this is obviously a Python OO question:
>
> > > Since Python isn't stringly typed,
>
> > I expect this is an innocent typo, and you mean strictly.
>
> > > single-dispatch isn't available per se. So is the "double-dispatch" 
> > > Visitor pattern,
>
> Yes, typo, I meant strictly.
>
>
>
>
>
> > Wait, what?
> > First of all, python is strictly typed in that every object has exactly
> > one type, which is different from other types. So you can't do "1"+2, as
> > you can in some other languages.
>
> > Anyway, this is interesting: Tell me more about how Python's dynamic
> > nature makes it impossible to do whatever you're trying to do. I'm
> > baffled. What are you trying to do, anyway?
>
> > > which is usually used
> > > in OO systems to implement code generators. So, what is the de facto
> > > method in Python to handle source code generation?
>
> > WHOA! Now if that isn't a Gedankensprung. Also, I'm still very far from
> > your train of thought, apparently: Now, the thing that code generators
> > probably share is that they write code to files. It depends on what I'm
> > trying to do of course, but I expect there's a good chance that if I
> > wrote a code generator in Python, it wouldn't be particularly
> > object-oriented at all.
>
> Well, I'm most experienced in OO, so writing OO in Python seems like
> the way to start with Python. The visitor pattern uses single-
> dispatch, that is, it determines which method to call be the type of
> object passed in. I did some reading and it turned out that Python
> can't do it without some tricks (function decorators and 3rd party
> code). For what I'm doing, I can't, or rather don't want to rely on
> 3rd party code (that has reasons). Thus, the visitor OO pattern must
> be replaced by some other way.

Oh brother.

Around these parts, we consider the main use of most Design Patterns
to be to work around limitations of other languages.  Visitor Pattern
is probably the worst example of it.

In Python it's completely unnecessary (at least in its boilerplate-
heavy incarnation as used in C++), and the fact that Python isn't
strongly typed, as you put it, is exactly the reason why.

Say you have a bunch of unrelated types that define a calculate
method, you have a variable x that could be any of these types.
Here's how you would do that in Python:

x.calculate()

Bam, that's it.  Visitor Pattern in Python.  You don't have to create
a bunch of homemade dispatching boilerplate like you do in C++.


Carl Banks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Ian Hobson

On 15/07/2010 18:58, Karsten Wutzke wrote:

Hello,

this is obviously a Python OO question:

Since Python isn't stringly typed, single-dispatch isn't available per
se. So is the "double-dispatch" Visitor pattern, which is usually used
in OO systems to implement code generators. So, what is the de facto
method in Python to handle source code generation?

Karsten
   

I'm baffled. Not by what you mean by stringly, but

What feature of Python stops you writing the three parts of the visitor 
pattern:


IIRC you need:

A tree walker that creates the visitor and walks the tree calling
node.visitFrom(visitor)
on each one in the required order.

The  visitfrom(aVisitor) routines in each node type that calls
aVisitor.visitedMyNodeType(self)
where MyNodeType is, naturally different for each node type!

All the
   def visitedNodeType(aNode):  routines in visitor to generate the code.

Simples! No? :)

Ian




--
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Ian Hobson

On 15/07/2010 18:58, Karsten Wutzke wrote:

Hello,

this is obviously a Python OO question:

Since Python isn't stringly typed, single-dispatch isn't available per
se. So is the "double-dispatch" Visitor pattern, which is usually used
in OO systems to implement code generators. So, what is the de facto
method in Python to handle source code generation?

Karsten
   

I'm baffled. Not by what you mean by stringly, but

What feature of Python stops you writing the three parts of the visitor 
pattern:


IIRC you need:

A tree walker that creates the visitor and walks the tree calling
node.visitFrom(visitor)
on each one in the required order.

The  visitfrom(aVisitor) routines in each node type that calls
aVisitor.visitedMyNodeType(self)
where MyNodeType is, naturally different for each node type!

All the
   def visitedNodeType(aNode):  routines in visitor to generate the code.

Simples! No? :)

Ian




--
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Stefan Behnel

MRAB, 15.07.2010 21:33:

Stefan Behnel wrote:

Karsten Wutzke, 15.07.2010 20:45:

Well, I'm most experienced in OO, so writing OO in Python seems like
the way to start with Python. The visitor pattern uses single-
dispatch, that is, it determines which method to call be the type of
object passed in.


Well, then do that. Put the types into a dict and map them to the
functions to call, then call the function through the dict. That's a
pretty common way to do dispatching.



Note, that I have an hierarchical object structure which I want to
iterate over, so using OO looked natural to me. If there's a better
approach, I'm all ears.


You speak in riddles, but my guess is that your problem is that you
don't want to dispatch mechanism to match only exact types but also
subtypes. No problem, just build your dict incrementally and add new
types as they come in. See this file for an example:

http://hg.cython.org/cython-devel/file/tip/Cython/Compiler/Visitor.py


Another variation: the dispatch table starts with entries for certain
types then it adds subtypes on demand:

def visit(self, obj):
try:
handler = self.dispatch_table[type(obj)]
except KeyError:
for disp_type, disp_func in self.dispatch_table.items():
if isinstance(obj, disp_type):
self.dispatch_table[type(obj)] = disp_func
handler = disp_func
else:
raise RuntimeError("Visitor does not accept object: %s" % obj)
return handler(obj)


Well, yes, that's basically what the code behind the above link does, 
except that it follows the type hierarchy correctly to find the closest match.


Stefan

--
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Matt McCredie
Karsten Wutzke  web.de> writes:

> So, what is the de facto method in Python to handle source code generation?


Take a look at the NodeVisitor class in the ast module in python 2.6+. 
The visitor pattern is implemented in the python standard library.

Matt

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread MRAB

Stefan Behnel wrote:

Karsten Wutzke, 15.07.2010 20:45:

Well, I'm most experienced in OO, so writing OO in Python seems like
the way to start with Python. The visitor pattern uses single-
dispatch, that is, it determines which method to call be the type of
object passed in.


Well, then do that. Put the types into a dict and map them to the 
functions to call, then call the function through the dict. That's a 
pretty common way to do dispatching.




Note, that I have an hierarchical object structure which I want to
iterate over, so using OO looked natural to me. If there's a better
approach, I'm all ears.


You speak in riddles, but my guess is that your problem is that you 
don't want to dispatch mechanism to match only exact types but also 
subtypes. No problem, just build your dict incrementally and add new 
types as they come in. See this file for an example:


http://hg.cython.org/cython-devel/file/tip/Cython/Compiler/Visitor.py


Another variation: the dispatch table starts with entries for certain
types then it adds subtypes on demand:

def visit(self, obj):
try:
handler = self.dispatch_table[type(obj)]
except KeyError:
for disp_type, disp_func in self.dispatch_table.items():
if isinstance(obj, disp_type):
self.dispatch_table[type(obj)] = disp_func
handler = disp_func
else:
raise RuntimeError("Visitor does not accept object: %s" 
% obj)

   return handler(obj)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Stefan Behnel

Karsten Wutzke, 15.07.2010 21:00:

Yes, typo, I meant strictly.


Damn, I mean strongly. At least not for identifying which methods to
call depending on the type/s.


I think you meant "statically typed".

http://c2.com/cgi-bin/wiki?StronglyTyped
http://www.c2.com/cgi/wiki?StaticTyping

Stefan

--
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Stefan Behnel

Karsten Wutzke, 15.07.2010 20:45:

Well, I'm most experienced in OO, so writing OO in Python seems like
the way to start with Python. The visitor pattern uses single-
dispatch, that is, it determines which method to call be the type of
object passed in.


Well, then do that. Put the types into a dict and map them to the functions 
to call, then call the function through the dict. That's a pretty common 
way to do dispatching.




Note, that I have an hierarchical object structure which I want to
iterate over, so using OO looked natural to me. If there's a better
approach, I'm all ears.


You speak in riddles, but my guess is that your problem is that you don't 
want to dispatch mechanism to match only exact types but also subtypes. No 
problem, just build your dict incrementally and add new types as they come 
in. See this file for an example:


http://hg.cython.org/cython-devel/file/tip/Cython/Compiler/Visitor.py

Stefan

--
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Thomas Jollans
On 07/15/2010 08:45 PM, Karsten Wutzke wrote:
> On 15 Jul., 20:28, Thomas Jollans  wrote:
>> On 07/15/2010 07:58 PM, Karsten Wutzke wrote:
>>
>>> Hello,
>>
>>> this is obviously a Python OO question:
>>
>>> Since Python isn't stringly typed,
>>
>> I expect this is an innocent typo, and you mean strictly.
>>
>>> single-dispatch isn't available per se. So is the "double-dispatch" Visitor 
>>> pattern,
>>
> 
> Yes, typo, I meant strictly.
> 
>> Wait, what?
>> First of all, python is strictly typed in that every object has exactly
>> one type, which is different from other types. So you can't do "1"+2, as
>> you can in some other languages.
>>
>> Anyway, this is interesting: Tell me more about how Python's dynamic
>> nature makes it impossible to do whatever you're trying to do. I'm
>> baffled. What are you trying to do, anyway?
>>
>>> which is usually used
>>> in OO systems to implement code generators. So, what is the de facto
>>> method in Python to handle source code generation?
>>
>> WHOA! Now if that isn't a Gedankensprung. Also, I'm still very far from
>> your train of thought, apparently: Now, the thing that code generators
>> probably share is that they write code to files. It depends on what I'm
>> trying to do of course, but I expect there's a good chance that if I
>> wrote a code generator in Python, it wouldn't be particularly
>> object-oriented at all.
> 
> Well, I'm most experienced in OO, so writing OO in Python seems like
> the way to start with Python. The visitor pattern uses single-
> dispatch, that is, it determines which method to call be the type of
> object passed in. I did some reading and it turned out that Python
> can't do it without some tricks (function decorators and 3rd party
> code).

Well, yes: the name of a function or method refers to a single callable
object and piece of code. if you care about the type of the argument,
you must say so explicitly:

class A:
def dothing(self, obj):
if isinstance(obj, str):
self.dostringthing(obj)
elif isinstance(obj, (int,float)):
self.donumberthing(obj)
else:
self.dogenericthing(obj)

# ...

while python doesn't have C++-style function overloading, its
alternative also doesn't have the limitations that come with it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Karsten Wutzke
>
> Yes, typo, I meant strictly.
>

Damn, I mean strongly. At least not for identifying which methods to
call depending on the type/s.

Karsten
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Karsten Wutzke
On 15 Jul., 20:28, Thomas Jollans  wrote:
> On 07/15/2010 07:58 PM, Karsten Wutzke wrote:
>
> > Hello,
>
> > this is obviously a Python OO question:
>
> > Since Python isn't stringly typed,
>
> I expect this is an innocent typo, and you mean strictly.
>
> > single-dispatch isn't available per se. So is the "double-dispatch" Visitor 
> > pattern,
>

Yes, typo, I meant strictly.

> Wait, what?
> First of all, python is strictly typed in that every object has exactly
> one type, which is different from other types. So you can't do "1"+2, as
> you can in some other languages.
>
> Anyway, this is interesting: Tell me more about how Python's dynamic
> nature makes it impossible to do whatever you're trying to do. I'm
> baffled. What are you trying to do, anyway?
>
> > which is usually used
> > in OO systems to implement code generators. So, what is the de facto
> > method in Python to handle source code generation?
>
> WHOA! Now if that isn't a Gedankensprung. Also, I'm still very far from
> your train of thought, apparently: Now, the thing that code generators
> probably share is that they write code to files. It depends on what I'm
> trying to do of course, but I expect there's a good chance that if I
> wrote a code generator in Python, it wouldn't be particularly
> object-oriented at all.

Well, I'm most experienced in OO, so writing OO in Python seems like
the way to start with Python. The visitor pattern uses single-
dispatch, that is, it determines which method to call be the type of
object passed in. I did some reading and it turned out that Python
can't do it without some tricks (function decorators and 3rd party
code). For what I'm doing, I can't, or rather don't want to rely on
3rd party code (that has reasons). Thus, the visitor OO pattern must
be replaced by some other way.

As I expected, you already hinted a non-OO solution. Which is now that
*I* am wondering what that would look like...

Note, that I have an hierarchical object structure which I want to
iterate over, so using OO looked natural to me. If there's a better
approach, I'm all ears.

Karsten
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Christian Heimes
> Since Python isn't stringly typed, single-dispatch isn't available per
> se. So is the "double-dispatch" Visitor pattern, which is usually used
> in OO systems to implement code generators. So, what is the de facto
> method in Python to handle source code generation?

Do you mean strongly typed langauge?

You are wrong, Python is a strongly typed language. Perhaps you are
confusing strong/weak with dynamic/static? These attributes are
orthogonal to each other. Python is a strongly and dynamicly typed language.

The visitor pattern is required for double dispatching in *some* OO
language like C++, to work around issues with inheritance and function
overloading. Python's OO works differently.

Christian

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Thomas Jollans
On 07/15/2010 07:58 PM, Karsten Wutzke wrote:
> Hello,
> 
> this is obviously a Python OO question:
> 
> Since Python isn't stringly typed,

I expect this is an innocent typo, and you mean strictly.

> single-dispatch isn't available per se. So is the "double-dispatch" Visitor 
> pattern,

Wait, what?
First of all, python is strictly typed in that every object has exactly
one type, which is different from other types. So you can't do "1"+2, as
you can in some other languages.

Anyway, this is interesting: Tell me more about how Python's dynamic
nature makes it impossible to do whatever you're trying to do. I'm
baffled. What are you trying to do, anyway?

> which is usually used
> in OO systems to implement code generators. So, what is the de facto
> method in Python to handle source code generation?

WHOA! Now if that isn't a Gedankensprung. Also, I'm still very far from
your train of thought, apparently: Now, the thing that code generators
probably share is that they write code to files. It depends on what I'm
trying to do of course, but I expect there's a good chance that if I
wrote a code generator in Python, it wouldn't be particularly
object-oriented at all.

-- 
http://mail.python.org/mailman/listinfo/python-list


Code generator and visitor pattern

2010-07-15 Thread Karsten Wutzke
Hello,

this is obviously a Python OO question:

Since Python isn't stringly typed, single-dispatch isn't available per
se. So is the "double-dispatch" Visitor pattern, which is usually used
in OO systems to implement code generators. So, what is the de facto
method in Python to handle source code generation?

Karsten
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My extension code generator for C++

2010-07-03 Thread Stefan Behnel

Rouslan Korneychuk, 03.07.2010 19:22:

The code also never uses PyArg_ParseTuple or its variants. It converts
every argument using the appropriate PyX_FromY functions. I noticed
PyBindGen does the following when a conversion is needed for one argument:

py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &self->obj->y)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);

On the other hand, here's the implementation for __sequence__getitem__:

PyObject * obj_DVector___sequence__getitem__(obj_DVector
*self,Py_ssize_t index) {
try {
std::vector > &base =
cast_base_DVector(reinterpret_cast(self));
return PyFloat_FromDouble(base.at(py_ssize_t_to_ulong(index)));

} EXCEPT_HANDLERS(0)
}


Check the code that Cython uses for these things. It generates specialised 
type conversion code that has received a lot of careful benchmarking and 
testing on different platforms.


Stefan

--
http://mail.python.org/mailman/listinfo/python-list


Re: My extension code generator for C++

2010-07-03 Thread Rouslan Korneychuk

I missed one:


func="operator[]" would also work, I assume?



Yes, you can also supply a function if the first parameter accepts the 
type being wrapped (__rop__ methods will even accept the second 
parameter taking the wrapped type).

--
http://mail.python.org/mailman/listinfo/python-list


Re: My extension code generator for C++

2010-07-03 Thread Rouslan Korneychuk

On 07/03/2010 01:54 PM, Thomas Jollans wrote:

On 07/03/2010 07:22 PM, Rouslan Korneychuk wrote:

It's still in the rough, but I wanted to give an update on my C++
extension generator. It's available at http://github.com/Rouslan/PyExpose


Question that pops to mind immediately: How does this differentiate
itself from SWIG? ( I can't say I'm familiar with SWIG, but the question
had to be posed. )



I have never tried swig, but as far as I understand, SWIG uses a layered 
approach where part of the extension is defined C/C++ and that is 
wrapped in Python code. Mine implements the extension completely in C++.




The documentation is a little slim right now but there is a
comprehensive set of examples in test/test_kompile.py (replace the k
with a c. For some reason, if I post this message with the correct name,
it doesn't show up). The program takes an input file like

  
  
  module doc string

  
  class doc string
  
  
  
  
  


func="operator[]" would also work, I assume?


  
  
  

and generates the code for a Python extension.

[snip]

I'm really interested in what people think of this little project.


How does it deal with pointers? What if something returns a const
pointer - is const correctness enforced?



When returning pointers or references, you either have to specify a 
conversion explicitly or use the "return-semantic" attribute. The 
current options are "copy", which dereferences the pointer and copies by 
value, and "managed-ref" which is for exposed classes, where the 
returned PyObject stores the value as a reference and holds on to a 
reference-counted pointer to the object the returned the value (there is 
also "self" which has nothing to do with returning pointers. With 
"self", the return value of the wrapped method is ignored and a pointer 
to the class is returned).


I can easily add other options for "return-semantic", such as keeping a 
pointer and deleting it upon destruction. I just implemented the ones I 
need for the thing I'm working on.


As far as returning const pointers and const correctness, I'm not sure 
exactly what you mean. If you mean is there a mechanism to hold on to 
const objects and prevent them form being modified, the answer is no. 
It's not something I need.



All in all, it looks rather neat.

Thomas


Thanks for the comment.

--
http://mail.python.org/mailman/listinfo/python-list


Re: My extension code generator for C++

2010-07-03 Thread Thomas Jollans
On 07/03/2010 07:22 PM, Rouslan Korneychuk wrote:
> It's still in the rough, but I wanted to give an update on my C++
> extension generator. It's available at http://github.com/Rouslan/PyExpose

Question that pops to mind immediately: How does this differentiate
itself from SWIG? ( I can't say I'm familiar with SWIG, but the question
had to be posed. )

> 
> The documentation is a little slim right now but there is a
> comprehensive set of examples in test/test_kompile.py (replace the k
> with a c. For some reason, if I post this message with the correct name,
> it doesn't show up). The program takes an input file like
> 
>  
>  
>  module doc string
> 
>  
>  class doc string
>  
>  
>  
>  
>   return-semantic="copy"/>

func="operator[]" would also work, I assume?

>  
>  
>  
> 
> and generates the code for a Python extension.
> 
> [snip]
> 
> I'm really interested in what people think of this little project.

How does it deal with pointers? What if something returns a const
pointer - is const correctness enforced?

All in all, it looks rather neat.

Thomas
-- 
http://mail.python.org/mailman/listinfo/python-list


My extension code generator for C++

2010-07-03 Thread Rouslan Korneychuk
It's still in the rough, but I wanted to give an update on my C++ 
extension generator. It's available at http://github.com/Rouslan/PyExpose


The documentation is a little slim right now but there is a 
comprehensive set of examples in test/test_kompile.py (replace the k 
with a c. For some reason, if I post this message with the correct name, 
it doesn't show up). The program takes an input file like


 
 
 module doc string

 
 class doc string
 
 
 
 
 return-semantic="copy"/>

 
 
 

and generates the code for a Python extension.

The goal has been to generate code with zero overhead. In other words I 
wanted to eliminate the tedium of creating an extension without 
sacrificing anything. In addition to generating a code file, the 
previous input would result in a header file with the following:


extern PyTypeObject obj_DVectorType;
inline PyTypeObject *get_obj_DVectorType() { return &obj_DVectorType; }
struct obj_DVector {
PyObject_HEAD
storage_mode mode;
std::vector > base;

PY_MEM_NEW_DELETE
obj_DVector() : base() {

PyObject_Init(reinterpret_cast(this),get_obj_DVectorType());
mode = CONTAINS;
}
obj_DVector(std::allocator const & _0) : base(_0) {

PyObject_Init(reinterpret_cast(this),get_obj_DVectorType());
mode = CONTAINS;
}
obj_DVector(long unsigned int _0,double const & 
_1,std::allocator const & _2) : base(_0,_1,_2) {


PyObject_Init(reinterpret_cast(this),get_obj_DVectorType());
mode = CONTAINS;
}
obj_DVector(std::vector > const & _0) 
: base(_0) {


PyObject_Init(reinterpret_cast(this),get_obj_DVectorType());
mode = CONTAINS;
}
};

so the object can be allocated in your own code as a single block of 
memory rather than having a PyObject contain a pointer to the exposed type.


storage_type is an enumeration, adding very little to the size of the 
Python object (or maybe nothing depending on alignment), but if you add 
new-initializes="true" to the  tag and the exposed type never 
needs to be held by a pointer/reference (as is the case when the exposed 
type is inside another class/struct), even that variable gets omitted.


The code also never uses PyArg_ParseTuple or its variants. It converts 
every argument using the appropriate PyX_FromY functions. I noticed 
PyBindGen does the following when a conversion is needed for one argument:


py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &self->obj->y)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);

On the other hand, here's the implementation for __sequence__getitem__:

PyObject * obj_DVector___sequence__getitem__(obj_DVector 
*self,Py_ssize_t index) {

try {
std::vector > &base = 
cast_base_DVector(reinterpret_cast(self));

return PyFloat_FromDouble(base.at(py_ssize_t_to_ulong(index)));

} EXCEPT_HANDLERS(0)
}

(cast_base_DVector checks that base is initialized and gets a reference 
to it with regard to how it's stored in obj_DVector. If the class is 
new-initialized and only needs one means of storage, it's code will just 
be "return obj_DVector->base;" and should be inlined by an optimizing 
compiler.)



I'm really interested in what people think of this little project.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Code Generator written in python

2010-01-14 Thread Arnaud Delobelle
trzewiczek  writes:

> On 01/13/2010 05:09 PM, Arnaud Delobelle wrote:
[...]
>> Sure, here are some example of self-evaluating python objects,
>> i.e. for each v below,
>>
>> v == eval(v)
>>
>> I'm quite proud of the last one.
[...]
>> v = "\"%s\" %% ((r\"%s\",)*2)" % ((r"\"%s\" %% ((r\"%s\",)*2)",)*2)
>>
>> :)
>>
>>
> If you're proud of the last one, consider moving to Perl. Python is -
> as I heard - about elegance and readability of code...

No thanks.  It's far too easy to write unreadable code in Perl and I
like a challenge :)

Seriously - this is a self-evaluating string, not code for landing a
$1bn rocket on Mars.  Do you expect it to be readable?  I don't.
However, I definitely find a certain elegance to it.

-- 
Arnaud
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code Generator written in python

2010-01-14 Thread trzewiczek

On 01/13/2010 05:09 PM, Arnaud Delobelle wrote:

nyoka  writes:

   

Can someone help me with sample python code for a code generator
 

Sure, here are some example of self-evaluating python objects, i.e. for each v
below,

v == eval(v)

I'm quite proud of the last one.

v = (lambda x:x%('"''""'+x+'"''""'))("""(lambda 
x:x%%('"''""'+x+'"''""'))(%s)""")

v = (lambda x:x%('r\"'+x+'\"'))(r"(lambda x:x%%('r\"'+x+'\"'))(%s)")

v = (lambda x:x%`x`)('(lambda x:x%%`x`)(%s)')

v = (lambda x: x+"("+`x`+")")('(lambda x: x+"("+`x`+")")')

v = "\"%s\" %% ((r\"%s\",)*2)" % ((r"\"%s\" %% ((r\"%s\",)*2)",)*2)

:)

   
If you're proud of the last one, consider moving to Perl. Python is - as 
I heard - about elegance and readability of code...

--
http://mail.python.org/mailman/listinfo/python-list


Re: Code Generator written in python

2010-01-14 Thread Steve Ferg
http://nedbatchelder.com/code/cog/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code Generator written in python

2010-01-13 Thread Gabriel Genellina
En Wed, 13 Jan 2010 13:09:38 -0300, Arnaud Delobelle  
 escribió:



nyoka  writes:


Can someone help me with sample python code for a code generator


Sure, here are some example of self-evaluating python objects, i.e. for  
each v

below,

   v == eval(v)

I'm quite proud of the last one.


And I'm still trying to disembowel it! :)

v = (lambda x:x%('"''""'+x+'"''""'))("""(lambda  
x:x%%('"''""'+x+'"''""'))(%s)""")


v = (lambda x:x%('r\"'+x+'\"'))(r"(lambda x:x%%('r\"'+x+'\"'))(%s)")

v = (lambda x:x%`x`)('(lambda x:x%%`x`)(%s)')

v = (lambda x: x+"("+`x`+")")('(lambda x: x+"("+`x`+")")')

v = "\"%s\" %% ((r\"%s\",)*2)" % ((r"\"%s\" %% ((r\"%s\",)*2)",)*2)


--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: Code Generator written in python

2010-01-13 Thread Arnaud Delobelle
nyoka  writes:

> Can someone help me with sample python code for a code generator

Sure, here are some example of self-evaluating python objects, i.e. for each v
below, 

   v == eval(v)

I'm quite proud of the last one.

v = (lambda x:x%('"''""'+x+'"''""'))("""(lambda 
x:x%%('"''""'+x+'"''""'))(%s)""")

v = (lambda x:x%('r\"'+x+'\"'))(r"(lambda x:x%%('r\"'+x+'\"'))(%s)")

v = (lambda x:x%`x`)('(lambda x:x%%`x`)(%s)')

v = (lambda x: x+"("+`x`+")")('(lambda x: x+"("+`x`+")")')

v = "\"%s\" %% ((r\"%s\",)*2)" % ((r"\"%s\" %% ((r\"%s\",)*2)",)*2)

:)

-- 
Arnaud
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code Generator written in python

2010-01-13 Thread Peter Otten
nyoka wrote:

> Can someone help me with sample python code for a code generator

>>> print "print"
print

Seriously, you have to provide more information if you want a meaningful 
answer. If the generated code is Python, too, then the advice is most likely 
that you don't need to generate any code at all.

Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code Generator written in python

2010-01-13 Thread Stefan Behnel

nyoka, 13.01.2010 16:48:

Can someone help me with sample python code for a code generator


Such as Cheetah?

http://www.cheetahtemplate.org/

BTW, you might want to be more specific about your problem at hand. Code 
generation is a rarely used technique in Python. Most of the time, it's 
more maintainable (and not necessarily harder or more work) to actually 
write the code by hand.


Stefan
--
http://mail.python.org/mailman/listinfo/python-list


Code Generator written in python

2010-01-13 Thread nyoka
Can someone help me with sample python code for a code generator
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Integrating a code generator into IDLE

2008-06-01 Thread Diez B. Roggisch

Sam Denton schrieb:
Code generators seem to be popular in Python. 
(http://www.google.com/search?q=python+code-generator)


Certainly not. The most of them will be used for generating bindings. 
Apart from that, you rareley (if ever) need to generate code.


I have one that I'd like to integrate into IDLE.  Ideally, I'd like to 
(1) have a new file type show up when I use the File/Open dialog, and 
(2) have a function key that lets me run my generator against the file, 
just like F5 lets me run my Python code; ideally, I'd like to re-purpose 
the F5 key to be file-type aware.  I've got a simple extension written 
that uses the F6 key to "compile" my files, but two goals I've listed 
seem a bit beyond me.  Does anyone have any advice/pointers?  Or is one 
or both ideas impractical?  Thanks!


You might consider using eric, a python-ide written in python with the 
Qt-Framework. It allows plugins.


Diez
--
http://mail.python.org/mailman/listinfo/python-list


Re: Integrating a code generator into IDLE

2008-06-01 Thread Marc 'BlackJack' Rintsch
On Sun, 01 Jun 2008 10:40:09 -0500, Sam Denton wrote:

> Code generators seem to be popular in Python.

I don't think so.

Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list


Integrating a code generator into IDLE

2008-06-01 Thread Sam Denton
Code generators seem to be popular in Python. 
(http://www.google.com/search?q=python+code-generator)


I have one that I'd like to integrate into IDLE.  Ideally, I'd like to 
(1) have a new file type show up when I use the File/Open dialog, and 
(2) have a function key that lets me run my generator against the file, 
just like F5 lets me run my Python code; ideally, I'd like to re-purpose 
the F5 key to be file-type aware.  I've got a simple extension written 
that uses the F6 key to "compile" my files, but two goals I've listed 
seem a bit beyond me.  Does anyone have any advice/pointers?  Or is one 
or both ideas impractical?  Thanks!

--
http://mail.python.org/mailman/listinfo/python-list


Re: C Source Code Generator For Test Cases

2007-10-03 Thread gamename

> You might want to look at COG (http://www.nedbatchelder.com/code/
> cog/).  It might be helpful to you.  I really enjoy using it and keep
> finding things to use it with.

Thanks Mike.  I agree. COG looks really promising.

-T

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C Source Code Generator For Test Cases

2007-10-01 Thread MikeBeard
On Sep 28, 1:48 pm, gamename <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Can anyone recommend a good method of using python to generate c
> source code?   I have tables of test cases to use as input to a
> process which would generate the test's source code.  The Cheetah tool
> looks interesting.  Has anyone used it? Any other suggestions?
>
> TIA,
> -T

You might want to look at COG (http://www.nedbatchelder.com/code/
cog/).  It might be helpful to you.  I really enjoy using it and keep
finding things to use it with.

Good luck.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C Source Code Generator For Test Cases

2007-09-29 Thread gamename

> Instead of reading the testcase tables and generating source for test
> routines you simply can do the tests right away.
>

Can't. :(  This is for an embedded system.  I need to create source
(in C) on one machine and then compile on others.  The only thing that
I can be certain of is an ANSI compiler on any machine I use.

-T

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C Source Code Generator For Test Cases

2007-09-28 Thread Marc 'BlackJack' Rintsch
On Fri, 28 Sep 2007 12:57:49 -0700, gamename wrote:

>> How about using c-types to access your C-stuff to test, and use python + the
>> testcase-tables to invoke that?
>>
> 
> Sure, that's possible.  But the source code for tests (once all the
> parms are read)
> still needs to be generated.  Calling the lib from python or from C,
> there still
> needs to be a way to generate 100+ test routines. ;-)

Instead of reading the testcase tables and generating source for test
routines you simply can do the tests right away.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C Source Code Generator For Test Cases

2007-09-28 Thread gamename
>
> How about using c-types to access your C-stuff to test, and use python + the
> testcase-tables to invoke that?
>

Sure, that's possible.  But the source code for tests (once all the
parms are read)
still needs to be generated.  Calling the lib from python or from C,
there still
needs to be a way to generate 100+ test routines. ;-)

-T

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C Source Code Generator For Test Cases

2007-09-28 Thread Diez B. Roggisch
gamename wrote:

> Hi,
> 
> Can anyone recommend a good method of using python to generate c
> source code?   I have tables of test cases to use as input to a
> process which would generate the test's source code.  The Cheetah tool
> looks interesting.  Has anyone used it? Any other suggestions?

How about using c-types to access your C-stuff to test, and use python + the
testcase-tables to invoke that?

Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


C Source Code Generator For Test Cases

2007-09-28 Thread gamename
Hi,

Can anyone recommend a good method of using python to generate c
source code?   I have tables of test cases to use as input to a
process which would generate the test's source code.  The Cheetah tool
looks interesting.  Has anyone used it? Any other suggestions?

TIA,
-T

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I wrote a C++ code generator in Python, would anyone please help me to review the code? :)

2007-01-17 Thread Kevin Wan
I've added a document for fgen.

Please check it.

Thanks,
Kevin
[EMAIL PROTECTED] wrote:
> Kevin Wan wrote:
> > fgen is a free command line tool that facilitates cross platform c++
> > development, including header generation, cpp file generation, makefile
> > generation, unit test framework generation, etc.
> >
> > http://sf.net/projects/fgen
> >
> > I'm not very familiar with Python. Any feedback are appreciated!
>
> No documentation?
>
> Am I supposed to reverse engineer all the source files to figure out
> how I'm
> supposed to use it?
> 
> > Or
> > anyone like to develop it with me?
> > 
> > Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I wrote a C++ code generator in Python, would anyone please help me to review the code? :)

2007-01-16 Thread Kevin Wan
Sorry, I didn't write that much document.

But you can use fgen --help to get the usage.

I'm writing document now. :)

Thanks,
Kevin
[EMAIL PROTECTED] wrote:
> Kevin Wan wrote:
> > fgen is a free command line tool that facilitates cross platform c++
> > development, including header generation, cpp file generation, makefile
> > generation, unit test framework generation, etc.
> >
> > http://sf.net/projects/fgen
> >
> > I'm not very familiar with Python. Any feedback are appreciated!
>
> No documentation?
>
> Am I supposed to reverse engineer all the source files to figure out
> how I'm
> supposed to use it?
> 
> > Or
> > anyone like to develop it with me?
> > 
> > Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I wrote a C++ code generator in Python, would anyone please help me to review the code? :)

2007-01-16 Thread Kevin Wan
I'm writing the document for fgen. You can use SVN to access the most
updated files.

Basically you can use fgen --help to get the usage.

It's my c++ development tool, and I didn't spend that much time on
writing document. Sorry. But I'm writing now.

Thanks and waiting to work with you guys,
Kevin

Vineeth  Kashyap wrote:
> Hi,
> I am interested in your proposal. I am basically a C/C++ programmer,
> but recently fell in love with python. Please send more details on
> fgen. We could probably start working. :)
> Kevin Wan wrote:
> > fgen is a free command line tool that facilitates cross platform c++
> > development, including header generation, cpp file generation, makefile
> > generation, unit test framework generation, etc.
> >
> > http://sf.net/projects/fgen
> >
> > I'm not very familiar with Python. Any feedback are appreciated! Or
> > anyone like to develop it with me?
> > 
> > Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I wrote a C++ code generator in Python, would anyone please help me to review the code? :)

2007-01-16 Thread [EMAIL PROTECTED]

Kevin Wan wrote:
> fgen is a free command line tool that facilitates cross platform c++
> development, including header generation, cpp file generation, makefile
> generation, unit test framework generation, etc.
>
> http://sf.net/projects/fgen
>
> I'm not very familiar with Python. Any feedback are appreciated!

No documentation?

Am I supposed to reverse engineer all the source files to figure out
how I'm
supposed to use it?

> Or
> anyone like to develop it with me?
> 
> Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I wrote a C++ code generator in Python, would anyone please help me to review the code? :)

2007-01-16 Thread Vineeth Kashyap
Hi,
I am interested in your proposal. I am basically a C/C++ programmer,
but recently fell in love with python. Please send more details on
fgen. We could probably start working. :)
Kevin Wan wrote:
> fgen is a free command line tool that facilitates cross platform c++
> development, including header generation, cpp file generation, makefile
> generation, unit test framework generation, etc.
>
> http://sf.net/projects/fgen
>
> I'm not very familiar with Python. Any feedback are appreciated! Or
> anyone like to develop it with me?
> 
> Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


I wrote a C++ code generator in Python, would anyone please help me to review the code? :)

2007-01-15 Thread Kevin Wan
fgen is a free command line tool that facilitates cross platform c++
development, including header generation, cpp file generation, makefile
generation, unit test framework generation, etc.

http://sf.net/projects/fgen

I'm not very familiar with Python. Any feedback are appreciated! Or
anyone like to develop it with me?

Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Code generator

2006-10-12 Thread Massi
Hello NG! Can anybody explain me how to install the code generator fo
ctypes on my pc? I use windows...
for example I found this line command on the overview:

python h2xml.py windows.h -o windows.xml -q -c

Where do I have to type? and where do I have to put the file that I got
from the repository?
Thank you for the help!

Massi

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code Generator Help

2004-12-28 Thread Andrew Dalke
Steve Holden wrote:
> If this isn't spam I'll eat my hat. How many other irrelevant newsgroups 
> has this been sent to? Headers follow for abuse tracking and retribution.

More precisely, the email is from a marketer in Pakistan.
  http://www.pid.org.pk/resume.html
Note the lack of programming experience.

The software mentioned comes from Alachisoft which is a
subsidiary of Diyatech which does its software development
in "South Asia".

Andrew
[EMAIL PROTECTED]

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code Generator Help

2004-12-28 Thread Steve Holden
[EMAIL PROTECTED] wrote:
Code Generators!!!
I think now a days programmers should prefer Code Generator to do their
coding rather than doing everything by hand. They are almost generator
for every database. If you do n't have enough time write all the code
by hand, invest some in code genetor and make you lifew easy. I just
want to share my thought with this user group. You are welcome to send
me an email about it
[EMAIL PROTECTED]
My favorite is TierDeveloper from www.alachisoft.com
Here are some of features list on their website and I just copy paste
it here.
[feature list etc. snipped]
If this isn't spam I'll eat my hat. How many other irrelevant newsgroups 
has this been sent to? Headers follow for abuse tracking and retribution.

regards
 Steve
Path: 
news1.east.cox.net!east.cox.net!filt02.cox.net!peer01.cox.net!cox.net!cyclone1.gnilink.net!gnilink.net!news.glorb.com!postnews.google.com!z14g2000cwz.googlegroups.com!not-for-mail
From: [EMAIL PROTECTED]
Newsgroups: comp.lang.python
Subject: code Generator Help
Date: 28 Dec 2004 07:56:18 -0800
Organization: http://groups.google.com
Lines: 91
Message-ID: <[EMAIL PROTECTED]>
NNTP-Posting-Host: 203.215.172.162
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1104249382 1818 127.0.0.1 (28 Dec 2004 
15:56:22 GMT)
X-Complaints-To: [EMAIL PROTECTED]
NNTP-Posting-Date: Tue, 28 Dec 2004 15:56:22 + (UTC)
User-Agent: G2/0.2
Complaints-To: [EMAIL PROTECTED]
Injection-Info: z14g2000cwz.googlegroups.com; posting-host=203.215.172.162;
   posting-account=7YudzA0fMdqpJCBHcNyqldiXgatK
Xref: cox.net comp.lang.python:394356
X-Received-Date: Tue, 28 Dec 2004 10:56:24 EST (news1.east.cox.net)

--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


code Generator Help

2004-12-28 Thread emran . syed
Code Generators!!!

I think now a days programmers should prefer Code Generator to do their
coding rather than doing everything by hand. They are almost generator
for every database. If you do n't have enough time write all the code
by hand, invest some in code genetor and make you lifew easy. I just
want to share my thought with this user group. You are welcome to send
me an email about it

[EMAIL PROTECTED]

My favorite is TierDeveloper from www.alachisoft.com
Here are some of features list on their website and I just copy paste
it here.

Cheers,




Single & multi-table object mapping

Unmapped objects (creates tables in db for them)

Map objects to views as updateable

Formula fields

Identity, sequences, and trigger changed columns

Static object queries

1-1, n-1, 1-n, and m-n relationships

Stored procedure calls

Bulk update and delete methods

Custom load, insert, and update operations

Datasets and Typed Datasets

.NET components for COM+

.NET standalone components (for Windows Forms etc.)

Export DDL scripts (New)

Integrated SQL tool

Database validation and synchronization

Generate ASP.NET application

Generate Windows Forms application

Generate HTML design doc for objects

C# and VB.NET support

SQL Server 7.0/2000 (SQLClient)

Microsoft Access (OLEDB)

SQL Server 7.0/2000 (OLEDB)

Oracle 8i/9i (OLEDB & OracleClient)

DB2 7.x/8.1 (OLEDB) (New)

Multiple databases in one project

100% VS.NET 2002/2003 integration

Dynamic object queries

Web services for objects

Custom hooks (safe from code generation)

Generate stored procedures for SQL

Parent/Child relationship & life-cycle mgmt

Generate Windows Forms remote client (New)

Customize ASP.NET application GUI (New)

Customize Windows Forms application GUI (New)
Customize Windows Forms remote client GUI (New)

-- 
http://mail.python.org/mailman/listinfo/python-list