• zrzka

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

    posted in Pythonista read more
  • zrzka

    Basically all modules listed here are not available outside of Pythonista. There's no repository, source code, package in PyPI, ... It has no sense, because they're Pythonista specific. If you'd like to run your script on Mac, you have to provide your own sound module with functions you do use in Pythonista.

    I was thinking about new project providing compatibility layer for Mac, because I was tired of patching, mocking, ... (Sphinx, Travis CI, ...) But then I realized that almost all build / CI / ... servers I do use are running GNU/Linux. One layer for Mac, another one for GNU/Linux, ... Decided not to do it, it's not worth it.

    You should check PyObjC If you'd like to leverage existing macOS frameworks, which gives you bidirectional bridge between Python and ObjC world. If you'd like to just play sound, it can be as simple as calling afplay /path/to/your/sound/file from the Python.

    posted in Pythonista read more
  • zrzka

    Hi @ETPH. Couple of generic advices:

    • Do not use magic constants in your code (like position_options) in multiple places, it's a nightmare when you want to change them. Move them outside of create_tile, touch_began and reuse them there. Like MARGIN_OF_ERROR.
    • Keep your functions / methods short. It's good when they can fit one screen (well, depends how the screen is big :), but you know what I mean. Not a hard rule, but it's about readability and crunching all these bugs quickly. It's easier when it's short. touch_moved is very long and overly complicated.
    • You shouldn't hardcode positions based on your device in case you want to run it on iPhone SE for example.
    • Split your task into several smaller ones. Replace one huge function with many small ones doing just one thing. Again, readability & easier way how to spot a bug.

    I didn't dive into your touch_moved method, sorry. But I did quickly hack an example of generic board & moving tiles. You can find it here.

    posted in Pythonista read more
  • zrzka

    @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

    posted in Pythonista read more
  • zrzka

    Same here, no emails. //cc @omz

    posted in General Discussion read more
  • 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>

    posted in Pythonista read more
  • zrzka

    @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 :)

    posted in Pythonista read more
  • zrzka

    Here's a simple document describing how to ask a good question and why it is so important to include as many details as possible. I still feel that some people don't understand it and it's a good thing to have kind of reminder. Would be nice to have something like this as sticky topic (like Slack topic).

    Forum

    This forum is not a paid support. Pythonista, Editorial, ... is developed by @omz - single person. Ole tries to help everyone here, but day has 24h and he is not simply capable to answer all questions. He's fixing bugs, working on new features and also he has a life outside of Pythonista and Editorial.

    We have a lot of volunteers trying to help as well. These people are doing it for free, in their spare time, ... and they decide if they're going to help or not. This decision is based on a lot of things - your attitude, time you spent on your problem, attempts you made, ... You're going to receive help if you're polite, if you show some work to solve your problem, ... It's up to you. These people invest their time, you should invest yours into detailed description of your issue at least.

    Another important fact is that these volunteers live around the globe. You can have morning, but people capable to solve your issue can be in bed, ... Always think about this and wait for 24h before you ping your topic again, ... I can write a comment at 11pm, go to bed "in the middle of conversation" and you can feel I left you. That's not the truth, I just did go to bed for example. Others will help or I'll when I wake up.

    And the last thing is English language. It's not that hard language like Czech, Chinese, ... for example, but no one's perfect and there're different levels of English around. Keep this in mind, some sentences can sound as a personal attack, but it can be just something like not a very good knowledge of English, ...

    People are going to help, they really do, but they have a freedom to choose in what thing they're going to invest their time. Be polite, don't use words like hell, stupid acting python ide, ... if you're seeking for help.

    Short version

    What you should provide?

    • Device, iOS version, Pythonista version
    • Explain what you're trying to achieve, what's your goal
    • Attach your complete project, not just part of it
    • Include all related testing data (input files, ...) as well
    • Include complete traceback if it crashes
    • Do not try to summarise any of it, you can make a mistake

    Do I have to include everything every single time I ask? Well, it depends on the problem you're trying to solve. It's not necessary sometimes. Just stop for a while, think about it and provide whatever you think it's necessary. More is always better than less.

    Longer version

    Device, iOS version, Pythonista version

    There're differences in iOS behavior when it comes to devices like iPad vs iPhone. Same applies to different iOS versions on the same device. And same applies to different Pythonista versions on the same device and iOS.

    You should update Pythonista to the latest available version before you ask your question. Issue can be solved in the newest version.

    Because of all these things, you should include device information, iOS version and Pythonista version. It's more important in bug reports, but can help with your issue as well.

    Explain what you're trying to achieve, what's your goal

    It happens and it's not so rare. Sometimes people tend to use wrong tool a.k.a. module, approach, ... You can learn new things, get better answer / solution if you explain what you're trying to achieve.

    Attach your complete project, not just part of it

    What is a project in this context? Everything what is related to your problem. It can be single script or bunch of scripts (modules), input data (files, images, ...). It's always good to attach example one can run and which shows symptoms you're trying to solve. It leads to a quicker solution.

    It's not so rare that your issue lies elsewhere than you think. You can have two functions, trying to solve why the second one doesn't work, you paste it here and the problem can be in the first one for example.

    Also Pythonista behaves differently when your script is saved in This iPad, in site-packages, ...

    Don't try to be smart, don't hide what you did, don't feel ashamed, no one's perfect. Everyone's making mistakes. I made lot of them during my career and some of them were kind of fatal. It's a life, never ending learning process.

    Or you can create a Minimal, Complete, and Verifiable example as @dgelessus did point out in the comments below.

    Include all related testing data (input files, ...) as well

    To reproduce your problem we need your input data. Because your script can work with another set of input data. Again, this is not rare. Algorithm can be written in a wrong way and it can work when we're going to test it - input data differs - yours and ours.

    Yes, it's pretty clear what's the issue sometimes. But sometimes not, can be nasty one. Less information you provide, more time it takes.

    Include complete traceback if it crashes

    The worst thing you can do is to summarise traceback with your words. Never do this. Attach verbatim copy of it.

    Do not try to summarise any of it, you can make a mistake

    If you're not able to solve your issue, you're likely going to make a mistake in your summary as well. Code, traceback, input data, ... Please, don't do this, it just slows things down. Reproducibility and accurate info is crucial. Remember what I wrote about volunteers living around the globe? If you do not include precise description it can prolong solution for several days. We're going to ask, then bed, you'll answer, but we're sleeping, ...

    Invest some time, because you're asking us to invest our time to solve your problem. Answer questions we ask even if they sound like completely unrelated ones to you. They can lead to a solution you don't see yet.

    How to

    Code in the post

    Forum supports Markdown and you can include code in this way:

    Three backticks alone or followed by python, json, ..., your code and another three backticks. You'll get nicely formatted, highlighted, ... code, json, text, ...

    Share via Gist

    Create GitHub account and follow instructions. Do not update Gist when you already linked it here in the forum. Do you want to show something new you just did? Create another one.

    Gist is preferred for longer code, one gist can have multiple files, ...

    Attach image

    It's also helpful to attach an image sometimes. Unfortunately, forum doesn't support image uploading. You can upload image to any service and just paste link.

    If you want to include it in the post (not just link) do it via Markdown:

    ![](http://some-link-to-an-image)
    

    In case of Dropbox, copy image link, replace dl=0 at the end with raw=1:

    ![](https://www.dropbox.com/s/eolt6blu2pndow1/forum-expand-error.jpeg?raw=1)
    

    Traceback

    Do you see something like this? Tap on the expand button.

    Tap on the Print Traceback row.

    Close exception overlay and copy & paste the whole traceback here. Use three backticks.

    Unsure what to copy? Clear console, reproduce your problem again and copy & paste whole console. You'll known that you're going to copy & paste relevant information only.

    Conclusion

    I wrote this, because I see that people are doing same mistakes again and again. I'm not forcing anyone to follow these instructions. If you do, you'll receive help more likely. If you don't, it's your problem which is not going to be solved. Think about it. Get a life now, go and grab some beer :)

    posted in Pythonista read more
  • zrzka

    It's not a Pythonista issue, but something's wrong with your Password.py script. What you see is an exception & traceback - Python feature. Attach your script. Forum supports Markdown and you can use three backticks to format your code for example. Also you can include images in your posts in this way:

    ![](http://some-link-to-image)
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!