Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

About Pythonwin

iwilld0itiwilld0it Posts: 1,134Member
Ok I can write scripts and batch files now, so Im happy. My question is:

Is there a way to turn intellisense on for pythonwin when in scripting mode. I notice that intellisense only kicks in when you have used the
property or method at least once.

Plus can anyone explain list comprehensions a little better for me.
It seems a bit abstract to me. A simple example would be helpful.

Thanx.

Comments

  • infidelinfidel Posts: 2,900Member
    : Is there a way to turn intellisense on for pythonwin when in scripting mode. I notice that intellisense only kicks in when you have used the property or method at least once.

    That's something that's always bothered me a bit. It seems that you only get a "full" intellisense drop down if the module/class/whatever in question has been imported (meaning you've run your script within PythonWin). At least that appears to be the case. Not sure if there's a way around that currently.

    : Plus can anyone explain list comprehensions a little better for me.
    : It seems a bit abstract to me. A simple example would be helpful.

    List comprehensions are a shorthand way of making a list by applying the same code to every element in another sequence.

    mylist = ['foo','bar','gee','haw']

    If I wanted to make that list into an HTML unordered list, I could:

    print '
    '.join(['
      '] + ['
    • %s
    • ' % item for item in mylist] + ['
    '])

    That line is a little complex. The list comprehension part is:

    ['%s' % item for item in mylist]

    Which is logically equivalent to:
    [code]
    def makenewlist(mylist):
    newlist = []
    for item in mylist:
    newlist.append('%s' % item)
    return newlist
    [/code]


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

  • infidelinfidel Posts: 2,900Member
    : ['%s' % item for item in mylist]

    It suddenly occurred to me that you may not know about string substitutions yet. Just in case,

    [code]'%s' % item [/code]

    ... is kind of like C's:

    [code]printf("%s", item)[/code]




    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

Sign In or Register to comment.