Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 4 and Visual Studio 2010 > BOOK: Professional IronPython
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 23rd, 2011, 08: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
Reply With Quote
  #2 (permalink)  
Old June 23rd, 2011, 11: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
Reply With Quote
  #3 (permalink)  
Old June 28th, 2011, 10: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 .
Reply With Quote
Reply


Thread Tools
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing the current(system) date to output file RR_X12 XSLT 8 August 4th, 2010 08: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 11:08 AM
database design issue - generic vs performance elysian Oracle 0 March 27th, 2007 05:34 AM
Problem with generic collections demitry Visual Studio 2005 1 November 21st, 2005 05:30 PM



All times are GMT -4. The time now is 12:55 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.