On Mon, Mar 06, 2017 at 12:35:27PM -0500, leam hall wrote:
> What am I missing?
Let us start by reading the exception that you get, below the class.
That tells us *what* error occurred, but not how or why:
> class mysocket():
> import socket
> def __init__(self, sock=None);
> if sock is
On 03/06/2017 10:35 AM, leam hall wrote:
> What am I missing?
>
>
> class mysocket():
> import socket
> def __init__(self, sock=None);
> if sock is None:
> self.sock = socket.socket(socket.socket.AF_NET,
> socket.socket.SOCK_STREAM)
> else:
> self.sock = sock
>
>
> #
This.
def power(base, exponent):
""" Returns base**exponent. """
if exponent < 0:
base = 1 / base
exponent = abs(exponent)
result = 1
for _ in range(exponent):
result *= base
return result
On Mon, Mar 6, 2017 at 11:53 PM, Alex Kleider wrote:
> On 201
On 06/03/17 19:03, Sri Kavi wrote:
> Wow, this works like a charm!
> def power(base, exponent):
> """ Returns base**exponent. """
> result = 1
> for _ in range(abs(exponent)):
> result *= base
> if exponent < 0:
> return 1 / result
> return result
And just to ad
Wow, this works like a charm!
def power(base, exponent):
""" Returns base**exponent. """
result = 1
for _ in range(abs(exponent)):
result *= base
if exponent < 0:
return 1 / result
return result
On Mon, Mar 6, 2017 at 11:53 PM, Alex Kleider wrote:
> On 2017
On 2017-03-05 23:52, Sri Kavi wrote:
This version deals with both negative and non-negative exponents in a
single loop. I like this.
def power(base, exponent):
""" Returns base**exponent. """
if exponent == 0:
return 1
else:
result = 1
for _ in range(abs(exp
On 06/03/17 17:35, leam hall wrote:
> What am I missing?
I'd start by moving the import out of the class to
its more normal position at the top of the file.
>
> class mysocket():
> import socket
> def __init__(self, sock=None);
> if sock is None:
> self.sock = socket.socket(sock
On 03/05/2017 06:33 PM, Rafael Skovron wrote:
> This project compares two text files with parcel numbers. I think I'm
> messing up the function call. I'm getting this error:
>
> Traceback (most recent call last):
> File "amador.py", line 48, in
> remaining_parcels(auctionlist,removedlist)
>
What am I missing?
class mysocket():
import socket
def __init__(self, sock=None);
if sock is None:
self.sock = socket.socket(socket.socket.AF_NET,
socket.socket.SOCK_STREAM)
else:
self.sock = sock
Error:
NameError: global name "socket" is not defined.
__
ramakrishna reddy wrote:
> Can you please explain the functionality of collections.Callable ? If
> possible with a code snippet.
That's a pretty exotic beast that you stumbled upon.
>>> from collections.abc import Callable
You can use it to check if an object is callable, i. e. works like a
fu
On 06/03/17 01:33, Rafael Skovron wrote:
> This project compares two text files with parcel numbers. I think I'm
> messing up the function call. I'm getting this error:
>
> Traceback (most recent call last):
> File "amador.py", line 48, in
> remaining_parcels(auctionlist,removedlist)
> Name
I realize how complicated I made it!
If exponent is negative, this version takes abs(exponent) and iteratively
divides result by base.
def power(base, exponent):
""" Returns base**exponent. """
if exponent == 0:
return 1
elif exponent < 0:
result = 1
for _ in ra
On 06/03/17 03:07, ramakrishna reddy wrote:
> Can you please explain the functionality of collections.Callable ? If
> possible with a code snippet.
First of all, do you understand the concept of callable in Python?
Any object that can be used like a function is callable.
You might have a mixed co
13 matches
Mail list logo