python

Software Validation Server in Python?

I have been working on a huge project for work for a while now, and it is almost done. However, in an effort to prevent the program was being pirated (I already know there is pretty much no method that can't be cracked ), the software needs to be able to validate. I'm not exactly sure how to do this. Could some sort of software validatio...

python package get imported automatically when importing a global from a module

Let's say I have these files: - package1/ - __init__.py - package2/ - __init__.py - module1.py Content of package1/__init__.py: from package2.module1 import var1 print package2 Empty package1/package2/__init__.py Content of package1/package2/module1.py: var1 = 123 The question is why would package2 get imported? Run...

What is the working of web Crawler?

Will web crawler crawl the web and create a database of the web or it will just create a searchable index of web? If suppose it creates an index, who will exactly will gather the data of web pages and store it in database? ...

Here's why programming is hard for me...

I'm attempting to teach myself Python as my first language. After reading through "Python for Dummies" I searched out a number of easy projects that I could attempt. However, my main problem is not knowing a large enough breadth of modules and functions to use. I feel like I just don't know enough. Sure, I understand the basics of buil...

find a minimum value in an array of floats

how would one go about finding the minimum value in an array of 100 floats in python? I have tried minindex=darr.argmin() and print darr[minindex] with import numpy (darr is the name of the array) but i get: minindex=darr.argmin() AttributeError: 'list' object has no attribute 'argmin' what might be the problem? is there a better alte...

Google app engine images API - get image size

How can I get the size of an image transformed with the app engine images API? Note: I mean the size in bytes, not the dimensions. ...

How to convert an accented character in an unicode string to its unicode character code using Python?

Just wonder how to convert a unicode string like u'é' to its unicode character code u'\xe9'? Thank you for your help. ...

Referencing list entries within a for loop without indexes, possible?

A question of particular interest about python for loops. Engineering programs often require values at previous or future indexes, such as: for i in range(0,n): value = 0.3*list[i-1] + 0.5*list[i] + 0.2*list[i+1] etc... However I rather like the nice clean python syntax: for item in list: #Do stuff with item in list or for...

Buying a book targeted for intermediate to advance python

I currently have the budget to buy an intermediate to advanced python. The books price has to be below $50 (Canada), if possible, unless it's a really good book. Preferably there should be GUI programming in the book (not TK or QT, GTK or other toolsets preferred). Network programming (Socket) would be nice. The flavor of python that I...

How should I structure a video streaming web app?

I want a user to be able to create an account and upload a video to the site. How should I structure this web app, how should I start thinking about the project, how should I store the videos, and what stack would you recommend for this project? How should I think about the front-end, the server, and the database? The more detail, the ...

erase whole array Python

Hey guys, how would you erase a whole array, as in it has no items. I want to do this so I could store new values (a new set of 100 floats) into it and find the minimum. Right now my program is reading the minimum from sets before I think because it is appending itself with the previous set still in there (i use .append by the way). ...

Once I have identified the beginning and end parts of a section of an html document using lxml, how do I get everything between them

I am working with some html files. I am trying to figure out a way to consistently get to some text that exists in the documents. I know that the section I want begins with some bolded words and I know that the section ends with other bolded words. bolded_item=atree.cssselect('b') myKeys=[item for item in bolded_items if item.text if...

Convert Hexadecimal MAC address to user readable formating (Python)

Hi, I'm receiving from the socket a MAC address in this format: 0024e865a023 (hex converted from binary with received-string.encode("hex")) I would like to convert it to a user readable format like this : 00-24-e8-65-a0-23 Any easy way to do so ? Thanks ...

Efficient way of phrasing multiple tuple pair WHERE conditions in SQL statement

I want to perform an SQL query that is logically equivalent to the following: DELETE FROM pond_pairs WHERE ((pond1 = 12) AND (pond2 = 233)) OR ((pond1 = 12) AND (pond2 = 234)) OR ((pond1 = 12) AND (pond2 = 8)) OR ((pond1 = 13) AND (pond2 = 6547)) OR ((pond1 = 13879) AND (pond2 = 6)) I will have hundreds of thousands pond1-po...

find value of forloop at which event occurred Python

hey guys, this is very confusing... i am trying to find the minimum of an array by: for xpre in range(100): #used pre because I am using vapor pressures with some x molarity xvalue=xarray[xpre] for ppre in range(100): #same as xpre but vapor pressures for pure water, p pvalue=parray[p] d=math...

pyqt application lost icon after packaged by cx_freeze

I have a pyqt application whose icon is in a resource file. I can see the icon when run the application using python app.py. But after I package the application using cx_freeze, the icon is missing. I can see the compiled resource in the `library.zip' (generated by cx_freeze), but the icon is still missing. Any one can help? Thanks. ...

Python - Writing to a text file using functions ??

i wrote a simple function to write into a text file. like this, def write_func(var): var = str(var) myfile.write(var) a= 5 b= 5 c= a + b write_func(c) this will write the output to a desired file. now, i want the output in another format. say, write_func("Output is :"+c) so that the output will have a meaningful nam...

Quickest way to convert Cairo Surface to Pygame on OS-X

I'm looking for a way to draw smooth animations in Python. I want to use cairo, partly because I like the sub-pixel filtering and partly because I'm familiar with the API. My first approach was to use a GTK.DrawingArea as the target for a cairo surface. While the drawing was quick I couldn't find any reliable way to tie the display / buf...

Can you use Python v. 2.7 with Django?

The Django book says: "The core Django framework works with any Python version from 2.3 to 2.6, inclusive. Django’s optional GIS (Geographic Information Systems) support requires Python 2.4 to 2.6." ...

Trouble installing Django

I'm having trouble installing Django, even if I follow the instructions here: http://www.djangobook.com/en/2.0/chapter02/ Could someone please provide baby steps to installing Django. I'm talking baby steps that really break it down, so that a retarded person could do it. I've installed Django and unzipped the file, but I'm unsure wher...