f



Tabs/spaces for indentation (was Re: re.search when used within an if/else fails)

On Thu, Nov 29, 2012 at 8:39 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Perhaps it would be nice if Python honoured a directive setting indent
> style to spaces or indents, as it honours source code encoding lines:
>
> # -*- indent: <mode> -*-
>
> Where <mode> could be one of:
>
> space[s]        Only accept spaces in indentation
> tab[s]          Only accept tabs in indentation
> mixed           Accept "mixed" tabs and spaces, but only if consistent
>
> with mixed the default for backward compatibility.

I don't know that it needs to be a declaration like that; character
encodings are critical to parsing the file, but
newline-followed-by-tab and newline-followed-by-space are unambiguous.
But it would be of value to have something like that, as editors could
then be configured to respect it - set the editor to turn tab-key into
N spaces but only if "indent tab" is not set, for instance. The
question is, is it worth it? The main value would be when you're
editing someone else's code.

ChrisA
0
rosuav (4324)
11/28/2012 11:04:55 PM
comp.lang.python 77058 articles. 6 followers. Post Follow

0 Replies
380 Views

Similar Articles

[PageSpeed] 46

Reply:

Similar Artilces:

re.search when used within an if/else fails
python version 2.4.3, yes i know that it is old. getting the sysadmin to update the OS requires a first born. with the following code.. for signal in register['signals'] : 351 sigName = signal['functionName'] 352 if re.search( "rsrvd", sigName ) == None : 353 print sigName 354 newVal = "%s%s" % ( '1'*signal['bits'] , newVal ) #prepend 0's 355 if re.search( "rsrvd", sigName ) != None : 356 print sigName 357 newVal = "%s%s" % ( '0'*signal['bits'], newVal ) regardless of how i code line 352, i can not EVER use an else clause with it. if i use an else clause, the else will NEVER get executed... has any one experienced anything like this behavior? any suggestions? the above code works but... why should i have to code it like this? kevin On 2012-11-19 23:43, Kevin T wrote: > python version 2.4.3, yes i know that it is old. getting the sysadmin to update the OS requires a first born. > > with the following code.. > for signal in register['signals'] : > > 351 sigName = signal['functionName'] > 352 if re.search( "rsrvd", sigName ) == None : > 353 print sigName > 354 ...

Re: Tabs for indentation & Spaces for alignment in Python 3?
--001a1139638cc8e4c205097c87a5 Content-Type: text/plain; charset=UTF-8 Hello Ian, So, wrt Q2, what you are saying is, the following would cause issues in Python 3? int f(int x, ......int y) { --->return g(x, --->.........y); } Where: ---> for tabs (used for indentation) ..... for spaces (used for alignment) Best Aahan --001a1139638cc8e4c205097c87a5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hello Ian,<br><div><br>So, wrt Q2, what you are sa...

Re: Tabs for indentation & Spaces for alignment in Python 3? #2
--047d7bfea07a1873ab0509826c75 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello Ned, I thought that the use of tabs and spaces in the manner I suggested is pretty common. Linux Kernel follows the same technique, for example: https://github.com/torvalds/linux/blob/master/kernel/async.c#L100 Of course, I understand the gist of what you are saying=E2=80=94if people d= on't understand this technique properly and start mixing up tabs and spaces interchangeably or wrongly the code'd get mangled pretty quickly. Thank you for the head...

Re: Tabs for indentation & Spaces for alignment in Python 3? #3
--001a11c1fe0821549a0509833cbf Content-Type: text/plain; charset=UTF-8 Hello Ned, I didn't notice that he was using tabs more than as needed for indentation. Guess I trusted the wrong guy. :P Anyway, it's one more thing to keep in mind. Grrrr! -- Aahan Krish --001a11c1fe0821549a0509833cbf Content-Type: text/html; charset=UTF-8 <div dir="ltr"><div>Hello Ned, I didn&#39;t notice that he was using tabs more than as needed for indentation. Guess I trusted the wrong guy. :P Anyway, it&#39;s one more thing to keep in mind. Grrrr!<br><br...

Re: Re: Re: Marc Re: Andreessen Re: created Re: the Re: first Re: web Re: browser
no. ...

RE : Re: RE : Re: copulas and SAS
Thanks, I appreciate your comments,I understand that copula is not the appropriate tool to use, what will be the alternative ? Adel David L Cassell <davidlcassell@MSN.COM> a �crit : joewhitehurst@GMAIL.COM replied: > >Adel, > >You may find the following artilce interesting. [article by Thomas Mikosch not copied] This is a really good article, and a really useful point to make. But 55K is a lot of article to copy. Would it have been easier to point to a URL? The people who read SAS-L as a digest and the people who have slow connections are probably not overly thrilled...

Re: Re: Re: Re: No future for DB2
Well, IDS 10 + XPS 9 as open source = Astonishing cool !! J. -----Original Message----- From: "Obnoxio The Clown" <obnoxio@serendipita.com> To: "Jean Sagi" <jeansagi@myrealbox.com> Date: Wed, 27 Jul 2005 22:00:31 +0100 (BST) Subject: Re: Re: Re: No future for DB2 Jean Sagi said: > > Online 5. as open source = Quite cool. But hugely impractical, as it would reveal far too much about IDS to the competition. -- Bye now, Obnoxio "C'est pas parce qu'on n'a rien � dire qu'il faut fermer sa gueule" - Coluche A smile is a gift that is free to the giver and precious to the recipient. But giving someone the finger is free too, and I find it more personal and sincere. Jean Sagi jeansagi@myrealbox.com jeansagi@gmail.com sending to informix-list ...

RE: Re: Re: wxMac: loading a dynamic library with wxDynamicLibrary fails (NSCreateObjectFileImageFromFile fails)
Hi Bernhard thanks for testing, I'll look at it, perhaps using CFBundle would give a more versatile implementation at least for wxMac. Is there a reason why we must use=20 NSCreateObjectFileImageFromFile ? Best, Stefan=20 > -----Original Message----- > From: news [mailto:news@sea.gmane.org] On Behalf Of Bernard=20 > Krummenacher > Sent: Samstag, 1. April 2006 15:13 > To: wx-users@lists.wxwindows.org > Subject: Re: Re: wxMac: loading a dynamic library with=20 > wxDynamicLibrary fails (NSCreateObjectFileImageFromFile fails) >=20 > Stefan Csomor <csomor <at> advancedconcepts.ch> writes: >=20 > >=20 > > Hi > >=20 > > if you'd use CFBundle calls do they give better error codes ? > >=20 > > Best, > >=20 > > Stefan > >=20 >=20 > Hi Stefan, >=20 > Trying to load the bundle with CFBundle seems to work. I did=20 > this (borrowed from > Apple documentation): >=20 > CFURLRef bundleURL; > CFBundleRef myBundle; > =20 > // Make a CFURLRef from the CFString representation of the=20 > // bundle's path. > bundleURL =3D CFURLCreateWithFileSystemPath(kCFAllocatorDefault,=20 > CFSTR("<Some=20 > valid absolute > path>/DynLib.bundle"), > kCFURLPOSIXPathStyle, > ...

Re: Re: Re: Radio Re: Shack Re: TRP-100 Re: Printer Re:
> Also, trim your replies. Leaving a few pages of original text just so > you can add your few lines at the bottom is just insane. > > g. > > -- > Proud owner of F-15C 80-0007 > http://www.f15sim.com - The only one of its kind. > http://www.diy-cockpits.org/coll - Go Collimated or Go Home. > Some people collect things for a hobby. Geeks collect hobbies. > > ScarletDME - The red hot Data Management Environment > A Multi-Value database for the masses, not the classes. > http://scarlet.deltasoft.com - Get it _today_! > --- Synchrone...

RE RE
EEE ...

RE RE
EEE ...

re: re
I am studying the re module and still do not understand how to do some really simple tasks: 1) say I need to capitalize any word that is between the words 'United' and 'of America'. So I do re.findall|match|search('United .* of America', s) this may return 'United States of America', but not 'States', which is the word of interest. 2) There is a further problem: even if I had a way to specify 'States' in the example above as the matched regex, the sub function proves insufficient: re.sub allows me to specify only the replacement string, but...

RE: RE
edward wrote: > Hi, > I was wondering if anybody could help with the implementation of ordinary texture mapping. I have an textured cube object, using .raw files & Visual Studio 2005. > > I now need to get this parallaxed mapped. From normal texture mapping to parallax mapping is a long way. Read up on: - Cg shaders - bumpmapping - parallax mapping (some tutorials avaiable on the internet) Once you get bumpmapping working (you need to work in tangent space, also generate tangents), parallax mapping is relatively easy in its simplest form. More exotic versions exist though...

Re: Re: Re: Not Using a Text Editor Interface for Mathematica
For some interesting reading take a look at Chapter 2 in Edward R. Tufte's 'Visual Explanations'. Dr. John Snow found the cause of the 1854 Cholera Epidemic in London by FIRST plotting the case data on a map of London, and THEN doing the analysis. In the case of the Challenger Space Shuttle disaster, although they were aware of the potential problem, the technicians never made the proper graphic that related risk to temperature in past launches and thus failed to present a convincing case for not launching. Maybe graphics doesn't always come before analysis, but ...

RE : Re: RE : Re: contribution of independent variables in a
Thanks David, My question was about the "contribution of each indepedent vaiable in the variance of the dependent variable". I take your point , that it is not a correct question in the first time, I had some references from othe members of the list Thanks for the suggestions Adel David L Cassell <davidlcassell@MSN.COM> a �crit : adel_tangi@YAHOO.FR wrote back: > > >David L Cassell a �crit : > adel_tangi@YAHOO.FR wrote: > > > >Hi, > > > > I have a continuous depedent variable y and 3 independent variable X1 > >(binary), X2...

Re: SUSPECT: RE: SUSPECT: RE: SUSPECT: RE: SUSPECT: RE: Download
Anyway, Thank you Philip. I took a look at your co., I didn� t know about your WPS, and neither it did exist a open alternative for SPSS.... Daniel -----Mensaje original----- De: Philip Rack [mailto:PhilRack@MineQuest.com] Enviado el: dilluns, 2 / novembre / 2009 17:59 Para: Fern�ndez Rodr�guez, Dani; SAS-L@LISTSERV.UGA.EDU Asunto: SUSPECT: RE: SUSPECT: RE: SUSPECT: RE: SUSPECT: RE: Download a file from HTTP I don't see a provision for this. Perhaps someone else on SAS-L has a workaround. Philip Rack MineQuest, LLC SAS & WPS Consulting and WPS Reseller Tel: (614) 457-3714 Web: ww...

RE: Python in Games (was RE: [Stackless] Python in Games)
Dave LeCompte (really) wrote: >> Who is using Python in games >>=20 >> Python has been used in a number of games, including >>=20 >> * ToonTown - http://www.toontown.com/ >> * EveOnline - http://www.eve-online.com/ >> * Blade of Darkness - http://www.codemastersusa.com/blade/ Add to that: - `The Temple of Elemental Evil`__ - `Vampire: The Masquerade: Bloodlines`__ ... __: http://www.troikagames.com/toee.htm ... __: http://www.vampirebloodlines.com/ Moved to python-list because it's gone beyond Stackless :) Tim Delaney My understandi...

Using re.VERBOSE, and re-using components of regex?
Hi, I'm trying to compile a regex Python with the re.VERBOSE flag (so that I can add some friendly comments). However, the issue is, I normally use constants to define re-usable bits of the regex - however, these doesn't get interpreted inside the triple quotes. For example: import re TIMESTAMP = r'(?P<timestamp>\d{2}:\d{2}:\d{2}.\d{9})' SPACE = r' ' FOO = r'some_regex' BAR = r'some_regex' regexes = { 'data_sent': re.compile(""" TIMESTAMP # Timestamp of our log message SPACE FOO # Some comment SPACE """, re.VERBOSE), 'data_received': re.compile(""" TIMESTAMP # Timestamp of our log message SPACE BAR # Some comment SPACE """, re.VERBOSE), } Is there a way to use CONSTANTS (or at least re-use fragments of my regex), and also use re.VERBOSE so I can comment my regex? Cheers, Victor On 17/04/2013 00:45, Victor Hooi wrote: > Hi, > > I'm trying to compile ...

Re: Re: Use of % notation
I'm not sure what you mean, Jens, by "in the FrontEnd". In any case, I would say avoid the use of % when it refers to output from a different cell. But in doing derivations by a series of calculational steps WITHIN ONE CELL I find that % and %% are extremely useful and completely safe. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ From: Jens-Peer Kuska [mailto:kuska@informatik.uni-leipzig.de] Avoid the usage of % in the FrontEnd. Regards Jens Hi, I mean, that if you run the Mathematica kernel alone in a command line session or ...

Re: Re: python and gpl
Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote: > > Tim Churches <tchur@optushome.com.au> writes: > > >The question is: does shipping a backend which imports a module that > > > links with GPL code make some or all of the library GPL. > > We sought formal legal advice on this issue from a lawyer with > > expertise in open source licensing ...> > > The answer was that the GPL does not apply to combination of code at > > run-time. Specifically, Section 0., Para 1 (assuming zero-based > > paragraph numbering...) says:> &g...

RE: using re.finditer()
Erik Johnson wrote: > I am still fairly new to Python and trying to learn to=20 > put RE's to good use. I am a little confused about the > finditer() method... > ...it doesn't document any restriction about multiline matching, > but it certainly seems to have one... > finditer() doesn't accept a flag like re.DOTALL,=20 > as re.match() and re.search() do. It seems a shame not > to be able to put an otherwise smart design to use. Embed the flag(s) you desire in the regex itself. For example, to include DOTALL, change r'<td.*?>(.*?)</td>' t...

Re: Using BIND
----- Original Message Follows ----- > mayer wrote: > [] > >> In my own small network, by the way, I have fixed IP addresses and > >> avoid DHCP. I have made the router start at 192.168.0.100 (or > >> whatever) so there is a space of clear addresses in the > >> 192.168.0.1..99 range that I can assign myself. I have around 10 > >> PCs. This means that I use the HOSTS file to assign names to > >> numbers. > >> > > > > That's silly. Just install BIND on one of your system and have it > > provide the ...

Re: Using BIND
----- Original Message Follows ----- > mayer wrote: > [] > > I'm not trying to convince you, it's up to you to make you own > > decisions on what makes sense on your own network. I just strongly > > recommend against > > using a hosts file as it's error prone, requires repropogation, is > > vunerable to viruses and can generally not be relied on. One virus I > > saw going around last year made use of it to add bad addresses of > > all of the various virus makers making it impossible to contact them > > to download new virus defi...

Re: Using BIND
----- Original Message Follows ----- > mayer wrote: > [] > > The ARM is available online, but you also have your own local copy. > >> From Google I found this online: > > http://www.fiveanddime.net/bind-9/bind-9.3.1/doc/arm/ > > > > Danny > > Thanks for that, Danny. Arrgh! I don't know if it's just my Web > browser, but all I get there is a directory list. Perhaps you mean: > > > http://www.fiveanddime.net/bind-9/bind-9.3.1/doc/arm/Bv9ARM.html.html > These HTML pages come with both the Windows binaries and the source....

Web resources about - Tabs/spaces for indentation (was Re: re.search when used within an if/else fails) - comp.lang.python

Indentation - Wikipedia, the free encyclopedia
Some languages (e.g., Hebrew and Arabic ) are written right-to-left, and if indentation is used, in the above "left" and "right" should be swapped ...

format callback indentation bugs · Issue #49 · maxogden/standard-format · GitHub
standard-format - converts your code into Standard JavaScript Format

Design: Outline indentation and Markdown?
The puzzle The user enters a Markdown document in an outline. How to interpret indentation? Necessary background This is a design puzzle ...

Resources last updated: 3/10/2016 11:27:19 AM