ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-Tutor
python-Tutor
[Tutor] Help with the technique "Menu Processing"
by other posts by this author
Apr 29 2001 2:30AM messages near this date
[Tutor] popen | RE: [Tutor] Help with the technique "Menu Processing"
Hi Everyone,
I was wondering if I might be able to get some help with "Menu Processing".
What I'm looking for is an example of how it might be done within an object.
I've been trying myself, but I keep getting an error.

Here's an example of what I'm trying to do:

Class msg:
	def __init__(self):
		self.msgtype = {"priv":send_priv_msg,
				"pub":send_pub_msg,
				"action":send_action_msg,
				"notice":send_notice_msg,
				"ctcp":send_ctcp_msg}
		...more stuff...

	def send_priv_msg(connection, nick, text):
		... send code ..
	def send_pub_msg(connection, nick, text):
		... send code ..
	def send_action_msg(connection, nick, text):
		... send code ..
	def send_notice_msg(connection, nick, text):
		... send code ..
	def send_ctcp_msg(connection, nick, text):
		... send code ..

	def send_msg_by(connection, nick, text, type):
		self.msgtype[type](connection, nick, text)


Thanks,

Juno



_______________________________________________
Tutor maillist  -  Tutor@[...].org
http://mail.python.org/mailman/listinfo/tutor
Thread:

Andrew Wilkins

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved