Search Results

Showing results 1 to 40 of 834
Search took 0.05 seconds.
Search: Posts Made By: Gribouillis
Forum: Python 1 Hour Ago
Replies: 2
Views: 34
Posted By Gribouillis
You can use the 'key' argument to 'sort' or 'sorted'. Here, Data is a list. You can write

def my_key(item):
return item[1][1] # this returns 3.1 if item is ('1023', ['Name', '3.1',...
Forum: Python 8 Hours Ago
Replies: 5
Views: 59
Posted By Gribouillis
According to your previous post, I think that you are using the "graphics.py" module like this one (http://mcsp.wartburg.edu/zelle/python/). In that case, since p1 and p2 are not numbers but Points,...
Forum: Python 17 Hours Ago
Replies: 3
Views: 122
Posted By Gribouillis
Here is a code that finds the Src Port and Dst Port in your second example.
When you write regular expressions, always use raw strings prefixed with 'r', like r"my regex". Also, the character '.' in...
Forum: Python 20 Hours Ago
Replies: 3
Views: 122
Posted By Gribouillis
You can use this code snippet (http://www.daniweb.com/code/snippet217237.html).
Forum: Python 1 Day Ago
Replies: 8
Views: 144
Posted By Gribouillis
I ran pylint (http://www.logilab.org/project/pylint) on this code. Here is the result (note that this depends on my personal configuration of pylint, it may give a different result on your system)
...
Forum: Python 1 Day Ago
Replies: 11
Views: 287
Posted By Gribouillis
Yes, I knew there was a function like this, but I couldn't remember where it was. Thanks.
Forum: Python 2 Days Ago
Replies: 4
Views: 109
Posted By Gribouillis
You can also use format

message = "z's value is {z:0{digits}n}".format(z=2, digits=3)
print(message)
Forum: Python 2 Days Ago
Replies: 1
Views: 73
Posted By Gribouillis
I don't know OS X, but couldn't you run idle with the -s option and write a startup file, say startup.py containing os.chdir(os.path.expanduser('~/Documents/Python/')), and then set the IDLESTARTUP...
Forum: Python 2 Days Ago
Replies: 9
Views: 172
Posted By Gribouillis
The answer to "Can Python do this ?" is usually Yes.
"I need help" often means it's homework due in 2 hours.
Forum: Python 2 Days Ago
Replies: 4
Views: 168
Posted By Gribouillis
I'm afraid I can't help you more.It seems that you are having a problem with your package sources. Perhaps you could try to configure them with easy urpmi (http://easyurpmi.zarb.org/?language=en)....
Forum: Python 2 Days Ago
Replies: 4
Views: 168
Posted By Gribouillis
Mandriva 2010 is out ! Download it from here (http://www2.mandriva.com/downloads/?p=linux-one). It has packages python3 and tkinter3.
Forum: Python 3 Days Ago
Replies: 5
Views: 134
Posted By Gribouillis
great !
Forum: Python 3 Days Ago
Replies: 5
Views: 134
Posted By Gribouillis
Did you place a 'graphics.py' (good) or a 'graphic.pyc' (bad) in the site-packages folder ? Try to remove the '.pyc' and run again, it may work. Otherwise, you can attach graphics.py to a post, so...
Forum: Python 3 Days Ago
Replies: 5
Views: 134
Posted By Gribouillis
A simple thing to do is to put the file "graphics.py" in a folder named "site-packages" which is a subfolder of your python Lib folder. You should locate it easily on your computer.

Another...
Forum: Python 3 Days Ago
Replies: 6
Views: 199
Posted By Gribouillis
Here is a script which should work for 1 .pdb file and many .pd files. It creates the new versions of the .pd files (with less lines) in a separate output directory. See the usage at the end of the...
Forum: Python 3 Days Ago
Replies: 14
Solved: palindrome
Views: 271
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 3 Days Ago
Replies: 6
Views: 199
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 3 Days Ago
Replies: 6
Views: 199
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 3 Days Ago
Replies: 8
Views: 141
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 4 Days Ago
Replies: 8
Views: 141
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 4 Days Ago
Replies: 8
Views: 141
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 4 Days Ago
Replies: 4
Views: 168
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 4 Days Ago
Replies: 3
Views: 135
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 4 Days Ago
Replies: 4
Views: 129
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 4 Days Ago
Replies: 4
Views: 129
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 5 Days Ago
Replies: 18
Views: 368
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 5 Days Ago
Replies: 6
Views: 211
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 5 Days Ago
Replies: 6
Views: 211
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 5 Days Ago
Replies: 18
Views: 368
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 5 Days Ago
Replies: 18
Views: 368
Posted By Gribouillis
selec tfull set of sources
Forum: Python 5 Days Ago
Replies: 18
Views: 368
Posted By Gribouillis
When you build python3 form sources, it's installed in /usr/local. There is no risk of conflict.
Forum: Python 5 Days Ago
Replies: 18
Views: 368
Posted By Gribouillis
Did you try to click on the "add" button in your last picture ?
Forum: Python 5 Days Ago
Replies: 4
Views: 177
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 6 Days Ago
Replies: 18
Views: 368
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 6 Days Ago
Replies: 18
Views: 368
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 6 Days Ago
Replies: 4
Views: 136
Posted By Gribouillis
It already exists (py >= 2.6)

from itertools import product
myproduct = set(product(myset1, myset2))
Forum: Python 8 Days Ago
Replies: 0
Views: 174
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 8 Days Ago
Replies: 18
Views: 368
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 8 Days Ago
Replies: 9
Views: 216
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 8 Days Ago
Replies: 9
Views: 216
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...
Showing results 1 to 40 of 834

 


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

©2003 - 2009 DaniWeb® LLC