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
}
??? 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 }
???
"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
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
"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.
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
> 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.
"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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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.
|
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
|
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...
|
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,
| |
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
|
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.
|
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?
|
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 :
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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();...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |