About 343,000 results
Open links in new tab
  1. python - How to make a class JSON serializable - Stack Overflow

    Sep 22, 2010 · It's unfortunate that the answers all seem to answer the question "How do I serialize a class?" rather than the action question "How do I make a class serializable?" These …

  2. how to save/read class wholly in Python - Stack Overflow

    Feb 26, 2010 · som = SOM_CLASS() # includes many big difficult data structures som.hard_work() som.save_to_disk(filename) #then later or another program som = …

  3. Implementing use of 'with object() as f' in custom class in python

    Sep 23, 2010 · I have to open a file-like object in python (it's a serial connection through /dev/) and then close it. This is done several times in several methods of my class. How I WAS doing …

  4. python - Serializing class instance to JSON - Stack Overflow

    That is because your class doesn't have a .__init__() method function, so your class instance has an empty dictionary. In other words, {} is the correct result for your example code.

  5. python - How to decorate a class? - Stack Overflow

    Apart from the question whether class decorators are the right solution to your problem: In Python 2.6 and higher, there are class decorators with the @-syntax, so you can write: @addID class …

  6. Proper way to declare custom exceptions in modern Python?

    Dec 17, 2013 · What's the proper way to declare custom exception classes in modern Python? My primary goal is to follow whatever standard other exception classes have, so that (for instance) …

  7. Pet class python - Stack Overflow

    Sep 25, 2014 · Once this class has been written, write a program that creates an object of the class and prompts the user to enter the name, type, and age of the pet. The data should be …

  8. Python unittesting for a class method - Stack Overflow

    Sep 20, 2015 · A beginner level question.. trying to understand how I can best use the built-in unittest. In the trivial example below, the method consume_food picks a food item and then I …

  9. When should I be using classes in Python? - Stack Overflow

    Oct 12, 2015 · In python the simple heuristic for when you should use a class comes down to whether or not your abstraction needs to be concerned with state. Abstractions that carry …

  10. python - How to make a class property? - Stack Overflow

    In python I can add a method to a class with the @classmethod decorator. Is there a similar decorator to add a property to a class? I can better show what I'm talking about. class …