On my Verizon iPhone 4S (CDMA), when WiFi is off or unavailable (but cellular connectivity might be available), the following will trigger a socket.gaierror error (which you could trap with a try: block):

Not sure about other models of iOS device, but on mine you don't have a resolvable IP address until you attempt to make a connection - so just querying your IP address information (which doesn't make a connection) fails. If you have a WiFi connection, you have a dedicated, always query-able WiFi IP address and the above code succeeds / doesn't return an error.

If the above code returns an error, then you can run the following to determine if you're connected to the internet (with 3G service but no WiFi):

As for Pythonista providing this kind of information directly via a custom class, omz would need to use some of this code: https://github.com/tonymillion/Reachability - which is a port of sample code that Apple wrote originally for iOS 4 to iOS 5+ compatible (with support for ARC/garbage collection).

This bit of code would allow Pythonista to directly query the device for what kind of connectivity options are present.

As for which WiFi network you're connected to, the available WiFi networks in the area, etc. - none of that is possible in iOS any more (in either python or ObjC). Apple removed all of the public and private frameworks for that.

That's why you don't see WiFi scanner apps in the app store any more. Apple a.) expressly prohibits them and b.) you literally and technically just can't write that kind of code in iOS any more.