omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    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.


    How to ask a good question

    Pythonista
    8
    29
    18742
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dgelessus
      dgelessus last edited by

      Nicely written @zrzka!

      For image uploads I would suggest Imgur (https://imgur.com/), since it provides all essential image hosting features for free without requiring a login - you can even delete images uploaded anonymously (you get a special link for that after the upload).

      Although using Dropbox works, I don't think it's a very good place to host images. Once you use Dropbox to host an image, you have to keep it around in your files, or the link will break. Even if it's "just" for a support thread, broken images/links are a pain for people who read the support thread later because they have a similar issue. Also, on iOS the Dropbox app has this "feature" where any Dropbox link is opened in the app rather than the browser. This isn't a problem for embedded images, but with regular links it's quite annoying.

      About posting the complete code with which the problem happens - I agree that you shouldn't leave out important info, but posting the entire code isn't always good either, especially when it's a lot of code across multiple files. If possible, try to narrow down where in your code the problem happens, and post only the code needed to reproduce the problem - this is called a minimal, complete, and verifiable example. Doing this makes it much easier for others to help, and in the process you might even figure out the problem on your own.

      One other thing... we all agree that this person that you're linking to wasn't very nice, but I think they got the message. There's no need to keep bashing them, it's not going to make them a better person.

      mikael 1 Reply Last reply Reply Quote 3
      • zrzka
        zrzka last edited by

        @dgelessus good point with the minimal, complete and verifiable example. Thanks for it.

        I'm not bashing anyone, just linked it as an example (removed the link from the post few seconds ago). Tried to help even when these words were used :)

        Matteo 1 Reply Last reply Reply Quote 1
        • JonB
          JonB last edited by

          Idea for either a future pythonista enhancement, or an executable url:
          An "Ask For Help" script/action which has the following options:

          • Attach last traceback(or, allow user to copy/paste) and/or faulthandler trace
            * Attach current script (or select files to attach)
            * Select images to attach
            * Asks for detailed description, along with hints on how to write a good question.
            * Automatically includes pythonista and ios version

          All of this gets formatted to a forum post (using pythonista gist settings, and anonymous imgur for files/images). Ideally this would live in a separate area in the forum. We could even auto-answer or link to common threads for common problems (*$&# enum.py!), maybe even explain a few exceptions ("I see you have an AttributeError. You were trying to access an attribute called xxx on an object of type yyy, but no such attribute exists. Here is a link to some debugging ideas to try first".)

          1 Reply Last reply Reply Quote 3
          • Matteo
            Matteo @zrzka last edited by

            @zrzka Very good explanation, thank you!
            Writing to this forum, I ask two things:

            1. with Markdown can we change image dimensions directly inside the command ![(http://some-link-to-an-image)? I've noticed that the images I post here are too large.
            2. Often I read Pythonista forum via Safari in my little iphone: sometimes I need to copy an entire code posted by users but I can't find easy to select the full text of the codes/scripts in the forum. Do you know some other ways to quickly select (with Safari or Pythonista web browser) only all text between </> in order to copy the full script in clipboard (then it is easy to paste in a new Pythonista script)?

            Thank you
            Regards

            JonB 1 Reply Last reply Reply Quote 0
            • zrzka
              zrzka last edited by zrzka

              @Matteo

              Re 1 - There're many extensions doing this, but I don't know if NodeBB supports it. Search for them and try. I doubt that it will work.

              Re 2 - Little bit of scripting, but doable.

              Let's say you have a topic with URL like https://forum.omz-software.com/topic/4622/notification-module-api. Every comment starts with a line like Phuket2 posted a day ago. When you tap on a day ago, URL changes to https://forum.omz-software.com/topic/4622/notification-module-api/6. And now:

              • You can prepend /api to get JSON
              • /6 is a post number starting from 1, so, the index is 6-1=5

              JSON response contains posts, which is an array of dictionaries and every dictionary has key content. You have a content now. You can get <code>xxx</code> via regex CODE_PATTERN = re.compile('\<code.*?\>(.*?)\<\/code\>', re.MULTILINE | re.DOTALL).

              Here's code with fixed URL inside:

              UPDATE: <snip>...see gist in following post, removed code & sample just not to clutter this topic...</snip>

              1 Reply Last reply Reply Quote 2
              • zrzka
                zrzka last edited by

                @Matteo decided to make your life easier :) https://gist.github.com/zrzka/7fc25156da0714daa9aa79a17898da2f

                Matteo 2 Replies Last reply Reply Quote 1
                • Phuket2
                  Phuket2 last edited by

                  @omz, not sure if you can have more than one post pinned in a forum or not. But it seems to me that a consolidation of this post pinned to this forum would benefit everyone. The shame is that in a week or so, this post will get swallowed up with all the other posts. If you dont want to pin it in this forum, maybe in the General Discussion. Even if new users dont see it, it can be easily found and new users can be directed to read it to help themselves when popsing questions here.
                  Just my 2 cents worth

                  1 Reply Last reply Reply Quote 1
                  • mikael
                    mikael @zrzka last edited by

                    @zrzka, impressive, as always.

                    I would add, at the very top, that before even asking the question, you should always search for a solution with Google or other preferred external search engine, and including the word ”Pythonista” in your search.

                    As well as checking Pythonista-Tools first for some reference implementations.

                    +1 for sticking this thread.

                    1 Reply Last reply Reply Quote 0
                    • Matteo
                      Matteo @zrzka last edited by

                      Hi @zrzka , sorry for delay, thank you very much for your help! I surely will try your procedure next weekend to make easier to copy and paste in a new Pythonista script a full script posted by any user in this forum using browser. I find a lot of useful scripts or pieces of code here.

                      It would be useful for any Pythonista user to have an updated first post written by you with new info about using this forum (practical info). The new info that any user can add in this thread with his/her personal post based on personal experience could be examinated and maybe, if correct and useful, added to your first post, in order to have always an updated first post about state of art in pythoning with Pythonista.
                      I'm agree with you about having this thread always in the first/second position from top in the forum, for fast reading.

                      Thank you,
                      Regards
                      Bye

                      1 Reply Last reply Reply Quote 0
                      • enceladus
                        enceladus last edited by enceladus

                        getting a copy of the code from a forum-post ( code from omz)
                        https://forum.omz-software.com/topic/2022/a-copy-code-button-here-in-the-forum/4

                        1 Reply Last reply Reply Quote 0
                        • mikael
                          mikael @dgelessus last edited by

                          @dgelessus, went to imgur, and it seems that login is now needed?

                          1 Reply Last reply Reply Quote 0
                          • dgelessus
                            dgelessus last edited by dgelessus

                            @mikael At the top of https://imgur.com/ there is a "New post" button, when you tap it you get an upload dialog that doesn't require a login. If you're not on a regular computer, you probably get the mobile site by default, which is useless and just wants you to download the app. In that case reload the page in desktop mode (in Safari, you can long-tap on the reload button to get the desktop site option).

                            mikael 1 Reply Last reply Reply Quote 1
                            • mikael
                              mikael @dgelessus last edited by

                              @dgelessus, thanks. Still, on the phone, I have so far not found out how to get the actual link to just the picture.

                              1 Reply Last reply Reply Quote 0
                              • zrzka
                                zrzka last edited by

                                @mikael check this https://gist.github.com/zrzka/b61c74975c777a77232035a3e171337d

                                • Follow instructions above line 21 to get an client ID
                                • This script can be run from the Pythonista or you can add it to share extensions and run it from Photos for example
                                1 Reply Last reply Reply Quote 0
                                • Matteo
                                  Matteo @zrzka last edited by

                                  Hi @zrzka, I'm trying to follow the steps you have suggested me and I discovered a new feature of Pythonista never tried before (sorry for my ignorance): user can create a script that can executes some operations on a web page or other files through "Share Extension Shortcuts"!

                                  I have a little problem with the code forum-post-copy-code.py

                                  Info:

                                  1. iOS=10.3.3
                                  2. Pythonista = 3.1 (301016)
                                  3. I'm following the steps in this link
                                  4. I obtain an error:
                                  File "/private......../forum-post-copy-code.py", line 17 
                                     raise ValueError(f'{url} does not point to the Pythonista Forum)
                                  SyntaxError: invalid syntax
                                  

                                  Can you kindly help me to solve this?
                                  Thank you
                                  Regards

                                  1 Reply Last reply Reply Quote 0
                                  • zrzka
                                    zrzka last edited by

                                    @Matteo update to 3.2 & use 3.6 as default interpreter (the error is about f strings).

                                    Matteo 1 Reply Last reply Reply Quote 0
                                    • dgelessus
                                      dgelessus last edited by

                                      @zrzka If I remember correctly, @Matteo said in another thread that he isn't able to update, because of the Python 2 matplotlib crashes in 3.2.

                                      If the f-strings are the only issue, you can probably translate them to format calls by hand, which work on any Python version since 2.6 or so. For example, f"{url} does not point to the Pythonista forum" would become "{} does not point to the Pythonista forum".format(url).

                                      1 Reply Last reply Reply Quote 1
                                      • Matteo
                                        Matteo @zrzka last edited by

                                        @zrzka Hi, ok it is a problem related to version of Pythonista, but @dgelessus is right: for now I'm happy with 3.1 version so no need to upgrade.
                                        I understand that there is a solution for my problem without upgrade. Can you (@zrzka , @dgelessus or someone else) kindly show me how can I modify the rest of the script in order to not obtain errors related to f-string? In other words can you provide a modified version of the script working with python 2.7.12?

                                        Thank you for help
                                        Regards

                                        1 Reply Last reply Reply Quote 0
                                        • JonB
                                          JonB @Matteo last edited by JonB

                                          @Matteo An approach to enable fstrings in 3.1:

                                          In stash:
                                          pip install tokenize_rt

                                          Then, Download future_fstrings.py, and install into site-packages-3.

                                          Create usercustomize.py in site-packages-3, which includes

                                          import future_fstrings
                                          future_fstrings.register()
                                          

                                          (Iirc, pythonista_startup doesnt get executed by the extension, but usercustomize.py does)

                                          Finally, add

                                          # -*- coding: future_fstrings -*-
                                          

                                          to the top of any file where you want fstrings enabled, such as zrzka's script.

                                          Matteo 2 Replies Last reply Reply Quote 1
                                          • Matteo
                                            Matteo @JonB last edited by Matteo

                                            Hi @JonB, thank you for suggestion! I will try your procedure.

                                            @enceladus thank you for showing me an other way to do what I ask: when I will be able to use @zrzka script with python 2.7.12 by trying to copy the code here (as you suggest) in clipboard, I will try also the @omz script!

                                            Regards

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Powered by NodeBB Forums | Contributors