473,498 Members | 37 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'Hidden Features of Python'

Having read through the link below I finally managed to grasp some
concepts that I only read about in the docs but never got to really
understand. Maybe it will be helpful for people like myself who are
not yet fully comfortable with some of Python's `hidden' features.

http://stackoverflow.com/questions/1...ures-of-python
Oct 17 '08 #1
6 1042
On Oct 17, 2008, at 10:00 AM, coldpizza wrote:
http://stackoverflow.com/questions/1...ures-of-python
Thanks, there are a lot of useful nuggets there. However, can anybody
explain the "Main messages" one? It doesn't include any explanatory
text at all, just a code snippet:

import this
# btw look at this module's source :)

I don't see what I'm supposed to get from that. If I'm supposed to
see the magic (and explanation) be examining the source for the 'this'
module, well, I don't see how I can do that either. Can someone who
gets this share a clue?

Thanks,
- Joe

Oct 17 '08 #2
If you are using and IDE, such as Eclipse, PyScripter, etc, then CTR
+click on 'this' should do the trick.
In ipython you can do 'import this' and then type 'this??' Or if you
are *not* lazy, you could try locating the file in the Python tree.
import this
# btw look at this module's source :)

I don't see what I'm supposed to get from that. *If I'm supposed to *
see the magic (and explanation) be examining the source for the 'this' *
module, well, I don't see how I can do that either. *Can someone who *
gets this share a clue?

Thanks,
- Joe
Oct 17 '08 #3
On Oct 17, 2008, at 10:35 AM, coldpizza wrote:
If you are using and IDE, such as Eclipse, PyScripter, etc, then CTR
+click on 'this' should do the trick.
In ipython you can do 'import this' and then type 'this??' Or if you
are *not* lazy, you could try locating the file in the Python tree.
Oh! They're actually talking about a module literally called 'this'!
I thought that was just a placeholder, like "foo".

Interesting (and useful).

As for examining the source though, it seems like it could be
shortened up quite a bit now -- in fact all the source except the
assignment to s could be replaced with the one-liner

print s.encode('rot13')

Though the existing source is interesting in its own way too.

Thanks,
- Joe
Oct 17 '08 #4
On Fri, Oct 17, 2008 at 11:48 AM, Joe Strout <jo*@strout.netwrote:
On Oct 17, 2008, at 10:35 AM, coldpizza wrote:
>If you are using and IDE, such as Eclipse, PyScripter, etc, then CTR
+click on 'this' should do the trick.
In ipython you can do 'import this' and then type 'this??' Or if you
are *not* lazy, you could try locating the file in the Python tree.

Oh! They're actually talking about a module literally called 'this'! I
thought that was just a placeholder, like "foo".

Interesting (and useful).

As for examining the source though, it seems like it could be shortened up
quite a bit now -- in fact all the source except the assignment to s could
be replaced with the one-liner

print s.encode('rot13')
Methinks you miss the point -- read the Zen, and apply its principles
to the "this" module. I think they managed to break pretty much all
of them, probably to illustrate a point, all in good fun. Tim Peters
rocks!

For more fun with the Zen, see this thread:

http://mail.python.org/pipermail/pyt...ly/055857.html

Best,

Kurt
Oct 17 '08 #5
In message <ma**************************************@python.o rg>, Kurt Smith
wrote:
For more fun with the Zen, see this thread:

http://mail.python.org/pipermail/pyt...ly/055857.html
For someone complaining about improperly-spaced punctuation, they can't
spell "orthographical". :)

--
Lawrence "Skitt's Law? What Skitt's Law?" D'Oliveiro
Oct 17 '08 #6
On Oct 17, 11:00*am, coldpizza <vri...@gmail.comwrote:
Having read through the link below I finally managed to grasp some
concepts that I only read about in the docs but never got to really
understand. Maybe it will be helpful for people like myself who are
not yet fully comfortable with some of Python's `hidden' features.

http://stackoverflow.com/questions/1...ures-of-python
+1 good link.
Oct 17 '08 #7

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

Similar topics

176
7993
by: Thomas Reichelt | last post by:
Moin, short question: is there any language combining the syntax, flexibility and great programming experience of Python with static typing? Is there a project to add static typing to Python? ...
1
1457
by: Kl | last post by:
Hi, python is really easy to learn in my opinion. There are loads of tutorials/books on the web talking about the most common python features. The problem comes when they add something new to the...
8
2048
by: Georg Brandl | last post by:
Hello c.l.py, what features would you expect of a Python package manager, similar to CPAN or rubygems? I am currently planning to write such a thing, at first privately for myself, and if...
351
12696
by: CBFalconer | last post by:
We often find hidden, and totally unnecessary, assumptions being made in code. The following leans heavily on one particular example, which happens to be in C. However similar things can (and...
19
3801
by: Badr.ALmuzini | last post by:
hi,there how can i make php file extension hidden in the URL somthing like this (http://mail.google.com/mail/?view) Regard....
0
2058
by: BcNexus | last post by:
Hello all, The search function of this forum isn't working although I found a similar question on the forum using Google, but the replies don't help me. So, forgive me please if this has been...
1
1067
by: Beliavsky | last post by:
A Parade of New Features Debuts in Python 2.5 by Gigi Sayfan "Python 2.5 still has the smell of fresh paint but it's the perfect time to drill down on the most important new features in this...
2
2549
by: corykendall | last post by:
Here is my code: ... Setting hidden input to: <dsp:valueof param="tabname"/> <input name="tabname" type="hidden" value='<dsp:valueof param="tabname"/>'/> </dsp:form> hidden input set...
5
2571
by: bearophileHUGS | last post by:
I often use Python to write small programs, in the range of 50-500 lines of code. For example to process some bioinformatics data, perform some data munging, to apply a randomized optimization...
0
7124
marktang
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,...
0
7163
Oralloy
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,...
0
7200
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...
0
7375
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...
0
5460
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,...
1
4904
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...
0
3090
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
651
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.