LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-17-2015, 03:22 AM   #1
abd_bela
Member
 
Registered: Dec 2002
Location: algeria
Distribution: redhat 7.3, debian lenny
Posts: 627

Rep: Reputation: 31
key tab permits the indent in python3


while in python2 , the key tab permits the indent, specially we use it in loop or if block,
in python3, tab is binded to completion ,
so it in not possible to write a for block in interactive python3.
ipython3 does it automatically, python3 doesn't neither automatically nor manually.
thanks for help
 
Old 08-17-2015, 05:22 AM   #2
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by abd_bela View Post
so it in not possible to write a for block in interactive python3.
I beg to differ. Check this out:
Code:
>>> aList = ['foo', 'bar', 'baz']
>>> for item in aList:
... print(item)
  File "<stdin>", line 2
    print(item)
        ^
IndentationError: expected an indented block
>>> for item in aList:
...   print(item)
... 
foo
bar
baz
>>>
Can you spot the difference? In the first example there is no indentation before the print statement:
Code:
... print(item)
But in the second there is:
Code:
...   print(item)
Simply hit the space bar twice, and you're good to go!

Best regards,
HMW
 
Old 08-18-2015, 02:12 PM   #3
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Was your python3 built without readline?
 
Old 08-18-2015, 02:38 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
https://docs.python.org/3/library/site.html
Quote:
On systems that support readline, this module will also import and configure the rlcompleter module, if Python is started in interactive mode and without the -S option. The default behavior is enable tab-completion and to use ~/.python_history as the history save file. To disable it, delete (or override) the sys.__interactivehook__ attribute in your sitecustomize or usercustomize module or your PYTHONSTARTUP file.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Which indent variable gives perfect indent in vim ? techie_san778 Linux - Software 1 07-25-2014 03:16 AM
[SOLVED] Remove Double tab indent on vim d4nt3 Linux - Software 1 04-09-2013 09:46 PM
do you use tab or the spacebar to indent? newbiesforever General 12 05-23-2010 11:06 PM
vim tab key redhax8 Programming 3 09-02-2006 09:44 PM
Tab Key and arrow key zillah Solaris / OpenSolaris 12 05-26-2005 02:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration