#module nametest def showName(): print("__name__ is: " + str(__name__)) If I import nametest into another module or into the shell interpreter and call nametest.showName() I find that name = "nametest", in other words __name__ gets the module name it is a built-in member of? The only exception I know of is if I define showName directly in the shell without importing it in a module, then __name__ shows "__main__". Is there any other way to get the function "showName()" to print a value other than "nametest".

Member Avatar
Member Avatar
+0 forum 4

In Python: #python class myClass: istat = 111 #exists as soon as import class def __init__(self): print("in ctor") self.iauto = 222 #does not exist until instance created ..... mc1 = myClass() mc2 = myClass() In C++: //C++ class myClass { public: static int istat; int iauto; }; ..... //main myClass mc1, mc2; I am trying to refresh my C++ and learn Python. It is interesting to compare them. Would the following be correct (regarding static class members of each language?) - Python: class members are by default static, and values can be accessed from either class or instances of class, …

Member Avatar
Member Avatar
+0 forum 1

import os def a(): print("A") def b(): print("B") # I want to sometimes skip the main body if os.path.isdir("C:\\Blender\\mainbody"): print("main body of module_A") Is there a way to control whether or not the main body of a module gets executed by passing in arguments to the import command, such as import module_A "mainbody" Right now I am controlling it by checking for existence of a directory, I know I could also open some kind of config file which is essentially the same approach but how about just passing in an argument along with import xxx ????

Member Avatar
Member Avatar
+0 forum 5

I am finding myself a little confused about how Python imports. Would the following be a correct statement: In any Python interactive shell, if the shell (since it was initiated or opened) has never before imported "myScript.py" then if the user types in "myScript" he will get an error like: NameError, name 'myScript' is not defined. At this point, entering the command "import myScript" will import myScript.py from the native OS diskfile system, i.e. from Windows folder or Unix directory, based upon a search path directed by "sys.path". Even if "myScript" is defined or has been imported in some other …

Member Avatar
Member Avatar
+0 forum 2

[CODE] private void testFunc() { int[] arrayParam = new int[88]; arrayParam[2] = 67; calledFunc(arrayParam); Console.WriteLine("testFunc Done"); } private void calledFunc(int[] intArray) { Console.WriteLine(intArray[2]); //if new array declared, values not changed in testFunc intArray = new int[66]; intArray[2] = 33; intArray[5] = 55; } [/CODE] If calledFunc simply changes array values, the changes are passed back to the calling method. But if calledFunc allocates a new array, this is not passed back to the caller. How do I get a called method to have the ability to either change existing array elements, or pass back a new array and its new …

Member Avatar
Member Avatar
+0 forum 5

I have an OpenGL program using GLUT which works fine on my Windows XP desktop using Visual C++ Express. I copied it over to my Vista laptop 64 bit and I copied the glut3.dll into Windows/system32 but although it compiles, when I try to run it I get a glut32.dll not found error. Is there an OpenGL download for Vista 64? I tried looking at the OpenGL website and it is very confusing, I think even Vista 64 still uses glut32.dll? Has anybody else encounered the glut32.dll not found problem on Vista, or can anyone give me some OpenGL code …

Member Avatar
+0 forum 0

I am reading "Database Systems" by Kifer, Bernstein, and Lewis. In chapter 19 on transaction models, it discusses how a flat transaction can adhere perfectly to ACID, but other transaction models are needed that sacrifice some of the ACID properties (such as isolation) for gains in performance, flexibility, etc... The archetypal example given is a flat transaction for a multiple segment international flight reservation: London/NY/Chicago/DesMoines with oversea and domestic trip segments where if a domestic segment (NY/Chic/DM) needs to be rerouted (NY/St Louis/DM) a flat transaction has to abort completely and loses a successful subtransaction (London/NY), but with savepoints after …

Member Avatar
+0 forum 0

Here is some old VBA code inside a Word 2003 document to open and then save a word document: [code] Documents.Open FileName:=docFileName, ConfirmConversions:=True, _ ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _ PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _ WritePasswordTemplate:="", Format:=wdOpenFormatAuto 'do stuff to the opened file here... ActiveDocument.SaveAs _ FileName:=docFileName, _ FileFormat:=wdFormatDocument, _ LockComments:=False, _ Password:="", _ AddToRecentFiles:=True, _ WritePassword:="", _ ReadOnlyRecommended:=False, _ EmbedTrueTypeFonts:=False, _ SaveNativePictureFormat:=False, _ SaveFormsData:=False, _ SaveAsAOCELetter:=False [/code] I ported the code to a word 2007 document, but now if I open a word 2007 doc the save code still saves it in the old format even if I specify a docx extension. …

Member Avatar
+0 forum 0

This is pertaining to debugging VBA macros for Word 2003. I am debugging a document with a LOT of buttons which launch macros. If I place a breakpoint in a subroutine, and execute the macro by running it from the VBE debugger, execution stops at the breakpoint. But is there a way to have the VBE debugger launched as soon as I call a macro from a document even if VBE is not open, e.g. if buttons a, b, c, ... z launch macros then I want to open the document, click on a, b, or c, ... z and …

Member Avatar
Member Avatar
+0 forum 1

In VC++ 2008 Express, I open a new "Hello World" project (CLR Console Application). If I right-click the project in the solution explorer, and select "properties", I get a "... Property Pages" window which shows a line entry for: Configuration Properties / C,C++ / General / Additional Include Directories. It also has a line entry for: Configuration Properties / Resources / General / Additional Include Directories. (Both lines are empty). If I go to the main menu, and select: Tools / Options / Projects and Solutions / VC++ Directories, and select "Show Directories for Include Files", I see another multiline …

Member Avatar
Member Avatar
+0 forum 1

Well I made it through my first semester of an MSCS. Almost. This summer I want to build a game. I am trying to understand a little bit of the history of Windows graphics and am a bit confused. There's WinAPI. There's OpenGL. There's DirectX. As I understand it, OpenGL was initially offered on NT platforms for high end engineering (CAD) apps and required high end (at the time) hardware. But isn't it a Unix based graphics library? So then some guys at Microsoft (Eisler, Engstrom, etc...) decided lower end PC's needed graphics libraries for games and introduced DirectX. Direct3D …

Member Avatar
Member Avatar
+0 forum 4

In XP, or from the DOS command line, is there a nice way to list the objects inside a .dll or .lib file.

Member Avatar
Member Avatar
+0 forum 1

In linear algebra a 1 by m array of (let's say integers) can be considered a vector (row or column). Given 2 row vectors of the same size, can they be compared using <,> ? If so, what relation between individual elements in the arrays is required for "less than" to be true? Is vector {2,3,3} < vector {2,3,4}... ...or does every element have to be less (i.e. {1,2,3} < {2,3,4} but not so for {2,3,3})

Member Avatar
Member Avatar
+0 forum 4

It's tough being 50 and back in college! If anyone has recently taken an Algorithm class, my question is this: Is the proof for Prim's algorithm any different than for Kruskal? I understand both algorithms are greedy in the sense of picking the least weight edge each itiration. Prims only adds the next least expensive edge that can connect to the existing, growing subtree, whereas Kruskal just picks the next least cost edge period, as long as it creates no cycles, so that eventually all subtrees connect. I am finding many proofs for Kruskal (e.g. Wikipedia), but trouble finding proofs …

Member Avatar
Member Avatar
+1 forum 1

I was a Unix, C, C++ programmer for 17 years then got out of IT during the 2001 dot com crash (to teach Junior/High School). Teaching was/is rewarding but I want to finish my working years in IT. I've been taking some steps (updating my training, etc...) to return to IT but am wondering if my age will be a barrier. I wanted to ask you code warriors out there if you have many fifty year old programmers in your IT groups? All I know is the few interviews I've been to, the hiring managers and programmers all look very …

Member Avatar
Member Avatar
+0 forum 8

The End.