Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Python

Python Discussion forum for Python, a high-level language with simple syntax, but yet powerful.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-23-2008, 04:25 AM
SolidState SolidState is offline
Newbie
 
Join Date: Aug 2008
Posts: 4
Rep Power: 0
SolidState is on a distinguished road
Send a message via AIM to SolidState
Default I love dictionaries!

I am by no means an expert in programming, but I thought that I would share with the forum my recent love for the dictionary data-type in Python. This seems to be a versatile data-type and recently I found a use for it in a game project I'm working on.

I used it to store a room object's, exit objects by a string name.
This allows me to take raw_input from the user to utilize said exit object

Here is my move() function to give a visual to what I'm talking about.

Code:
def move(char, rooms, exit):
    #Here we move our character through one of his room's exits
	for i in rooms:
		if i.loc == char.loc:
                    #lock testing
			if i.exits[exit].locked == "yes":
				if i.exits[exit].openwith in char.inventory:
					char.loc = i.exits[exit].link
				elif i.exits[exit].conditions in char.conditions:
					char.loc = i.exits[exit].link
			else:
                            #if not locked
				char.loc = i.exits[exit].link
			break
I know it's not much but I wanted to share. Anyone else have a love for dictionaries, or another data-type?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 08-23-2008, 12:38 PM
amrosama's Avatar   
amrosama amrosama is offline
Guru
 
Join Date: Aug 2007
Location: egypt
Age: 20
Posts: 2,105
Last Blog:
OO Life
Rep Power: 22
amrosama is a jewel in the roughamrosama is a jewel in the roughamrosama is a jewel in the roughamrosama is a jewel in the rough
Send a message via MSN to amrosama
Default Re: I love dictionaries!

i didnt use python at all,
ut ur code seems interesting good work
__________________
A good programmer is someone who always looks both ways before crossing a one-way street
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-23-2008, 01:40 PM
MeTh0Dz|Reb0rn's Avatar   
MeTh0Dz|Reb0rn MeTh0Dz|Reb0rn is offline
My Posts Are Moderated
 
Join Date: Jul 2008
Posts: 77
Rep Power: 0
MeTh0Dz|Reb0rn is an unknown quantity at this point
Default Re: I love dictionaries!

Yeah, linked lists.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-23-2008, 01:53 PM
Xav's Avatar   
Xav Xav is offline
Code Warrior
 
Join Date: Mar 2008
Location: On God's Planet
Posts: 9,852
Last Blog:
Web slideshow in JavaS...
Rep Power: 78
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: I love dictionaries!

I particularly have feelings for the boolean data type. There's something about it, dunno what. The fact you can only store two things in it, probably. Plus, the name is funny - I've never known how to pronounce it lol.
__________________


Mr. Xav | Website | Forums | Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 10-30-2008, 09:38 AM
manux manux is offline
Newbie
 
Join Date: Oct 2008
Posts: 26
Rep Power: 1
manux is on a distinguished road
Default Re: I love dictionaries!

Hah, funny hash tables...

Yes dictionnairies in python are extremely useful .
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sign Of Love Jaan The Lounge 36 08-19-2008 01:55 PM
I know you love it F0551L Introductions 31 07-24-2008 09:19 AM
l realy love programming but i dont know how to study for it kia C and C++ 10 01-17-2008 04:46 PM
Why I love and hate Firefox? TcM Computer Software/OS 25 08-28-2007 05:46 AM


All times are GMT -5. The time now is 04:03 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads