How to warn about class (name) deprecation

Maybe I could make OldClsName a function which emits a warning (to logs) and constructs the NewClsName object from its parameters (using *args and **kvargs) but it doesn’t seem elegant enough (or maybe it is?). Yup, I think that’s pretty standard practice: def OldClsName(*args, **kwargs): from warnings import warn warn(“get with the program!”) return NewClsName(*args, … Read more

Why is Python 3 not backwards compatible? [closed]

Is Python 3.0 backward-compatible and why? Python 3.0 implements a lot of very useful features and breaks backward compatibility. It does it on purpose, so the great features can be implemented even despite the fact Python 2.x code may not work correctly under Python 3.x. So, basically, Python 3.0 is not backward-compatible on purpose. Thanks … Read more

Weak Linking – check if a class exists and use that class

TLDR Current: Swift: if #available(iOS 9, *) Obj-C, iOS: if (@available(iOS 11.0, *)) Obj-C, OS X: if (NSClassFromString(@”UIAlertController”)) Legacy: Swift (versions prior to 2.0): if objc_getClass(“UIAlertController”) Obj-C, iOS (versions prior to 4.2): if (NSClassFromString(@”UIAlertController”)) Obj-C, iOS (versions prior to 11.0): if ([UIAlertController class]) Swift 2+ Although historically it’s been recommended to check for capabilities (or … Read more

Python’s many ways of string formatting — are the older ones (going to be) deprecated?

The new .format() method is meant to replace the old % formatting syntax. The latter has been de-emphasised, (but not officially deprecated yet). The method documentation states as much: This method of string formatting is the new standard in Python 3, and should be preferred to the % formatting described in String Formatting Operations in … Read more

Enabling auto layout in iOS 6 while remaining backwards compatible with iOS 5

Autolayout can be enabled or disabled on each .storyboard or .xib file. Just select the particular file and modify the “Use Autolayout” property using the File inspector in Xcode: Using autolayout enabled interface files with the deployment target set to an iOS version prior to 6.0 results in compilation errors, e.g.: Error in MainStoryboard.storyboard:3: Auto … Read more

How to install both Python 2.x and Python 3.x in Windows

I found that the formal way to do this is as follows: Just install two (or more, using their installers) versions of Python on Windows 7 (for me work with 3.3 and 2.7). Follow the instuctions below, changing the parameters for your needs. Create the following environment variable (to default on double click): Name: PY_PYTHON … Read more

Can I pass an array as arguments to a method with variable arguments in Java?

Yes, a T… is only a syntactic sugar for a T[]. JLS 8.4.1 Format parameters The last formal parameter in a list is special; it may be a variable arity parameter, indicated by an elipsis following the type. If the last formal parameter is a variable arity parameter of type T, it is considered to … Read more

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