Skip to main content

Home/ Mac Attack/ Group items tagged generative

Rss Feed Group items tagged

Benjamin Bandt-Horn

[SLUT] - 0 views

  • ABOUT Slut is a programming framework for generative, synthetic, interactive, network-enabled graphics. Slut generates images from processes. Such processes may be simple "construction plans" or they may depend on user input. They may be drawn from incoming network data or messages that are sent to the network. Produced images may be adaptive, accumulative or static. They may look and feel like computer games or they may inform like scientific visualizations. They may be lyrical, cynical, political, intrusive (literally over the network), simply beautiful or banal.
  •  
    ABOUT Slut is a programming framework for generative, synthetic, interactive, network-enabled graphics. Slut generates images from processes. Such processes may be simple "construction plans" or they may depend on user input. They may be drawn from incoming network data or messages that are sent to the network. Produced images may be adaptive, accumulative or static. They may look and feel like computer games or they may inform like scientific visualizations. They may be lyrical, cynical, political, intrusive (literally over the network), simply beautiful or banal.
Benjamin Bandt-Horn

Classes & Iterators - Dive Into Python 3 - 0 views

  • Comprehensions are just a simple form of iterators. Generators are just a simple form of iterators
  • The first argument of every class method, including the __init__() method, is always a reference to the current instance of the class. By convention, this argument is named self.
  • self is not a reserved word in Python, merely a naming convention
  • ...6 more annotations...
  • To build an iterator from scratch, Fib needs to be a class, not a function.
  • in most cases), __iter__() simply returns self, since this class implements its own __next__() method.
  • a for loop will call this automatically, but you can also call it yourself manually
  • the __next__() method raises a StopIteration exception, this signals to the caller that the iteration is exhausted. Unlike most exceptions, this is not an error; it’s a normal condition that just means that the iterator has no more values to generate. If the caller is a for loop, it will notice this StopIteration exception and gracefully exit the loop. (In other words, it will swallow the exception.)
  • Do not use yield here; that’s a bit of syntactic sugar that only applies when you’re using generators. Here you’re creating your own iterator from scratch; use return instead
  • raise StopIteration
  •  
    Comprehensions are just a simple form of iterators. Generators are just a simple form of iterators
Benjamin Bandt-Horn

Boilerplate code - Wikipedia, the free encyclopedia - 0 views

  • Or in C# using Automatic Properties with compiler generated backing fields: public class Pet { public PetName Name { get; set; } public Person Owner { get; set; } }
  •  
    Or in C# using Automatic Properties with compiler generated backing fields: public class Pet { public PetName Name { get; set; } public Person Owner { get; set; } }
Benjamin Bandt-Horn

How does polymorphism work in Python? - Stack Overflow - 0 views

  • idiomatic Python dictates that you (almost) never do type-checking, but instead rely on duck-typing for polymorphic behavior. There's nothing wrong with using isinstance to understand inheritance, but it should generally be avoided in "production" code
  •  
    idiomatic Python dictates that you (almost) never do type-checking, but instead rely on duck-typing for polymorphic behavior. There's nothing wrong with using isinstance to understand inheritance, but it should generally be avoided in "production" code
Benjamin Bandt-Horn

Accumulator Generator - 0 views

  • class foo: def __init__(self, n): self.n = n def __call__(self, i): self.n += i return self.n
  • function foo (n) { return function (i) { return n += i } }
  •  
    ...in various languages
Benjamin Bandt-Horn

Binary Search Tree library in Python | Laurent Luce's Blog - 0 views

  • This article is about a Python library I created to manage binary search trees. I will go over the following: Node class Insert method Lookup method Delete method Print method Comparing 2 trees Generator returning the tree elements one by one
  • https://laurentluce@github.com/laurentluce/python-algorithms.git
  • binary search tree
  • ...5 more annotations...
  • Delete method
  • There are 3 possibilities to handle: 1- The node to remove has no child. 2- The node to remove has 1 child. 3- The node to remove has 2 children.
  • look for its successor by going right then left until we reach a leaf
  • if node is None:
  • ‘A’ < ‘B’ is True in Python.
  •  
    This article is about a Python library I created to manage binary search trees. I will go over the following: Node class Insert method Lookup method Delete method Print method Comparing 2 trees Generator returning the tree elements one by one
Benjamin Bandt-Horn

How to implement __iter__(self) for a container object (Python) - Stack Overflow - 0 views

  • usually __iter__() just return self if you have already define the next() method (generator object)
  • While you are looking at the collections module, consider inheriting from Sequence, Mapping or another abstract base class if that is more appropriate. Here is an example for a Sequence subclass:
  • if hasattr(self.data[0], "__iter__": return self.data[0].__iter__() return self.data.__iter__()
  •  
    if not self.data: raise StopIteration
Benjamin Bandt-Horn

PyQT Tutorial - 0 views

  • a much better way to write GUI apps in Python is to use Trolltech's QT Designer to WYSIWYG-ly create a nice-looking interface, and then automatically generate the necessary code for it with pyuic (which is a UI compiler for QT that comes with the PyQT package.)
1 - 8 of 8
Showing 20 items per page