What is this doing?
print >fd, _(__doc__)
I'm guessing line-splitting __doc__ into a list, but what's that
leading underscore do?
Thanks! 9 1114
Skye <sp****@gmail.c omwrites:
What is this doing?
print >fd, _(__doc__)
Without any context, it's impossible to know.
I'm guessing line-splitting __doc__ into a list, but what's that
leading underscore do?
Look at the rest of the module to see where that name comes from;
perhaps an assignment, or an 'import foo as _'.
My guess would be someone has used the common convention of naming the
"get the corresponding localised version of this string from the
application's gettext database" function as '_' for convenience.
That's only a guess though; you should believe the code you have in
front of you, not my guesses.
--
\ "Pinky, are you pondering what I'm pondering?" "Well, I think |
`\ so, Brain, but 'apply North Pole' to what?" -- _Pinky and The |
_o__) Brain_ |
Ben Finney
Skye wrote:
What is this doing?
print >fd, _(__doc__)
I'm guessing line-splitting __doc__ into a list, but what's that
leading underscore do?
It's calling a function with a single argument, like sqrt(x), except the
function is named _ and the argument is named __doc__. The underscores
have no special significance here, but they do make the code hard to read.
The first part of the statement directs the print to send the output to
a file, named fd, which was presumably opened earlier ... but I don't
think that was part of your question.
Gary Herron
Thanks!
-- http://mail.python.org/mailman/listinfo/python-list
Ohh, it's a function _() call. Now it makes sense.
Of course Python would be consistent... I was expecting trickery!
It's actually from the Mailman source, def _(s) is a string function
for i18n
Thanks,
Skye
My guess would be someone has used the common convention of naming the
"get the corresponding localised version of this string from the
application's gettext database" function as '_' for convenience.
Funny that this comes up.
I just noticed this in some code I was looking at the other day. A
number of statements in the form:
print _(something)
My question is: Why would anyone decide to obfuscate something as easy
to read as Python??? At first I thought that they were making a function
out of print (which makes some sense), but I don't think that is the
case. I tried (not very hard) to trace back the code to figure out where
_() is being assigned, but gave up. Oh, this is in the gdesklets package
if anyone is interested.
**** Listen to my CD at http://www.mellowood.ca/music/cedars ****
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: bo*@mellowood.c a
WWW: http://www.mellowood.ca
Skye wrote:
What is this doing?
print >fd, _(__doc__)
I'm guessing line-splitting __doc__ into a list, but what's that
leading underscore do?
Thanks!
I think it is standard practice to use the underscore for unicode converts.
bvdp <bo*@mellowood. cawrites:
My question is: Why would anyone decide to obfuscate something as easy
to read as Python???
They didn't decide to obfuscate; they decided to follow a
strongly-expected convention for the name of that function by existing
users of the 'gettext' functionality, in contexts that predate the
appearance of that functionality in Python.
--
\ Hercules Grytpype-Thynne: "Well, Neddie, I'm going to be |
`\ frank." Ned Seagoon: "Right, I'll be Tom." Count Moriarty: |
_o__) "I'll be Gladys." *slap* -- The Goon Show, _World War I_ |
Ben Finney
My question is: Why would anyone decide to obfuscate something as easy
to read as Python???
They didn't decide to obfuscate; they decided to follow a
strongly-expected convention for the name of that function by existing
users of the 'gettext' functionality, in contexts that predate the
appearance of that functionality in Python.
Well _ can also mean the previous output statement that wasn't null,
so it has OTHER uses... co*********@gma il.com a écrit :
>>My question is: Why would anyone decide to obfuscate something as easy to read as Python???
They didn't decide to obfuscate; they decided to follow a strongly-expected convention for the name of that function by existing users of the 'gettext' functionality, in contexts that predate the appearance of that functionality in Python.
Well _ can also mean the previous output statement that wasn't null,
In the shell only IIRC.
John Fabiani a écrit :
Skye wrote:
>What is this doing?
print >fd, _(__doc__)
I'm guessing line-splitting __doc__ into a list, but what's that leading underscore do?
Thanks!
I think it is standard practice to use the underscore for unicode converts.
Actually, it's for i18n, not for encoding. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: claudel |
last post by:
Hi
I have a newb PHP/Javascript question regarding checkbox processing
I'm not sure which area it falls into so I crossposted to comp.lang.php
and comp.lang.javascript.
I'm trying to construct a checkbox array in a survey form where one
of the choices is "No Preference" which is checked by default.
If the victim chooses other than "No Preference", I'd like to uncheck
|
by: csx |
last post by:
Hi everyone!
two quick questions relating to arrays.
Q1,
Is it possible to re-assign array elements?
int array = {{2,4}, {4,5}};
array = {2,3}
|
by: Walter Tross |
last post by:
Somebody with a very regulatory mind in this newsgroup has written
that it's better not to use a leading underscore for class member
names, because names with a leading underscore are used internally by
compilers (well, not so internally, since they appear in header
files).
I personally use the leading underscore (followed by a lower case
letter), which I consider to be much more readable than the trailing
underscore.
My reasoning is...
|
by: Tcs |
last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't
loaded it yet. I'm still using MS Access. And no, I don't believe this is an
Access question. (But who knows? I COULD be wrong... :) I've tried the
access group...twice...and all I get is "Access doesn't like ".", which I know,
or that my query names are too long, as there's a limit to the length of the SQL
statement(s). But this works when I don't try to...
|
by: Pete Horm |
last post by:
Hi everyone,
I have a question about using this variable. I am new to programming and I
had a book that was a couple of years old regarding php programming. None
of the examples were working correctly, until I discovered that my new
version of PHP 4.4 disabled global variables. I figured out how to make
the following php script work correctly, but I don't know if the way I made
it work is the accepted way of doing things with $_POST. I...
| |
by: aurelien.chanudet |
last post by:
Hi all,
Can someone tell me about the difference between these two statements ?
char *string = _("foo");
char *string = "foo";
Thanks,
Aurelien
|
by: jaysherby |
last post by:
I'm new at Python and I need a little advice. Part of the script I'm
trying to write needs to be aware of all the files of a certain
extension in the script's path and all sub-directories. Can someone
set me on the right path to what modules and calls to use to do that?
You'd think that it would be a fairly simple proposition, but I can't
find examples anywhere. Thanks.
|
by: Steven W. Orr |
last post by:
On Friday, Feb 23rd 2007 at 11:12 -0500, quoth Steven W. Orr:
=>I understand that two leading underscores in a class attribute make the
=>attribute private. But I often see things that are coded up with one
=>underscore. Unless I'm missing something, there's a idiom going on here.
=>
=>Why do people sometimes use one leading underscore?
I found the answer. It turns out that if you say:
|
by: Alexander Dong Back Kim |
last post by:
Dear all,
I used to use C++ programming language at all time but moved to C# and
Java. Few days ago, I restarted studying about C++ with a very
beginner's mind. I wrote a simple class and gcc couldn't compile the
class. Any hints that I'm missing?
Header File:
#ifndef __Calc_h__
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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: 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: 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: 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.
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |