Site Sponsors:
Python 2100: Objects, Factories, & Frameworks 
Today we proudly release our latest training offering.

Designed for ADVANCED 'Python'eers, in Python 2100 we will discover how to use @staticmethod, @classmethod, getattr(), hasattr() as well as object factories, and "abstract" signature classes.

In addition to advanced framework & object management patterns, this one (1) hour training opportunity will also cover multi-object initialization as well as modern framework testing & maintenance strategies.

[ view entry ] ( 1260 views )   |  permalink  |  related link
Python Stock Market 
Today we are hosting yet another "meetup." Designed for those who have been taking our Python 1000, 2000, and 3000 training, our goal is to build-up the resumes of our students.

Targeting a REAL WORLD game-play scenario that would impress would-be employers, we have set our sights upon a simple strategy.... Whoever can make the most "money" in the stock market, wins?

Anticipating the need, we decided to demonstrate how to get closing quotes from a particularly favorite quotation service:

# pip install urllib, first!
import urllib.request

class Stocks01:

def __init__(self, endpoint="", key="demo"):
self.end = endpoint.strip()
self.key = key.strip()

def get_history(self, token):
url = self.end + '&symbol=' + token.strip().upper() + "&apikey=" + self.key

response = urllib.request.urlopen(url)
except Exception as ex:
return None

stocks = Stocks01()
data = stocks.get_history("msft")

if data is not None:
import json
info = json.loads(str(data, "utf8"))
for row in info:
print("*" * 10, "KEY:", row)
if row != "Time Series (Daily)":
for ss, val in enumerate(sorted(info[row])):
print(ss, val)
for rec in sorted(info[row][val]):
print("\t\t", rec, info[row][val][rec])

Rather than using "demo," the link below will tell you how to get a free API key.

Hope you find it useful!

BONUS: Inspired by this meetup, PyDAO is a neat way to convert CSV / TEXT data (from NASDAQ, etc.) into Python.

[ view entry ] ( 864 views )   |  permalink  |  related link
OpenSCAD ... and the True Type Font! 
We went looking to create a few 'logoed projects recently. Since printing text can be a problem in 3D (strange looking 'As, 'Os, 'Qs, etc.), for best results when hollow-rendering one should us a STENCIL font.

Sadly, far from being universally supported, at the moment modern operating systems never provide any type of stencil-family fonts.

Arriving to the rescue however, today we should note that OpenSCAD will allow us to 'import' a font for ourselves.

Here is an example of using a True Type Font (.ttf) with OpenSCAD:
line1="Randall Nagy";

zlength = 10;

zscale = 4;
zscale2 = 7;
zscale3 = 8;

use </d_archive_static/Ttf_2016_002/allerta_stencil.ttf>

difference() {
minkowski() {
cube([max(len(line1), len(line2), len(line3)) * zscale + border, zlength, 0.75], center=true);
if(line2||line3) {
translate([0,-15,0]) cube([max(len(line1),len(line2),len(line3))*zscale2+border,15,0.75], center=true);
if(line3) {
translate([0,-30,0]) cube([max(len(line1),len(line2),len(line3))*zscale3+border,15,0.75], center=true);

font_name = "Allerta";
zhi = 3;
szfont = 8;
union() {
linear_extrude(height = zhi, center=true)
text(line1, font = font_name, "center", size = szfont, valign="center", halign="center");
if(line2) {
translate([0,-15,0]) linear_extrude(height = zhi, center=true)
text(line2, font = font_name, "center", size = szfont, valign="center", halign="center");
if(line3) {
translate([0,-30,0]) linear_extrude(height = zhi, center=true)
text(line3, font = font_name, "center", size = szfont, valign="center", halign="center");

Sharing is caring!

[ view entry ] ( 888 views )   |  permalink  |  related link

<<First <Back | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Next> Last>>