Some recent posts about Python programming style got me thinking.
Since we have the PEP 8 which gives some guidelines about the style to
be used, do we have any program that can check for violations of these
guidelines within the source code? I understand that there are a lot
of code beautifiers out there, but i haven't seen one specially
tailored for Python... Is there even a desire in Python community for
a program like this (by Python community I mean the people in this
group:) ) ? I think it would be a nice little project for practice and
I'd like to do it, but if there is already something like this then I
can probably spend my time on something more productive. So, I'd like
to hear your opinion on this...
There is one thing that I don't understand about PEP 8 - why is using
spaces considered more desirable than using tabs for indentation? 7 1790 mo*********@gma il.com schrieb:
Some recent posts about Python programming style got me thinking.
Since we have the PEP 8 which gives some guidelines about the style to
be used, do we have any program that can check for violations of these
guidelines within the source code? I understand that there are a lot
of code beautifiers out there, but i haven't seen one specially
tailored for Python... Is there even a desire in Python community for
a program like this (by Python community I mean the people in this
group:) ) ? I think it would be a nice little project for practice and
I'd like to do it, but if there is already something like this then I
can probably spend my time on something more productive. So, I'd like
to hear your opinion on this...
There is one thing that I don't understand about PEP 8 - why is using
spaces considered more desirable than using tabs for indentation?
Pylint is one of them ( http://www.logilab.org/857)
With spaces you get always the same len of the line, where tabs can use 2,4,8
spaces, dependingt on the settings of the IDE
Alexander
montyphyton wrote this on Thu, 31 May 2007 05:16:30 -0700. My reply
is below.
I understand that there are a lot of code beautifiers out there, but
i haven't seen one specially tailored for Python.
Consider PythonTidy:
o http://lacusveris.com/PythonTidy/PythonTidy.python
--
... Chuck Rhode, Sheboygan, WI, USA
... Weather: http://LacusVeris.com/WX
... 75° — Wind SSE 9 mph — Sky haze.
Alexander Eisenhuth wrote:
Pylint is one of them (http://www.logilab.org/857)
BTW: Why does pylint want all names with underscores? I tested it
and it complains about malformed names in e.g. the following cases
that are conformant to PEP 8:
- single letter as parameter
- firstLowerCamel Case names for instances and instance methods in
class declarations ("should match [a-z_][a-z0-9_]{2,30}$")
- all lowercase method names in class declarations
Those policies are barely usable, IMHO, and neither practical.
LOL, and it rates my code -1.9/10. The minus is no typo.
Regards,
Björn
--
BOFH excuse #291:
Due to the CDA, we no longer have a root account.
On 5/31/07, Bjoern Schliessmann
<us************ **************@ spamgourmet.com wrote:
Alexander Eisenhuth wrote:
Pylint is one of them (http://www.logilab.org/857)
BTW: Why does pylint want all names with underscores? I tested it
and it complains about malformed names in e.g. the following cases
that are conformant to PEP 8:
- single letter as parameter
This seems to be an Logilab internal restriction.
- firstLowerCamel Case names for instances and instance methods in
class declarations ("should match [a-z_][a-z0-9_]{2,30}$")
- all lowercase method names in class declarations
No. Quoting PEP 8:
Functions:
"""
mixedCase is allowed only in contexts where that's already the
prevailing style (e.g. threading.py), to retain backwards compatibility.
"""
Methods and instances:
"""
Use the function naming rules: lowercase with words separated by
underscores as necessary to improve readability.
"""
Those policies are barely usable, IMHO, and neither practical.
I Desagree.
--
EduardoOPadoan (eopadoan->altavix::com )
Bookmarks: http://del.icio.us/edcrypt
Eduardo "EdCrypt" O. Padoan wrote:
No. Quoting PEP 8:
Functions:
"""
mixedCase is allowed only in contexts where that's already the
prevailing style (e.g. threading.py), to retain backwards
compatibility.
"""
Methods and instances:
"""
Use the function naming rules: lowercase with words separated by
underscores as necessary to improve readability.
"""
Has this been updated recently? I could've sworn I had read that
stuff like has_key was "old".
Regards,
Björn
--
BOFH excuse #432:
Borg nanites have infested the server
Bjoern Schliessmann wrote:
Eduardo "EdCrypt" O. Padoan wrote:
>No. Quoting PEP 8: Functions: """ mixedCase is allowed only in contexts where that's already the prevailing style (e.g. threading.py), to retain backwards compatibility. """ Methods and instances: """ Use the function naming rules: lowercase with words separated by underscores as necessary to improve readability. """
Has this been updated recently? I could've sworn I had read that
stuff like has_key was "old".
You can check the revision history here: http://svn.python.org/view/peps/trun...55405&view=log
Looks to me like camelCase became unacceptable in Revision 1781, back in
March 2004.
STeVe
In <5c************ *@mid.individua l.net>, Bjoern Schliessmann wrote:
[ripped out of context :-)]
Has this been updated recently? I could've sworn I had read that
stuff like has_key was "old".
Yes, `has_key()` is "old", it's spelled ``in`` these days. :-)
if mapping.has_key (ham): pass
# ->
if ham in mapping: pass
Ciao,
Marc 'BlackJack' Rintsch This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: |
last post by:
Tables:
=====
User
------
ID
Name
NationID
StateID
|
by: Xamle Eng |
last post by:
I am looking for a data oriented schema-enforcing XML editor. By
schema-enforcing I mean an editor that doesn't just have a button to
verify the schema - I want an editor that actively enforces it and
makes it difficult or impossible to generate data not conforming to the
schema.
I have downloaded many XML editors, both free/open-source and...
|
by: Daniel Billingsley |
last post by:
I'm always curious on some of these style issues if there seem to actually
be objective reasons for doing things one way or the other, so here goes for
a little lighter discussion.
1) Default constructors. Do you always write a constructor for every
class, even when it doesn't do anything special, or do you "trust" the
default one that...
|
by: Ron Burd |
last post by:
Hi,
As my company is moving into C# they are enforcing the use of styling
convention in the source code, such as methods naming conventions, newlines,
etc.
Does someone know of products that are good at this job? (free and/or
commercial)
|
by: Frosty |
last post by:
Howto make datagrid enforce rules of xml schema?
Created xml schema in the designer. Constraints created there using the following
<xs:simpleType name="zipcode"><xs:restriction base="xs:string"><xs:pattern value="\d{5}" /></xs:restriction></xs:simpleType
Datagrid does not enforce this rule, even though dataGrid1_Validating() is called.
...
| |
by: David Johnson |
last post by:
I am using Forms Authentication. What is best practice of enforcing each user to only be permitted to run a single instance of the application. I would like to enforce this even if the authenticated user attempts to connect on a different computer.
Thanks for any advice.
Regards
David Johnson
|
by: Joel Hedlund |
last post by:
Hi!
The question of type checking/enforcing has bothered me for a while, and
since this newsgroup has a wealth of competence subscribed to it, I
figured this would be a great way of learning from the experts. I feel
there's a tradeoff between clear, easily readdable and extensible code
on one side, and safe code providing early errors and...
|
by: ddtbhai |
last post by:
Hello folks,
Just wanted to know if there are some 'standard' approaches to
enforcing an order in the invocation of calling functions. It is
usually needed when initializing some object.
e.g
class A
{
|
by: Mark McIntyre |
last post by:
Hallvard B Furuseth wrote:
Setting aside that 4 is an entirely sensible tab width...
This seems to be the showstopper. Unless you now entirely own the code
yourself alone, don't reformat it it, will merely annoy the
collaboration team.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |