python

python file copying

Is there any difference in speed of copying files from one location to another betwen python or delphi or c++ ? I guess that all 3 laguages uses same or similar win api calls and that there is not much performance difference. ...

Use of properties in python like in example C#

Hi there, I currently work with Python for a while and I came to the point where I questioned myself whether I should use "Properties" in Python as often as in C#. In C# I've mostly created properties for the majority of my classes. It seems that properties are not that popular in python, am I wrong? How to use properties in Python? r...

Yielding until all needed values are yielded, is there way to make slice to become lazy

Is there way to stop yielding when generator did not finish values and all needed results have been read? I mean that generator is giving values without ever doing StopIteration. For example, this never stops: (REVISED) from random import randint def devtrue(): while True: yield True answers=[False for _ in range(randint(1...

What are the technologies that i should use for developing SaaS. Software as a service

Hello Everyone, Guys i would like to know what are the tools and technologies needed to start a software as a service business. What are the requirements needed ? ...

Stoping generator in first answer, use return instead

I am using too much to my taste the pattern (after every possible solution branch of the search). This is the code to find boggle words in given square. It had a bug if the words are not preselected to include only those whose letter pairs are neighbours, which I fixed now by changing comparrision not pos to pos is None. def word_path(w...

Python - The request headers for mechanize

I am looking for a way to view the request (not response) headers, specifically what browser mechanize claims to be. Also how would I go about manipulating them, eg setting another browser? Example: import mechanize browser = mechanize.Browser() # Now I want to make a request to eg example.com with custom headers using browser The pu...

Bug in third-party dependency creates python packaging dilemma

Hi everyone, I'm a developer on a software project for Linux that uses Python and PyGTK. The program we are writing depends on a number of third-party packages that are available through all mayor distro repositories. One of these is a python binding (written in C) that allows our program to chat with a common C library. Unfortunately, t...

How to let PyDev autocomplete named arguments

Hi, I noticed that my PyDev does not autocomplete named arguments. For example, class Author(models.Model): first_name = CharField(max_length=30) last_name = CharField(max_length=30) email = models.EmailField(blank=True,verbose_n [caret] It'd be great if I could hit ctrl+space here and get verbose_name etc. Can this be c...

How to re-read in the last point ! python

hello everyone how to read txt file and stop then continue at last read line example: Joe LOley Hana fat oh beef come one example = the txt file and that last line i had read it is Hana fat so how i can continue ? like that: #!/usr/bin/python #this script name is x.py don't forget that import os f= open("Str1k3r.txt", "r") for pwd i...

XPath: match multiple elements in one expression

Hi, I'm trying to do this (using lxml): //*[@id="32808345" or @id="33771423" or @id="15929470" or @id="33771117" or @id="15929266"] in order to get all elements, no matter what tag, with the specified id's. I'm getting the following traceback: invalid attribute predicate this is how I'm generating the str (if that is relevant to t...

Why Python is not full object-oriented ?

I want to know , why Python is not full object-oriented ? (e.g : Does not support private , public , protected) . What`s the advantage and disadvantage of this ? By this expressions , Python is suitable for what applications (Desktop , Scientific , Web or ...) ? Thanks . ...

How to cache username and passwd in pysvn

here is my code #!/usr/bin/python # -*- coding:utf-8 -*- import sys import pysvn def main(): client = pysvn.Client() client.callback_get_login = lambda realm, username, may_save:(True, "myusername", "mypasswd", True) print client.cat('http://svn.mydomain.com/file1.py') print client.cat('http://svn.mydomain.com/file2.py')...

Creating indexes - MongoDB

Hi folks, my "table" look like this: {'name':'Rupert', 'type':'Unicorn', 'actions':[ {'time':0, 'position':[0,0], 'action':'run'}, {'time':50, 'position':[50,0], 'action':'stoprun'}, {'time':50, 'position':[50,0], 'action':'jump'}, {'time':55, 'position':[50,0], 'action':'laugh'}, ... ]} any way I can index the it...

How to install OpenCV for python

HI! I'm trying to install opencv and use it with python, but when I compile it I get no errors but I can't import cv module from python: patrick:release patrick$ python Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>...

Python Sorting Question

Hi, i need to sort the following list of Tuples in Python: ListOfTuples = [('10', '2010 Jan 1;', 'Rapoport AM', 'Role of antiepileptic drugs as preventive agents for migraine', '20030417'), ('21', '2009 Nov;', 'Johannessen SI', 'Antiepilepticdrugs in epilepsy and other disorders--a population-based study of prescriptions', '19679449'),....

What is the relation between PATH_MAX and NAME_MAX, and how do I obtain?

In limits.h, and in various places in the POSIX manpages, there are references to PATH_MAX and NAME_MAX. How do these relate to one another? Where is the official documentation for them? How can I obtain them at run time, and (where relevant) compile time for the C, Python, and GNU (shell) environments? ...

How to handle configuration files with distutils to respect unixen's FHS?

Suppose we have a program called foo. If use absolute path: setup(..., data_files=[..., ('/etc', ['foo.cfg'])] ) Then foo$ python setup.py --prefix=/usr/local and we will have /etc/foo.cfg. But we should have /usr/local/etc/foo.cfg instead according to FHS. What if we use a relative path? setup(..., data_f...

Python list, lookup object name, efficiency advice

Suppose I have the following object: class Foo(object): def __init__(self, name=None): self.name = name def __repr__(self): return self.name And a list containing multiple instances, such as: list = [Foo(name='alice'), Foo(name='bob'), Foo(name='charlie')] If I want to find an object with a given name, I could use the ...

Python: Accessing Values For Dict Key Made Using Variables

Hi I've been coding a console version of Minesweeper just to learn some of the basics of Python. It uses a coordinate system that is recorded in a dictionary. Now, I have been able to implement it successfully but accessing or assigning a value to a specific coordinate key using variables for the "x,y" of the coordinate seems... clunky. ...

use gtk in a nautilus extension using python

The following code import gtk import nautilus import os def alert(message): """A function to debug""" dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, message) dialog.run() dialog.destroy() class TestExtension(nautilus.MenuProvider): def __init__(self): pass def ge...