Sep 102009

I found an interesting python development method that can be done from a usb drive.
portable python
portableapps.com has many interesting apps:
1. commandprompt portable
2. notepad++ portable
3. sumatrapdf portable
4. putty portable
5. winscp portable
etc.
After installing portablepython
execute
SPE-Portable.exe
open manage.py
and run (F9) with argument “runserver”

Posted by weboom at 5:57 pm Tagged with: , ,
Aug 042009

Then,
import datetime

Posted by weboom at 7:49 am Tagged with: , ,
Aug 022009

If you don’t want to refer to the elements of a collection by their position number but prefer some other type of object as a key,
use a python dictionary
———–
e.g.,
>>> tel = {’jack’: 4098, ’sape’: 4139}
>>> tel['guido'] = 4127
>>> tel
{’sape’: 4139, ‘guido’: 4127, ‘jack’: 4098}
>>> tel['jack']
4098
>>> del tel['sape']
>>> tel['irv'] = 4127
>>> tel
{’guido’: 4127, ‘irv’: 4127, ‘jack’: [...]

Posted by weboom at 7:18 pm Tagged with: , , ,
Aug 022009

Python list and tuple, both of them consists of multiple objects identified its position.
list
L=[1, 2, 3]
tuple
T=(1,2,3)
Difference between them is that tuple is immutable.
That is,
L[0]=100
is OK, but
T[0]=100
is not allowed.

Posted by weboom at 7:12 pm Tagged with: , , ,
Aug 022009

Python tuple
consist of a number of objects which can be referenced by their position number within the object.
———
e.g.,
fruit = (”Apple”,”Banana”,”Cherry”,”Fig”,”Grapefruit”)

Posted by weboom at 7:09 pm Tagged with: ,
Aug 022009

__unicode__
is for displaying objects.
———–
For example,
>>>p = Card.objects.create(name=’Hot Pot’, city=’San Diego’)
>>>card_list = Card.objects.all()
>>>card_list
[<Card: Card object>]
without __unicode__, you will see just “Card object”
if you define __unicode__
def __unicode__(self):
return self.name
then, you will see
[<Card: Hot Pot>]

Posted by weboom at 5:22 am Tagged with: , ,
Aug 022009

Python list
isĀ  a container that holds a number of other objects, in a given order.
L=[1, 2, 3, 4]

Posted by weboom at 5:02 am Tagged with: ,
Jul 282009

Pygments
takes a source code and
outputs a beautiful looking code.

Posted by weboom at 7:56 pm Tagged with: ,
Jul 252009

def func(*args, **kwargs):
Python functions and methods can pass and receive arguments in two forms:
1. positional argument (the order is important)
2. keyword argument(names along with the values)

In Python, list and dictionary types are used for positional and keyword arguments respectively.
Passing a list as an argument and prefixing it with a single asterisk(*) will cause each item [...]

Posted by weboom at 3:19 pm Tagged with: , , , ,
Jul 252009

lower()
is a Python string method to return a string converted to lowercase
—-
e.g.,
def get_absolute_url(self):
return “/card/%s/%s/” % (self.pub_date.strftime(”%Y/%b/%d”).lower(), self.slug)

Posted by weboom at 2:33 pm Tagged with:
Switch to our mobile site
Page 2 of 4«1234»Top Footer