Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7658319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:11:11+00:00 2026-05-31T13:11:11+00:00

Possible Duplicate: Tool to convert python indentation from spaces to tabs? I have a

  • 0

Possible Duplicate:
Tool to convert python indentation from spaces to tabs?

I have a number of python files (>1000) that need to be reformatted so indentation is done only with tabs (yes, i know PEP-8, but this is a coding standard of a company). What is the easiest way to do so? Maybe some script in Python that will os.walk over files and do some magic? I can’t just grep file content since file can be malformed (mixed tab and spaces, different amount of spaces) but Python will still run it and i get it back working after conversion.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:11:12+00:00Added an answer on May 31, 2026 at 1:11 pm

    I would suggest using this Reindent script on PyPI to convert all of your horribly inconsistent files to a consistent PEP-8 (4-space indents) version.

    At this point try one more time to convince whoever decided on tabs that the company coding standard is stupid and PEP-8 style should be used, if this fails then you could use sed (as in hc_’s answer) or create a Python script to replace 4 spaces with a single tab at the beginning of every line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Tool to convert java to c# code I have done a project
Possible Duplicate: Is there a tool that can display a SVN repository visually (
Possible Duplicate: Is there a tool which lists exported methods from a DLL? I
Possible Duplicate: Do you know tool building tree of include files in project\file? Currently
Possible Duplicate: Convert VB.NET code to C# Hey, I'm looking for a powerfull tool
Possible Duplicate: how to convert a VS 2010 soultion back to 2008 I have
Possible Duplicate: Tool to enforce python code style/standards Are there any tools to enforce
Possible Duplicate: Tool for importing CSV files into MySQL database? A guy at work
Possible Duplicate: Tool to identify unused css definitions Lets say I have a page
Possible Duplicate: Tool to compare large numbers of PDF files? I am in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.