Re: Is there an easy way to control indents in Python

2014-10-21 Thread Ian Kelly
On Tue, Oct 21, 2014 at 2:45 AM, Simon Kennedy wrote: > On Monday, 20 October 2014 18:56:05 UTC+1, Ian wrote: >> Rather, I'm saying that where the blank line is should be the start of >> a new function. There would still be a blank line, just no longer >> inside the function. >> >> Now, maybe you

Re: Is there an easy way to control indents in Python

2014-10-21 Thread jumppanen . jussi
On Wednesday, October 15, 2014 12:13:51 PM UTC+10, ryguy7272 wrote: > I'm just learning Python. One of the best ways to learn any language is to type in the example code by hand. As you type in the code you will make mistakes, you will learn from your mistakes and that will help you learn the l

Re: Is there an easy way to control indents in Python

2014-10-21 Thread Simon Kennedy
On Monday, 20 October 2014 18:56:05 UTC+1, Ian wrote: > Rather, I'm saying that where the blank line is should be the start of > a new function. There would still be a blank line, just no longer > inside the function. > > Now, maybe you think there should be more blank lines in the above, in > wh

Re: Is there an easy way to control indents in Python

2014-10-20 Thread Juan Christian
Sorry guys, my post about SQL was not meant to be here!!! On Mon, Oct 20, 2014 at 5:43 PM, MRAB wrote: > On 2014-10-20 20:04, Juan Christian wrote: > >> Ok, new code using ?: >> >> import sqlite3 >> >> db = sqlite3.connect('db.sqlite') >> >> >> def create_db(): >> db.execute(''' >> CREATE T

Re: Is there an easy way to control indents in Python

2014-10-20 Thread MRAB
On 2014-10-20 20:04, Juan Christian wrote: Ok, new code using ?: import sqlite3 db = sqlite3.connect('db.sqlite') def create_db(): db.execute(''' CREATE TABLE TOPICS( ID INT PRIMARY KEY NOT NULL, URL VARCHAR NOT NULL, AUTHOR VARCHAR NOT NULL, MESSAGE VARCHAR NOT NULL ); ''') def insert

Re: Is there an easy way to control indents in Python

2014-10-20 Thread Ian Kelly
On Mon, Oct 20, 2014 at 1:04 PM, Juan Christian wrote: > Ok, new code using ?: I suspect you meant to post this to some other thread. > def get_db(_id): > cursor = db.execute("SELECT ID, URL, AUTHOR, MESSAGE FROM TOPICS WHERE ID = > ?", (_id)) > return cursor.fetchone() (_id) is not a tuple; it

Re: Is there an easy way to control indents in Python

2014-10-20 Thread Juan Christian
Ok, new code using ?: import sqlite3 db = sqlite3.connect('db.sqlite') def create_db(): db.execute(''' CREATE TABLE TOPICS( ID INT PRIMARY KEY NOT NULL, URL VARCHAR NOT NULL, AUTHOR VARCHAR NOT NULL, MESSAGE VARCHAR NOT NULL ); ''') def insert_db(_id, url, auth

Re: Is there an easy way to control indents in Python

2014-10-20 Thread Ian Kelly
On Mon, Oct 20, 2014 at 11:54 AM, Ian Kelly wrote: > On Mon, Oct 20, 2014 at 9:54 AM, Simon Kennedy wrote: >> Not having ever attempted to go beyond even the basics of Perl, the aspect >> that causes me to refer to Perl 'dismissively' as well comment in this >> thread, is that I don't find Perl

Re: Is there an easy way to control indents in Python

2014-10-20 Thread Ian Kelly
On Mon, Oct 20, 2014 at 9:54 AM, Simon Kennedy wrote: > Not having ever attempted to go beyond even the basics of Perl, the aspect > that causes me to refer to Perl 'dismissively' as well comment in this > thread, is that I don't find Perl to be an aesthetically pleasing language > and I consid

Re: Is there an easy way to control indents in Python

2014-10-20 Thread Simon Kennedy
On Saturday, 18 October 2014 11:53:16 UTC+1, Steven D'Aprano wrote: > I'm curious what aspect of idiomatic Perl code you are referring to. When > people talk about Perl code dismissively, I normally think of three things: > > - excessively long one-liners; > - excessive use of symbols and sigils

Re: Is there an easy way to control indents in Python

2014-10-18 Thread Steven D'Aprano
Simon Kennedy wrote: > On Wednesday, 15 October 2014 20:31:15 UTC+1, Ian wrote: >> I agree. I very rarely use blank lines inside functions. As I see it, >> if you feel you need a blank line for separation within a function, >> that's an indication your function is overly complex and should be >>

Re: Is there an easy way to control indents in Python

2014-10-16 Thread Gregory Ewing
On 16/10/2014 12:32 AM, Chris “Kwpolska” Warrick wrote: Why? Because things like `print 'done'` usually have an empty line before it: Not in my code, they don't. I never put blank lines inside functions. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there an easy way to control indents in Python

2014-10-16 Thread Chris Angelico
On Fri, Oct 17, 2014 at 1:08 AM, Simon Kennedy wrote: > On Wednesday, 15 October 2014 20:31:15 UTC+1, Ian wrote: >> I agree. I very rarely use blank lines inside functions. As I see it, >> if you feel you need a blank line for separation within a function, >> that's an indication your function is

Re: Is there an easy way to control indents in Python

2014-10-16 Thread Simon Kennedy
On Wednesday, 15 October 2014 20:31:15 UTC+1, Ian wrote: > I agree. I very rarely use blank lines inside functions. As I see it, > if you feel you need a blank line for separation within a function, > that's an indication your function is overly complex and should be > broken up. Whereas I feel t

Re: Is there an easy way to control indents in Python

2014-10-15 Thread alex23
On 16/10/2014 12:32 AM, Chris “Kwpolska” Warrick wrote: It should parse this as else: print 'false' print 'done' Why? Because things like `print 'done'` usually have an empty line before it: if True: print 'true' else: print 'false' print 'done' That should be parsed the way you w

Re: Is there an easy way to control indents in Python

2014-10-15 Thread Ian Kelly
On Wed, Oct 15, 2014 at 11:12 AM, Terry Reedy wrote: > On 10/15/2014 10:32 AM, Chris “Kwpolska” Warrick wrote: >> It should parse this as >> >> else: >> print 'false' >> print 'done' >> >> Why? Because things like `print 'done'` usually have an empty line before >> it: > > > There is no

Re: Is there an easy way to control indents in Python

2014-10-15 Thread Terry Reedy
On 10/15/2014 10:32 AM, Chris “Kwpolska” Warrick wrote: On Wed, Oct 15, 2014 at 9:27 AM, alex23 wrote: On 15/10/2014 12:23 PM, Juan Christian wrote: Using PyCharm is easy: File > Settings > (IDE Settings) Editor > Smart Keys > Reformat on paste > choose "Reformat Block" This isn't as s

Re: Is there an easy way to control indents in Python

2014-10-15 Thread Chris “Kwpolska” Warrick
On Wed, Oct 15, 2014 at 9:27 AM, alex23 wrote: > On 15/10/2014 12:23 PM, Juan Christian wrote: >> >> Using PyCharm is easy: >> >> File > Settings > (IDE Settings) Editor > Smart Keys > Reformat on paste >> > choose "Reformat Block" > > > > This isn't as straight forward as you imply. Say I have m

Re: Is there an easy way to control indents in Python

2014-10-15 Thread alex23
On 15/10/2014 12:23 PM, Juan Christian wrote: Using PyCharm is easy: File > Settings > (IDE Settings) Editor > Smart Keys > Reformat on paste > choose "Reformat Block" This isn't as straight forward as you imply. Say I have misindented code like this: if True: print 'true' els

Re: Is there an easy way to control indents in Python

2014-10-14 Thread Chris Angelico
On Wed, Oct 15, 2014 at 1:35 PM, Zachary Ware wrote: >> But ultimately, the >> fault is almost certainly with the PDF. > > Agreed, although I'd say the PDF viewer could also be at fault. Good point, there are some really terrible PDF viewers around. Either way, the workaround of grabbing one line

Re: Is there an easy way to control indents in Python

2014-10-14 Thread Zachary Ware
On Tue, Oct 14, 2014 at 9:18 PM, Chris Angelico wrote: > On Wed, Oct 15, 2014 at 1:13 PM, ryguy7272 wrote: >> I'm just learning Python. It seems like indents are EXTREMELY important. I >> guess, since there are no brackets, everything is controlled by indents. >> Well, I'm reading a couple b

Re: Is there an easy way to control indents in Python

2014-10-14 Thread Dan Stromberg
On Tue, Oct 14, 2014 at 7:13 PM, ryguy7272 wrote: > I'm just learning Python. It seems like indents are EXTREMELY important. I > guess, since there are no brackets, everything is controlled by indents. > Well, I'm reading a couple books on Python now, and in almost all of the > examples they

Re: Is there an easy way to control indents in Python

2014-10-14 Thread Chris Angelico
On Wed, Oct 15, 2014 at 1:13 PM, ryguy7272 wrote: > I'm just learning Python. It seems like indents are EXTREMELY important. I > guess, since there are no brackets, everything is controlled by indents. > Well, I'm reading a couple books on Python now, and in almost all of the > examples they

Re: Is there an easy way to control indents in Python

2014-10-14 Thread Juan Christian
Using PyCharm is easy: File > Settings > (IDE Settings) Editor > Smart Keys > Reformat on paste > choose "Reformat Block" On Tue, Oct 14, 2014 at 11:13 PM, ryguy7272 wrote: > I'm just learning Python. It seems like indents are EXTREMELY important. > I guess, since there are no brackets, everyt

Is there an easy way to control indents in Python

2014-10-14 Thread ryguy7272
I'm just learning Python. It seems like indents are EXTREMELY important. I guess, since there are no brackets, everything is controlled by indents. Well, I'm reading a couple books on Python now, and in almost all of the examples they don't have proper indents, so when I copy/paste the code (