Hi,
I'm trying to write a little script to clean my directories. In fact I have:
pattern = re.compile(format[i])
...
current_f.append(pattern.search(str(ls)))
and I want to use a list comprehension but when I try:
In [25]: [i for i in current_f.group(0)]
I get:
AttributeError: 'list' object has no attribute 'group'
So how to ma...
While coding in Python it's better to code by following the guidelines of PEP8.
And while coding for Symbian it's better to follow its coding standards.
But when I code for PyS60 which guidelines should I follow? Till now I have been following PEP8, but this code shows the opposite. Do I need to rework my code?
...
I am trying to get Python running with swig to do C/C++. I am running the tutorial here, 'building a python module'. When I do the call
gcc -c example.c example_wrap.c -I /my_correct_path/python2.5
I get an error:
my_correct_path/python2.5/pyport.h:761:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc ...
for a tool i need to figure all vim buffers that are still listed (there are listed and unlisted buffers)
unfortunately vim.buffers contains all buffers and there doesnt seem to be an attribute to figure if a buffer is listed or unlisted
the vim command of what i want to do is
:buffers
unfortunately all thats possible with the vim p...
I see this kind of thing sometimes:
(k for k in (j for j in (i for i in xrange(10))))
Now this really bends my brain, and I would rather it wasn't presented in this way.
Are there any use-cases, or examples of having used these nested expressions where it was more elegant and more readable than if it had been a nested loop?
Edit: Th...
Hi,
Is there a way to print out a function's parameter list?
For example:
def func(a, b, c):
pass
print_func_parametes(func)
Which will produce something like:
["a", "b", "c"]
...
I'm playing around with Twisted and documentation found on their homepage doesn't answer all my questions.
The topic I am most interested at the moment is Twisted Application Framework. Also some open source servers using twisted framework would provide nice material for studying how it's all tied up together in a bigger project.
So fa...
From Python docs: http://docs.python.org/library/stdtypes.html#comparisons
Implementation note: Objects of different types except numbers are ordered by their type names; objects of the same types that don’t support proper comparison are ordered by their address.
Is there any reason for choosing to do this over raising an exception...
I'm pretty new to Python, and haven't been able to find an answer to this question from searching online.
Here is an example decorator that does nothing (yet)
def my_decorator(text):
def wrap(f):
# grab magic f.parent_class_object.my_var and append text
def wrap_f(*args, **kwargs):
f(*args, **kwargs)
return wrap_f
...
I am trying to understand Iterability in Python.
As I understand, __iter__() should return an object that has next() method defined which must return a value or raise StopIteration exception. Thus I wrote this class which satisfies both these conditions.
But it doesnt seem to work. What is wrong?
class Iterator:
def __init__(self)...
So I'm in the middle of web-based filesystem abstraction layer development.
Just like file browser, except it has some extra features like freaky permissions etc.
I would like users to be notified somehow about directory changes.
So, i.e. when someone uploads a new file via FTP, certain users should get a proper message. It is not re...
I have a list of integers. I want to know whether the number 13 appears in it and, if so, where. Do I have to search the list twice, as in the code below?
if 13 in intList:
i = intList.index(13)
In the case of dictionaries, there's a get function which will ascertain membership and perform look-up with the same search. Is there ...
I use flup as fastcgi server for Django.
Please explain to me how can I use singleton?
I'm not sure I understand threading models for Flup well.
...
I'm using pygame to draw a line between two arbitrary points. I also want to append arrows at the end of the lines that face outward in the directions the line is traveling.
It's simple enough to stick an arrow image at the end, but I have no clue how the calculate the degrees of rotation to keep the arrows pointing in the right direct...
Dear all, I'm new to python programming.
I have this problem: I have a list of text files (both compressed and not) and I need to :
- connect to the server and open them
- after the opening of the file, I need to take his content and pass it to another python function that I wrote
def readLogs (fileName):
f = open (fileName, 'r')
inStr...
When using re.sub, how to you handle a situation where you need a capture followed by a number in the replacement string? For example, you cannot use "\10" for capture 1 followed by a '0' character because it will be interpreted as capture 10.
...
While the particular data I'm working with right now will not be user-generated, and will be sanitized within an inch of its life during my usual validation routines, I would like to learn how to do your basic INSERT, SELECT, etc. SQL queries while protecting myself against SQL injection attacks, just for future reference. I'd rather le...
I want to change my website's header only it if's not the homepage. Is there a tal:condition expression for that?
I've been reading this and can't find what I'm looking for...
thanks!
...
One of Python's strongest points is the ease of writing C and C++ extensions to speed up processor intensive parts of the code. Can these extensions avoid the Global Interpreter Lock or are they also restricted by the GIL? If not, then this "ease of extension" is even more of a killer feature than I previously realized. I suspect the ans...
A simple Python IRC client library that supports SSL?
...