• Sparky01-

    the python dictionary is fine and printing what i want, printing the dict prints
    {'hi': 1, 'hello': 1}
    but when i dump it puts the yaml at the end of the file rather than overriding the file

    posted in Pythonista read more
  • Sparky01-

    yaml.dump() appending to file rather than overwriting
    how do i make set 'hi' to 1 and 'hello' to 1

    import yaml
    
    class myClass():
      def __init__(self):
        self.configFile = open('config.yml', 'r+')
        self.config = yaml.load(self.configFile)
        self.config['hi'] = 1
        self.config['hello'] = 1
        yaml.dump(
          self.config,
          self.configFile,
          default_flow_style=False
        ) 
        print(self.config)
        # returns {'hi': 1, 'hello': 1} 
        
    myClass()
    

    config file before:

    hi: 0
    hello: 0
    

    after:

    hi: 0
    hello: 0
    hi: 1
    hello 1
    

    what i want:

    hi: 1
    hello: 1
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!