* Create a list.
* Each time, the user gets an answer add it to the list
* At the end of the program: sort the list and print each element of it
- Patrick
On 2011-05-11 12:49, Johnson Tran wrote:
Hi Guys,
I've been working on a Python program where I create an 8 ball that will allow
you to
A queue is a data structure, which keeps track of multiple objects. You
can add data to a queue or you can remove it. When you remove an object
from a queue you get the element which you have added first. Therefore,
it is also called FIFO (First In First Out). A basic implementation
could look
You have a lot of options:
GUI: Any major gui toolkit will do the job. It's probobly easiest to
stick with tkinter.
HTML Template: Use a template language, e.g. mako or django templates
Pdf Templates: Reportlab is an option.
File Access: Of course you could just open a file and write to it, b
On 2010-12-29 10:54, Tommy Kaas wrote:
It works fine but besides # I also get spaces between the columns in the
text file. How do I avoid that?
You could use the new print-function and the sep keyword argument, e.g.:
from __future__ import print_function
f = open("filename", "w")
print("1", "
So far this is what I have:
letras =
["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","x","y","z"]
letra1 = 0
letra2 = 0
letra3 = 0
for i in letras:
for j in letras:
for k in letras:
print letras[letra1]+letras[letra2]+letras[letra3
ipAddress = "123.123.123.123"
emails = ipAddress.GetEmailAddresses()
Not exactly sure, what you want, but maybe something like this?
class mystr(str):
def GetEmailAddresses(self):
return [str(self)]
ipAddress = mystr("123.123.123.123")
emails = ipAddress.GetEmailAddresses()
I found this piece of code, which completely puzzles me, in the pdb
module of the trunk:
class Pdb(bdb.Bdb, cmd.Cmd):
...
def _runscript(self, filename):
# The script has to run in __main__ namespace (or imports from
# __main__ will break).
#
# So we clear
Giorgio wrote:
Depends on your python version. If you use python 2.x, you have to
use a u before the string:
s = u'Hallo World'
Ok. So, let's go back to my first question:
s = u'Hallo World' is unicode in python 2.x -> ok
s = 'Hallo World' how is encoded?
I am not 100% sure,
Mmm ok. So all strings in the app are unicode by default?
Depends on your python version. If you use python 2.x, you have to use a
u before the string:
s = u'Hallo World'
Do you know if there is a function/method i can use to check encoding of
a string?
AFAIK such a function doesn't exis
Giorgio wrote:
i am looking for more informations about encoding in python:
i've read that Amazon SimpleDB accepts every string encoded in UTF-8.
How can I encode a string? And, what's the default string encoding in
python?
I think the safest way is to use unicode strings in your application
Jeff R. Allen wrote:
a, b = 0
Traceback (most recent call last):
File "", line 1, in
TypeError: 'int' object is not iterable
I understand why it doesn't work, but I don't understand the wording
of the exception. Could someone explain how I accidentally introduced
iteration into the picture
Wayne Werner wrote:
and my question is what is the difference between the two? Is there a
difference other than one is an object the other is an instance? I
googled "python object vs. instance" and didn't find anything terribly
useful.
Yes there is a difference. One class inherits from objec
wrobl...@cmich.edu wrote:
Thank you for the reply.. I tried putting the print repr(n)
before I defined 'n' with raw_input. My script looks like
this--
def divisible(n):
if n%3 == 0:
print n, "is divisible by 3"
else:
print n, "is not divisible by 3"
n= raw_input("enter
You could invert your if-expressions, e.g. instead of
if query_company_name:
...
you could write
if not query_company_name:
return adresses, company
...
This way you could save some indentation.
If you want to get rid of the for loops, you could look at list
comprehensions, e
John wrote:
Hi,
I think I understand what decorators are and how they work. Maybe it's just
me but I don't know where I'd use them in my real world programming. I see
how they work with profile or coverage but does anyone have real world uses.
@classmethod, @staticmethod, @property, @abs
Laurii wrote:
Hello all,
I am currently reading through the Tutorial for Non-Programers by Josh
Cogliati. I have had great success until now.
The exercise to modify a number guessing program from a fixed number
"number = 78" to using the time module and use the seconds at the time
the prog
Ansuman Dash schrieb:
Hello Everybody,
In Python scripting, how can I execute a command (which can be run from
spcific directory) and then retrieve the result (after executing the
command it give the command is executed successfull or not), so that I
can validate it.
Thanks,
AD
import
dan06 wrote:
I've recently delved into python, about a week or so ago; I'm trying to
figure out how to create on-the-fly thumbnails. Are there python standard
library modules I could/should use or should I use external libraries like:
GD, Gimp, or ImageMagick?
When I needed thumbnails of my i
> But for sorting the list with the first element as key, I tried it
using
just mylist.sort() without the lambda, and its working also. Then why
use the lambda?
There is a little difference between those two variations.
Example:
>>> sorted([[1,2],[1,3],[1,1]])
[[1, 1], [1, 2], [1, 3]]
>>> s
Maybe something like this helps you to solve your problem:
# get code via http, etc.
code = """
def blah():
print 'blah'
print 'hello'
blah()
"""
compiled_code = compile(code, 'filename', 'exec')
exec(compiled_code)
This way you could execute some code from a web client, but the client
wo
The official docs
http://www.pygtk.org/pygtk2tutorial/index.html
http://library.gnome.org/devel/pygtk/stable/
worked for me.
- Patrick
Ajith Gopinath schrieb:
I will appreciate , if somebody guides me to a proper doc. on pygtk
for 2.5/2.6. I am currently unable to find a good doc for the same
21 matches
Mail list logo