How to get the owner and group of a folder with Python on a Linux machine?
Title says it all pretty much. Is there any way how I can find out about the owner and group of a folder with Python? Thank you so much, you guys are amazing! ...
Title says it all pretty much. Is there any way how I can find out about the owner and group of a folder with Python? Thank you so much, you guys are amazing! ...
I'm playing with Python Class inheritance and ran into a problem where the inherited __init__ is not being executed if called from the sub-class (code below) the result I get from Active Python is: >>> start Tom Sneed Sue Ann Traceback (most recent call last): File "C:\Python26\Lib\site-packages\pythonwin\pywin\framework\scriptutils...
I have a dictionary which store a string as the key, and an integer as the value. In my output I would like to have the key displayed as a string without parenthesis or commas. How would I do this? for f_name,f_loc in dict_func.items(): print ('Function names:\n\n\t{0} -- {1} lines of code\n'.format(f_name, f_loc)) output: En...
I know this kind of question gets asked all the time but either i've been unable to come across the answer i need, or i've been unable to understand it when i did. I want to be able to do something like: spam = StringVar() spam.set(aValue) class MyScale(Scale): def __init__(self,var,*args,**kwargs): Scale.__init__(self,*arg...
The title says it mostly. If I have an object in Python and want to access the name of the class it is instantiated from is there a standard way to do this? ...
I am working on porting over a database from a custom MSSQL CMS to MYSQL - Wordpress. I am using Python to read a txt file with \t delineated columns and one row per line. I am trying to write a Python script that will read this file (fread) and [eventually] create a MYSSQL ready .sql file with insert statements. A line in the file I'm...
What is the proper way to loop over a Python object's methods and call them? Given the object: class SomeTest(): def something1(self): print "something 1" def something2(self): print "something 2" ...
In Django, when you have a parent class and multiple child classes that inherit from it you would normally access a child through parentclass.childclass1_set or parentclass.childclass2_set, but what if I don't know the name of the specific child class I want? Is there a way to get the related objects in the parent->child direction witho...
I was doing some beginner AppEngine dev on a Windows box and installed Eclipse for that. I liked the autocompletion I got with the objects and functions. I moved my dev environment over to my Macbook, and installed Eclipse Ganymede. I installed the AppEngine SDK and Eclipse plug in. However, when I am typing out code now, the autocom...
I'm trying to convert one range of numbers to another, maintaining ratio. Maths is not my strong point. I have an image file where point values may range from -16000.00 to 16000.00 though the typical range may be much less. What I want to do is compress these values into the integer range 0-100, where 0 is the value of the smallest poin...
I can't see why this won't work. I am performing lstrip() on the string being passed to the function, and trying to see if it starts with """. For some reason, it gets caught in an infinite loop def find_comment(infile, line): line_t = line.lstrip() if not line_t.startswith('"""') and not line_t.startswith('#'): print (...
Hi, I am writing some small games in Python with Pygame & Pyglet as hobby projects. A class for 2D array would be very handy. I use py2exe to send the games to relatives/friends and numpy is just too big and most of it's features are unnecessary for my requirements. Could you suggest a Python module/recipe I could use for this. -- C...
Projectfundingdetail has a foreign key to project. The following query gives me the list of all projects that have any projectfundingdetail under 1000. How do I limit it to latest projectfundingdetail only. projects_list.filter(projectfundingdetail__budget__lte=1000).distinct() I have defined the following function, def latest_fundi...
I have this code in my forms.py: from django import forms from formfieldset.forms import FieldsetMixin class ContactForm(forms.Form, FieldsetMixin): full_name = forms.CharField(max_length=120) email = forms.EmailField() website = forms.URLField() message = forms.CharField(max_length=500, widget=forms.Textarea) send...
I'm having terrible trouble trying to understand python scoping rules. With the following script: a = 7 def printA(): print "Value of a is %d" % (a) def setA(value): a = value print "Inside setA, a is now %d" %(a) print "Before setA" printA() setA(42) print "After setA" printA() Gives the unexpected (to me) output of:...
How do I find out the current runtime directory from within a Python script? ...
I have 2 simple questions about python: 1.How to get number of lines of a file in python? 2.How to locate the position in a file object to the last line easily? ...
Hi all, Can someone please tell me if there is an equivalent for Python's lambda functions in Java? ...
I have a database full of names like: John Smith Scott J. Holmes Dr. Kaplan Ray's Dog Levi's Adrian O'Brien Perry Sean Smyre Carie Burchfield-Thompson Björn Árnason There are a few foreign names with accents in them that need to be converted to strings with non-accented characters. I'd like to convert the full names (...
I found many different ways of getting the last element from a list in python alist[-1] alist[len(alist) -1] Which is the way you would do this? ...