2007年01月13日 星期六 09:50
ÔÚpythonÖУ¬ÔõôÑù²ÅÄܲ»ÓÃpropertyÀ´ÊµÏÖÖ»¶ÁÊôÐÔÄØ¡£ ÎÒд³ÌÐòµÄʱºò£¬×ÜÓÐһЩֻ¶ÁµÄÊôÐÔ£¬µ«ÎªÁËÒ»¸öÕâÑùµÄÊôÐÔ£¬¾ÍµÃдһ¸öº¯Êý£¬È»ºóÓÃpropertyÉè³ÉÖ»¶ÁµÄ£¬ÊDz»ÊÇÓеãÌ«Âé·³ÁËÄØ£¿¸÷λÓÐʲô¸üºÃµÄ·½°¸Â𣿠-- ££££££££ ÏàÐÅÐÒ¸££¬ ÏàП¶³öµÄŬÁ¦£¡ ££££££££ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070113/971d86db/attachment.html
2007年01月13日 星期六 13:56
要是有C++的const关键字就好了;-) ASPN有个例子,Automating simple property creation ,http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/157768 可以参考一下. ----- Original Message ----- From: moqiancong To: python-chinese at lists.python.cn Sent: Saturday, January 13, 2007 9:50 AM Subject: [python-chinese] 怎么不用property来实现只读属性? 在python中,怎么样才能不用property来实现只读属性呢。 我写程序的时候,总有一些只读的属性,但为了一个这样的属性,就得写一个函数,然后用property设成只读的,是不是有点太麻烦了呢?各位有什么更好的方案吗? -- -------- 相信幸福, 相信付出的努力! -------- ------------------------------------------------------------------------------ _______________________________________________ python-chinese Post: send python-chinese at lists.python.cn Subscribe: send subscribe to python-chinese-request at lists.python.cn Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20070113/f2faa9dd/attachment.html
2007年01月13日 星期六 14:15
¼ÇµÃÇ°¼¸ÌìÖ£±òͬѧÎʹý¡¶ÔÚpythonÖÐҪʵÏÖÀàËÆdefineµÄ¹¦ÄÜÔõô°ì¡·£¬limodouÌá¹ýÓÃproperty¡£ µ«ËµÊµ»°£¬ÓÃÕâÖÖ·½·¨¶ÔÀàÖеÄÖ»¶ÁÊôÐÔÀ´Ëµ£¬ÕæµÄºÜÂé·³¡£µ«ÄÇ×éÓʼþºóÀ´¶¼³ÉÁËÌÖÂÛC/C++È¥ÁË¡£Ôε¹¡£²»µÃ²»µ¥¿ª¸öÓʼþÀ´ÎÊÕâ¸öÎÊÌâ¡£ ллvccÌṩµÄÕâ¸ö·½·¨¡£ ÔÚ07-1-13£¬vcc <vcc在163.com> дµÀ£º > > ÒªÊÇÓÐC++µÄconst¹Ø¼ü×־ͺÃÁË;-) > ASPNÓиöÀý×Ó,Automating simple property creation , > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/157768 > ¿ÉÒԲο¼Ò»ÏÂ. > > ----- Original Message ----- > *From:* moqiancong <moqiancong在gmail.com> > *To:* python-chinese在lists.python.cn > *Sent:* Saturday, January 13, 2007 9:50 AM > *Subject:* [python-chinese] Ôõô²»ÓÃpropertyÀ´ÊµÏÖÖ»¶ÁÊôÐÔ£¿ > > ÔÚpythonÖУ¬ÔõôÑù²ÅÄܲ»ÓÃpropertyÀ´ÊµÏÖÖ»¶ÁÊôÐÔÄØ¡£ > > ÎÒд³ÌÐòµÄʱºò£¬×ÜÓÐһЩֻ¶ÁµÄÊôÐÔ£¬µ«ÎªÁËÒ»¸öÕâÑùµÄÊôÐÔ£¬¾ÍµÃдһ¸öº¯Êý£¬È»ºóÓÃpropertyÉè³ÉÖ»¶ÁµÄ£¬ÊDz»ÊÇÓеãÌ«Âé·³ÁËÄØ£¿¸÷λÓÐʲô¸üºÃµÄ·½°¸Â𣿠> > -- > > ££££££££ > ÏàÐÅÐÒ¸££¬ > ÏàП¶³öµÄŬÁ¦£¡ > ££££££££ > > ------------------------------ > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -- ££££££££ ÏàÐÅÐÒ¸££¬ ÏàП¶³öµÄŬÁ¦£¡ ££££££££ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070113/79acfb63/attachment.htm
2007年01月13日 星期六 14:22
手册中推荐的方法是加两个'-'为前导 在07-1-13,moqiancong <moqiancong在gmail.com> 写道: > > 记得前几天郑彬同学问过《在python中要实现类似define的功能怎么办》,limodou提过用property。 > 但说实话,用这种方法对类中的只读属性来说,真的很麻烦。但那组邮件后来都成了讨论C/C++去了。晕倒。不得不单开个邮件来问这个问题。 > > 谢谢vcc提供的这个方法。 > > 在07-1-13, vcc <vcc在163.com> 写道: > > > > 要是有C++的const关键字就好了;-) > > ASPN有个例子,Automating simple property creation ,http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/157768 > > > > 可以参考一下. > > > > ----- Original Message ----- > > *From:* moqiancong <moqiancong在gmail.com> > > *To:* python-chinese在lists.python.cn > > *Sent:* Saturday, January 13, 2007 9:50 AM > > *Subject:* [python-chinese] 怎么不用property来实现只读属性? > > > > > > 在python中,怎么样才能不用property来实现只读属性呢。 > > > > 我写程序的时候,总有一些只读的属性,但为了一个这样的属性,就得写一个函数,然后用property设成只读的,是不是有点太麻烦了呢?各位有什么更好的方案吗? > > > > -- > > > > -------- > > 相信幸福, > > 相信付出的努力! > > -------- > > > > ------------------------------ > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to > > python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > -- > > -------- > 相信幸福, > 相信付出的努力! > -------- > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -------------- 下一部分 -------------- 一个HTML附件被移除... URL: http://python.cn/pipermail/python-chinese/attachments/20070113/ae0e675c/attachment.html
2007年01月13日 星期六 23:47
¿É²»¿ÉÒÔÔÚ__setattrº¯ÊýÀï×öһЩ´¦ÀíÄØ£¿ ÔÚ07-1-13£¬moqiancong <moqiancong在gmail.com> дµÀ£º > > ÔÚpythonÖУ¬ÔõôÑù²ÅÄܲ»ÓÃpropertyÀ´ÊµÏÖÖ»¶ÁÊôÐÔÄØ¡£ > > ÎÒд³ÌÐòµÄʱºò£¬×ÜÓÐһЩֻ¶ÁµÄÊôÐÔ£¬µ«ÎªÁËÒ»¸öÕâÑùµÄÊôÐÔ£¬¾ÍµÃдһ¸öº¯Êý£¬È»ºóÓÃpropertyÉè³ÉÖ»¶ÁµÄ£¬ÊDz»ÊÇÓеãÌ«Âé·³ÁËÄØ£¿¸÷λÓÐʲô¸üºÃµÄ·½°¸Â𣿠> > -- > > ££££££££ > ÏàÐÅÐÒ¸££¬ > ÏàП¶³öµÄŬÁ¦£¡ > ££££££££ > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -- It's a long journey to go! -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070113/efb914ee/attachment.htm
2007年01月15日 星期一 03:57
在__setattr__ 做手脚的话初始赋值会有问题 On 1/13/07, Gao Hong <joy.highland在gmail.com> wrote: > 可不可以在__setattr函数里做一些处理呢? > > > 在07-1-13,moqiancong <moqiancong在gmail.com> 写道: > > > > 在python中,怎么样才能不用property来实现只读属性呢。 > > > 我写程序的时候,总有一些只读的属性,但为了一个这样的属性,就得写一个函数,然后用property设成只读的,是不是有点太麻烦了呢?各位有什么更好的方案吗? > > > > -- > > > > -------- > > 相信幸福, > > 相信付出的努力! > > -------- > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > > > > > > -- > It's a long journey to go! > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > Detail Info: > http://python.cn/mailman/listinfo/python-chinese >
2007年01月15日 星期一 09:20
ÄܾßÌåµØ˵һÏÂÂ𣿠2007/1/15, shhgs <shhgs.efhilt在gmail.com>: > > ÔÚ__setattr__ ×öÊֽŵĻ°³õʼ¸³Öµ»áÓÐÎÊÌâ > > On 1/13/07, Gao Hong <joy.highland在gmail.com> wrote: > > ¿É²»¿ÉÒÔÔÚ__setattrº¯ÊýÀï×öһЩ´¦ÀíÄØ£¿ > > > > > > ÔÚ07-1-13£¬moqiancong <moqiancong在gmail.com> дµÀ£º > > > > > > ÔÚpythonÖУ¬ÔõôÑù²ÅÄܲ»ÓÃpropertyÀ´ÊµÏÖÖ»¶ÁÊôÐÔÄØ¡£ > > > > > > ÎÒд³ÌÐòµÄʱºò£¬×ÜÓÐһЩֻ¶ÁµÄÊôÐÔ£¬µ«ÎªÁËÒ»¸öÕâÑùµÄÊôÐÔ£¬¾ÍµÃдһ¸öº¯Êý£¬È»ºóÓÃpropertyÉè³ÉÖ»¶ÁµÄ£¬ÊDz»ÊÇÓеãÌ«Âé·³ÁËÄØ£¿¸÷λÓÐʲô¸üºÃµÄ·½°¸Â𣿠> > > > > > -- > > > > > > ££££££££ > > > ÏàÐÅÐÒ¸££¬ > > > ÏàП¶³öµÄŬÁ¦£¡ > > > ££££££££ > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to > > python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe to > > python-chinese-request在lists.python.cn > > > Detail Info: > > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > -- > > It's a long journey to go! > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to > > python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to > > python-chinese-request在lists.python.cn > > Detail Info: > > http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -- It's a long journey to go! -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070115/2bc7c16d/attachment-0001.html
Zeuux © 2025
京ICP备05028076号