pygame - importing GL - very bad...

Discussion in 'Python' started by someone, Jan 1, 2013.

  1. someone

    someone Guest

    See this code (understand why I commented out first line):

    # from OpenGL.GL import *
    from OpenGL.GL import glEnable, GL_DEPTH_TEST, \
    glShadeModel, GL_SMOOTH, glClearColor, \
    GL_CULL_FACE, GL_BLEND, glBlendFunc, \
    GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, \
    glClear, GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, \
    glLoadIdentity, glTranslate, glRotate, \
    glMultMatrixf, glPushMatrix, glCallList, \
    glPopMatrix, glDisable, GL_LIGHTING

    The reason why I commented out the first line is that I use "pylint" and
    it reports: "[W] Redefining built-in 'format'" for this line.

    From: http://www.logilab.org/card/pylintfeatures tell:
    W0621: Redefining name %r from outer scope (line %s) Used when a
    variable's name hide a name defined in the outer scope.

    I don't like to redefine already defined names so therefore I had to
    outcomment first line and then keep on adding stuff until I could run my
    program... But this SUCKS! I can see that pygame hasn't been updated for
    a long while - not many users use it? I'm not very happy about this...

    Any good / clever solution to this problem, so I avoid this nasty crappy
    work-around?

    Any ideas / suggestions ?
    Thanks.
    someone, Jan 1, 2013
    #1
    1. Advertising

  2. On Tue, Jan 1, 2013 at 10:00 PM, someone <> wrote:
    > See this code (understand why I commented out first line):
    >
    > # from OpenGL.GL import *
    > from OpenGL.GL import glEnable, GL_DEPTH_TEST, \
    > glShadeModel, GL_SMOOTH, glClearColor, \
    > GL_CULL_FACE, GL_BLEND, glBlendFunc, \
    > GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, \
    > glClear, GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, \
    > glLoadIdentity, glTranslate, glRotate, \
    > glMultMatrixf, glPushMatrix, glCallList, \
    > glPopMatrix, glDisable, GL_LIGHTING
    >
    > Any good / clever solution to this problem, so I avoid this nasty crappy
    > work-around?


    You could simply

    import OpenGL.GL as GL

    and then use all those names as GL.glPopMatrix, GL.GL_LIGHTING, etc. I
    don't know if that's better or worse.

    ChrisA
    Chris Angelico, Jan 1, 2013
    #2
    1. Advertising

  3. On Tue, 01 Jan 2013 12:00:32 +0100, someone wrote:

    > See this code (understand why I commented out first line):
    >
    > # from OpenGL.GL import *

    [...]
    > The reason why I commented out the first line is that I use "pylint" and
    > it reports: "[W] Redefining built-in 'format'" for this line.
    >
    > From: http://www.logilab.org/card/pylintfeatures tell: W0621: Redefining
    > name %r from outer scope (line %s) Used when a variable's name hide a
    > name defined in the outer scope.
    >
    > I don't like to redefine already defined names so therefore I had to
    > outcomment first line and then keep on adding stuff until I could run my
    > program... But this SUCKS! I can see that pygame hasn't been updated for
    > a long while - not many users use it? I'm not very happy about this...


    from pygame import *
    del format


    pylint may still complain, but you can ignore it. By deleting the name
    "format", that will unshadow the builtin format.


    --
    Steven
    Steven D'Aprano, Jan 1, 2013
    #3
  4. someone

    Peter Otten Guest

    someone wrote:

    > See this code (understand why I commented out first line):
    >
    > # from OpenGL.GL import *
    > from OpenGL.GL import glEnable, GL_DEPTH_TEST, \
    > glShadeModel, GL_SMOOTH, glClearColor, \
    > GL_CULL_FACE, GL_BLEND, glBlendFunc, \
    > GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, \
    > glClear, GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, \
    > glLoadIdentity, glTranslate, glRotate, \
    > glMultMatrixf, glPushMatrix, glCallList, \
    > glPopMatrix, glDisable, GL_LIGHTING
    >
    > The reason why I commented out the first line is that I use "pylint" and
    > it reports: "[W] Redefining built-in 'format'" for this line.
    >
    > From: http://www.logilab.org/card/pylintfeatures tell:
    > W0621: Redefining name %r from outer scope (line %s) Used when a
    > variable's name hide a name defined in the outer scope.
    >
    > I don't like to redefine already defined names so therefore I had to
    > outcomment first line and then keep on adding stuff until I could run my
    > program... But this SUCKS! I can see that pygame hasn't been updated for
    > a long while - not many users use it? I'm not very happy about this...
    >
    > Any good / clever solution to this problem, so I avoid this nasty crappy
    > work-around?
    >
    > Any ideas / suggestions ?
    > Thanks.


    It turns out pylint is lying. The situation is equivalent to

    $ cat module.py
    for format in [42]:
    pass
    del format

    $ cat main.py
    original_format = format
    from module import *
    assert format is original_format
    $ python main.py

    The assert doesn't trigger, so format is not redefined. But pylint complains
    anyway:

    $ pylint main.py -rn
    No config file found, using default configuration
    ************* Module main
    W: 2: Redefining built-in 'format'
    C: 1: Missing docstring
    C: 1: Invalid name "original_format" (should match (([A-Z_][A-Z0-9_]*)|
    (__.*__))$)
    W: 2: Wildcard import module

    If you can ignore the warning about the wildcard import you should be able
    to ignore the "redefining built-in" warning, too. Personally I would avoid
    putting magic comments like

    from module import * # pylint: disable=W0622

    $ pylint main.py -rn
    No config file found, using default configuration
    ************* Module main
    I: 2: Locally disabling W0622
    C: 1: Missing docstring
    C: 1: Invalid name "original_format" (should match (([A-Z_][A-Z0-9_]*)|
    (__.*__))$)
    W: 2: Wildcard import module

    into the code.
    Peter Otten, Jan 1, 2013
    #4
  5. someone

    alex23 Guest

    alex23, Jan 1, 2013
    #5
  6. someone

    someone Guest

    On 01/01/2013 12:13 PM, Chris Angelico wrote:
    > On Tue, Jan 1, 2013 at 10:00 PM, someone <> wrote:
    >> See this code (understand why I commented out first line):
    >>
    >> # from OpenGL.GL import *
    >> from OpenGL.GL import glEnable, GL_DEPTH_TEST, \
    >> glShadeModel, GL_SMOOTH, glClearColor, \
    >> GL_CULL_FACE, GL_BLEND, glBlendFunc, \
    >> GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, \
    >> glClear, GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, \
    >> glLoadIdentity, glTranslate, glRotate, \
    >> glMultMatrixf, glPushMatrix, glCallList, \
    >> glPopMatrix, glDisable, GL_LIGHTING
    >>
    >> Any good / clever solution to this problem, so I avoid this nasty crappy
    >> work-around?

    >
    > You could simply
    >
    > import OpenGL.GL as GL
    >
    > and then use all those names as GL.glPopMatrix, GL.GL_LIGHTING, etc. I
    > don't know if that's better or worse.


    You're right - but I forgot to write that even though this maybe
    should/is recommended many places then I've seen a lot of opengl code on
    the internet and IMHO NOBODY does that and it'll be a lot slower to type
    that in front of all the opengl commands...

    So this solution is not something I like too... But I can see some other
    people came up with good solutions, which I didn't knew about..

    Thank you.
    someone, Jan 1, 2013
    #6
  7. someone

    someone Guest

    On 01/01/2013 12:49 PM, Steven D'Aprano wrote:
    > On Tue, 01 Jan 2013 12:00:32 +0100, someone wrote:
    >
    >> See this code (understand why I commented out first line):
    >>
    >> # from OpenGL.GL import *

    > [...]
    >> The reason why I commented out the first line is that I use "pylint" and
    >> it reports: "[W] Redefining built-in 'format'" for this line.
    >>
    >> From: http://www.logilab.org/card/pylintfeatures tell: W0621: Redefining
    >> name %r from outer scope (line %s) Used when a variable's name hide a
    >> name defined in the outer scope.
    >>
    >> I don't like to redefine already defined names so therefore I had to
    >> outcomment first line and then keep on adding stuff until I could run my
    >> program... But this SUCKS! I can see that pygame hasn't been updated for
    >> a long while - not many users use it? I'm not very happy about this...

    >
    > from pygame import *
    > del format


    Are you sure about this? Because I'm not (OTOH I'm maybe not as
    experienced in python as some of you)... Ipython log:

    --------
    In [6]: test=format(43)

    In [7]: type(test)
    Out[7]: str

    In [8]: from pygame import *

    In [9]: test=format(43)

    In [10]: type(test)
    Out[10]: str

    In [11]: del format
    ---------------------------------------------------------------------------
    NameError Traceback (most recent call last)
    <ipython-input-11-028e6ffb84a8> in <module>()
    ----> 1 del format

    NameError: name 'format' is not defined
    --------

    What does this mean? Why does it say 'format" cannot be deleted after I
    did the wildcard import ?

    > pylint may still complain, but you can ignore it. By deleting the name
    > "format", that will unshadow the builtin format.


    Are you sure?
    someone, Jan 1, 2013
    #7
  8. someone

    someone Guest

    On 01/01/2013 01:56 PM, Peter Otten wrote:
    > someone wrote:


    > It turns out pylint is lying. The situation is equivalent to
    >
    > $ cat module.py
    > for format in [42]:
    > pass
    > del format
    >
    > $ cat main.py
    > original_format = format
    > from module import *
    > assert format is original_format
    > $ python main.py
    >
    > The assert doesn't trigger, so format is not redefined. But pylint

    complains
    > anyway:
    >
    > $ pylint main.py -rn
    > No config file found, using default configuration
    > ************* Module main
    > W: 2: Redefining built-in 'format'
    > C: 1: Missing docstring
    > C: 1: Invalid name "original_format" (should match (([A-Z_][A-Z0-9_]*)|
    > (__.*__))$)
    > W: 2: Wildcard import module
    >
    > If you can ignore the warning about the wildcard import you should be

    able

    In the case of opengl import, I'll ignore the wildcard import warning.
    But in other cases I'll likely look a bit into it and see if I can avoid
    it or at least change it to something like: "import OpenGL.GL as GL" etc.

    > to ignore the "redefining built-in" warning, too. Personally I would

    avoid
    > putting magic comments like
    >
    > from module import * # pylint: disable=W0622


    Oh, I just learned something new now... How come I cannot type "#pylint:
    enable=W0622" in the line just below the import ?

    Not so intuitively/logically for me...

    > $ pylint main.py -rn
    > No config file found, using default configuration
    > ************* Module main
    > I: 2: Locally disabling W0622
    > C: 1: Missing docstring
    > C: 1: Invalid name "original_format" (should match (([A-Z_][A-Z0-9_]*)|
    > (__.*__))$)
    > W: 2: Wildcard import module
    >
    > into the code.


    Thank you very much...

    Another thing is that I don't understand this warning:

    Invalid name "original_format" (should match (([A-Z_][A-Z0-9_]*)|
    > (__.*__))$)


    I get it everywhere... I don't understand how it wants me to label my
    variables... Maybe I should disable this warning to get rid of it...
    someone, Jan 1, 2013
    #8
  9. someone

    someone Guest

    On 01/01/2013 11:39 PM, alex23 wrote:
    > On Jan 1, 9:00 pm, someone <> wrote:
    >> I can see that pygame hasn't been updated for
    >> a long while - not many users use it?

    >
    > It helps if you look in the right place:
    >
    > pygame "Last Updated 2012-12-29": https://bitbucket.org/pygame/pygame/src
    > pygame2: http://code.google.com/p/pgreloaded/


    Maybe... But if you look for stable releases here:

    http://www.pygame.org/download.shtml

    You'll find the top option: 1.9.1 Packages (August 6th 2009)


    And then previous releases is just below 1.9.1:

    pygame-1.9.0release.tar.gz ~ 1.4M - August 1, 2009
    pygame-1.8.1release.tar.gz ~ 1.4M - July 30, 2008
    pygame-1.8.0release.tar.gz ~ 1.4M - March 29, 2008
    pygame-1.7.1release.tar.gz ~ 1.3M - August 16, 2005
    1.7.0 ~ no source release was made.
    pygame-1.6.2.tar.bz2 ~ 1140 kb -
    pygame-1.6.tar.gz ~ 832 kb - October 23, 2003
    pygame-1.5.tar.gz ~ 736 kb - May 30, 2002
    pygame-1.4.tar.gz ~ 808 kb - Jan 30, 2002
    pygame-1.3.tar.gz ~ 731 kb - Dec 19, 2001
    pygame-1.2.tar.gz ~ 708 kb - Sep 4, 2001
    pygame-1.1.tar.gz ~ 644 kb - Jun 23, 2001
    pygame-1.0.tar.gz ~ 564 kb - Apr 5, 2001
    pygame-0.9.tar.gz ~ 452 kb - Feb 13, 2001
    pygame-0.5.tar.gz ~ 436 kb - Jan 6 14, 2001
    pygame-0.4.tar.gz ~ 420 kb - Dec 14, 2000
    pygame-0.3b.tar.gz ~ 367 kb - Nov 20, 2000
    pygame-0.2b.tar.gz ~ 408 kb - Nov 3, 2000
    pygame-0.1a.tar.gz ~ 300 kb - Oct 28, 2000


    Back to year 2000...

    Maybe they should get a grip on themselves and distribute a new stable
    releases in year 2013 - then it would at least SEEM to look as the
    project is not dead. But in any case, I'm happy with it - haven't
    experienced any big issues with pygame yet, so don't take this as I
    don't value what they do. Maybe they've made a great version back in
    2009 and it's so good that there wasn't any need for a newer stable
    version before 2013.

    But it gives the impression that nothing happens, when so many years
    pass on...

    Anyway, thanks a lot to all...

    (And sorry I accidentally replied privately to some of you - in
    thunderbird I should hit the "followup"-button but maybe they've removed
    it and instead I keep on hitting "reply" - very confusing that the first
    button in thunderbird is reply instead of followup, which is what I
    always prefer to use (so other people can see the answers).

    Thanks you for pointing out that (at least) something did happen on
    2012-12-29, when it looks a bit dead on the official homepage.
    someone, Jan 1, 2013
    #9
  10. someone

    Nobody Guest

    On Wed, 02 Jan 2013 00:49:36 +0100, someone wrote:

    > In [11]: del format
    > ---------------------------------------------------------------------------
    > NameError Traceback (most recent call last)
    > <ipython-input-11-028e6ffb84a8> in <module>()
    > ----> 1 del format
    >
    > NameError: name 'format' is not defined
    > --------
    >
    > What does this mean? Why does it say 'format" cannot be deleted after I
    > did the wildcard import ?


    You can't delete built-in names.

    It has nothing to do with the wildcard import. The PyOpenGL modules delete
    "format" from the module's variables as soon as they are finished with
    it, so the set of names created by the wildcard import doesn't include
    "format".
    Nobody, Jan 2, 2013
    #10
  11. someone

    someone Guest

    On 01/02/2013 04:01 AM, Nobody wrote:
    > On Wed, 02 Jan 2013 00:49:36 +0100, someone wrote:
    >
    >> In [11]: del format
    >> ---------------------------------------------------------------------------
    >> NameError Traceback (most recent call last)
    >> <ipython-input-11-028e6ffb84a8> in <module>()
    >> ----> 1 del format
    >>
    >> NameError: name 'format' is not defined
    >> --------
    >>
    >> What does this mean? Why does it say 'format" cannot be deleted after I
    >> did the wildcard import ?

    >
    > You can't delete built-in names.


    Ah, ok - and cannot overwrite it too, I guess... A shame that pylint
    didn't knew about this.

    > It has nothing to do with the wildcard import. The PyOpenGL modules delete
    > "format" from the module's variables as soon as they are finished with
    > it, so the set of names created by the wildcard import doesn't include
    > "format".


    Ok, sounds to me like I can safely ignore this pylint warning in any
    case... Thanks!
    someone, Jan 2, 2013
    #11
  12. On Wed, 02 Jan 2013 00:49:36 +0100, someone wrote:

    > On 01/01/2013 12:49 PM, Steven D'Aprano wrote:
    > > On Tue, 01 Jan 2013 12:00:32 +0100, someone wrote:
    > >
    > >> See this code (understand why I commented out first line):
    > >>
    > >> # from OpenGL.GL import *

    > > [...]
    > >> The reason why I commented out the first line is that I use "pylint"
    > >> and it reports: "[W] Redefining built-in 'format'" for this line.
    > >>
    > >> From: http://www.logilab.org/card/pylintfeatures tell: W0621:
    > >> Redefining name %r from outer scope (line %s) Used when a variable's
    > >> name hide a name defined in the outer scope.
    > >>
    > >> I don't like to redefine already defined names so therefore I had to
    > >> outcomment first line and then keep on adding stuff until I could
    > >> run my program... But this SUCKS! I can see that pygame hasn't been
    > >> updated for a long while - not many users use it? I'm not very happy
    > >> about this...

    > >
    > > from pygame import *
    > > del format

    >
    > Are you sure about this? Because I'm not (OTOH I'm maybe not as
    > experienced in python as some of you)...


    In the general case of deleting global names that shadow builtin names,
    yes I am.

    In the specific case of importing * from pygame, no. I trusted you that
    pygame exports format. Unfortunately, it seems that you were fooled by an
    invalid warning from pylint, so we were both mistaken.


    > Ipython log:
    >
    > --------
    > In [6]: test=format(43)
    > In [7]: type(test)
    > Out[7]: str
    > In [8]: from pygame import *
    > In [9]: test=format(43)
    > In [10]: type(test)
    > Out[10]: str
    > In [11]: del format
    > ------------------------------------------------------------------------
    > NameError Traceback (most recent call last)
    > <ipython-input-11-028e6ffb84a8> in <module>()
    > ----> 1 del format
    >
    > NameError: name 'format' is not defined
    > --------
    >
    > What does this mean? Why does it say 'format" cannot be deleted after I
    > did the wildcard import ?


    It means that there is no "format" in the current scope, which implies
    that pygame no longer has a "format" which can be imported.

    You don't need an import to shadow built-ins. See for example:

    py> format
    <built-in function format>
    py> format = "NOBODY expects the Spanish Inquisition!"
    py> format # this shadows the built-in "format"
    'NOBODY expects the Spanish Inquisition!'
    py> del format # get rid of the Spanish Inquisition
    py> format
    <built-in function format>
    py> del format
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'format' is not defined


    When a name is not discovered in the current scope, the builtin scope is
    checked before Python gives up and reports a NameError. But del only
    works on the current scope, to stop you from accidentally deleting the
    wrong object.


    > > pylint may still complain, but you can ignore it. By deleting the
    > > name "format", that will unshadow the builtin format.

    >
    > Are you sure?


    Since it turns out that pylint was actually wrong to complain, no format
    was actually imported, then yes you can safely ignore it :)



    --
    Steven
    Steven D'Aprano, Jan 2, 2013
    #12
  13. someone

    alex23 Guest

    On Jan 2, 1:01 pm, Nobody <> wrote:
    > You can't delete built-in names.


    Actually, you can. If you ever need to shoot yourself in the foot in
    this particular way, you can always do:

    del __builtins__.format

    Not saying you _should_, just that you _can_ :)
    alex23, Jan 2, 2013
    #13
  14. someone

    Peter Otten Guest

    pylint, was Re: pygame - importing GL - very bad...

    someone wrote:

    > On 01/01/2013 01:56 PM, Peter Otten wrote:


    >> from module import * # pylint: disable=W0622

    >
    > Oh, I just learned something new now... How come I cannot type "#pylint:
    > enable=W0622" in the line just below the import ?


    With what intended effect?

    > Another thing is that I don't understand this warning:
    >
    > Invalid name "original_format" (should match (([A-Z_][A-Z0-9_]*)|
    > > (__.*__))$)

    >
    > I get it everywhere... I don't understand how it wants me to label my
    > variables... Maybe I should disable this warning to get rid of it...


    pylint wants global names to be uppercase (what PEP 8 recommends for
    constants) or "special" (two leading and two trailing underscores):

    THATS_OK = 42
    __thats_ok_too__ = object()
    but_thats_not = "spam"
    Peter Otten, Jan 2, 2013
    #14
  15. someone

    someone Guest

    On 01/02/2013 10:52 AM, alex23 wrote:
    > On Jan 2, 1:01 pm, Nobody <> wrote:
    >> You can't delete built-in names.

    >
    > Actually, you can. If you ever need to shoot yourself in the foot in
    > this particular way, you can always do:
    >
    > del __builtins__.format
    >
    > Not saying you _should_, just that you _can_ :)


    Ok, good to know (not saying I would ever try it) :)
    someone, Jan 2, 2013
    #15
  16. someone

    someone Guest

    On 01/02/2013 08:39 AM, Steven D'Aprano wrote:
    > On Wed, 02 Jan 2013 00:49:36 +0100, someone wrote:


    >> What does this mean? Why does it say 'format" cannot be deleted after I
    >> did the wildcard import ?

    >
    > It means that there is no "format" in the current scope, which implies
    > that pygame no longer has a "format" which can be imported.
    >
    > You don't need an import to shadow built-ins. See for example:
    >
    > py> format
    > <built-in function format>
    > py> format = "NOBODY expects the Spanish Inquisition!"
    > py> format # this shadows the built-in "format"
    > 'NOBODY expects the Spanish Inquisition!'
    > py> del format # get rid of the Spanish Inquisition
    > py> format
    > <built-in function format>
    > py> del format
    > Traceback (most recent call last):
    > File "<stdin>", line 1, in <module>
    > NameError: name 'format' is not defined


    Ok, thank you very much - that was/is very illustrative...

    > When a name is not discovered in the current scope, the builtin scope is
    > checked before Python gives up and reports a NameError. But del only
    > works on the current scope, to stop you from accidentally deleting the
    > wrong object.


    Ok, I'll remember that in the future, thank you.

    >> > pylint may still complain, but you can ignore it. By deleting the
    >> > name "format", that will unshadow the builtin format.

    >>
    >> Are you sure?

    >
    > Since it turns out that pylint was actually wrong to complain, no format
    > was actually imported, then yes you can safely ignore it :)


    Ok, I can see from your example that you're right. Nice to know the real
    explanation, thank you very much. :)
    someone, Jan 2, 2013
    #16
  17. someone

    someone Guest

    Re: pylint, was Re: pygame - importing GL - very bad...

    On 01/02/2013 01:07 PM, Peter Otten wrote:
    > someone wrote:
    >
    >> On 01/01/2013 01:56 PM, Peter Otten wrote:

    >
    >>> from module import * # pylint: disable=W0622

    >>
    >> Oh, I just learned something new now... How come I cannot type "#pylint:
    >> enable=W0622" in the line just below the import ?

    >
    > With what intended effect?


    If I have a section with A LOT OF warnings and I don't want those in
    that section to show up ? Isn't that valid enough?

    >> Another thing is that I don't understand this warning:
    >>
    >> Invalid name "original_format" (should match (([A-Z_][A-Z0-9_]*)|
    >> > (__.*__))$)

    >>
    >> I get it everywhere... I don't understand how it wants me to label my
    >> variables... Maybe I should disable this warning to get rid of it...

    >
    > pylint wants global names to be uppercase (what PEP 8 recommends for
    > constants) or "special" (two leading and two trailing underscores):
    >
    > THATS_OK = 42
    > __thats_ok_too__ = object()
    > but_thats_not = "spam"


    OMG... I don't want to type those underscores everywhere... Anyway,
    thank you very much for explaining the meaning of what it wants...
    someone, Jan 2, 2013
    #17
  18. someone

    Dave Angel Guest

    Re: pylint, was Re: pygame - importing GL - very bad...

    On 01/02/2013 09:09 AM, someone wrote:
    > On 01/02/2013 01:07 PM, Peter Otten wrote:
    >> someone wrote:
    >>
    >>> On 01/01/2013 01:56 PM, Peter Otten wrote:

    >>
    >>>> from module import * # pylint: disable=W0622
    >>>
    >>> Oh, I just learned something new now... How come I cannot type
    >>> "#pylint:
    >>> enable=W0622" in the line just below the import ?

    >>
    >> With what intended effect?

    >
    > If I have a section with A LOT OF warnings and I don't want those in
    > that section to show up ? Isn't that valid enough?
    >
    >>> Another thing is that I don't understand this warning:
    >>>
    >>> Invalid name "original_format" (should match (([A-Z_][A-Z0-9_]*)|
    >>> > (__.*__))$)
    >>>
    >>> I get it everywhere... I don't understand how it wants me to label my
    >>> variables... Maybe I should disable this warning to get rid of it...

    >>
    >> pylint wants global names to be uppercase (what PEP 8 recommends for
    >> constants) or "special" (two leading and two trailing underscores):
    >>
    >> THATS_OK = 42
    >> __thats_ok_too__ = object()
    >> but_thats_not = "spam"

    >
    > OMG... I don't want to type those underscores everywhere... Anyway,
    > thank you very much for explaining the meaning of what it wants...
    >
    >
    >


    Global const values should be ALL_CAPS, so it's obvious that nobody
    intends to modify them. It's the non-const global attributes that
    expect to be underscored.

    You shouldn't have to use those underscores very often. After all,
    there is seldom a need for a non-const global value, right? Don't think
    of it as a pylint problem, but as a hint from pylint that perhaps you
    should use fewer globals.



    --

    DaveA
    Dave Angel, Jan 2, 2013
    #18
  19. Re: pylint, was Re: pygame - importing GL - very bad...

    On Wed, Jan 2, 2013 at 11:07 PM, Peter Otten <> wrote:
    > someone wrote:
    >> Another thing is that I don't understand this warning:
    >>
    >> Invalid name "original_format" (should match (([A-Z_][A-Z0-9_]*)|
    >> > (__.*__))$)

    >>
    >> I get it everywhere... I don't understand how it wants me to label my
    >> variables... Maybe I should disable this warning to get rid of it...

    >
    > pylint wants global names to be uppercase (what PEP 8 recommends for
    > constants) or "special" (two leading and two trailing underscores):
    >
    > THATS_OK = 42
    > __thats_ok_too__ = object()
    > but_thats_not = "spam"


    Okay, I have to ask... why? Does it have an exception for names of classes?

    I don't like linters that enforce too much style. Catch things that
    might be mis-coded (like C's classic "if (x = 1)"), but don't complain
    about my names. They're MY business.

    ChrisA
    Chris Angelico, Jan 2, 2013
    #19
  20. someone

    Ian Kelly Guest

    Re: pylint, was Re: pygame - importing GL - very bad...

    On Wed, Jan 2, 2013 at 7:32 AM, Chris Angelico <> wrote:
    > Okay, I have to ask... why? Does it have an exception for names of classes?


    Yes, and for module-level functions.

    > I don't like linters that enforce too much style. Catch things that
    > might be mis-coded (like C's classic "if (x = 1)"), but don't complain
    > about my names. They're MY business.


    pylint is configurable though, so you can disable any warnings you
    don't care about. My pylint macro has a fairly large number of -d
    options in it.
    Ian Kelly, Jan 2, 2013
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raymond Arthur St. Marie II of III

    very Very VERY dumb Question About The new Set( ) 's

    Raymond Arthur St. Marie II of III, Jul 23, 2003, in forum: Python
    Replies:
    4
    Views:
    469
    Raymond Hettinger
    Jul 27, 2003
  2. shanx__=|;-

    very very very long integer

    shanx__=|;-, Oct 16, 2004, in forum: C Programming
    Replies:
    19
    Views:
    1,612
    Merrill & Michele
    Oct 19, 2004
  3. Abhishek Jha

    very very very long integer

    Abhishek Jha, Oct 16, 2004, in forum: C Programming
    Replies:
    4
    Views:
    416
    jacob navia
    Oct 17, 2004
  4. rantingrick
    Replies:
    44
    Views:
    1,195
    Peter Pearson
    Jul 13, 2010
  5. rantingrick

    [pygame-bug] Pygame.cdrom bug

    rantingrick, Jan 30, 2011, in forum: Python
    Replies:
    1
    Views:
    303
    Benjamin Kaplan
    Jan 30, 2011
Loading...

Share This Page