473,383 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

alternatives to making blocks like { } or other ??

Tim Williams writes:
I have to put my 2 cents in here. I love Python, but the one thing I
miss is using {} or something to enclose blocks. I edit in emacs
python-mode, and believe in indentation, but sometimes I'll
inadvertently change a line of code's indentation and it throws the
logic off. I found a bug in one of my programs recently where a line
of code should have been outside of an 'if', but wasn't because I hit
TAB one too many times. A {} block would've caught that. I know that's
just being careless, but I need all the help I can get!


I don't mind using C-derived languages occasionally, but one thing that
bothers me is having to use {} or something to enclose blocks. I use
various editors, and I believe in both delimiting and indenting, but
sometimes I'll inadvertently change indentation or move the position of
a brace and either way it throws the logic off. I created a bug in one of
my programs recently just by adding logging. It looked like this:

if (some_complicated_condition)
log_message("Error has occurred: taking corrective action");
take_corrective_action();

When I read through the code it LOOKED like it worked, but of course
the corrective action was taken even when it wasn't needed. I've also
seen more complex examples like this:

if (condition_1) {
code_1;
} else if (condition_2)
if (condition_2_a) {
code_2_a;
}
// nothing to do for 2b
else {
code_3;
}

But the ones that I hate the MOST are the ones that my unit tests can't
catch. A typical example looks like this:

if (condition) {
code;
goes;
here;
} else {
more;
code;
}

Notice how that one line ("here;") is indented wrong? Obviously, that
doesn't meet our coding standards, yet there's no way for the compiler
to catch it, because the compiler looks only at the braces and ignores
the indentation! I know that's just being careless, but I need all the
help I can get! If only there were a better language I could use.

-- Michael Chermside
Jul 18 '05 #1
0 1393

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: CYBER | last post by:
Hello Is there any other way under python to create blocks ?? instead of def sth(x): return x
1
by: Michael Chermside | last post by:
I (Michael Chermside) wrote: > a brace and either way it throws the logic off. I created a > bug in one of > my programs recently just by adding logging. It looked like this: > > if...
20
by: Doug Holton | last post by:
Is there any metaclass trick or something similar to allow anonymous code blocks? I'd like to be able to let users do something like this fictitious example: b = Button() b.OnClick =: print...
14
by: Carl Ribbegaardh | last post by:
What other c++ constructs can I use instead of #define for executing a couple of functions? Example: #define DO_STUFF doThis(); doThat(); I'd guess that I can either use a template function,...
43
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own...
8
by: | last post by:
It's likely that I will have to find another web server to use in place of IIS due to its poor security. We have already developed a reasonable amount of code in ASP.NET however. I've heard that...
1
by: Doug | last post by:
Looking for opinions/suggestions: Suppose I have a "region" of an aspx page I want to hide or show based on whatever runtime conditions. Additionally, the entire region is defined by an HTML...
5
by: ddtbhai | last post by:
Hello all, I selected Pathan recently to add basic XPath query support for an application. However, the site gives me an impression of "abandonware" as the latest release has been in beta for...
6
by: greek_bill | last post by:
Hi, I'm interested in developing an application that needs to run on more than one operating system. Naturally, a lot of the code will be shared between the various OSs, with OS specific...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.