Skip to content

Instantly share code, notes, and snippets.

View danilobellini's full-sized avatar

Danilo de Jesus da Silva Bellini danilobellini

  • Sao Paulo, Brazil
View GitHub Profile
@danilobellini
danilobellini / warnbug.py
Created November 14, 2012 04:03
Strange behaviour with pytest + warnings
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 14 01:39:53 2012
@author: Danilo J. S. Bellini
"""
from warnings import warn, catch_warnings
import pytest
@danilobellini
danilobellini / metametaclass.py
Created October 13, 2012 08:21
Metaclass of a metaclass
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created on Sat Oct 13 by Danilo de Jesus da Silva Bellini
#
# This code raises:
# TypeError: Can't instantiate abstract class A with abstract methods blablah
# However, it does not when class A inherits from "type" or "ABCMeta".
from abc import ABCMeta, abstractproperty
class A(object):
@danilobellini
danilobellini / pyqt.py
Created September 29, 2012 14:49
Python GUI toolkits simple example
#!/usr/bin/env python
import sys
from PyQt4 import QtGui, QtCore
app = QtGui.QApplication(sys.argv)
# Main window, sizers and widgets
win = QtGui.QMainWindow()
wd = QtGui.QWidget()
vb = QtGui.QVBoxLayout()
@danilobellini
danilobellini / doomsday.py
Created September 21, 2012 05:13
Eruption explosive doomsday calculation
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 19 05:54:37 2012
Eruption explosive doomsday calculation.
Copyright (C) 2012 Danilo de Jesus da Silva Bellini
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@danilobellini
danilobellini / t9.py
Created September 12, 2012 18:24
T9 Message to cell phone numbers to be pressed
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 11 20:48:25 2012
T9 Message to cell phone numbers to be pressed
Problem description:
http://dojopuzzles.com/problemas/exibe/escrevendo-no-celular/