Re: Fwd: Could not load correctly
On 5/21/22 09:14, Robert Loomis wrote: Forwarded Message Subject: Could not load correctly Date: Sat, 21 May 2022 10:58:39 -0400 From: Robert Loomis Reply-To: [email protected] To: [email protected] I am new to python.I tried to download it to a virtual environment since I have been learning on another version. I downloaded version 3.10.4 into my windows10 operating system into directory c:\Users\Bob\PyVer\Py3913 and it said it was successful.I went to C:\Users\Bob\PyProj and made my environment by c:\Users\Bob\PyVer\Py3913\python -m venv my_env.I then activated it by my_env\Scripts\activate and it came back with a prompt.Then I tried to test it by typing python and I got what is below. What did I do wrong? there's nothing below. If you tried to send a screenshot it must have gotten stripped by the mailing list. We generally hate screenshots anyway, because you can't cut and paste code from them. -- https://mail.python.org/mailman/listinfo/python-list
oop issue
i am trying to print this code but it keeps giving me this typeerror,
please help. the csv file format i am trying to change into a list is in a
different module.
class invest_crypto:
crypto_current_rate = 0.05
client_list = []
def __init__(self, name, surname, amount_Deposited, amount_to_transfer):
self.name = name
self.surname = surname
self.amount_Deposited = amount_Deposited
self.amount_to_transfer = amount_to_transfer
invest_crypto.client_list.append(self)
def calculate_customer_transfer(self):
self.customer_transfer = (self.crypto_current_rate * self.
amount_Deposited) + self.amount_Deposited
return self.customer_transfer
@classmethod
def access_client_details(cls):
with open('C:\\Users\\ojomo\\OneDrive\\Desktop\\myexcel\\
oop_learn.py\\myExperiment.py\\clientDetails.csv', 'r' ) as f:
reader = csv.DictReader(f)
clientDetails = list(reader)
for item in clientDetails:
invest_crypto(
name=item.get('name'),
surname=item.get('surname'),
amount_Deposited=item.get('amount_deposited'),
amount_to_transfer=item.get('amount_to_transfer')
)
@staticmethod
def __repr__(self):
return f"('{self.name}', '{self.surname}', '{self.amount_Deposited}',
'{self.amount_to_transfer}')"
invest_crypto.access_client_details()
print(invest_crypto.client_list())
--
https://mail.python.org/mailman/listinfo/python-list
Re: oop issue
On 2022-05-23 20:36, Tola Oj wrote:
i am trying to print this code but it keeps giving me this typeerror,
please help. the csv file format i am trying to change into a list is in a
different module.
class invest_crypto:
crypto_current_rate = 0.05
client_list = []
def __init__(self, name, surname, amount_Deposited, amount_to_transfer):
self.name = name
self.surname = surname
self.amount_Deposited = amount_Deposited
self.amount_to_transfer = amount_to_transfer
invest_crypto.client_list.append(self)
def calculate_customer_transfer(self):
self.customer_transfer = (self.crypto_current_rate * self.
amount_Deposited) + self.amount_Deposited
return self.customer_transfer
@classmethod
def access_client_details(cls):
with open('C:\\Users\\ojomo\\OneDrive\\Desktop\\myexcel\\
oop_learn.py\\myExperiment.py\\clientDetails.csv', 'r' ) as f:
reader = csv.DictReader(f)
clientDetails = list(reader)
for item in clientDetails:
invest_crypto(
name=item.get('name'),
surname=item.get('surname'),
amount_Deposited=item.get('amount_deposited'),
amount_to_transfer=item.get('amount_to_transfer')
)
@staticmethod
def __repr__(self):
return f"('{self.name}', '{self.surname}', '{self.amount_Deposited}',
'{self.amount_to_transfer}')"
invest_crypto.access_client_details()
print(invest_crypto.client_list())
"this typeerror"? What type error? You haven't shown the traceback.
I'm guessing that it's complaining about the last line, where you're
calling 'client_list', which is a list. Don't call something that's not
callable!
The last line should be:
print(invest_crypto.client_list)
(I'm not going to mention the way you're creating instances that append
themselves onto a list that's on the class; that's just weird, IMHO...)
--
https://mail.python.org/mailman/listinfo/python-list
oop issue
i just finished learning oop as a beginner and trying to practice with it
but i ran into this typeerror issue, help please.
Traceback (most recent call last):
File
"c:\Users\ojomo\OneDrive\Desktop\myexcel\oop_learn.py\myExperiment.py\mainMain.py",
line 36, in
print(invest_crypto.client_list)
TypeError: invest_crypto.__repr__() missing 1 required positional argument:
'self'
this is my code below:
import csv
class invest_crypto:
crypto_current_rate = 0.05
client_list = []
def __init__(self, name, surname, amount_Deposited, amount_to_transfer):
self.name = name
self.surname = surname
self.amount_Deposited = amount_Deposited
self.amount_to_transfer = amount_to_transfer
invest_crypto.client_list.append(self)
def calculate_customer_transfer(self):
self.customer_transfer = (self.crypto_current_rate * self.
amount_Deposited) + self.amount_Deposited
return self.customer_transfer
@classmethod
def access_client_details(cls):
with open('C:\\Users\\ojomo\\OneDrive\\Desktop\\myexcel\\
oop_learn.py\\myExperiment.py\\clientDetails.csv', 'r' ) as f:
reader = csv.DictReader(f)
clientDetails = list(reader)
for item in clientDetails:
invest_crypto(
name=item.get('name'),
surname=item.get('surname'),
amount_Deposited=item.get('amount_deposited'),
amount_to_transfer=item.get('amount_to_transfer')
)
@staticmethod
def __repr__(self):
return f"('{self.name}', '{self.surname}', '{self.amount_Deposited}',
'{self.amount_to_transfer}')"
invest_crypto.access_client_details()
print(invest_crypto.client_list)
--
https://mail.python.org/mailman/listinfo/python-list
Re: Convert the decimal numbers expressed in a `numpy.ndarray` into a matrix representing elements in fractional form
> hongy... wrote > > This method doesn't work, as shown below: > ? b > > [0.0, -1.0, 0.0, 0.25] > [1.0, 0.0, 0.0, 0.25] > [0.0, 0.0, 1.0, 0.25] > [0.0, 0.0, 0.0, 1.0] > > a > > 0 0 0 1 > # --- Using debian 11.3 bullseye python 3.9 numpy 1,21,5 Code as I posted in my reply dated 2022-05-18 $ python3 np_array_to_fractions_2.py b [0.0, -1.0, 0.0, 0.25] [1.0, 0.0, 0.0, 0.25] [0.0, 0.0, 1.0, 0.25] [0.0, 0.0, 0.0, 1.0] a 0 -1 0 1/4 1 0 0 1/4 0 0 1 1/4 0 0 0 1 -- Stanley C. Kitching Human Being Phoenix, Arizona -- https://mail.python.org/mailman/listinfo/python-list
Re: oop issue
On 23/05/2022 22:54, Tola Oj wrote:
i just finished learning oop as a beginner and trying to practice with it
but i ran into this typeerror issue, help please.
Traceback (most recent call last):
File
"c:\Users\ojomo\OneDrive\Desktop\myexcel\oop_learn.py\myExperiment.py\mainMain.py",
line 36, in
print(invest_crypto.client_list)
TypeError: invest_crypto.__repr__() missing 1 required positional argument:
'self'
@staticmethod
def __repr__(self):
return f"('{self.name}', '{self.surname}', '{self.amount_Deposited}',
'{self.amount_to_transfer}')"
What are you trying to achieve with the staticmethod decorator?
--
https://mail.python.org/mailman/listinfo/python-list
Re: oop issue
invest_crypto.client_list.append(self)
I am wondering about the phrasing above.
When you are in the dunder init function, you normally create and change items
in YOURSELF so why is your code not changing self.crypto_client_list?
And what are you appending to before ever creating it? Would it kill you to
create some form of container in the main class definition initialized
appropriately to some variation of empty?
I won't claim to fully understand what the code wants to do. Adding yourself to
the list of clients may make sense to you but if you understand object oriented
programming, you may have an inkling that objects need to be CREATED somewhere
before they can be used. Most of your code looks like it is DEFINING an object.
The last few lines try to access a method in an object that has never been
instantiated. Yes, you do have a way to store methods in a class and call them
without any objects but this is not a case like that.
You need something like "myobj = invest_crypto(args)" and then the rest of your
code can do changes and calculations and perhaps create other similar or
different objects. You seem to be using a method that reads in a file and dumps
a version of the contents and that might work if you did a line like this next:
"myobj.access_client_details()" albeit not how I would name it or do it.
And, of course, your print() again names the class, not an instance of a class.
Your code wraps in a few places and I wonder if it contains errors as in this
set of lines:
return f"('{self.name}', '{self.surname}', '{self.amount_Deposited}',
'{self.amount_to_transfer}')"
Is that really how you think you set up a formatted string?
Even if you get that working, how does the print statement know what to do with
a list of objects?
Some might design a method you can call to print the contents of a list which
would loop over the list. But is there ever more than one client (yourself) in
the list?
The above rambling is just reflecting my opinion that you have not learned
enough or thought it through and may even be copying and modifying various
snippets of code perhaps from places where it works to a place that might be
better designed from scratch.
Have fun. As someone else mentioned, smaller more focused examples may work
better to get you up to speed, but then again, we often find out someone is
given a homework assignment ...
-Original Message-
From: Tola Oj
To: [email protected]
Sent: Mon, May 23, 2022 4:54 pm
Subject: oop issue
i just finished learning oop as a beginner and trying to practice with it
but i ran into this typeerror issue, help please.
Traceback (most recent call last):
File
"c:\Users\ojomo\OneDrive\Desktop\myexcel\oop_learn.py\myExperiment.py\mainMain.py",
line 36, in
print(invest_crypto.client_list)
TypeError: invest_crypto.__repr__() missing 1 required positional argument:
'self'
this is my code below:
import csv
class invest_crypto:
crypto_current_rate = 0.05
client_list = []
def __init__(self, name, surname, amount_Deposited, amount_to_transfer):
self.name = name
self.surname = surname
self.amount_Deposited = amount_Deposited
self.amount_to_transfer = amount_to_transfer
invest_crypto.client_list.append(self)
def calculate_customer_transfer(self):
self.customer_transfer = (self.crypto_current_rate * self.
amount_Deposited) + self.amount_Deposited
return self.customer_transfer
@classmethod
def access_client_details(cls):
with open('C:\\Users\\ojomo\\OneDrive\\Desktop\\myexcel\\
oop_learn.py\\myExperiment.py\\clientDetails.csv', 'r' ) as f:
reader = csv.DictReader(f)
clientDetails = list(reader)
for item in clientDetails:
invest_crypto(
name=item.get('name'),
surname=item.get('surname'),
amount_Deposited=item.get('amount_deposited'),
amount_to_transfer=item.get('amount_to_transfer')
)
@staticmethod
def __repr__(self):
return f"('{self.name}', '{self.surname}', '{self.amount_Deposited}',
'{self.amount_to_transfer}')"
invest_crypto.access_client_details()
print(invest_crypto.client_list)
--
https://mail.python.org/mailman/listinfo/python-list
--
https://mail.python.org/mailman/listinfo/python-list
