• JonB

    It seems to me you could also dispense with most of the long / short specific logic, and just compute the other edge, then figure out which one is the long vs short after the fact.

    posted in Pythonista read more
  • JonB

    If you just want to parse the HTML, use requests. Unless you need JavaScript to run I guess.

    @mikael isn't there a delegate that would let you filter by uri? I forget if the should_load_uri or whatever gets called for <img>'s -- in which case he could just return false for non-html urls.

    posted in Pythonista read more
  • JonB

    Btw, python is case sensitive -- so make sure you check case exactly.

    posted in Pythonista read more
  • JonB

    Sorry I should have mentioned you need to import os

    If you want to see what path your script is operating in, use os.getcwd()

    But when you got the play button pythonista sets the current path to the script path, so generally you can use open('filename') as long as filename is in the same folder as your main script.

    posted in Pythonista read more
  • JonB

    You can reinstall the app store version. Or just wait a few days, usually the tesflight version gets updated soon after it expires

    posted in Pythonista read more
  • JonB

    If you place your script and csv file in the same folder, you can usually just use local path names.

    A good way to debug this type of thing:
    In the console:

    print(os.listdir())

    The "My iPad" folder is
    os.expanduser(~/Documents)

    If you are trying to open a file in iCloud or external shared file, those work differently...

    posted in Pythonista read more
  • JonB

    Btw, you can of course define your own wrappers for sind/cosd (sin or cos in deg)!

    sind=lamda x:math.sin(math.radians(x))
    print(sind(90))

    posted in Pythonista read more
  • JonB

    Radians are much more natural when computing sin/cos's.

    sin(x) = x - x**3/3! + x**5/5! - .... 
    

    So, small angles are easy to work with in radians, because sin(x) = x. Also, from a beauty perspective, sin and cosine are defined this way -- using any other unit results in ugly equations, which therefore are less fundamental.

    Consider other branches of physics/engineering where you deal with oscillators/wave equations. There you have sins/cos's of other unitless quantities, such as frequency times time, or distance divided by wavelength -- things get really clumsy if everything must be defined in degrees.

    Degrees really only ever make sense when talking about geometrical things, though arguably "revolutions" is a more fundamental / intuitive concept..

    posted in Pythonista read more
  • JonB

    If you press the little + button that shows up in the editor (bottom right on iPad, just above keyboard), this lets you select images, sounds, or colors.

    posted in Pythonista read more
  • JonB

    See

    https://developer.apple.com/documentation/scenekit/scngeometryprimitivetype/scngeometryprimitivetypepolygon?language=objc

    @cvps code used polygon primatives -- so the data first has list of polygon lengths, then list of vertices making each face.

    If you want to make your cube out of squares, you would need 8 vertices (cvp has 6), then if you ordered the vertices going clockwise in the first plane, then clockwise in the second plane, then you would have

    [4,4,4,4,4,4, # six faces, each has 4 sides
    0,3,2,1# bottom face
    1,2,6,5,# right face
    2,3,7,6# back face
    3,0, 4,7# left face
    0,1,5,4 # front face
    4,5,6,7]

    Depending on how your order your vertices, it might be a little different for you.

    You'll want to make sure you provide indexes in a clockwise order for each face as viewed from outside, otherwise some of the faces will be considered inside faces, which might screw with lighting/shading or applying textures.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!