This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Console output code
@cook no I mean like say you typed in a error into the console it'll say all of the red texted error I want the code for the output of the console (sorry if it confuses you)
If you want to change the console's text color and such, look at Pythonista's
If you want to know how Python displays error messages and tracebacks, look at the CPython source code (https://github.com/python/cpython). The
tracebackmodule source might be easier to understand though since it's written in Python.
Webmaster4o last edited by
@VIC3 It's still not clear at all what you mean.
@Webmaster4o if you have some way of me contacting you I can send you a picture of what I mean
ccc last edited by
@VIC3 Do you want to get the text that is printed to the console?
@VIC3 The forum allows posting images. Upload your image to an image hosting site like http://imgur.com/, then insert it into your post using this syntax:
Here take a look I typed the "/" at the top I want the code for the output (circled)
@VIC3 It would help a lot if you could post the code that you ran. But it looks like you used
pprintto print a tuple.
I'm still not sure what you mean with "the code for the output". You can just look at the source code of the script that you ran.
# coding: utf-8 import ui from objc_util import * import console import os import sys, traceback NSFileManager = ObjCClass('NSFileManager') UIDevice = ObjCClass('UIDevice') print 'Enter directory' path = raw_input() files = NSFileManager.defaultManager().contentsOfDirectoryAtPath_error_(path,None) print files @ui.in_background def file_browser(message): alert_result=console.alert(path,path,'Dismiss',hide_cancel_button=True) def back_console(sender): console.show_input() @ui.in_background def about(message): alert_result=console.alert('About', 'Project based off of Billy Ellis app called "iFiles" I take no credits for idea of this') def find_ios(sender): vers = UIDevice.currentDevice().systemVersion() string = str(vers) v = sender.superview label = v['label1'].text = string v = ui.load_view() v.present('sheet')
If you want to get a list of all files in a folder, use
os.listdir. It returns a normal Python
listthat you can work with as usual. There's no need to use
JonB last edited by
I think you need to use a few more words to explain your end goal!
You have used variations on "code for console output" a few times, and no one seems to know what you mean.... perhaps because your question might mean one of many things!
Code for console output might mean:
- How can I write some text to the console?
- How can I read what has already been written to the console?
- How can I figure out which piece of code produced the output that I see in the console?
- What code would I have to write to produce this specific output in the picture.
Do any of these summarize your question?
Do you want to know how to take the list of files and use it in something like a tableview rather than just printing it in the console?
I assume that's something you want to do, since you're basing your app idea off of iFiles. But this part isn't coded in your script yet...also we don't know what your UI looks like...
@cook Yes, exactly like iFiles by Billy Ellis here's the photo:
Alright I see. I've never used that app so I don't know! But anyway it's okay.
Can you tell us this (just for clarity sake...):
When you click on
browserin your UI, please describe what you want to happen.
@cook I want it to have the file directory popup ever time I click browser but the only that I already have it to show what I'm typing in I just want it to read the console output it gives you in the alert
I think I'm still a little confused. But let's see if this is right:
- You start your script
- You type in a path (
- The UI comes up
- You want
browserto show a file browser view using your
path*(quick way would be a tableview) *
If that's the case you first need to construct your data differently. You will need either a list or a dictionary to use for a tableview data source. Have you made a tableview before?
Did you try
os.listdirlike @dglessus mentioned?
#os.listdir takes a path argument my_file_list = os.listdir('../Documents')
Also: You could get
pathinput from a
console.input_alert()(a popup) rather than typing it into the console.