listname[:] = []
Example:
>>fruit = ['apple', 'orange','lemon']
>>print fruit
['apple', 'orange', 'lemon']
>>len(fruit)
3
>>fruit[:]=[]
>>print fruit
[]
>>len(fruit)
0
listname[:] = []
>>fruit = ['apple', 'orange','lemon']
>>print fruit
['apple', 'orange', 'lemon']
>>len(fruit)
3
>>fruit[:]=[]
>>print fruit
[]
>>len(fruit)
0
from Inputfiles_Dialog import Inputfiles_Dialog
#Inputfiles_Dialog is the ui created by QtCreater
d = Inputfiles_Dialog(self.iface)
d.show()
if d.exec_():
self.Inputfiles_set = d.getInputs()
self.connect(self.OK_buttonBox, SIGNAL("accepted()"),self.ProcessInfo)4. In your custom dialg, add a function to return values:
.
.
.
def ProcessInfo(self):
#do somthing
.
.
.
self.accept()
def getInputs(self):
return usefulinfo
from pyspatialite import dbapi2 as sqlite3
dbName = str(self.txtOutputDB.text()) #textOutputDB is a lineEdit object(PyQt)
#if os.path.exists(dbName) :
ocon = sqlite3.connect(dbName)
ocur = ocon.cursor()
sql = 'SELECT InitSpatialMetadata()'
ocur.execute(sql)
#add projection information
sql = "INSERT INTO spatial_ref_sys (srid, auth_name, auth_srid, ref_sys_name, proj4text) VALUES (4326, 'epsg', 4326, 'WGS 84', '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs');"
ocur.execute(sql)
#delete unnecessary spatial_ref_sys
sql = 'DELETE FROM "spatial_ref_sys" where srid!= 2326 and srid!= 4326'
ocur.execute(sql)
sql = 'VACUUM'
ocur.execute(sql)
>>> import re
>>> st = "9394 811 813 815"
>>> result = [str(x) for x in filter(None, re.split('[ ,\n,\t]',st))]
>>> print result
['9394', '811', '813', '815']
>>>
fp = open(ifile,"rb")
byte = fp.read(1)
block = fp.read(30)block = fp.read(30)
(Year,) = struct.unpack('b',block[3:4])
(Month,) = struct.unpack('b',block[4:5])
(Day,) = struct.unpack('b',block[5:6])
(Hour,) = struct.unpack('b',block[6:7])
(Minute,) = struct.unpack('b',block[7:8])
(Second,) = struct.unpack('b',block[8:9])
recdate = str(Year) + '-' + str(Month) + '-' + str(Day) + ' ' + str(Hour) + ':' + str(Minute)
(Cellname,) = struct.unpack('8s',blk[2:10])
Format | C Type | Python type | Standard size | Notes |
---|---|---|---|---|
x | pad byte | no value | ||
c | char | string of length 1 | 1 | |
b | signed char | integer | 1 | (3) |
B | unsigned char | integer | 1 | (3) |
? | _Bool | bool | 1 | (1) |
h | short | integer | 2 | (3) |
H | unsigned short | integer | 2 | (3) |
i | int | integer | 4 | (3) |
I | unsigned int | integer | 4 | (3) |
l | long | integer | 4 | (3) |
L | unsigned long | integer | 4 | (3) |
q | long long | integer | 8 | (2), (3) |
Q | unsigned long long | integer | 8 | (2), (3) |
f | float | float | 4 | (4) |
d | double | float | 8 | (4) |
s | char[] | string | ||
p | char[] | string | ||
P | void * | integer | (5), (3) |
Operator | Description | Example |
---|---|---|
& | Binary AND Operator copies a bit to the result if it exists in both operands. | (a & b) will give 12 which is 0000 1100 |
| | Binary OR Operator copies a bit if it exists in eather operand. | (a | b) will give 61 which is 0011 1101 |
^ | Binary XOR Operator copies the bit if it is set in one operand but not both. | (a ^ b) will give 49 which is 0011 0001 |
~ | Binary Ones Complement Operator is unary and has the efect of 'flipping' bits. | (~a ) will give -60 which is 1100 0011 |
<< | Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand. | a << 2 will give 240 which is 1111 0000 |
>> | Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand. | a >> 2 will give 15 which is 0000 1111 |
import sys
sys.path
>>> import sysResult from QGIS Python Console:
>>> sys.path
['', 'C:\\windows\\system32\\python25.zip', 'c:\\python25\\DLLs', 'c:\\python25\\lib', 'c:\\python25
\\lib\\plat-win', 'c:\\python25\\lib\\lib-tk', 'c:\\python25', 'c:\\python25\\lib\\site-packages']
>>> import sys
>>> sys.path
['C:/PROGRA~1/QUANTU~1/apps/qgis/./python', 'C:/Documents and Settings/19/.qgis/python', 'C:/Documents and Settings/19/.qgis/python/plugins', 'C:/PROGRA~1/QUANTU~1/apps/qgis/./python/plugins', 'C:\\PROGRA~1\\QUANTU~1\\apps\\gdal-17\\pymod', 'C:\\Program Files\\Quantum GIS Copiapo', 'C:\\PROGRA~1\\QUANTU~1\\bin\\python25.zip', 'C:\\PROGRA~1\\QUANTU~1\\apps\\Python25\\DLLs', 'C:\\PROGRA~1\\QUANTU~1\\apps\\Python25\\lib', 'C:\\PROGRA~1\\QUANTU~1\\apps\\Python25\\lib\\plat-win', 'C:\\PROGRA~1\\QUANTU~1\\apps\\Python25\\lib\\lib-tk', 'C:\\PROGRA~1\\QUANTU~1\\apps\\qgis\\bin', 'C:\\PROGRA~1\\QUANTU~1\\apps\\Python25', 'C:\\PROGRA~1\\QUANTU~1\\apps\\Python25\\lib\\site-packages', 'C:\\PROGRA~1\\QUANTU~1\\apps\\Python25\\lib\\site-packages\\win32', 'C:\\PROGRA~1\\QUANTU~1\\apps\\Python25\\lib\\site-packages\\win32\\lib', 'C:\\PROGRA~1\\QUANTU~1\\apps\\Python25\\lib\\site-packages\\Pythonwin', 'C:\\PROGRA~1\\QUANTU~1\\apps\\Python25\\lib\\site-packages\\wx-2.8-msw-unicode', 'C:\\PROGRA~1\\QUANTU~1\\apps\\qgis\\python\\plugins\\fTools\\tools']
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Python]
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore]
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.5]
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.5\Help]
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.5\Help\Main Python Documentation]
@="C:\\Python25\\Doc\\Python25.chm"
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.5\InstallPath]
@="C:\\Python25\\"
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.5\InstallPath\InstallGroup]
@="Python 2.5"
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.5\Modules]
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.5\PythonPath]
@="C:\\Python25\\Lib;C:\\Python25\\DLLs;C:\\Python25\\Lib\\lib-tk"
C:\Program Files\Quantum GIS Copiapo\apps\Python25\Scripts>python easy_install-2.5-script.py pyodbc
Traceback (most recent call last):
File "easy_install-2.5-script.py", line 5, in
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
C:\Program Files\Quantum GIS Copiapo\apps\Python25\Scripts>python eas_install-script.py jinja
python: can't open file 'eas_install-script.py': [Errno 2] No such file or directory
C:\Program Files\Quantum GIS Copiapo\apps\Python25\Scripts>python easy_install-script.py jinja
Searching for jinja
Reading http://pypi.python.org/simple/jinja/
Reading http://wsgiarea.pocoo.org/jinja/
Reading http://jinja.pocoo.org/
Best match: Jinja 1.2
Downloading http://pypi.python.org/packages/2.5/J/Jinja/Jinja-1.2-py2.5-win32.egg#md5=27b0804a126c2c
0ebd4a9dacffb9dcbb
Processing Jinja-1.2-py2.5-win32.egg
creating c:\progra~1\quantu~1\apps\python25\lib\site-packages\Jinja-1.2-py2.5-win32.egg
Extracting Jinja-1.2-py2.5-win32.egg to c:\progra~1\quantu~1\apps\python25\lib\site-packages
Adding Jinja 1.2 to easy-install.pth file
Installed c:\progra~1\quantu~1\apps\python25\lib\site-packages\jinja-1.2-py2.5-win32.egg
Processing dependencies for jinja
Finished processing dependencies for jinja
Copyright (c) 2010 Python Code Blog All rights reserved. Design by CSS Templates | Blogger Templates by TeknoMobi | Sponsored by Bodrum48.