This is my homework #7 for my UW Python course,
To handle exceptions in python we use
try - except, in my case I'm using it to handle:
- IOError when a file I want to import doesn't exist.
- Use Ctl+c to close and save in a clean way.
Pickle is used for Object Serialization, in our case loading/dumping a dictionary in a file.
In additional I learn pprint to get a more clean dictionary printing.
I tried to document all in my code then I'm posting it here:
#!/usr/bin/python
# Pickle: https://docs.python.org/2/library/pickle.html
# Pickle examples: https://wiki.python.org/moin/UsingPickle
import pickle
# Data pretty printer https://docs.python.org/2/library/pprint.html
import pprint
filename = "inventory.bin"
print "Assignment07 by Fredy Pulido-Lopez"
# Based on Assignement04 I did using try except
print "Importig and printing data from ",filename
# Exception handler to take care if the file is not present
try:
with open (filename,'rb') as file:
dictionary = pickle.load(file)
pprint.pprint(dictionary)
except IOError:
print "ERROR: Failed loading (IOError) ",filename,", starting from scratch"
# No file loaded then i'm creating my dictionary here
dictionary = []
print "############## Inventory composer ##############"
print "WARNING: Ctl+c will write ",filename," file."
# Exception handler, close and save when Ctl+c send a KeyboardInterrupt signal
try:
# Infinite loop to feed the inventory in memory:
while True:
item = raw_input("Item : "),
value = raw_input("Value : "),
dictionary.append({'item': item, 'value': value})
except KeyboardInterrupt:
print "\nWriting inventory in ",filename
# After the exception the loop is done and we have a feeded dictionary in memory
# Now we will save our dictionary in a file called inventory.txt
with open (filename,'w') as file:
pickle.dump(dictionary,file,-1)
En wordpress no funciona, pero en blogger si?
Hola todos
El mundo está cambiando fuertemente como cuando apareció la imprenta y
el motor de este cambio es Internet, desafortunadamente la red está
siendo atacada de forma directa, usando como caballo de trolla la
industria del copy rigth, es tan grave que en protesta Google, Amazon,
Mozilla, Twitter, Linkedin y otros han optado por algo que se ha
denomidando la opción nuclear:
http://alt1040.com/2012/01/opcion-nuclear-el-23-de-enero-google-podria-desconectar-la-red-contra-sopaY yo creo que todo el mundo se pregunta que puede hacer, bueno lo más
fácil es hacer una firma en linea, OJO: bajen y encuentren la sección
"Not in the us? Petition the state department"
http://americancensorship
.org/
Donar dinero a mozilla que está haciendo una fuertre campaña:
https://donate.mozilla.org/page/s/commit-to-call-pipaFinalmente sería bueno que el 22 y 23 de enero impriman una hoja, o
cientos de ellas y la cargen visible para hacer publicidad, una imagen
como esta es buena:
http://cdn.digitaltrends.com/wp-content/uploads/2011/11/stop-sopa-pipa.png
Estoy haciendo el sitio de la real y para el tema del formulario de contacto gasté un buen tiempo, finalmente elegí
Administrador de formularios hecho por Campbell Hoffman.
Pero hice un cambio en
/wp-content/plugins/wordpress-form-manager/css/style.css para que el botón enviar quedara debajo del rechaptcha:
.fm-form input.submit{
float:left;
margin-left:430px;
}
Para dshabilitar los comentarios en las páginas instalé
Disable Comments de Samir Shah.
Etiquetas: contact, form, wordpress
Estoy usando este
excelente tema para la página de
La Real Acacemia del Sonido y uno de los problemas que yo tenia era con las imágenes de fondo por que las subia de un tamaño y las mostraba de otro (recortadas) y la solución está en
la documentación:
Slideshow -> 3. Getting the images adjusted:
Default size of the big image in the slideshow: 756x250px, but the image should be bigger than 756x567px.
Why? When you create your feature image, you have to keep in mind that it will be displayed at 756 x 250. That is the big image you have in your slideshow. However, doing this, will cut your image on the small preview-menu in the slideshow.
Best is to create images at 756 x 567. This will keep the 4:3 ratio in the menu, and your image will be displayed as usual. You just have to center what you want to be in the big image on the slideshow.
Etiquetas: image, theme, wordpress
Fiesta de despedida hoy viernes 9pm en la 7a con 47 BOG/Col, bar capella y Sábado a las 7pm aeropuerto. Abrazos
Tenía esto por hay y bueno mejor publicarlo ...
Only autorization for use this idea in open source software:
I am a organized person, and much much time i try have my files organiced but have problems becouse for example one criteria for organization can to be the tipe of files (music, images, pictures ...), the type of file (.html, .odt, .ogg ...), other will be the year, the site (University, work) the type of acces (share, private ...).
In UNIX and UNIX type operative systema every file have one inodo and by inode you have minimal one hard link, in the hard link you have the name of the file.
My idea for tag files is very siple:
- files who need tobe tags are user data, the user data is in /home and /home not have directory mount points
- files are taged by te user
i develop my idea whit a example script:
1- creating "special" directory called tags and "special" subdirectory with the tag name
2- make a hard link of the file in the tag directory
digitalfredy@debian $ cat /usr/local/bin/tagfile
#!/bin/sh
# $1 is the file and $2 is the tag
mkdir -p $HOME/tags/$2
ln $1 $HOME/tags/$2/
You like see the files in a tag? use ls /tags/$TAG
Los sistemas operativos POSIX siempre han tenido soporte para tags, si, un tag es una carpeta en la cual hay enlaces duros que son un nombre para un inodo y el inodo es el que nos dice donde está el archivo
El problema es la forma en que accedemos y visualizamos el sistema de archivos, el problema es la falta de herramientas que nos permitan acceder el sistema de archivos usando una filosofía diferente al arbol de archivos
Ejemplo comando tag
tag operandos
operandos: archivo1 archivoN tag1 tagN
Pending: you can go to tags and find the files but not know how to show the tags of a file (show the hardlinks of a file)