How to get filename of the __main__ module in Python?

How to get filename of the __main__ module in Python?

Suppose I have two modules:a.py:import bprint __name__, __file__b.py:print __name__, __file__I run the "a.py" file. This prints:b C:\path\to\code\b.py__main__ C:\path\to\code\a.pyQuestion: how do I obtain the path to the __main__ mod

how to capture the key event from a view ?

how to capture the key event from a view ?

I'm trying to capture the key event from a view as follows:myView = Backbone.View.extend({ el: $('#someDiv'), initialize: function(){ // initialize some subviews }, render: function(){ return this; }, events:{ 'keypress #someD

App.Config change value

App.Config change value

This is my App.Config With this code I make the changelang = "Russian";private void Main_FormClosing(object sender, FormClosingEventArgs e){ System.Configuration.ConfigurationManager.AppSettings.Set("lang", lang);}But it not chan

.write not working in Python

.write not working in Python

I'm fairly new to Python so hopefully I'm just missing something obvious here, but it has me stumped. Snippet of my program below:outFile = open('P4Output.txt', 'w')outFile.write(output)print outputprint "Output saved to \"P4Output.txt\"\n

How can I get user type C# syntax highlighting working again in VS 2012 RC?

How can I get user type C# syntax highlighting working again in VS 2012 RC?

Somehow part of my syntax highlighting for C# code has disappeared in the VS 2012 IDE. Uninstalling, rebooting, and reinstalling does nothing, nor does resetting the colors in the options dialog.Here are some examples of items which all app

Iterating a JavaScript object's properties using jQuery

Iterating a JavaScript object's properties using jQuery

Is there a jQuery way to perform iteration over an object's members, such as in: for (var member in obj) { ... }I just don't like this for sticking out from amongst my lovely jQuery notation! 1:$.each( { name: "John", lang:

Convert string in dot notation to get the object reference [duplicate]

Convert string in dot notation to get the object reference [duplicate]

This question already has an answer here: Convert JavaScript string in dot notation into an object reference 23 answers Consider this object in javascr

Accessing Express.js local variables in client side JavaScript

Accessing Express.js local variables in client side JavaScript

Curious if I'm doing this right and if not how you guys would approach this.I have a Jade template that needs to render some data retrieved from a MongoDB database and I also need to have access to that data inside a client side JavaScript

Detect element content changes with jQuery

Detect element content changes with jQuery

change() function works and detects changes on form elements, but is there a way of detecting when a DOM element's content was changed?This does not work, unless #content is a form element$("#content").change( function(){ // do something

Adding a point to polygon

Adding a point to polygon

I've created a class that extends the awt.Polygon class. I'm trying to write a method that given the PathIterator of the polygon and a Point representing a vertex, adds the point at the appropriate location in the path.For Example: A Polygo

how to save canvas data to file

how to save canvas data to file

i am using node.js to save canvas to image img in writeFile is extractedby using toDataURL on my canvas element.it doenot save filehere is my codevar fs = IMPORTS.require('fs');var path = IMPORTS.require('path');path.exists('images/', funct

Can I pass parameters by reference in Java?

Can I pass parameters by reference in Java?

I'd like semantics similar to C#'s ref keyword. 1:Java is confusing because everything is passed by value. However for a parameter of reference type (i.e. not a parameter of primitive type) it is the reference itself which is passed by v

How do you set the Content-Type header for an HttpClient request?

How do you set the Content-Type header for an HttpClient request?

I'm trying to set the Content-Type header of an HttpClient object as required by an API I am calling.I tried setting the Content-Type like below:using (var httpClient = new HttpClient()){ httpClient.BaseAddress = new Uri("http://example.

Application.Exit

Application.Exit

I am using VSTS 2008 + .Net 3.5 + C# to develop Windows Forms application. My confusion is, seems Application.Exit does not force application to terminate? If not, which method should I call to make application terminate?EDIT 1:Normally the

How to install an older version of package via NuGet?

How to install an older version of package via NuGet?

I want to install an older version of a package (Newtonsoft.Json). But NuGet rolls back. PM> Install-Package Newtonsoft.Json -Version 4.0.5Successfully installed 'Newtonsoft.Json 4.0.5'.Install failed. Rolling back...Install-Package : Alrea

Pointers in JavaScript?

Pointers in JavaScript?

Can we pass a reference of a variable that is immutable as argument in a function?Example:var x = 0;function a(x){ x++;}a(x);alert(x); //Here I want to have 1 instead of 0 1:Since JavaScript does not support passing parameters by refe

Parsing FtpWebRequest ListDirectoryDetails line

Parsing FtpWebRequest ListDirectoryDetails line

I need some help with parsing the response from ListDirectoryDetails in C#.I only need the following fields. File Name/Directory NameDate Createdand the File Size.Here's what some of the lines look like when I run ListDirectoryDetails:d--x-

How to keep a Python script output window open?

How to keep a Python script output window open?

I have just started with Python. When I execute a python script file on Windows, the output window appears but instantaneously goes away. I need it to stay there so I can analyze my output. How can I keep it open? 1:You have a few option

Using Node.JS, how do I read a JSON object into (server) memory?

Using Node.JS, how do I read a JSON object into (server) memory?

BackgroundI am doing some experimentation with Node.js and would like to read a JSON object, either from a text file or a .js file (which is better??) into memory so that I can access that object quickly from code. I realize that there are

字体的选用

字体的选用

Fonts Represent Your ContentTheres no doubt that your words, your posts, are the meat and potatoes of your blog or website. Those words, along with your lovely colors and pictures, tell your websites