What does the slash mean when help() is listing method signatures?

It signifies the end of the positional only parameters, parameters you cannot use as keyword parameters. Before Python 3.8, such parameters could only be specified in the C API. It means the key argument to __contains__ can only be passed in by position (range(5).__contains__(3)), not as a keyword argument (range(5).__contains__(key=3)), something you can do with … Read more

Differences of using “const cv::Mat &”, “cv::Mat &”, “cv::Mat” or “const cv::Mat” as function parameters?

It’s all because OpenCV uses Automatic Memory Management. OpenCV handles all the memory automatically. First of all, std::vector, Mat, and other data structures used by the functions and methods have destructors that deallocate the underlying memory buffers when needed. This means that the destructors do not always deallocate the buffers as in case of Mat. … Read more

Can I get parameter names/values procedurally from the currently executing function?

I realize people linked to other questions which mentioned PostSharp, but I couldn’t help posting the code that solved my problem (using PostSharp) so other people could benefit from it. class Program { static void Main(string[] args) { Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); new MyClass().MyMethod(44, “asdf qwer 1234”, 3.14f, true); Console.ReadKey(); } } public class MyClass { public … Read more

When a method has too many parameters? [closed]

There is no clear limit, but I am uncomfortable with more than 3-4 parameters. AFAIR Uncle Bob Martin in Clean Code recommends max 3. There are several refactorings to reduce the number of method parameters (see Working Effectively with Legacy Code, by Michael Feathers for details). These come to my mind: encapsulate many related parameters … Read more

How do I call New-Object for a constructor which takes a single array parameter?

This approach to using new-object should work: $cert = new-object System.Security.Cryptography.X509Certificates.X509Certificate ` -ArgumentList @(,$bytes) The trick is that PowerShell is expecting an array of constructor arguments. When there is only one argument and it is an array, it can confuse PowerShell’s overload resolution algorithm. The code above helps it out by putting the byte array … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)