You could just ignore the error data by try.. except.

self is not good name for regular parameter as it is normally used in oo programs for the instance itself.

Tony

rproffitt commented: Good idea about the "self" variable. +8

I think it is easy to choose subset of unicode letters (one special language specific letter from each letter set from each language specific letter set and special symbol set, for example, upto 256 set), that are unlikely to all occur in same document. And If you have one letter that does not occur in file, all sequences including that letter are not included in file, if you want longer non-occuring string.

Gribouillis commented: Yes but how to write it down ? +14

How about hashing the letters in file, generate random letters until random letter hits empty slot in hash. If there is enough empty slots in hash, it should not take too many guesses. And guess + hash + check is quite fast operation. This, if you want to find unicode letter not used in file. With some very simple hash function (maybe simple mod n, not, but something slightly more complex) it might be able to limit guesses in subset of unicode letters based on the index of empty hash slot.

For longer n-length string, it should be quite easy to find unicode letter very unlikely to appear more than n times in the file. Then you just make sure that for hit h, letter h in string generated differs from letter h letters after hit h. You could also record one letter after each hit. There should be many holes in unicode letters, as the hits should not be many. And available unicode choices are many for the second letter of not-matching string. If the rare letter is not found in file is of course trivial and should be dominant case for average running time of the algorithm.

Here is example of minimum function with iterable and function to calculate distance:

``````from math import hypot
from functools import partial

def distance(p1, p2):
return hypot(p2[1] - p1[1], p2[0] - p1[0])

points = [(81,3), (34, 32), (-4, 6)]

reference = (10,23)

print(min(points, key=partial(distance, reference)))``````
Gribouillis commented: I didn't know hypot() ! +14

Use list comprehension/generator with min-function.

Here is my code changed to produce text mode banner effect by os independent way of printing empty lines for clearing the screen. This method suprizingly seems to work better for IDLE window than terminal (console) screen/window.

``````# -*- coding: cp1252 -*-
from __future__ import print_function
import time
try:
from itertools import izip_longest
except ImportError:
# Python 3
from itertools import zip_longest as izip_longest

def rot_right(a, fillvalue=None):
return list(izip_longest(*a[::-1], fillvalue=fillvalue))

hello = dict(zip('helowrd'.upper(),'''

*  *
*  *
****
*  *
*  *
§

****
*
****
*
****
§

*
*
*
*
****
§

***
*   *
*   *
*   *
***
§

*  *  *
*  *  *
*  *  *
*  *  *
*  *
§

* *
*  *
***
*  *
*   *
§

***
*  *
*  *
*  *
***
'''.split('\n§')))

hello[' '] = 5 * '     \n'
spacing = 10
# at least lines per terminal minus banner hight
# or less for multibanner effect
much = 25 - 6
banner_length = 80
banner = ['' for line in range(8)]
for c in 'Hello world'.upper():
print(c)
for n, line in enumerate(hello[c].split('\n')):
print(n,line)
banner[n] += line.ljust(spacing)
n += 1
while n < len(banner):
banner[n] += ' '.ljust(spacing)
n += 1

for rot in range(480):
rot = rot % banner_length
time.sleep(0.1)
print('\n' * much) # system independant emptying of screen
print('\n'.join((b[rot:] + spacing*' ' + b[:rot])[:banner_length] for b in banner))``````

I think in Python3 it is called zip_longest. I updated my code in original post.

Hi, double newlines seemed to work in Windows, but rotating the text turned out to be little more involved than I thought. I even had to revise my earlier rotation code to use izip_longest to deal with not square rotation of the character matrix.

``````try:
from itertools import izip_longest
except ImportError:
# Python 3
from itertools import zip_longest as izip_longest

def rot_right(a, fillvalue=None):
return list(izip_longest(*a[::-1], fillvalue=fillvalue))

hello = dict(zip('helowrd'.upper(),'''
*  *
*  *
****
*  *
*  *
§
****
*
****
*
****
§
*
*
*
*
****
§
***
*   *
*   *
*   *
***
§
*  *  *
*  *  *
*  *  *
*  *
§
****
*   *
*  *
***
*  *
*   *
§
***
*  *
*  *
*  *
***
'''.split('\n§')))

hello[' '] = 5 * '     \n'
print('\n\n'.join(hello[c] for c in 'Hello world'.upper()))

print('Rotated:')
for c in 'Hello world'.upper():
print('\n'.join(''.join(data)
for data in rot_right(hello[c].split('\n'),
fillvalue=' ')
))``````

IDLE does not like lines only space characters, so here safer version that works.

``````hello = dict(zip('helowrd'.upper(),'''
*  *
*  *
****
*  *
*  *

****
*
****
*
****

*
*
*
*
****

***
*   *
*   *
*   *
***

*  *  *
*  *  *
*  *  *
*  *

****
*   *
*  *
***
*  *
*   *

***
*  *
*  *
*  *
***
'''.split('\n\n')))

hello[' '] = 5 * '\n'
print('\n\n'.join(hello[c] for c in 'Hello world'.upper()))``````

Here little bigger version

``````hello = dict(zip('helo wrd'.upper(),'''
*  *
*  *
****
*  *
*  *

****
*
****
*
****

*
*
*
*
****

***
*   *
*   *
*   *
***

*  *  *
*  *  *
*  *  *
*  *

****
*   *
*  *
***
*  *
*   *

***
*  *
*  *
*  *
***
'''.split('\n\n')))

print('\n\n'.join(hello[c] for c in 'Hello world'.upper()))``````

print("Hello World")

Can anybody print out "Hello World" vertically?

``print('\n'.join("Hello World"))``
``````from ScrolledText import *
from Tkinter import *

main = Tk()
mywin = ScrolledText(main)
mywin.pack(fill=BOTH, expand=YES)

main.title('Favorite Movies')
favorite_movies = [
"Gone with the Wind",
"Batman IV",
"Spiderman VII",
"Sniper III"]
mywin.insert(END,'\n'.join(favorite_movies))
mywin.focus_set()
mywin.mainloop()``````

I read this thread, and of course I would use the count method, but I got to make this task by yet another method and thought to share it.

``````def count(haystack, needle):
return sum(haystack[n:].startswith(needle)
for n in range(len(haystack) - len(needle) + 1))

print(count('assessement', 'as'))
# -> 1
print(count('assessement', 'sse'))
# -> 2
print(count('trans panamanian bananas', 'an')
# -> 6``````
Slavi commented: Nice one +5

File is file,just attach whole file. It is receiver who opens the content, it does not matter except for the mime type.

pymotw is good place to learn about using modules. Here is the lesson on zipfile:
http://pymotw.com/2/zipfile/

Also by example of the module you see that text of the message is input as preamble:

https://docs.python.org/2.7/library/email-examples.html

Also I believe that you should be reading the file as normal file (not zf) with read without parameters. The file would be previously zipped, so it would only be read as binary file and encoded with base64 (see last example end, else-part)

So change the zipfile part to normal open('file.zip', 'rb')

You must use serialization by cPickle or json or similar.
http://stackoverflow.com/questions/2311223/how-do-i-store-a-dict-list-in-a-database

Combinations, permutations etc can be found in itertools module.

You must use `keyGen = KeyGenerator.my_generator_function()` If `my_generator_function` is the function defined in the module `KeyGenerator` and it does not take any parameters.

It sounds that you are using statement `KeyGenerator(....)` which does not make sense.

If you want to suggest exercises for novice programmers, you can contribute to sticky thread started by vegaseat for that purpose.

If you want to ask question you need to provide proof of your efforts and specific question.

You can reverse a string my doing

``the_string[::-1]``

There are also built in function for reverse `reversed` which produces reversed object which you can use for same purpose.

It actually creates a new string, why you are limiting your self to 255 elements, no need for such limit.

int function returns the value of binary number, for example

``print(int('10001',2))``

prints `7`.

``  im.save('E:/Usuarios/Daniel/Documents/APNAE/QR/%s.jpeg' % nom)``

Lambda expressions are not used so extensively and are kind of limitted in Python compared to functional programming like Lisp/Scheme. I would use simple basic expression, maybe list comprehension form:

``[line for line in myfile if not line[0].isdigit()]``

Do shallow copy of input list as list is mutable by slice [:] or .copy() method call.

tuples of function calls without using their return values here are very strange for me

``````    def openFiles(selection):
if selection == "animation":
saveAnim(), animation()
if selection == "compositing":
saveComp(), compositing()
return``````

We do not understand as the tree has single cargo contents, nothing about expressions. You must include example data also, output you get for that and the desired result.

Variable even is not defined.