Re: how to format a python source file with tools?

2009-11-30 Thread Lie Ryan

On 12/1/2009 4:30 AM, Falcolas wrote:

Nonetheless, it would be better to implement coding standards that
everyone can stick to.


Agreed. You can't solve social issues with program.
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to format a python source file with tools?

2009-11-30 Thread Falcolas
On Nov 30, 7:37 am, gil_johnson  wrote:
> On Nov 27, 9:58 am, "Diez B. Roggisch"  wrote:
> [...]
>
> > > so i would like to have a tool to intelligently format the code for me
> > > and make the code more beautiful
> > > and automated.
>
> > This is not possible. Consider the following situation:
> > [...]
> > Both are semantically radically different, and only you know which one
> > is the right one.
> > Diez
>
> I have to agree with Diez, there is no way to automate this. Some
> human intervention is needed. What I would like is an editor that will
> indicate what Python will consider a logical block (and sub-block, and
> sub-sub-block, etc.)
> It's complicated. I've tried to think of a way to do it, and have
> gotten lost after a few changes of indentation.
> Does anyone know of such a thing?
> I miss curly braces with an editor that will highlight matching
> parentheses, braces, etc.
> Gil

At least with Windows, you get a number of scripts included in your
Python install - under the python directory/tools/scripts. There are
several scripts here which are intended to help with indentation
issues - such as reindent and pindent. Those might help you out some.

Nonetheless, it would be better to implement coding standards that
everyone can stick to.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to format a python source file with tools?

2009-11-30 Thread gil_johnson
On Nov 27, 9:58 am, "Diez B. Roggisch"  wrote:
[...]
> > so i would like to have a tool to intelligently format the code for me
> > and make the code more beautiful
> > and automated.
>
> This is not possible. Consider the following situation:

> [...]

> Both are semantically radically different, and only you know which one
> is the right one.

> Diez

I have to agree with Diez, there is no way to automate this. Some
human intervention is needed. What I would like is an editor that will
indicate what Python will consider a logical block (and sub-block, and
sub-sub-block, etc.)
It's complicated. I've tried to think of a way to do it, and have
gotten lost after a few changes of indentation.
Does anyone know of such a thing?
I miss curly braces with an editor that will highlight matching
parentheses, braces, etc.
Gil
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to format a python source file with tools?

2009-11-30 Thread Neil Cerutti
On 2009-11-27, Diez B. Roggisch  wrote:
> The only thing that migh be automatized after a piece of code
> is valid is normalization, like de-tabifying or making
> everything based on 4 space characters indention. No idea if
> there is something out there that does that.

In vim, you can do something like:

:set tabstop=4
:set expandtab
:retab

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


Re: how to format a python source file with tools?

2009-11-30 Thread 84715...@qq.com
On 11月27日, 下午2时40分, 李白,字一日  wrote:
> or is it possible for large source files?

 http://www.jerseysup.com";
target="sport jersey">sport   jersey
http://www.sport-jersey.net"; target="sport
jersey">sports jerseyhttp://www.uggwomen.net"; target="ugg
women">uggboothttp://www.nike-market.com"; target="nike
market">nike
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to format a python source file with tools?

2009-11-27 Thread Diez B. Roggisch

李白,字一日 schrieb:

On Nov 27, 3:35 pm, Ben Finney  wrote:

李白,字一日  writes:

or is it possible for large source files?

Is what possible? What do you want the tool to do?

--
 \   “I do not believe in forgiveness as it is preached by the |
  `\church. We do not need the forgiveness of God, but of each |
_o__)other and of ourselves.” —Robert G. Ingersoll |
Ben Finney


sometimes i need to merge some code snippets from files into a file,
and when time comes to do this merge, i always find it difficult to
reformat the python code
because after pasting and copy, the code indentation different from
one to another.
and it is the tedious job for us to manually move the code from one
segment to another.

so i would like to have a tool to intelligently format the code for me
and make the code more beautiful
and automated.


This is not possible. Consider the following situation:


code a:


if something:
do_something()


code b:

if anything:
do_something_else()


No lets say you copy b after a. At which level should it be? Like this


if something:
   do_something()

if anything:
do_something_else()


Or like this?

if something:
   do_something()

   if anything:
   do_something_else()



Both are semantically radically different, and only you know which one 
is the right one.


What my editor (emacs) allows, and other IDEs/editors as well is to mark 
blocks, and shift these wholesome left or right, to get the desired 
indention level.


The only thing that migh be automatized after a piece of code is valid 
is normalization, like de-tabifying or making everything based on 4 
space characters indention. No idea if there is something out there that 
does that.


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


Re: how to format a python source file with tools?

2009-11-27 Thread 李白,字一日
On Nov 27, 7:04 pm, Marco Mariani  wrote:
> ??,??? wrote:
> > or is it possible for large source files?
>
> Google for polystyle.
>
> It's a tool that reformats a program (in several languages) using an
> example you must provide (let's call it a "style sheet", written in
> Python or whatever) of how you would want to format it.
>
> You can then reformat any python program according to your "style sheet"

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


Re: how to format a python source file with tools?

2009-11-27 Thread 李白,字一日
On Nov 27, 3:35 pm, Ben Finney  wrote:
> 李白,字一日  writes:
> > or is it possible for large source files?
>
> Is what possible? What do you want the tool to do?
>
> --
>  \           “I do not believe in forgiveness as it is preached by the |
>   `\        church. We do not need the forgiveness of God, but of each |
> _o__)                    other and of ourselves.” —Robert G. Ingersoll |
> Ben Finney

sometimes i need to merge some code snippets from files into a file,
and when time comes to do this merge, i always find it difficult to
reformat the python code
because after pasting and copy, the code indentation different from
one to another.
and it is the tedious job for us to manually move the code from one
segment to another.

so i would like to have a tool to intelligently format the code for me
and make the code more beautiful
and automated.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to format a python source file with tools?

2009-11-27 Thread Marco Mariani

??,??? wrote:


or is it possible for large source files?



Google for polystyle.

It's a tool that reformats a program (in several languages) using an 
example you must provide (let's call it a "style sheet", written in 
Python or whatever) of how you would want to format it.


You can then reformat any python program according to your "style sheet"
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to format a python source file with tools?

2009-11-27 Thread 84715...@qq.com
On 11月27日, 下午3时45分, cmptrwhz  wrote:
> On Nov 27, 12:40 am, 李白,字一日  wrote:
>
> > or is it possible for large source files?
>
> are you trying to format the file with the proper indentations?

 http://www.jerseysup.com";
target="sport jersey">sport   jersey
http://www.sport-jersey.net"; target="sport
jersey">sports jerseyhttp://www.uggwomen.net"; target="ugg
women">uggboothttp://www.nike-market.com"; target="nike
market">nike
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to format a python source file with tools?

2009-11-26 Thread cmptrwhz
On Nov 27, 12:40 am, 李白,字一日  wrote:
> or is it possible for large source files?

are you trying to format the file with the proper indentations?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to format a python source file with tools?

2009-11-26 Thread Ben Finney
李白,字一日  writes:

> or is it possible for large source files?

Is what possible? What do you want the tool to do?

-- 
 \   “I do not believe in forgiveness as it is preached by the |
  `\church. We do not need the forgiveness of God, but of each |
_o__)other and of ourselves.” —Robert G. Ingersoll |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


how to format a python source file with tools?

2009-11-26 Thread 李白,字一日
or is it possible for large source files?
-- 
http://mail.python.org/mailman/listinfo/python-list