473,804 Members | 3,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

alternatives to making blocks like { } or other ??

Hello

Is there any other way under python to create blocks ??

instead of

def sth(x):
return x

could i use something else like

def sth(x):
{
return x
}
???
Jul 18 '05 #1
31 2089
Blocks in Python are defined not with {} but rather
with indention. You indent to start a block and
stop indenting when you wish to end it. Seems odd
at first, but turns out to be excellent way to
handle blocks (and to properly format you code).

HTH, Larry Bates

"CYBER" <usenet@zly_adr es.com> wrote in message
news:c8******** **@news.atman.p l...
Hello

Is there any other way under python to create blocks ??

instead of

def sth(x):
return x

could i use something else like

def sth(x):
{
return x
}
???

Jul 18 '05 #2
"Larry Bates" <lb****@swamiso ft.com> wrote in message
news:FJ******** ************@co mcast.com...
Blocks in Python are defined not with {} but rather
with indention. You indent to start a block and
stop indenting when you wish to end it. Seems odd
at first, but turns out to be excellent way to
handle blocks (and to properly format you code).

HTH, Larry Bates

"CYBER" <usenet@zly_adr es.com> wrote in message
news:c8******** **@news.atman.p l...
Hello

Is there any other way under python to create blocks ??

instead of

def sth(x):
return x

could i use something else like

def sth(x):
{
return x
}
???


.... and no religious wars on where the braces are supposed to go, HOORAY!!!

And I'll second Larry's comment - it takes about 10-20 minutes to get used
to, but then you just focus on indentation, and it seems *very* natural -
liberating, even!

-- Paul
Jul 18 '05 #3
CYBER wrote:
Is there any other way under python to create blocks ??
instead of
def sth(x):
return x
could i use something else like
def sth(x):
{
return x
}


Not without changing the language a lot. But just try the normal way for a
couple of days, you'll get used to it in no time.

--
Timo Virkkala
Jul 18 '05 #4
"Timo Virkkala" <a@a.invalid> wrote in message
news:Z1******** *******@read3.i net.fi...
CYBER wrote:
Is there any other way under python to create blocks ??
instead of
def sth(x):
return x
could i use something else like
def sth(x):
{
return x
}


Not without changing the language a lot. But just try the normal way for a
couple of days, you'll get used to it in no time.


Or you could try this, which works almost exactly as well:

def sth(x):
#
return x
#

<g,d&r>
--
I don't actually read my hotmail account, but you can replace hotmail with
excite if you really want to reach me.
Jul 18 '05 #5
On Tue, 18 May 2004 21:27:17 +0200, CYBER <usenet@zly_adr es.com>
wrote:
Hello

Is there any other way under python to create blocks ??

instead of

def sth(x):
return x

could i use something else like

def sth(x):
{
return x
}
???

Of course there is another way!

Just use # in front of your favourite block separator.

I'm too lazy now to search the archives on who first suggested this,
but it works:

def something(x):
#{
return x
#}

However, as with any and all block separators, this can lead to holy
wars - is the above the 'one true way', or is it one of the following?
All are valid Python...

def something_else( x):
#{
return x
#}

def something_or_ot her(x):
#{
return x
#}

def something_compl etely_different (x): #(
return x
#}

--
Christopher
Jul 18 '05 #6
> Of course there is another way!

Just use # in front of your favourite block separator.

I'm too lazy now to search the archives on who first suggested this,
but it works:

def something(x):
#{
return x
#}


Thank you.

Jul 18 '05 #7

"CYBER" <usenet@zly_adr es.com> wrote in message
news:c8******** **@news.atman.p l...
Hello

Is there any other way under python to create blocks ??

instead of

def sth(x):
return x

could i use something else like

def sth(x):
{
return x
}
???


http://www.python.org/doc/Humor.html#parsing
Jul 18 '05 #8
On Wed, 19 May 2004 01:46:02 GMT, "Chad Thompson" <ch**@sabinasp. com>
wrote:

"CYBER" <usenet@zly_adr es.com> wrote in message
news:c8******* ***@news.atman. pl...
Hello

Is there any other way under python to create blocks ??

instead of

def sth(x):
return x

could i use something else like

def sth(x):
{
return x
}
???


http://www.python.org/doc/Humor.html#parsing


Ah yes, that was the link, I'd completely forgotten about the Python
humour page!

Oh, and CYBER: my post was *meant* ironic, but Python is flexible
enough that it can be taken at face value - so glad to have been of
help ;-)

--
Christopher
Jul 18 '05 #9
On 2004-05-18, Paul McGuire <pt***@austin.r r._bogus_.com> wrote:
could i use something else like

def sth(x):
{
return x
}
... and no religious wars on where the braces are supposed to
go, HOORAY!!!
But as religious wars go, the great Python "tab" debate ranks
right up there.
And I'll second Larry's comment - it takes about 10-20 minutes
to get used to, but then you just focus on indentation, and it
seems *very* natural - liberating, even!


Especially if you've got an editor with a "python mode".

--
Grant Edwards grante Yow! I guess we can live
at on his POT FARM in HADES!!
visi.com
Jul 18 '05 #10

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

Similar topics

0
1421
by: Michael Chermside | last post by:
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...
20
2027
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 "you clicked me" But that would require adding a special "=:" operator to bind a code block to a function.
14
4464
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, an inlined function or an inlined static method. //1
43
5031
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 libraries. I'm not sure if that's a good thing or not. AFAIK, most of Qt is compatable with the Standard Library. That is, QLT can interoperate with STL, and you can convert back and forth between std::string and Qt::QString, etc. Are there any...
8
5315
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 Apache can't be used with ASP.NET and that the Cassini server is used mostly for testing purposes. What options do I have (barring starting all over using Apache and PHP)? Will any other servers work with ASP.NET? Thanks,
1
1299
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 <TABLE>. There is nothing else in the region beyond whatever is contained in the <TABLE>. I see at least two options for showing/hiding this region. 1. Wrap the table in an <ASP:Panel> and set the panel's Visible property to
5
1226
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 about two years now. I had tried making sense of Apache Xalan, but the material was heavily geared towards XSLT and some other acronyms i wasn't interested in ... and the sample weren't encouraging.
4
449
by: lucavilla | last post by:
If you go to http://europe.nokia.com/A4305060, fill the "Enter your product code:" field with the value "0523183" and press "Go" (the ending page URL varies because there's a variable session-ID in the URL-link associated to "Go") you will obtain this string: "Version: RM43_V1.10.030" Is it possible to have a string.php page that just display this string? how can I do it?
6
2159
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 functionality being kept separate. I've been going over the various approaches I could follow in order to implement the OS-specific functionality. The requirements I have are as follows :
0
10326
jinu1996
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10317
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9143
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.