No need to type by hand:
PLAIN TEXT
PYTHON:
alphabet = 'abcdefghijklmnopqrstuvwxyz'
This prints the small letters:
PLAIN TEXT
PYTHON:
print map (chr, range (97, 123))
And that's the case:
PLAIN TEXT
PYTHON:
print map (chr, range (65, 91))
But you can also count on Python itself (batteries included, after all!)
PLAIN TEXT
PYTHON:
from string import ascii_letters
print ascii_letters
And again:
PLAIN TEXT
PYTHON:
import string
print string.ascii_lowercase
print string.ascii_uppercase
I'm doing the Project Euler and challenges in the first ten have seen three prime numbers. My first algorithm naively tested the primality of a number trying to divide it by all numbers less than him.
A list with 1,000 prime numbers in this way generates just under a second on my computer. Already 2000, [...]
In Python, the error in the title of this post happens when you flip through a dictionary and it is changed during the loop.
This can happen when we do:
PLAIN TEXT
PYTHON:
>>> Dictionary = ('name', 'Julio', 'surname': 'Nobrega')
>>> For k, v in dicionario.iteritems ():
... Print v
... Del dictionary [k]
...
Nobrega
Traceback (most recent call last):
File "<stdin>", line 1, in?
RuntimeError: dictionary changed [...]
I started to make a GUI using wxPython to play a music file with the code yesterday. Implemented the selection button of the file, that even filters the files to be shown in accordance with the specified extensions. In my case, *. mp3 and *. ogg.
Except that the file selected, the interface crashed. Searching in [...]
No additional libraries or as libmpg123 gstreamer or whatever. Python. Well, almost, since PyMedia is written mostly in C, but once installed you can use import to bring it.
PLAIN TEXT
PYTHON:
import the sound pymedia.audio.sound
import pymedia.audio.acodec the ACODEC
def playFile (file_name):
file_extension file_name.split = ('.') [-1]. lower ()
parms = ('id': [...]
There is a program called mechanoid done in Python, a collage of programs that make up the mechanize, which only returned to perform certain specific tasks such as entering the Sourceforge or check out the Yahoo Mail.
Basically it emulates a browser, opening pages, clicking links, filling out forms. It's so easy that it hurts my eyes ...
A small Python script to count the number of lines of all files in a directory (and subdirectories). Just edit the variable directory.
PLAIN TEXT
PYTHON:
import os.path
directory = "/ var / www / html / site /"
def visit (arg, dirname, names):
for file in names:
arquivo_caminho = os.path.join (dirname, file)
if os.path.isfile (arquivo_caminho):
[...]