hello!
i have this problem with this code. I mean everything works just fine except i dont know how to change program to return me new value. in my program i had to make 2 functions. preberiKontakte() to get their names & id and izlusciOsebe(vrstica, kontakti) to get set of people on the picture.
and then i have to write down the programm to get dictionary of people that know each other depending on the pictures they were on together.

for example this is what my program does:

{'Ahmed': set(), 'Mustafa': set(), 'Abdulah ibn Husein': set(), 'Abdul': set(), 'Husein': set(), 'Osama': set(), 'Fadil': set(), 'Omar': set(), 'Jibril': set()}
that means that

now i would have to edit my program to get all the pairs of people that ever apeared on the picture together
so instead that i would get what i have above, i should get:

Osama Abdul
Abdul Osama
Osama Abdulah ibn Husein
Abdulah ibn Husein Osama
Osama Ahmed
Osama Mustafa
Ahmed Osama
Ahmed Mustafa
Mustafa Osama
Mustafa Ahmed
Abdulah ibn Husein Husein
Husein Abdulah ibn Husein
Ahmed Mustafa
Ahmed Jibril
and so on..
this shouldnt be too hard but i have already spend too much time on this and i have to move on with studying><
here are also some files if anyone would like to help me><
http://www.mediafire.com/file/8zrwyjdg8fyvad2/podatki-picasa2.zip

def preberiKontakte():
    d = {}
    for l in file("contacts.xml"):
        if not l.startswith(" <contact id="):
            continue
        id = l[14:30]
        ime = l[38:l.find("display")-2]
        d[id] = ime
    return d


def izlusciOsebe(vrstica, kontakti):
    osebe = set()
    for obraz in vrstica.strip().split(";"):
        kje, id = obraz.split(",")
        osebe.add(kontakti[id])
    return osebe


kontakti=preberiKontakte()


znanci={}
f=file(".picasa.ini","r")

for i in f:
    i.strip
    if not i.startswith("faces=rect64"):
        continue
    osebe= izlusciOsebe(i,kontakti)

    for oseba in osebe:

        if oseba not in znanci:
            znanci[oseba]=set()


        znanci[oseba].update(osebe)

for oseba, znani in znanci.items():
    znani.remove(oseba)


print znanci

Honestly, this sounds more like a database Program than a Dictionary.

IIRC Dictionaries are really structured lists that have a Key:Value

What you seem to be asking is for something with a third part to it, "Pictures Appeared In"

This could be done, possibly by restructuring your dictionary so that the "Key" is the Persons (Complete) Name, and the "Value" is a List of Pictures Appeared In.

Then you could access the Dictionary by Name and parse the Value whether a given person is in a given picture.

# Create the Dictionary
Photos={Person-1:[Photo-1, photo-2, photo-5]}
# Add or **Modify** Dictionary Entries
Photos["Person-2"]=[Photo-1, photo-2, photo-9]
Photos["Person-3"]=[Photo-1, photo-3, photo-6]
Photos["Person-4"]=[Photo-1, photo-7, photo-10]

and then i have to write down the programm to get dictionary of people that know each other depending on the pictures they were on together

The index would be the photo, pointing to a list or set of all people in the photo.

now i would have to edit my program to get all the pairs of people that ever apeared on the picture together

If you mean pairs that have been in more than one photo, you would take each photo/key in the dictionary, loop through the items to get one pair at a time, and see if both of the people in the pair are in any other of the dictionary's items.

# pseudo-code
keys_list = dictionary.keys()
for ctr, key in enumerate(keys_list):
    ## assume split into pairs to create tuple, each_pair
    for each_pair in dictionary[key]:
        # search the remainder of the dictionary
        for key_2 in key_list[ctr:]: 
            if pair[0] in dictionary[key_2] and pair[1] in dictionary[key_2]:
                print "found", pair, "in", key, key_2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.