Movatterモバイル変換


[0]ホーム

URL:


#define (was Re: python-list at python.org)

Alex Martellialeaxit at yahoo.com
Thu Apr 12 11:07:08 EDT 2001


"Vincent A. Primavera" <vincent_a_primavera at netzero.net> wrote in messagenews:mailman.987079936.13897.python-list at python.org...> Hello,> What I am trying to accomplish is to shorten statements such as> stdscr.addstr(10, 10, 'This is a test...', curses.color_pair(1))... ;o}> nothing too complicated.You don't need a #define (i.e., macros) for this; just wrap thisstatement into a function, with whatever arguments and defaultsyou desire.Suppose, for example, that (were this C) you would code:#define SAY(text,y) stdscr_addstr(10, y, text, curses_color_pair(1))The Pythonic equivalent would then be:def SAY(text, y):    stdscr.addstr(10, y, text, curses.color_pair(1))and of course, you can have default-valued arguments:def SAY(text, y, color=None):    if color is None: color = curses.color_pair(1)    stdscr.addstr(10, y, text, color)Nothing too complicated -- just nice, powerful, simple.I.e., Python.Alex


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp