python

Is there a way to install Python documentation to NetBeans?

Netbeans currently has intellisense, but I want documentation on methods and what they do. Is this possible on Netbeans? Maybe when pressing F1, have the doc window open. Thanks! ...

What does abs do in Python?

I don't understand how the following code works: #CodingBat.com Warmup 7 #Given an int n, return True if it is within 10 of 100 or 200. def near_hundred(n): return ((abs(100 - n) <= 10) or (abs(200 - n) <= 10)) What does "abs()" do? And how does this work to solve the problem above? ...

how to embed C code in python program?

i want to write a program using multi-threading, raw sockets, to scan the ports in python i have a C code for injection of raw socket. i want to perform a ACK scan so need a raw socket. So please help me. thank you ...

Gzip JS and CSS in Django

Hi. I tried profiling my web application and one of the bottlenecks reported was the lack of gzip compression. I proceeded to install the gzip middleware in Django and got a bit of a boost but a new report shows that it is only gzipping the HTML files i.e. any content processed by Django. Is there a way I could kludge/hack/force/make the...

How to configure logging to syslog in python?

I can't get my head around Python's logging module. My needs are very simple: I just want to log everything to syslog. After reading documentation I came up with this simple test script: import logging import logging.handlers my_logger = logging.getLogger('MyLogger') my_logger.setLevel(logging.DEBUG) handler = logging.handlers.SysLogH...

session in python 3.1

i want to have session without use web framework when i execute my code it return blank page i have python 3.1 with apache 2.2 #!c:\Python31\python print ('Content-Type: text/html\n') print from http import cookies import os c = cookies.SimpleCookie() c["1"]="2" c2= os.environ.get('HTTP_COOKIE') c3= c.load(c2) print (c3) ...

How to write a raw socket for tcp packet injection in python?

I want inject a tcp raw packet for port scanning using ACK scan, need some help in writing the code in python. Thank you ...

path to element with conditions on parent(s) attributes using xpath,lxml,python

Hello I am working on project using lxml. here is a sample xml <PatientsTree> <Patient PatientID="SKU065427"> <Study StudyInstanceUID="25.2.9.2.1107.5.1.4.49339.30000006050107501192100000001"> <Series SeriesInstanceUID="2.16.840.1.113669.1919.1176798690"/> <Series SeriesInstanceUID="2.16.840.1.113669.1919.117708...

stored procedures with python pymssql

I have this Stored procedure on my sql server : [InsertRecord] @param1 varchar(10), @Param2 varchar(50),@Param3 varchar(10)=NULL, @Param4 datetime = NULL AS BEGIN When I update it with the following code : connenction = pymssql.connect (host=host1,user=user1,password=password1,database=database1) curser = connection.cursor()...

in python 2.6 how do i change a global variable within a for loop

i want to change the value of a variable within a for loop, but then have the new preserved variable changed when the loop finishes my attempt (kinda simplified from what i'm actually doing) SNP is a list and compar_1 is a list of lists line_1 = empty_row for SNP1 in compar_1: global line_1 if SNP[3] == SNP1[3] compar...

Python Visual Basic's CDate equivalent

I used to have this code in Visual Basic: rpt.ParameterFields.GetItemByName("RowDate").AddCurrentValue CDate("2010-03-19") and I cannot figure out into what I have to convert date to make eatable for COM. Any suggestions? ...

How to choose a proper Python parser generator to parse C struct definitions?

Hi, I am working on a project which contains two servers, one is written in python, the other in C. To maximize the capacity of the servers, we defined a binary proprietary protocol by which these two could talk to each other. The protocol is defined in a C header file in the form of C struct. Usually, I would use VIM to do some subst...

Logging on ZSI server using mod_python

Hi all, I developed a soap server using python ZSI. The server is running fine but the problem appears when I'm trying to log the xml received into a file: import logging as log LOG_FILENAME = '/var/log/zsiserver.log' log.basicConfig(filename=LOG_FILENAME,level=log.DEBUG,) from ZSI import dispatch from mod_python import apache mod = ...

Python: how to substitute and know whether it matched

I know that re.sub(pattern, repl,text) can substitute when pattern matches, and then return the substitute my code is text = re.sub(pattern, repl, text1) I have to define another variable to to check whether it modified text2 = re.sub(pattern, repl, text1) matches = text2 != text1 text1 = text2 and, it has issues, e.g. text1='abc...

Showing the Foreign Key value in Django template

Hello everyone. Here is my issue. I am new to python/django (about 2 months in). I have 2 tables, Project and Status. I have a foreign key pointing from status to project, and I am looking to try to display the value of the foreign key (status) on my project template, instead of the address of the foreign key. Here is my models.py...

AttributeError: 'module' object has no attribute 'urlopen'

I'm trying to use Python to download the HTML source code of a website but I'm receiving this error. Traceback (most recent call last): File "C:\Users\Sergio.Tapia\Documents\NetBeansProjects\DICParser\src\WebDownload.py", line 3, in file = urllib.urlopen("http://www.python.org") AttributeError: 'module' object has no ...

Python-like "as" keyword (for namespacing) in Ruby

I was just over looking at this question. The first thought that popped to my head was that ruby must have some sort of "as" type keyword like Python's import to help avoid namespace pollution. I've googled a bit but it seems that it's recommended to wrap your code in modules to avoid namespace problems with ruby. This seems problemat...

How can I trigger and listen for events in python ?

How can I trigger and listen for events in python ? I need a practical example.. thanks Update #add Isosurface button def addIso(): #trigger event self.addButton = tk.Button(self.leftFrame, text="Add", command=addIso) #.grid(column=3, row=1) self.addButton.pack(in_=self.leftFrame, side="right", pady=2) ...

Python cross platform

If I create a gui for windows using python 2.6 and Qt, and then want to running in solaris or linux world. What do I need on both systems, I'm guessing 2.6 and Qt for both platforms. Is this correct or would there be a better solution. If wxpython, the same right? ...

weird range value in the colorbar, matplotlib

Hey guys, I am a new user to the python & matplotlib, this might be a simple question but I searched the internet for hours and couldn't find a solution for this. I am plotting precipitation data from which is in the NetCDF format. What I find weird is that, the data doesn't have any negative values in it.(I checked that many times,ju...