Recent Forum Posts
From categories:
Help with code.
josdarjosdar 14 Mar 2019 06:55
in discussion Hidden / Per page discussions » E1136

I am somewhat understanding this solution however I am unable to figure out how to apply it to my code that I am having a problem with. Could you help me out with figuring what the solution is?

The part that I need help with has the comment "problem code starts here".

# Simple socket server using threads
import os
import socket
import sys
 
HOST = ''   # Symbolic name, meaning all available interfaces
PORT = 5500  # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print('Socket created')
# problem starts here <.-.>
# Bind socket to local host and port
try:
    s.bind((HOST, PORT))
except socket.error as msg:
    print('Bind failed. Error Code : ' + str(msg[0]) + ' Message ' + msg[1])
    sys.exit()
print('Socket bind complete')
# Start listening on socket
s.listen(10)
print('Socket now listening')
# now keep talking with the client
while 1:
    # wait to accept a connection - blocking call
    conn, addr = s.accept()
    print('Connected with ' + addr[0] + ':' + str(addr[1]))
s.close()
Help with code. by josdarjosdar, 14 Mar 2019 06:55
scjodyscjody 12 Mar 2019 16:35
in discussion Hidden / Per page discussions » W0108

A further example, from factory_boy:

username = factory.Sequence(lambda n: "._-aA{}".format(n))

should be simplified to:

username = factory.Sequence("._-aA{}".format)

by scjodyscjody, 12 Mar 2019 16:35
Douglas GoodallDouglas Goodall 09 Nov 2018 03:49
in discussion Hidden / Per page discussions » R0201

Sometimes I include functions as members in order to encapsulate them with the rest of the class. Is this really a problem?

by Douglas GoodallDouglas Goodall, 09 Nov 2018 03:49

Being new to pylint, I have a lot to learn.

Please can someone with more experience give me some guidance?

I have a line of code which sets a string variable from a call to a class method.
The string is not intended to be modified within the scope of the function.

PRIKEY = p_database.get_key()

I made it upper case because it won't be changed.

C0103 says it doesn't comply with snake_case.

Do I really have to make it PRI_KEY to be snaky enough?

pista329pista329 20 Jun 2018 08:45
in discussion Hidden / Per page discussions » W0221

deleted

by pista329pista329, 20 Jun 2018 08:45
No, it isn't …
mceplmcepl 25 Feb 2018 15:31
in discussion Hidden / Per page discussions » E1003

Exactly this is known to lead to endless loops. See /a/18208725/164233 on stackoverflow.

No, it isn't … by mceplmcepl, 25 Feb 2018 15:31

I have a python program I'd like to be able to run on both python2 and python3. All my print statements use parens, so they are forward and backward compatible. I'd like to turn off C0325, but just for 'print' statements. Is that possible?

A style I have been using lately is to access the

self.__class__

object. This makes my code more portable, not subject to copy-paste errors as this lint code lends itself to. For this reason, I add this message to my list of ignored lint codes.

Example:

class ChildClass(ParentClass):
    def __init__(self, cik):
        super(self.__class__, self).__init__()
Safe to disable? by willcharltonwillcharlton, 30 Oct 2017 15:12
Parentheses
albanacoalbanaco 15 Jan 2017 06:43
in discussion Hidden / Per page discussions » C0325

Note that "parens" is short for "parentheses", the plural of "parenthesis".

Expressions cannot be "surrounded" by a single parenthesis, only by a pair of parentheses.

("Parenthesis" is pronounced "pah - wren - thuh - siss"; "parentheses" is pronounced "pah - wren - thuh - seas".)

Parentheses by albanacoalbanaco, 15 Jan 2017 06:43

It is trying to tell you that there is no point in using a lambda at all.

Instead of writing your code like this:

results = " ".join(rdd.map(lambda x: save_and_show(x)).collect())

You should write it like this:

results = " ".join(rdd.map(save_and_show.collect())

It just assumes that all the values that are in the rdd will be the same as all the values in the function.

Remove the lambda all together by zdubuzdubu, 21 Sep 2016 16:19
Josh EnglishJosh English 19 Sep 2016 16:18
in discussion Hidden / Per page discussions » E1101

The name of this error is no-member, so can be disabled on a single line with # pylint: disable=no-member

by Josh EnglishJosh English, 19 Sep 2016 16:18
Description
Sharaf AliSharaf Ali 25 Aug 2014 18:43
in discussion Hidden / Per page discussions » W0702

Used when an except clause doesn’t specify exceptions type to catch.

Description by Sharaf AliSharaf Ali, 25 Aug 2014 18:43

One thing worth to mention is that function/method arguments are also local variables.
If you get this message for function with say 5 arguments, but count only 12 local variables, then you have forgotten to count the arguments too.

class Farm: 
    def __init__(self): pass

 class Barn(Farm): 
    def __init__(self): 
        Farm.__init__(self)
This is the old syntax by ssbarneassbarnea, 07 Oct 2011 15:26
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License