grimofdoom's Profile User Rating: -----

Reputation: 1 Apprentice
Group:
Members
Active Posts:
17 (0.02 per day)
Joined:
14-August 12
Profile Views:
465
Last Active:
User is offline Yesterday, 08:00 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   grimofdoom has not set their status

Posts I've Made

  1. In Topic: Help with append list -> dict

    Posted 14 Jul 2014

    As I read it, it sounds almost exactly what i am currently trying to do-but more technical and strange. What i have now up there works if I take the function 'info' out of the class(and remove 'self'),but as it is now,does not work. I am trying to make it as easy as possible and doing 'pokemon.info(id#,wanted_element)' would be easier to understand than using just info outside of the class. But as I said, i get an error:
    Traceback (most recent call last):
      File "C:\Users\Admin\Desktop\Pokemon Mengakana\pokemon.py", line 399, in <module>
        Pokemon.info(1,0)
    TypeError: unbound method info() must be called with Pokemon instance as first argument (got int instance instead)
    
    

    I have the function inside the class and include the 'self' when needed.
  2. In Topic: Help with append list -> dict

    Posted 14 Jul 2014

    I feel kinda stupid now of not thinking i could add tuple to new list and search through that new list. I want to add a function to my class to speed up and make things easier when finding a specific spot. When i create the function outside of the class, it works. But if i insert it into the class(+ adding self to top) and change the calling of it to include the class name, it spits out an error saying Pokemon must be called before info (got int instead)
    import operator
    class Pokemon(object):
        def __init__(self,name):
            self.name=name
            self.pokemon=pokemon
        find=[
            ('???',0,0,0,0,0,0,0,'???','???','???'),
            ('Bulbasaur',45,49,49,65,65,45,1,'grass','poison','medslow'),
            ('Ivysaur',60,62,63,80,80,60,2,'grass','poison','medslow'),
            ('Venasaur',56,80,83,100,100,80,3,'grass','poison','medslow'),
            ('Charmander',39,52,43,60,50,65,4,'fire',0,'medslow'),
            ('Charmeleon',58,64,58,80,65,80,5,'fire',0,'medslow'),
            ('Charizard',78,84,78,109,85,100,6,'fire','flying','medslow'),
           
            ]
        def info(self,pokemon,place):
            found=Pokemon.find[pokemon]
            print 'name:',found[0]
            print 'Chosen Spot:',found[place]
    Pokemon.info(1,0)
    
    

    (i honestly feel stupid about the previous post and how wasteful of space it is. Though,searching the web has found no results that have worked. All the ones I come to say i should do something like 'info=pokemon.info()' or of the sort. Did not work doing that either. I would be really appreciate if I could get this last piece of the puzzle found and placed, with this i should be able to do everything else i planned)
  3. In Topic: Help with append list -> dict

    Posted 14 Jul 2014

    I think it is not exactly what you meant,but i do think i kinda figured out what you mean:
    class Pokemon(object):
        find=[
            ('???',0,0,0,0,0,0,0,'???','???','???'),
            ('Bulbasaur',45,49,49,65,65,45,1,'grass','poison','medslow'),
            ('Ivysaur',60,62,63,80,80,60,2,'grass','poison','medslow'),
            ('Venasaur',56,80,83,100,100,80,3,'grass','poison','medslow'),
            ('Charmander',39,52,43,60,50,65,4,'fire',0,'medslow'),
            ('Charmeleon',58,64,58,80,65,80,5,'fire',0,'medslow'),
            ]
        def __init__(self,name):
            self.name=name
    print Pokemon.find[5]
    
    

    I can grab the entire row, but now i am back to,kinda of, what was earlyier asked. From this point i can find the '[5]',but now how can i grab an element from it. I using 'print Pokemon.find[5[0]]',which then says:
    TypeError: 'int' object has no attribute '__getitem__'
    
    

    I tried switching my list to a dict, but still came with the same error. i have tried looking around and do not understand,yet, how it can be done.
  4. In Topic: Help with append list -> dict

    Posted 14 Jul 2014

    So I am trying to understand what your saying. I went around (using google) looking at static class attributes, and came up to find only static variables mentioned so I'm am guessing it's the same thing.http://broken.build/...hods-in-python/, and going off what you said, I should put those variables (john=123,doe=456) into a dict with a function so it ends up as get{john:123,doe:456}
    As I read it, and the other articles I've been finding, a lot of it is confusing.(btw,probably a little late,by my pokemon has more than just an id and name, inside it also contains stuff like its base stats(used to determine actual stats based on leveling mixed with other vars),it's rate of experience gain and the element types(2 spots taken by this))
  5. In Topic: Help with append list -> dict

    Posted 14 Jul 2014

    As it is still relatated to here, i have come to a problem. The website i have been using for learning the oo programming with python does not tell me how to find an instance by its attribute. And googling it has come to no usable answer even similar. I have built a lot of instances using a def in my main class, now i want to locate a single instance by an attribute. (i know your saying that, what if other have the same attribute, yes there are some attributes that share,but i have 2 attributes that are different. One containing name(pokemon) and other using it's ID) using this as an example:
    class Who(object):
        def __init__(self,name,id):
            self.name=name
            self.id=id
        def show_person(self,name,id)
            print 'name:',self.name,' ID:',self.id
    
    person1=Who('John',123)
    person2=Who('Doe',456)
    
    person1.show_person()
    
    

    (imagine that there was 100 others than just person1 and person2)
    from that example, how can i retrieve person1, by looking for the id 123?
    (i have been using http://www.tutorials...ses_objects.htm as a learning point for oo)

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

grimofdoom hasn't added any friends yet.

Comments

grimofdoom has no profile comments yet. Why not say hello?