Re: [Tutor] Doubt

2019-02-26 Thread Mats Wichmann
On 2/26/19 11:36 AM, Maninath sahoo wrote: is it possible reverse inheritance? mean child class to parent class Well, it's Python, so you can do all sorts of things, some of them good ideas, some bad... Like Alan says, the question as asked doesn't really make a lot of sense to us, but the

Re: [Tutor] I flip a coin 1 million times what is the consecutive times it will come up head and come up tails

2019-02-26 Thread Alan Gauld via Tutor
On 26/02/2019 20:34, shaef...@q.com wrote: > I am learning python. I assume you are coming from some other language? If not you have managed to come up with the most convoluted and un-pythonic way imaginable to do a fairly simple task! > I wanted to test my ability by making a program to > keep

Re: [Tutor] Doubt

2019-02-26 Thread Alan Gauld via Tutor
On 26/02/2019 18:36, Maninath sahoo wrote: > is it possible reverse inheritance? > mean child class to parent class I have no idea what you mean by that. How would it work? Can you give an example of the kind of thing you want to do? For example Circles and Rectangles are kinds of Shape so their

[Tutor] I flip a coin 1 million times what is the consecutive times it will come up head and come up tails

2019-02-26 Thread shaeffer
I am learning python. I wanted to test my ability by making a program to keep track of the flip of a coin to find how many consecutive times it came up heads and tails. Just want some criticism on what I have done. import random Hn = {} Tn = {} for i in range (0,31): va

[Tutor] Doubt

2019-02-26 Thread Maninath sahoo
is it possible reverse inheritance? mean child class to parent class ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Only appending one object to list, when I am expecting more than 1

2019-02-26 Thread Tobiah
On 2/26/19 6:39 AM, AdamC wrote: Sorry folks - my code didn't work due to my debug var count to ensure that I was looping properly. It should be: As was pointed out, the problem is not in your code. It's in your data. You only have one record with a proper 'tpe' value, so that's all you g

Re: [Tutor] Only appending one object to list, when I am expecting more than 1

2019-02-26 Thread AdamC
Sorry folks - my code didn't work due to my debug var count to ensure that I was looping properly. It should be: media = [] def loadFile(): filename = input('Filename? ') f = open(filename, 'r') createObjects(f) def createObjects(f): '''Takes a file object and iterates through en

Re: [Tutor] Only appending one object to list, when I am expecting more than 1

2019-02-26 Thread Cameron Simpson
Thank you for a well formed problem description. However, as Steven has remarked the code you've included doesn't run. Can you follow up/reply with your actual working script, and also include some of the output you get. That said, I've a few small remarks about the code you have posted: On

Re: [Tutor] Only appending one object to list, when I am expecting more than 1

2019-02-26 Thread Peter Otten
AdamC wrote: > I'm creating lots of objects from json in a file. Part of reading the json > back means that it iterates over the file and loads a json object and then > creates the object from the dictionary. > > This is my file: > > {"name": "Dwarf Fortress", "platform": "steam", "dateAdded":

Re: [Tutor] Only appending one object to list, when I am expecting more than 1

2019-02-26 Thread Steven D'Aprano
On Tue, Feb 26, 2019 at 09:09:56AM +, AdamC wrote: > def createObjects(f): > '''Takes a file object and iterates through entries, passing them to > create > object, depending on what object it is.''' > for line in f: > count = count + 1 This cannot be the code you are actu

[Tutor] Only appending one object to list, when I am expecting more than 1

2019-02-26 Thread AdamC
I'm creating lots of objects from json in a file. Part of reading the json back means that it iterates over the file and loads a json object and then creates the object from the dictionary. This is my file: {"name": "Dwarf Fortress", "platform": "steam", "dateAdded": "2019:02:25:16:56:1551113768