Java Virtal Machine.net

[ News ] rss

February 01, 2011

Mark Wielaard: New GPG key. Finally created a new GPG key using gnupg. The old one was a DSA/1024 bits one and 8 years old. The new one is a RSA/2048 bits one. I will use the new one in the future to sign any release tarballs I might create. pub 2048R/57816A6A 2011-01-29 Key f...

More »

February 01, 2011

Andrew Hughes: [SECURITY] IcedTea6 1.7.8, 1.8.5, 1.9.5 Released!. We are pleased to announce a new set of security releases, IcedTea6 1.7.8, IcedTea6 1.8.5 and IcedTea6 1.9.5. This update contains the following security updates: The IcedTea project provides a harness to build the source code from OpenJDK6 u...

More »

April/2024
SunMonTueWedThuFriSat
 123456
78910111213
141516171819 20
21222324252627
282930    

[ Archives News
for 'Developers' ]

home > news > developers > netbeans screenshot of the week #35: support for python's __all__ variable

NetBeans Screenshot of the Week #35: Support for Python's __all__ Variable

Let's start with a pretty simple module - an import, a function, and a couple of classes: (Notice by the way the semantic highlighting here - the unused parameters and variables are marked with a slight grey underline, method names in bold, parameters in orange. More on that another day.) Now let's go to a different file and import this module. Code completion is context dependent and shows us which symbols are being exported by the given module. We see not only our functions and classes, the imported symbol sys is also being defined by module, meaning that if you do from compl4 import * you would have sys defined as well: Python has a way to deal with this: You can specify a variable named __all__, which lets you define exactly what the public API for this module should be (more details). Let's go in and define the names we want exported by our module. I will add __all__ = [ "Bar " ] somewhere in the file, to specify that only Bar should be exported: Look at the file outline / navigator on the left hand side. As soon as I typed in the __all__ line, the icons changed to show me that only the Bar class and its method are now "public"; there are little lock icons on everything else! Let's see what code completion offers when we try to import this module again: Yep, only the public API is exported now. Let's append to the __all__ list to export the func function: You don't have to rely on icons to tell you if someth...


Date: November, 13 2008
Url: http://blogs.sun.com/tor/entry/netbeans_screenshot_of_the_week2


Others News

©2002-2019Java-Virtual-Machine.net web editor | static website generator | Bootstrap Templates | top website builder | bootstrap buttons