Help: Pythonista doesn't have same output as IDLE?
I downloaded Pythonista on my iPad for a college course I'm taking, figuring it would be an easy way to fit my assignments into my workflow. Up comes an assignment where we have to align multiple lines of code.
First issue, but one that isn't too relevant here, but maybe someone can help anyway, is I can't do multi-line strings in Pythonista (so it appears). Second, and bigger, problem is that Pythonista's command line output differs greatly from IDLE's. My teacher graded my assignment and told me that my lines are all out of line and I got docked for it when in Pythonista it was perfectly in line.
My question is, why is Pythonista not basically a copy of IDLE and how can I work around it (if there is a workaround) using only my iPad?
Do you have an example of the Pythonista vs IDLE output? (a sequence of commands and what it is supposed to look like vs what it does look like?)
Is your assignment to run a script, and take the printed output from the console and copy it to a text file? Or type interactive commands in the console? (In which case you want the >>>'s?)
How are you copying your text from the pythonista console? Are you just copying it into a .txt file in pythonista? Or into an email or something?
Copying from pythonista console to a pythonista text document ought to work. Copying into another app probably might screw with spacing, especially if not using a fixed spacing font.
If you are trying to replicate IDLE output, you might be able to write a little program that takes a line at a time of a file, outputs the >>>'s and redirects stdout. Let us know what you are trying to actually achieve.
@SkiNoCap btw, you can do multiline strings in the editor. Likely, you cannot do them in the console (although triple quoted string might...I forget)
@JonB the assignment required a .py file which would, when run in IDLE, output a business card-esque ASCII style image. I posed the same question over on StackOverflow and I was directed to use spaces instead of tabs (which are different sizes in different places), which did work (in Pyto and Pythonista at least, don't have access to IDLE currently). I have been using the text editor to create my files, not the console.
Here is a copy of my original code with tabs:
print("+------------------------------------------------+") print("| |\t\t\t |") print("| -|\t\t\t Zielinski, Michael |") print("| --|\t\t\t Tribute Liabilities Associate |") print("| ---|\t\t\t Parasail Capital |") print("| ---------\t |") print("| -------\t 4 Hunger Plaza |") print("|\t\t\t\t STE 1400 |") print("|\t\t\t\t District 12, Panem 00012 |") print("|\t\t\t\t |") print("| Work: (406)-214-1165\t@: email@example.com |") print("+------------------------------------------------+")
@JonB also is there a way to edit the tab sizes in Pythonista? I'm am really new to programming, as I've said, and don't really know all the features.
ccc last edited by
I was directed to use spaces instead of tabs
That is always a good idea in Python.
@SkiNoCap in the settings menu, keyboard and indentation, you can control whether pythonista uses tabs or spaces when hit tab, and whether to use 3 or 4 spaces.
Tabs are good for retaining semantic meaning, but not great for actually formatting with a specific format in mind. In other words, tabs are good for storing data, but usually not for display.
The idea of tabs for indentation is good -- similar to the way xml allows for device independent storing of data, which can then be rendered in a way that makes sense (say, small devices could use smaller spaces, or formatting into tabular format, etc)
But the reality is that many editors don't properly support tabs, and it is usually hard to tell the difference between spaces and tabs, so your safest bet is to set pythonista to replace tabs with 3 or 4 spaces depending on your aesthetic.