You can use the following commands in the Pythonista 3 Python console to copy the folder back:
>>> import os, shutil >>> shutil.copytree(os.path.expanduser("~/Documents/foldername"), os.path.expanduser("~/../Documents/foldername"))
foldernameis the name of the folder you want to copy (assuming that it's in the root of Pythonista 3's local files). You can also use
shutil.copytreeif you want to move the folder rather than copy it (which may be a good idea if it's very big).
By the way, is there any reason in particular why you're still using Pythonista 2? Pythonista 3 supports both Python 2 and 3, so there's generally no need for Pythonista 2 if you have Pythonista 3. In fact Pythonista 2 can no longer be bought on the App Store and won't receive any more updates.
Warning: Unfortunately, this module no longer works on iOS 11 and later because the underlying APIs have been removed from iOS.
I don't think
sys.displayhookwould be very helpful here - it only affects how the final evaluated object is displayed, it does not change anything about how the typed-in Python code is executed. In particular,
If you want to affect
sys.stdoutwith a custom file-like object.
If you want to affect the code execution even more than that, you're probably better off writing your own REPL, perhaps based on the standard
codemodule or simply
eval. This lets you run the entered code in a different environment (by passing a dict to
eval) and you can even analyze and modify the code before it gets run (although that might be overkill depending on what you want to do).
There are two possibilities I can think of:
- Do you have a file called
numpy.pyin Pythonista? If so, you need to rename it - otherwise
import numpy as npwill import your
numpy.pyand not the standard
- Try restarting Pythonista (swipe up from the bottom of the screen to open the app switcher, then swipe Pythonista upwards to close it, then reopen the app). It is possible that the
numpymodule isn't loaded completely; this can happen if you stop your script while the
import numpystatement is running. By restarting Pythonista, you can bring the Python environment back into a clean state.
- Do you have a file called
Normal Markdown doesn't have any native syntax for underlining -
__underline__produces underline, i. e. bold text. In standard Markdown,
__bold__is equivalent to
_italic_is the same as
Chat applications like Discord, Slack and Mattermost support syntax that is similar to normal Markdown, but isn't completely compatible (they include some custom features that don't exist in Markdown, and don't understand all standard Markdown syntax). Discord's underline feature is an example of that.
@omz I just played around a little and found that
#LyXat the start of a Python script apparently guarantees
fileto recognize it as a LyX document, overriding all of the Python code detection patterns. I'm still on OS X 10.11, but I have a newer
fileversion (5.35) installed through MacPorts, so hopefully its behavior is close to the version that 10.14 has.
I don't quite understand how magic file entries are prioritized and why exactly this works. I'm guessing it's because the LyX pattern looks for a literal string at byte 0, whereas the "smart" Python code detection patterns do a string search over a byte range, so the LyX rule is preferred because it's simpler.
~/.magicis documented in the manpage of my MacPorts version of
file, but not in the OS X default version's manpage. Maybe it's just a version difference, in which case it should work on 10.14. A custom magic file would probably be the best solution, so we don't have to keep looking for new ways to trick
fileevery time they improve their Python patterns.
General question: Does the TestFlight Beta override the installed app or is this separated?
The beta replaces the App Store version. If you already have the App Store version installed and then install the beta through TestFlight, you'll get a warning message saying that you may lose your data - this is generally not the case for Pythonista. (I've been in the Pythonista TestFlight beta since the beginning, and installing a beta has never overwritten my data. But if possible you should make an iTunes backup beforehand, just in case.)
You can also go back to the latest App Store release at any time, by going into your purchases and redownloading Pythonista there. This will replace the beta version, but also leaves your data intact (except perhaps for features that were introduced in the beta).
Being an objc muddler myself, I am wondering why your method and selector do not need to have the trailing underscore/colon.
Objective-C's requirements about where to put colons are only enforced at compile time (they are a part of the language syntax). At runtime it doesn't matter if the colons match up with the method arguments (at that point everything has been translated to regular C function pointer calls), so the runtime never checks the selector names in any way. It's similar to how Python lets you say
setattr(obj, "funny attribute name!", 42), even though you can't use
funny attribute name!as an attribute in your source code.
The underscores in the function name do matter to
create_objc_class, it counts the number of underscores in the name to figure out how many parameters the method has. So even though
controlTouchEvent_sender_eventis not really a correct Objective-C method name, it has two underscores, which matches the number of arguments that the Python function takes (in addition to
_cmd), so the call works in the end.
I didn't even fully grasp how the parameters needed to be defined or named in my function...
The example method (
(IBAction)doSomething:(id)sender forEvent:(UIEvent *)event) would translate to
doSomething:forEvent:as a selector, or
doSomething_event_as a Python function name. Only the word to the left of each colon is part of the selector. The word to the right of each parameter type is the internal parameter name - this only matters if you're implementing the method in Objective-C source code, you can ignore it when translating the method name to
In this case it doesn't matter though what exactly the method name is. You only need to make sure that the underscore/colon count in your function name matches how many arguments the function takes, otherwise
objc_utilwon't call your function with the correct number of arguments.
IIRC block invoke functions take the block itself as an implicit first argument (basically likeNevermind,
self). So you probably need to add an extra
InvokeFuncType's argument list, and add
blkas the first argument in your
blkboth refer to the block.
Also, regardless of whether I like Reddit or not, there are a few things that I think should be considered before moving the community to Reddit:
- @omz You should probably get in touch with the /r/Pythonista moderator and see if you can also become a moderator. (Might be a good idea to mention your Reddit username in a post here, so they can verify that it's actually you contacting them on Reddit.)
- What happens with the existing forum posts? Reddit doesn't support "importing" content, and automatically reposting all forum threads onto Reddit wouldn't work well (everything would be under one account, linear forum threads don't translate well to Reddit's tree-style replies, and this sort of mass posting would probably be considered spam). I suppose the existing threads could be converted to static pages and hosted in place of the forum.
- Could the community be realistically migrated off of Reddit again? Of course there's no "export" feature either, so the content would need to be downloaded some other way (I'm sure there are already tools for that). However there would be no way to redirect old links to the new location.
Also, another thing about Reddit that I forgot to mention in my previous post: after some time, Reddit posts are "archived", which means that they can't be voted or commented on anymore. This would be a problem for threads that are not updated often (for example threads about a specific project that are only updated when a new version is released). I don't know how exactly the archive mechanic works though - if the archive delay is based on the initial post date or the last comment date, or if it can be changed or disabled by moderators in any way.