Search Results

Showing results 1 to 40 of 819
Search took 0.04 seconds.
Search: Posts Made By: Gribouillis
Forum: Python 3 Hours Ago
Replies: 14
Views: 187
Posted By Gribouillis
You can also do this without a loop

#!/usr/bin/env python
import re

nonletters = re.compile("[^a-zA-Z]+")

def letters_only(mystring):
return nonletters.sub(lambda m: '', mystring)
Forum: Python 6 Hours Ago
Replies: 3
Views: 79
Posted By Gribouillis
If you have 10 file1 and 2000 file2, it makes 20000 file3 (output files). You should explain clearly what you want:
* Are the file1 in a separate directory ? How do you recognize that a file is a...
Forum: Python 8 Hours Ago
Replies: 3
Views: 79
Posted By Gribouillis
I think you could try something like this

def key(line):
return tuple(line.strip().split()[2:6])

def make_key_set(file_path):
return set(key(line) for line in open(file_path))

...
Forum: Python 11 Hours Ago
Replies: 8
Views: 90
Posted By Gribouillis
You must CALL the read method to get the file's content

text = foo.read()

Also please mark your other thread with the same error as solved.
Forum: Python 12 Hours Ago
Replies: 8
Views: 90
Posted By Gribouillis
The statement

special = re.compile(r"[etn]")

creates a regular expression object, which represents the set of characters 'e', 't' or 'n'. When

special.sub(escape, text)

is executed, all...
Forum: Python 12 Hours Ago
Replies: 8
Views: 90
Posted By Gribouillis
You can use regular expressions and the re.sub function, like this

import re

special = re.compile(r"[etn]")

def escape(match):
return "\\" + match.group(0)

if __name__ == "__main__":
Forum: Python 14 Hours Ago
Replies: 1
Views: 82
Posted By Gribouillis
You MUST NOT install packages using source code and "./configure, make, make install". It's the last resort for programs for which no mandriva package exist. The correct way to do it is to install...
Forum: Python 20 Hours Ago
Replies: 3
Views: 82
Posted By Gribouillis
When you open a file, the cursor is at the beginning of the file. However

myfile.seek(0)

goes to the beginning of the file. Finally, read this....
Forum: Python 23 Hours Ago
Replies: 4
Views: 90
Posted By Gribouillis
First, you must read this reference counting (http://docs.python.org/extending/extending.html#reference-counting-in-python).
Why do you need to incref results ? First argument, that's how code is...
Forum: Python 23 Hours Ago
Replies: 4
Views: 90
Posted By Gribouillis
Yes I think that you must always incref the results. Also consider using Py_XINCREF and Py_XDECREF which handle the case where you pass a null pointer.
A good idea is to test your code with the help...
Forum: Python 1 Day Ago
Replies: 17
Views: 298
Posted By Gribouillis
If you want a link to a tutorial, here is one (http://wiki.mandriva.com/en/Docs/Basic_tasks/Installing_and_removing_software#Making_more_applications_available). You should browse the mandriva...
Forum: Python 1 Day Ago
Replies: 6
Views: 158
Posted By Gribouillis
In fact, there is a simpler method

def remove_all(sub, s):
"""
>>> remove_all('an', 'banana')
'ba'
>>> remove_all('cyc', 'bicycle')
'bile'
>>> remove_all('iss', 'Mississippi')
'Mippi'
Forum: Python 1 Day Ago
Replies: 6
Views: 158
Posted By Gribouillis
A possible implementation of remove_all

import re

def remove_all(sub, s):
"""
>>> remove_all('an', 'banana')
'ba'
>>> remove_all('cyc', 'bicycle')
'bile'
Forum: Python 2 Days Ago
Replies: 17
Views: 298
Posted By Gribouillis
I don't know how to solve the mirrorlist problem. Normally you dont need to insert the DVD, but if you insert it I don't think it hurts.
You can attach images to posts.
I soon must go for a few...
Forum: Python 2 Days Ago
Replies: 17
Views: 298
Posted By Gribouillis
selec tfull set of sources
Forum: Python 2 Days Ago
Replies: 17
Views: 298
Posted By Gribouillis
When you build python3 form sources, it's installed in /usr/local. There is no risk of conflict.
Forum: Python 2 Days Ago
Replies: 17
Views: 298
Posted By Gribouillis
Did you try to click on the "add" button in your last picture ?
Forum: Python 2 Days Ago
Replies: 4
Views: 160
Posted By Gribouillis
Did you read this in your assingment ?

Although it can be helpful to you to discuss your program with other people, and that is a reasonable thing to do
and a good way to learn, the work you hand...
Forum: Python 2 Days Ago
Replies: 17
Views: 298
Posted By Gribouillis
Also note that it should be available soon, as this page (http://fr2.rpmfind.net/linux/rpm2html/search.php?query=tkinter3) proves. But I don't think you should try to install these packages on 2009...
Forum: Python 2 Days Ago
Replies: 17
Views: 298
Posted By Gribouillis
I said that you need libtk-devel and libtcl-devel if you want to build with tkinter. If the libraries don't show in the list, you must check that your rpm sources configuration is good: open the...
Forum: Python 3 Days Ago
Replies: 4
Views: 116
Posted By Gribouillis
It already exists (py >= 2.6)

from itertools import product
myproduct = set(product(myset1, myset2))
Forum: Python 5 Days Ago
Replies: 0
Views: 138
Posted By Gribouillis
Some time ago, I was writing a small command line interpreter, with the help of the standard module cmd (http://docs.python.org/library/cmd.html#module-cmd) which offers minimal support for such...
Forum: Python 5 Days Ago
Replies: 17
Views: 298
Posted By Gribouillis
In the applications menu of your desktop panel, you select install software (you need the root password for this). This opens the software manager, which has a search form. Put libtcl in the search...
Forum: Python 5 Days Ago
Replies: 9
Views: 206
Posted By Gribouillis
There are small differences, for example in Pickle, there are Pickler and Unpickler classes which don't exist in cPickle. Often such double implementations exist because someone first wrote a python...
Forum: Python 5 Days Ago
Replies: 9
Views: 206
Posted By Gribouillis
The standard library has examples of modules wich offer 2 implementations, a C and a pure python implementation. For example Pickle and cPickle and StringIO and cStringIO. For most problems, you can...
Forum: Python 5 Days Ago
Replies: 17
Views: 298
Posted By Gribouillis
You probably need at least libtk-devel and libtcl-devel to build with tkinter.
Forum: Python 5 Days Ago
Replies: 9
Views: 206
Posted By Gribouillis
I think it's only the terminology of the python documentation. Usually the documentation opposes 'user defined types' implemented in python to 'built in types' implemented in C.
Forum: Python 5 Days Ago
Replies: 9
Views: 206
Posted By Gribouillis
There are many examples of extensions written in C or C++. For example the numpy package implements classes written in C.
One of the main reasons to do this is that C or C++ run much faster than...
Forum: Python 5 Days Ago
Replies: 3
Views: 180
Posted By Gribouillis
I don't understand the content of the function parse1. To use strcat, you must make sure that the destination char* is large enough to hold the result. I donc think that you can pass a python string...
Forum: Python 6 Days Ago
Replies: 3
Views: 180
Posted By Gribouillis
Did you try

print(charp_getitem(d, 20))

?
Forum: C 6 Days Ago
Replies: 6
Views: 218
Posted By Gribouillis
I looked in the source code of gcc-4.3.2 and I found this

char **buildargv (const char *input)
{
char *arg;
char *copybuf;
int squote = 0;
int dquote = 0;
int bsquote = 0;
int...
Forum: C 6 Days Ago
Replies: 6
Views: 218
Posted By Gribouillis
Thanks for your replies. I think you're right, there are some functions related to this in OS source code, but they're not very useful. It would have been great to find a well known C function for...
Forum: C 6 Days Ago
Replies: 6
Views: 218
Posted By Gribouillis
Suppose that I have a program named myprog, and I type this in a shell

$ myprog -z hello -m "this is a message"

The function main in myprog will receive a char** argv containing the following...
Forum: Python 6 Days Ago
Replies: 3
Views: 120
Posted By Gribouillis
try

string2 = "Random Number is\n{value:^16}".format(value = string1)

Also, you can read this (http://www.daniweb.com/code/snippet232375.html) :)
Forum: Python 6 Days Ago
Replies: 7
Views: 204
Posted By Gribouillis
In the "if choice" sequence, you should replace raw_input by input because you want the user input to be interpreted as a number and not as a string. Also read this...
Forum: Python 7 Days Ago
Replies: 2
Solved: input a set
Views: 130
Posted By Gribouillis
You can enter a python list and then convert it using eval

userInput = input("Enter a python list: ")
mylist = eval(userInput.strip())

# check that it's a list
assert(isinstance(mylist,...
Forum: Python 7 Days Ago
Replies: 3
Views: 204
Posted By Gribouillis
A nice tool is sphinx (http://sphinx.pocoo.org/) which converts text written in rich text format to html.
Forum: Python 7 Days Ago
Replies: 5
Views: 208
Posted By Gribouillis
I discovered a new python book today http://www.linuxtopia.org/online_books/programming_books/python_programming/index.html.
Forum: Python 7 Days Ago
Replies: 8
Views: 196
Posted By Gribouillis
I suggest that you write a module

# mystartup.py
import os, sys
site_packages = os.path.join(os.path.split(os.__file__)[0], "site-packages")
sys.path.append(site_packages)

and put this...
Forum: Python 8 Days Ago
Replies: 12
Views: 694
Posted By Gribouillis
Formatting with colors in a linux console
The following module combines formatting strings and ansi escape sequences to support printing with color in a linux console. After importing the module,...
Showing results 1 to 40 of 819

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC