As someone who learned C first, when I came to Python everytime I read
about a new feature it was like, "Whoa! I can do that?!" Slicing, dir(),
getattr/setattr, the % operator, all of this was very different from C.
I'm curious -- what is everyone's favorite trick from a non-python
language? And -- why isn't it in Python?
Here's my current candidate:
So the other day I was looking at the language Lua. In Lua, you make a
line a comment with two dashes:
-- hey, this is a comment.
And you can do block comments with --[[ and ---]].
--[[
hey
this
is
a
big
comment
--]]
This syntax lets you do a nifty trick, where you can add or subtract a
third dash to change whether or not code runs:
--This code won't run because it's in a comment block
--[[
print(10)
--]]
--This code will, because the first two dashes make the rest a comment,
breaking the block
---[[
print(10)
--]]
So you can change whether or not code is commented out just by adding a
dash. This is much nicer than in C or Python having to get rid of """ or
/* and */. Of course, the IDE can compensate. But it's still neat :)
Jul 19 '05
134 6109
Steven D'Aprano wrote: with colour do begin red := 0; blue := 255; green := 0; end;
instead of:
colour.red := 0; colour.blue := 255; colour.green := 0;
c = colour
c.red = 0; c.blue = 255; c.green = 0
del c # Not strictly needed, but limits the scope of c
When everything's a reference, the Pascal 'with' syntax doesn't gain
you anything over a single-letter variable name. As I recall, it's
handy in Pascal because record assignment has value semantics rather
than reference semantics.
Cheers,
Nick.
Terry Hancock wrote: http://www.logilab.org/projects/python-logic/
This is something pretty new to me, so I can't comment on how well it would meet your expectations, but I see now that the site does mention OZ/Mozart as comparables.
I've used both, the logilab stuff is cool, but no where near the
maturity (or speed) of OZ/Mozart. OTOH, I can actually get things
done with the logilab code. But that might say more about me than
Mozart. :)
--
Benji York
If I had to choose one feature, I would like to see better support for
nested lexical scopes. However, I imagine this is no easy "trick" to
add to the language. I'm curious -- what is everyone's favorite trick from a non-python language? And -- why isn't it in Python?
"Paddy" <pa*******@nets cape.net> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. . Sadly, its not a solution that I'm after, but a particular toolkit that can be used for solving that type of problem.
Presuming this is an anwer to my comment about generators... I was pointing
you more to the method used than the particular solutions. Whether your
constraint problems are similar enough, I have no idea.
Terry J. Reedy
On Thursday 30 June 2005 10:21 am, to********@gmai l.com wrote: If I had to choose one feature, I would like to see better support for nested lexical scopes. However, I imagine this is no easy "trick" to add to the language.
Doesn't that already happen in versions 2.2+?
What exactly do you mean by "better" support for nested lexical
scopes? Can you give an example of something that doesn't work,
but should?
I'm just curious. The whole question of lexical scoping seemed
a bit esoteric to me at the time --- I think I must instinctively
avoid situations where it causes trouble. The most important
exception would have to be the behavior of lambda and locally-defined
functions --- I still expect them to know the variables in the defining
function's namespace. But I think that lexical scoping fixed this
so that they do, IIRC (I don't use them often, so I'm not so sure).
--
Terry Hancock ( hancock at anansispacework s.com )
Anansi Spaceworks http://www.anansispaceworks.com
Eh, just figured it'd be worth noting...map, filter, and reduce should
be possible with the extended list syntaxes. Well, filter I know is,
but hte others /should/ be possible.
filter(lambda: <<condition>> , <<seq>>)
[some_var for some_var in <<seq>> if <<condition>>]
Honestly, though, I hope they don't drop the map functions and such.
That's one of the stronger functions of the language (IMO).
-Wes
ncf wrote: Eh, just figured it'd be worth noting...map, filter, and reduce should be possible with the extended list syntaxes. Well, filter I know is, but hte others /should/ be possible.
filter(lambda: <<condition>> , <<seq>>) [some_var for some_var in <<seq>> if <<condition>>]
reduce isn't.
--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
Who needs a dream / Who needs ambition
-- The Russian, _Chess_
Sorry, I realized that shortly after my post =X
In article <ma************ *************** ***********@pyt hon.org>, Joseph Garvin wrote: I'm curious -- what is everyone's favorite trick from a non-python language? And -- why isn't it in Python?
Being able to use my native language without a hitch when naming my
variables &c. Java allows that because it supports almost any Unicode
character in its identifiers. With Python I occasionally have to stop and
think: "I can't name it that. What's better?"
Not everyone always writes their programs in English. Once you get used
to Java's naming possibilities, it's plain annoying to go back, even if
it's just a couple of letters that're lacking in my case.
--
Pekka Karjalainen - Oulu, Finland This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Randy Given |
last post by:
What is your favorite Java development environment? What others have you
tried? What are some pros and cons of each? Thanks!
|
by: Vic Cekvenich |
last post by:
Here is my favorite tag: http://displaytag.sf.net and see examples (in upper
right). Grid, Sorting, nested, group, export, everything you like, plus it's
free.
Here is example code of how I used it:
http://cvs.sourceforge.net/viewcvs.py/basicportal/bPproj/bP/WEB-INF/pgs/forums/ArticleLst.jsp
You can view here run time by clicking here:
http://basebeans.com/do/channelsPg
|
by: Matthew Louden |
last post by:
I want to make a link that allows users to add my web site to the favorite
in IE. Anyone knows how to do that?
|
by: Scott McNair |
last post by:
What's your favorite bit of "short-cut" code that you use?
One of my favorite shortcuts I'll use when coding a page is to create a sub
along the lines of the following:
Sub Print(myText)
Response.Write myText & vbcrlf
End Sub
And then I use Print instead of Response.Write thru my code.
|
by: edunetgen |
last post by:
I have a Web Aplication.
I want an own image when an user adds me to favorite.
Thanks,
Edu
| |
by: zhaoyandong |
last post by:
One of my interviewers ask me
"Two favorite features of C++, and over-rated, and misued features"
Could anybody give me some advice on this?
Thanks
|
by: Les |
last post by:
In ancient times I had a desire to make a game and I
started to do so, I quickly found the project was beyond
the hardware's capability for that era (even in
assembler) and had to shelf the project. I retried in the
dark ages of computers, when I was in college, and got
much further before realizing the same thing was taking
place and shelved the project again. In hopes that this
new PC technology may yeild something interesting.
...
|
by: Jensen bredal |
last post by:
Hello,
I need to offer the visitors of my siste to add it to the favorite list but
only when it is ot there.
the code below:
window.external.AddFavorite(location.href, document.title)
add the link.
How can i see if the current link is already there?
|
by: clintonG |
last post by:
Want to give up your most treasured posession?
Post the URL for your favorite RegEx library you've found most useful for
validating form input.
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
|
by: fiversen |
last post by:
Hello,
I have a site for the collegue with a football winning game.
...fussball.html
there I redirect the user to an cgi-page
../f11.cgi
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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.
| |