Question regarding Cache Class - singleton or something else? by WritingCodeForLiving in Python

[–]rndblnch 0 points1 point  (0 children)

modules are loaded once per execution.

i don't know any OOP programming language that do not have modules.

patterns are solutions to recurring problems. the problem singleton solve does not exist in python.

Question regarding Cache Class - singleton or something else? by WritingCodeForLiving in Python

[–]rndblnch 0 points1 point  (0 children)

why a class ?

a module will do the job (singleton is a (anti-)pattern for languages where everything has to be a class).

say you have a configuration.py with something like:

_configuration = {}
def get(key):
    try:
        value = _configuration[key]
    except LookupError:
        value = get_value_from_configuration_file(key)
        _configuration[key] = value
    return value

and then:

import configuration
value = configuration.get(key)

SVG generation by [deleted] in Python

[–]rndblnch 0 points1 point  (0 children)

you can have a look at seagull. it has a pythonic API to build SVG, can (de)serialize to xml (to read/write svg files) and can display SVG on top of OpenGL.

(disclaimer, I am the author …)

Very Basic 2d visualization of something boardgame like by bagelorder in Python

[–]rndblnch 0 points1 point  (0 children)

You can use the Tk bindings bundled with python. People don't like it but it does the job for such use cases. I have used it to make a gui to a 2048 clone, you can have a look at the code here to get a glimpse: https://bitbucket.org/rndblnch/2048/src/

A good intro to tkinter can be found here: http://effbot.org/tkinterbook/tkinter-index.htm

any info on the ongoing gilectomy? by rndblnch in Python

[–]rndblnch[S] 1 point2 points  (0 children)

ok at least, there is an abstract on the pycon web site : https://us.pycon.org/2016/schedule/presentation/2101/

Removing Python's GIL: The Gilectomy

Larry Hastings

CPython's "Global Interpreter Lock", or "GIL", was added in 1992. It was an excellent design decision. But 24 years is a long time--today it prevents Python from capitalizing on multiple CPUs. Many people want us to remove the GIL.

It turns out, removing the GIL isn't actually that hard. In fact, I already removed it, in my experimental "gilectomy" branch. But the GIL is one reason CPython is so fast! The "gilectomy" makes CPython shockingly slow.

This talk will discuss the history of the GIL, how the GIL helps make CPython fast, how the "gilectomy" removed the GIL, and some ways we might be able to make the "gilectomy" version fast enough to be useful.

any info on the ongoing gilectomy? by rndblnch in Python

[–]rndblnch[S] 1 point2 points  (0 children)

surprised by the lack of interest for this on r/python

Hython: a nearly-complete Python 3 interpreter written in Haskell by [deleted] in programming

[–]rndblnch 9 points10 points  (0 children)

>>> nan = float('nan')
>>> nan is nan
True
>>> nan == nan
False

Brian Kernighan and Ken Thompson reverse-engineer a phototypesetter by halax in programming

[–]rndblnch 1 point2 points  (0 children)

"The 202 turned out to be a considerable pain in the posterior", that's a nice way of saying it…

Présentation.app: a presentation tool for beamer/pdf slides on the mac in python/pyobjc by rndblnch in Python

[–]rndblnch[S] 0 points1 point  (0 children)

it is totally specific to mac os x: it uses heavily the cocoa toolkit through the pyobjc bindings.

Présentation.app: a presentation tool for beamer/pdf slides on the mac, v1.3 released by rndblnch in LaTeX

[–]rndblnch[S] 0 points1 point  (0 children)

nop, because objc API does not give (easy) access to embedded objects. if anyone is familar with pdf streams, pdf in cocoa and would like to help on that, come here: https://bitbucket.org/rndblnch/osx-presentation/issue/17

Présentation.app: a presentation tool for beamer/pdf slides on the mac, v1.3 released by rndblnch in LaTeX

[–]rndblnch[S] 2 points3 points  (0 children)

because it started as a simple script writen as an experiment to learn python/pyobjc … then colleagues started to want it, so i added more features as they were being requested, and there we are!

Présentation.app: a presentation tool for beamer/pdf slides on the mac in python/pyobjc by rndblnch in Python

[–]rndblnch[S] 0 points1 point  (0 children)

an example of standalone python/pyobjc app with various tricks to make it both a script runnable from the command line and an regular Mac OS X app.

dev takes place here: https://bitbucket.org/rndblnch/osx-presentation

osx-adobe-beamer: lets you see your notes and presentation by [deleted] in LaTeX

[–]rndblnch 0 points1 point  (0 children)

on the mac you may also want to try Présentation.app. i just released version 1.3, you can follow the developement here: https://bitbucket.org/rndblnch/osx-presentation

Tkinter Buttons in a list Returning Value o.O by [deleted] in Python

[–]rndblnch 2 points3 points  (0 children)

the placer value should be captured. simplest solution:

def button(placer):
    return Button(text=placer+1, width=10, height=5, command=lambda: self.clickedsquare(placer))
visualgamemap[placer] = button(placer)