python实现得到一个给定类的虚函数

yipeiwu_com5年前Python基础

本文实例讲述了python实现得到一个给定类的虚函数的方法,分享给大家供大家参考。具体如下:

现来看看如下代码:

import wx 

for method in dir(wx.PyPanel):   #这里改成给定的类 
  if method.startswith("base_"): 
    print method 

输出的结果为:

base_AcceptsFocus
base_AcceptsFocusFromKeyboard
base_AddChild
base_DoGetBestSize
base_DoGetClientSize
base_DoGetPosition
base_DoGetSize
base_DoGetVirtualSize
base_DoMoveWindow
base_DoSetClientSize
base_DoSetSize
base_DoSetVirtualSize
base_Enable
base_GetDefaultAttributes
base_GetMaxSize
base_InitDialog
base_OnInternalIdle
base_RemoveChild
base_ShouldInheritColours
base_TransferDataFromWindow
base_TransferDataToWindow
base_Validate 

另附一个常用的str的方法,官方文档如下:
str.startswith(prefix[,start[,end]])

Return True if string starts with theprefix, otherwise returnFalse.prefix can also be a tuple of prefixes to look for. With optionalstart, test string beginning at that position. With optionalend, stop comparing string at that position.

如果string以prefix开头,函数返回True.

希望本文所述对大家的Python程序设计有所帮助。

相关文章

Python实现按学生年龄排序的实际问题详解

前言 本文主要给大家了关于利用Python按学生年龄排序的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍: 问题:定义一个Class:包含姓名name、性别gen...

python3序列化与反序列化用法实例

本文实例讲述了python3序列化与反序列化用法。分享给大家供大家参考。具体如下: #coding=utf-8 import pickle aa={} aa["title"]="我是...

Python标准库之itertools库的使用方法

前言 因为最近事情不是很多,想写一些技术文章分享给大家,同时也对自己一段时间来碎片化接受的知识进行一下梳理,所谓写清楚才能说清楚,说清楚才能想清楚,就是这个道理了。 很多人都致力于把P...

python实现手机销售管理系统

python实现手机销售管理系统

本文实例为大家分享了python实现手机销售管理系统的具体代码,供大家参考,具体内容如下 要求如下: 手机销售系统     手机品牌 ...

python调用新浪微博API项目实践

python调用新浪微博API项目实践

因为最近接触到调用新浪微博开放接口的项目,所以就想试试用python调用微博API。 SDK下载地址:http://open.weibo.com/wiki/SDK 代码不多十几K,完全可...