[python-win32] Request for comments

Mike Driscoll mdriscoll at co.marshall.ia.us
Tue May 27 15:53:07 CEST 2008


Tim Golden wrote:
> <div class="moz-text-flowed" style="font-family: -moz-fixed">bob 
> gailer wrote:
>> Tim Roberts wrote:
>>> bob gailer wrote:
>>>>
>>>> Please omit the space before ( in code. I find that very 
>>>> distracting. Example:
>>>>
>>>> print result.Properties_ ("sValue").Value # current
>>>>
>>>> print result.Properties_("sValue").Value # preferred, and how most 
>>>> code I've seen looks.
>>>
>>> Do you understand that this is strictly a personal preference?  Some 
>>> people like it, some people don't.  You are certainly allowed to 
>>> "prefer" one over the other, but it's a bit much to ask someone else 
>>> to change their coding style to match yours, unless you are a paying 
>>> client.  ;)
>>
>> I agree. Please consider that all of the code examples I've seen in 
>> the official Python documentation have no space before the (. Most 
>> newcomers to Python who goes thru the tutorial will learn that way of 
>> coding. I imagine it would be confusing for them to later see code 
>> with the space. Same true for Python cookbook. Follow Tim's link to 
>> Windows Registry Functions 
>> <http://msdn.microsoft.com/en-us/library/ms724875%28VS.85%29.aspx>. 
>> MS's examples. Ditto. I'm aiming for consistency, and minimal 
>> confusion for many.
>
> It's a fair point. For now (basically because I can do it faster)
> I'll go with my spaces-before convention. When I get a chance to
> breathe we can revisit this and other other coding style issues.
> All the example code is in individual Python files so a global
> search-and-replace should be possible if it becomes desirable.
>
> [... snip description of problems with the PythonWin interpreter ...]
>
> Yes, I tried that to see what you meant. I'm not sure there's
> much I'm going to be able to do about that, unless someone
> jumps in with a solution. My main point about the examples is
> that they're self-contained. (ie you don't need to prearrange
> any data or install any modules unless indicated). The ability
> to drop them into a Python interpreter window is a nice-to-have
> which I make use of whenever I'm posting code.
>
> If anyone can suggest anything here, even in the form of a hint
> in the docs, please let me know.

Well, there's at least 2 ways around this.

1) Change it to:      import win32api; import win32con   (note the 
important semi-colon)
2) Change it to:      import win32api, win32con 

>
> Thanks for your continued interest, Bob.
>
> TJG
>
> </div>

I personally like to use my delete key, so when I try to copy and paste 
something like this into IDLE or PythonWin, I position my cursor at the 
end of the first import, add a semi-colon and hit delete until the 2nd 
import jumps to the first line.

However, any code that is more than one statement, I tend to copy into a 
blank file and save it before running it, which circumvents this issue 
entirely.

Mike



More information about the python-win32 mailing list