On 2019-02-27 05:25, AdamC wrote:
That's great - bug found. Thanks. However the next question is, how do
I
create an instance of a class with variable parameters (i.e. with
dateAdded
already computed and stored, or with dateAdded created for the first
time)?
Might this work?
class myClass(ob
On 27/02/2019 13:25, AdamC wrote:
> That's great - bug found. Thanks. However the next question is, how do I
> create an instance of a class with variable parameters (i.e. with dateAdded
> already computed and stored, or with dateAdded created for the first time)?
>
> I hope that makes sense.
Not
Without spending a lot of time on an answer, you can use default arguments in
the cases where only the number of arts differs in your instance creation. If
there's larger differences, look into @classmethod.
On February 27, 2019 5:25:02 AM PST, AdamC wrote:
>That's great - bug found. Thanks. Ho
Without fully understanding what you're getting at, I'll offer this:
class Car(object):
def __init__(self, **kwargs):
self.features = {
'make': 'Hyundai',
'color': 'purple'
That's great - bug found. Thanks. However the next question is, how do I
create an instance of a class with variable parameters (i.e. with dateAdded
already computed and stored, or with dateAdded created for the first time)?
I hope that makes sense.
Adam
On Tue, 26 Feb 2019 at 18:24, Tobiah wro
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
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
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
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":
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
10 matches
Mail list logo