Is there any utility to convert Python sources from space-based
block indentation to tab-based?
You can use "expand" convert from tabs->spaces, but "unexpand"
isn't bright enough to do the reverse.
--
Grant Edwards grante Yow! By MEER biz doo
at SCHOIN...
visi.com 15 3503
In article <41************ ***********@new sreader.visi.co m>,
Grant Edwards <gr****@visi.co m> wrote: Is there any utility to convert Python sources from space-based block indentation to tab-based?
Why would you want to?
--
David Eppstein
Computer Science Dept., Univ. of California, Irvine http://www.ics.uci.edu/~eppstein/
Grant Edwards said unto the world upon 28/07/2004 17:49: Is there any utility to convert Python sources from space-based block indentation to tab-based?
You can use "expand" convert from tabs->spaces, but "unexpand" isn't bright enough to do the reverse.
Hi,
<http://aspn.activestat e.com/ASPN/Cookbook/Python/Recipe/65226>
There are a couple of other tab/space recipes on the site, too.
Best,
Brian vdB
On 2004-07-28, David Eppstein <ep******@ics.u ci.edu> wrote: In article <41************ ***********@new sreader.visi.co m>, Grant Edwards <gr****@visi.co m> wrote:
Is there any utility to convert Python sources from space-based block indentation to tab-based?
Why would you want to?
So that I can submit patches to a Python application whos
devloper uses tabs. My Python editor uses spaces.
--
Grant Edwards grante Yow! So this is what it
at feels like to be potato
visi.com salad
On 2004-07-28, Brian van den Broek <bv****@po-box.mcgill.ca> wrote: Grant Edwards said unto the world upon 28/07/2004 17:49:
Is there any utility to convert Python sources from space-based block indentation to tab-based?
You can use "expand" convert from tabs->spaces, but "unexpand" isn't bright enough to do the reverse.
Hi,
<http://aspn.activestat e.com/ASPN/Cookbook/Python/Recipe/65226>
I don't see how that's useful.
There are a couple of other tab/space recipes on the site, too.
"unexpand" will do dumb conversion, but what's required is
something that understands Python block syntax. Something
similar to C's "indent" program.
--
Grant Edwards grante Yow! Did YOU find a
at DIGITAL WATCH in YOUR box
visi.com of VELVEETA?
Grant Edwards said unto the world upon 28/07/2004 18:12: On 2004-07-28, Brian van den Broek <bv****@po-box.mcgill.ca> wrote:
Grant Edwards said unto the world upon 28/07/2004 17:49:
Is there any utility to convert Python sources from space-based block indentation to tab-based?
You can use "expand" convert from tabs->spaces, but "unexpand" isn't bright enough to do the reverse.
Hi,
<http://aspn.activestat e.com/ASPN/Cookbook/Python/Recipe/65226>
I don't see how that's useful.
There are a couple of other tab/space recipes on the site, too.
"unexpand" will do dumb conversion, but what's required is something that understands Python block syntax. Something similar to C's "indent" program.
Hi,
OK, sorry. I'm still pretty new to Python and programming in general. But
I would have thought that the recipe I pointed to could be used as the
basis of a script that would uniformly replace all leading tabs with a set
number of spaces, thus preserving relative indents. (On the assumption
that the code being transformed is all tabs.)
But getting your response made me read the recipe more carefully, and now
I think I see why you doubt its usefulness for your task.
Still, the approach of replacing only leading tabs seems to me like it
would work. I did up a script and from my testing it appears to preserve
block structure. But I hesitate to post code; one gaff a day is enough ;-)
If there's a subtlety that is blowing past me in my newbieness,
enlightenment would be appreciated. On the other hand, if you'd like to
see the code, I'd be happy to share.
Anyway, sorry if I wasted your time.
Best,
Brian vdB
In article <ma************ *************** **********@pyth on.org>, Brian van den Broek wrote: "unexpand" will do dumb conversion, but what's required is something that understands Python block syntax. Something similar to C's "indent" program. OK, sorry. I'm still pretty new to Python and programming in general. But I would have thought that the recipe I pointed to could be used as the basis of a script that would uniformly replace all leading tabs with a set number of spaces, thus preserving relative indents. (On the assumption that the code being transformed is all tabs.)
1) The conversion I need to do is the other direction spaces->tabs.
2) Simply converting all leading spaces to the right number of
tabs (unexpand knows how to do that) isn't correct. Only
the spaces that are block-indent spaces should be converted.
For example:
1 ....if (asfsadfsadf and qwerqwrwer and
2 ........(asdf or qwer)):
3 ........doThis( )
4 ........doThat( )
Let's say we want to convert the lines above (indented with
groups of 4 spaces) into tab-indented code. In line 2, only the
first 4 spaces should be converted into a tab. The second set
of 4 spaces aren't block-indent spaces they're visual alignment
spaces used to line up the sub-expression, and they need to
remain 4 spaces regardless of the indentation level chosen by
the person viewing the tab-indented code.
Still, the approach of replacing only leading tabs seems to me like it would work. I did up a script and from my testing it appears to preserve block structure. But I hesitate to post code; one gaff a day is enough ;-)
If there's a subtlety that is blowing past me in my newbieness, enlightenment would be appreciated. On the other hand, if you'd like to see the code, I'd be happy to share.
The problem is that sometimes lines contain leading spaces that
shouldn't be converted to tabs.
--
Grant Edwards grante Yow! All right, you
at degenerates! I want this
visi.com place evacuated in 20
seconds!
Grant Edwards said unto the world upon 28/07/2004 19:15: In article <ma************ *************** **********@pyth on.org>, Brian van den Broek wrote:
"unexpand" will do dumb conversion, but what's required is something that understands Python block syntax. Something similar to C's "indent" program. OK, sorry. I'm still pretty new to Python and programming in general. But I would have thought that the recipe I pointed to could be used as the basis of a script that would uniformly replace all leading tabs with a set number of spaces, thus preserving relative indents. (On the assumption that the code being transformed is all tabs.)
1) The conversion I need to do is the other direction spaces->tabs.
Doh! :-[
2) Simply converting all leading spaces to the right number of tabs (unexpand knows how to do that) isn't correct. Only the spaces that are block-indent spaces should be converted.
<Helpful explanation snipped> If there's a subtlety that is blowing past me in my newbieness, enlightenment would be appreciated. On the other hand, if you'd like to see the code, I'd be happy to share.
The problem is that sometimes lines contain leading spaces that shouldn't be converted to tabs.
Hi Grant,
thanks for the explanation. Since you probably have better things to do
than play "spot the newbie's confusion" and I am fresh out of feet to
stick in my mouth, let's leave it there ;-)
Best,
Brian vdB
On 2004-07-28, Brian van den Broek <bv****@po-box.mcgill.ca> wrote: The problem is that sometimes lines contain leading spaces that shouldn't be converted to tabs.
thanks for the explanation. Since you probably have better things to do than play "spot the newbie's confusion" and I am fresh out of feet to stick in my mouth, let's leave it there ;-)
We were all newbie's at everything sometime and are newbies at
something all the time. ;)
--
Grant Edwards grante Yow! Were these parsnips
at CORRECTLY MARINATED in
visi.com TACO SAUCE?
[Grant Edwards, wants to convert spaces to tabs] ... 2) Simply converting all leading spaces to the right number of tabs (unexpand knows how to do that) isn't correct. Only the spaces that are block-indent spaces should be converted.
....
reindent.py is in your Python distribution, and is the state of the
art for "intelligen t" conversion of tab-infected files to
space-celebrating ones. I understand that's not the direction you
want, but it is the *code* you want to start from. Doing a good job
on this is harder than anyone believes until they've failed at least
once, and the problem is indeed dealing with "semantical ly
insignifcant" whitespace in a pleasant way, trying to guess the
author's intent about visual appearance. reindent.py is aware of the
*semantic* indentation level of each line, and you could fiddle its
internals to convert just the semantically significant leading spaces
to hard tabs. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Canneloni |
last post by:
Is there a conversion utility that will take a SQL server database and port
it to mySql ( or postGres sql ) ?
--
W '04 <:> Open
|
by: Mark Miller |
last post by:
I have a scheduled job that uses different XSL templates to transform XML
and save it to disk. I am having problems with the code below. The problem
shows up on both my development machine (Windows XP Pro SP 1, .Net Framework
1.1) and on our production server (Windows 2K SP 4, .Net Framework 1.1). I
have simplified the code and data to isolate...
|
by: Brian Pelton |
last post by:
My basic question is this:
Is there a Conversion class in the .Net framework that you can pass and
object to and a type to and get back an object of the given type?
For example. Let's say I have a string value of "32". Is there a
method that will take "32" and Type.GetType("System.Int32") and return
an object of the in32 type?
What I...
|
by: Konstantin Andreev |
last post by:
Recently I became interested, - Are the data, bulk loaded in the table with
LOAD utility, consume the same disk space as loaded with IMPORT utility? The
answer turned out to be NOT !
Here is a nutshell description of the test. The testing was done at
"DB2/LINUX 8.2.3".
Tables for tests:
F4106 has 5203 rows, 32 columns.
F42199 has...
|
by: Martin Jørgensen |
last post by:
Hi,
I've had a introductory C++ course in the spring and haven't programmed in
C++ for a couple of months now (but I have been programmed in C since
january). So I decided to do my conversion utility in C++, before I forget
everything. But it doesn't compile:
------------
| |
by: =?Utf-8?B?U2hhaWxlbiBTdWt1bA==?= |
last post by:
I have some code that was written in managed C++ using VS 2005. I want to
convert that code into C#. Is there a tool available to do this?
Thanks in advance.
--
Shailen Sukul
Architect
(BSc MCTS, MCSD.Net MCSD MCAD)
Ashlen Consulting Service P/L
|
by: Phil Stanton |
last post by:
I have a table of SpaceAreas eg Food Store, Garden Shed etc with the first
and last bin for each Space Area defined. eg Food Store First Space 1, last
space 26 and Gargen Shed First space 1, last Space 50.
SpaceAreas Table is
SpaceAreaID Auto
SpaceAreaDesc Text
FirstSpace Integer
LastSpace Integer
I have a...
|
by: vikasthukral17 |
last post by:
Hello Friends
i want to convert xml shown under into excel file,xml is as
<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="AggrPositions.xsl"?>
<DataOut>
<NoName>
<AggregatedPosition>
<PositionReference>549</PositionReference>
|
by: HxRLxY |
last post by:
I have a program that shows a thumbnail of an image. If the user clicks on the thumbnail a new JFrame is opened that shows the full size image. If the image is larger than the screen, it gets scaled to the the size of the screen.
Functionally, the program works well. However, when testing I found that after clicking the thumbnails of...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |