Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional IronPython
This is the forum to discuss the Wrox book Professional IronPython by John Paul Mueller; ISBN: 9780470548592
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional IronPython section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 23rd, 2011, 07:34 AM
MIB MIB is offline
Registered User
 
Join Date: Jun 2003
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default System.Collections.Generic Output Issue

Dear All
I created FirstClass.py as below:
Code:
class Employee:
    FirstName = ''
    LastName = ''
    Age = 0
Then I created another file TestFirstClass.py as below:
Code:
import sys
sys.path.append('C:\\WINDOWS\Microsoft.NET\\Framework\\v4.0.30319')
import clr
import System
import System.Collections.Generic
from FirstClass import Employee
list = System.Collections.Generic.List[type(Employee)]()
g1 = Employee
g1.FirstName = 'A'
g1.LastName = 'B'
g1.Age = 35
list.Add(g1)
g2 = Employee
g2.FirstName = 'C'
g2.LastName = 'D'
g2.Age = 5
list.Add(g2)
for s in list:
    print s.FirstName, s.Age
But the result it shows:
C 5
C 5
It should be
A 35
C 5
Does anyone know what is wrong??
Thank You
 
Old June 23rd, 2011, 10:49 AM
Wrox Author
Points: 62, Level: 1
Points: 62, Level: 1 Points: 62, Level: 1 Points: 62, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default System.Collections.Generic Output Issue

Is this one of the examples from the book? If so, I'm not seeing it. I highly recommend downloading the book's source code from http://www.wrox.com/WileyCDA/WroxTit...-DOWNLOAD.html, rather than attempting to type the code in yourself. Using the downloaded code eliminates the risk of typos and will make your learning experience far easier . Please let me know if this answers your question. I'll be more than happy to help in whatever way I can.

John
 
Old June 28th, 2011, 09:59 AM
Wrox Author
Points: 62, Level: 1
Points: 62, Level: 1 Points: 62, Level: 1 Points: 62, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Generics Example Added

I decided to upload the answer to this question, along with a complete discussion of how it works, to my blog at http://blog.johnmuellerbooks.com/201...h-classes.aspx. Please let me know if you have any questions about it. I'm only too happy to help .




Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing the current(system) date to output file RR_X12 XSLT 8 August 4th, 2010 07:36 AM
Chapter 2, system.collection.generic.list Ziaulhassan BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 2 January 2nd, 2010 03:51 AM
Chap 16 pg 570 System.Collections.Generic has some invalid arguments tomche BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 7 August 6th, 2009 10:08 AM
database design issue - generic vs performance elysian Oracle 0 March 27th, 2007 04:34 AM
Problem with generic collections demitry Visual Studio 2005 1 November 21st, 2005 05:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.