Source Network:
Public Static String Getmethodinfo (){ String STR = "" ; // Get the namespace of the current method STR + = " Namespace Name: " + System. reflection. methodbase. getcurrentmethod (). declaringtype. namespace +" \ N " ; // Obtain the full name of the current method class, including the namespace STR + = " Class Name: " + System. reflection. methodbase. getcurrentmethod (). declaringtype. fullname + " \ N " ; // Get the current method name STR + = "
_ RSEEUpdate. Why?}}}
In addition, we note that many classes have added a static constructor with the same content, as shown below:[MethodImpl (MethodImplOptions. NoInlining)]Static WebGrid (){}This constructor is called only when this class is used for the first time. The function is to backfill the extracted parts of the class to the assembly in the memory.
It is obvious that before each class is used for the first time, the static constructor is called to call method-1 () and method-2 (), th
and better than concealed ".Import thisYou can see the complete content.
The discussion here lists examples of each principle (http://stackoverflow.com/questions/228181/zen-of-python)
DirFunction
You can useDirThe function lists all identifiers defined by an object. For example, for a module, identifiers include functions, classes, and variables.
When youDir ()A function provides a module name that returns all the names defined in it.
WhenDir ()If the parameter is null, all names defined in th
identifiers defined by an object. For example, for a module, identifiers include functions, classes, and variables. When you provide a module name for the Dir () function, it returns all the names defined in it. If the Dir () parameter is null, all names defined in the current module are returned.
For example:
C: \ Users \ Administrator> pythonpython 3.2.2 (default, SEP 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32type "help", "Copyright ", "Credits" or "License" for more informa
to call the method. Therefore, you can trace the instance stack (do not forget to include system. diagnostics) and get the first index value of the frame, get a call from the call method corresponding to stackframe, and finally use reflection to get the method name.
01: using System.Diagnostics;02: 03: void Log(string eventMessage)04: { 05: 06: Console.WriteLine("Event logged by " + (new StackTrace()).GetFrame(1).GetMethod().Name); 07:
WriteToFile(ByVal Log As String) Dim clsName As String = "" Dim mtdName As String = "" Dim lnNo As String = "" Dim codeFilePath As String = "" Dim st As New StackTrace(True) If st.FrameCount > 1 Then Dim sf As StackFrame = st.GetFrame(1) mtdName = sf.GetMethod.Name Debug.WriteLine(mtdName) clsName = sf.GetMethod.ReflectedType.Name Debug.WriteLine(clsName) lnNo = sf.GetFi
How to record detailed call stack logs in Python
This example describes how to record detailed call stack logs in Python. Share it with you for your reference. The specific implementation method is as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
Import sys Import OS Def detailtrace (info ): RetStr = "" Curindex = 0 F = sys. _ getframe () F = f. f_back # first frame is detailtrace, ignore it While hasattr (f,
, 'outerposition', get (0, 'screensize'); % matlab window maximization frame = getframe (gcf ); im = frame2im (frame); % create a gif file. The image must be an index image [I, map] = rgb2ind (im, 20); if I = 1 imwrite (I, map, 'baidujing Yan.gif ', 'gif', 'loopcount', inf, 'delaytime', 0.5); % creation required for the first time! Elseif I = stepall else ', 'gif', 'writemode', 'append', 'delaytime', 0.5); else imwrite( I ,map,'baidujingyan.gif', 'gif
content to the address bar and press Enter:
Javascript: str = '
This code automatically checks the webpage. If a frame (including iframe) is embedded, the page Link in the frame is automatically displayed. Otherwise, an empty page or no response is displayed. Click the link to go to the corresponding page.
To ensure universality, the above Code only checks the first frame, which is not a problem for iframe, because there are not several normal people who will play nested iframe; but for normal
layout File
Img. setBackgroundResource (R. drawable. cwj_animation); // xml file defined by the animation
AnimationDrawable frameAnimation = (AnimationDrawable) img. getBackground (); // constructs the AnimationDrawable object
FrameAnimation. start () // start playing the animation
3. The AnimationDrawable class also provides some common methods as follows:
Void stop () stop
Void addFrame (Drawable frame, int duration) adds a frame, similar to the layout in xml
Drawable
the previous blog)
Let's take a look at the Magic Code below:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1 import sys
2
3 class TailRecurseException:
4 def _ init _ (self, args, kwargs ):
5 self. args = args
6 self. kwargs = kwargs
7
8 def tail_call_optimized (g ):
9 """
10 This function decorates a function with tail call
11 optimization. It does this by throwing an exception
12 if it is it's own grandparent, and catching such
13 exceptio
type objects, such as len, dir, getattr, and int, str, and list objects. Because of this, we can directly use the len function in the code, because according to the LEGB rules, we can__builtin__Module. Almost identical Process CreationsysModule and__main__Module. Process object after creationinterp->builtinsWill be set__builtin__The md_dict field of the module, that is, the dictionary field in the module object. Whileinterp->sysdictThe md_dict field of the sys module.
After the sys module is in
event for a specific property that has changed.
Tip: This method is virtual, which allows you to add additional steps in processing as needed. In addition, this means that you can overwrite this behavior as needed to track dirty data at the domain level.
By passing the attribute name as a string, calling the propertyhaschanged () method means hard encoding of the attribute name in the code. As we all know, string text is very difficult to maintain, so there is a reload that automatically co
net_dvr_realplaynetclose: Case exception_preview: break; default: break;} return ;}
Decfunction:
Here, decfunction completes the function of transferring decoded data. In the parameter, nport identifies the camera port, pbuf indicates the stream data, and the rest is the stream attributes ~Drawself indicates whether to obtain RGB data or grayscale data. Yv12toyuv completes converting yv12 into yvu data. It's not much to say about coding ~G_camoperate [pwndindex]. insertframe (pimg); // a m
The following website provides a free very useful GIF animation processing source code: http://www.fmsware.com/stuff/gif.html
Easy to use:
* Break down GIF:* Gifdecoder d = new gifdecoder ();* D. Read ("sample.gif ");* Int n = D. getframecount ();* For (INT I = 0; I * Bufferedimage frame = D. getframe (I); // frame I* Int T = D. getdelay (I); // display duration of frame in milliseconds* // Do something with Frame*}
* synthesize GIF: * animated
** kwargs parameter is used. In addition, if co_flags 0b100000 (0x20 )! = 0 indicates that this is a generator function ).
co = cat.sayHi.func_codeprint co.co_argcount # 1print co.co_names # ('name',)print co.co_varnames # ('self',)print co.co_flags 0b100 # 02.9. stack frame)
Stack frame indicates a frame in the function call stack when the program is running. A function has no attribute to obtain it, because it is generated only when the function is called, and the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.