Nallo's Profile User Rating: -----

Reputation: 163 Stalwart
Group:
Contributors
Active Posts:
255 (0.13 per day)
Joined:
19-July 09
Profile Views:
8,430
Last Active:
User is offline Jun 08 2014 01:43 PM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
50
Icon   Nallo has not set their status

Posts I've Made

  1. In Topic: Learning Python

    Posted 4 Jun 2014

    when you are writing
    x = Set([1, 3, 5, 7])
    print(x.union(Set([1, 4, 7])))
    
    

    other is Set([1, 4, 7]), so in the union fuction call in line
    for x in other:
    ...
    
    

    python tries to get an iterator over other ...
    ...python: thinking
    ...python: no __iter__ method defined
    ...python: oops, use some fallback
    ...not sure here, but python "does something" with __getitem__

    in other words:
    python needs an iterator to execute
    for x in other:
    
    

    but has some fallback if __iter__ is not provided for the other instance (again I am not sure about that fallback)
  2. In Topic: Help keeping track of attendees

    Posted 28 May 2014

    Edit: removed as was wrong
  3. In Topic: Help keeping track of attendees

    Posted 28 May 2014

    Why dont you just take the display() function from your first post ... you need to write the printdata function though.
  4. In Topic: Help keeping track of attendees

    Posted 28 May 2014

    what woooee said is not correct.

    Try to run woooee's code with this test data:
    test_data = [["John Doe", "ABC Company", "California", "JDoe@ABC.com"],
                 ["John Doe", "CDE Company", "Texas", "JD@CDE.com"]]
    
    


    Two different persons (with the same name). woooee's program will only remember the second when building info_dict. Forgetting John Doe from California :-(

    Your original program does handle that fine. woooee didn't read your program carefully! You buid a new dictionary there for every person, so his argument in his first post is not corect anyway.

    (Edit: actually he made the error he accused you of ^^)
  5. In Topic: Help keeping track of attendees

    Posted 28 May 2014

    you misunderstood, what the statement
    global data
    
    

    does. It doesn't make data a global variable it only changes the lookup rule
    for Python variables. Try the following programms:
    x = 1
    
    def f():
        x = 2
        def g():
            return x
        return g()
    
    print (f())
    
    


    x = 1
    
    def f():
        x = 2
        def g():
            global x
            return x
        return g()
    
    print (f())
    
    


    For your program the quick and dirty way would be:
    def main():
        global data
        #...
    
    data = []
    main() 
    
    


    but it is much cleaner to avoid global variables. Define data in main and pass it to your functions as a parameter:
    def add(data):
        #do something to data as in your program
        #as a side effect, as you did in your program
    
    def main():
        data = []
        #...
        #give data as a parameter to the add function
        add(data)
    
    

My Information

Member Title:
D.I.C Regular
Age:
101 years old
Birthday:
January 1, 1913
Gender:
Programming Languages:
who cares

Contact Information

E-mail:
Private
Website URL:
Website URL  http://