Hi,
I need to retrieve the content of some files which are placed on a
network drive so in order to open them I need the full path to the
file.
Unfortunately some times the path is longer than 256 characters and in
Windows such a path is too long with the result that the file is not
found (though
Hi,
I need to instantiate an object (my_object) whose methods I have to
use in two files (file1.py and file2.py) which are in the same
directory. Is it possible to instantiate such object in the
__init__.py file and then directly use it in file1.py and file2.py?
If not, as I seem to experience, wh
Hi,
I have a file containing four columns of data separated by tabs (\t)
and I'd like to read a specific column from it (say the third). Is
there any simple way to do this in Python?
I've found quite interesting the linecache module but unfortunately
that is (to my knowledge) only working on line
mplish that? I can't come up with any
solution...
Thanks in advance
Cesco
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I have a defaultdict which I have initialized as follows:
def train(features):
model = collections.defaultdict(lambda: 1)
for f in features:
model[f] += 1
return model
def_dict = train(large_set_of_words)
where large_set_of_words is the list of possible strings.
I'd lik
> l = [1, 2, 3, 4]
> [sum(l[:x+1]) for x in xrange(len(l))]
Thanks,
actually my problem is a bit more complex (I thought I could get a
solution by posting a simplified version...)
The list is composed of objects:
l = [obj1, obj2, obj3, obj4]
and I need to call a method (say method1) on each obje
Hi,
I have the following list:
l = [1, 2, 3, 4]
and I'd like to obtain a list like the following:
l_partial_sum = [1, 3, 6, 10] (that is [1, 1+2, 1+2+3, 1+2+3+4])
Is there a simple way to accomplish this?
I came up with the following solution but it seems a bit too
elaborated for the task:
l_par
Hi,
is there a one-liner to accomplish the following task?
>From the list
l = ['string1', 'string2', 'string3']
generate the list of lists
l = [['string1'], ['string1', 'string2'], ['string1', 'string2',
'string3']]
Any help would be appreciated.
Thanks
Francesco
--
http://mail.python.org/mail
Hi,
I have a string which is constructed like this:
string = "Butler's 15\" TV"
s = """my string goes here "%s" """ % string
the single string, unfortunately, gets escaped which is something I
want to avoid because I have to load the data into a database using
the json format and I get an "inval
I have a set of N blocks of different lengths. The length of each
block is a multiple of a basic unit. The blocks, once lined up, make a
path of distance equal to R. Let's say we have 5 blocks with the
following lengths: N_set_lengths = (1, 3, 2, 1, 3), then the path we
cover by lining them up is e
> Since people are posting their solutions now (originally only hints
> were provided for the homework problem), here's mine:
Well, I never really said it was a homework problem. Sure there are
more implications to my question that I had first imagined and I'm
really happy I could get so many insi
On Mar 9, 3:51 pm, Paul Rubin <http://[EMAIL PROTECTED]> wrote:
> "cesco" <[EMAIL PROTECTED]> writes:
> > I have to generate a list of N random numbers (integer) whose sum is
> > equal to M. If, for example, I have to generate 5 random numbers whose
> >
I have to generate a list of N random numbers (integer) whose sum is
equal to M. If, for example, I have to generate 5 random numbers whose
sum is 50 a possible solution could be [3, 11, 7, 22, 7]. Is there a
simple pattern or function in Python to accomplish that?
Thanks and regards
Francesco
--
Hendrik van Rooyen wrote:
> "cesco" <[EMAIL PROTECTED]> wrote:
>
> >
> > Neil Cerutti wrote:
> > > On 2007-01-08, cesco <[EMAIL PROTECTED]> wrote:
> > > > Hi,
> > > >
> > > > I have a dictionar
Neil Cerutti wrote:
> On 2007-01-08, cesco <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I have a dictionary of lists of tuples like in the following example:
> > dict = {1: [(3, 4), (5, 8)],
> > 2: [(5, 4), (21, 3), (19, 2)],
> > 3: [(16,
Hi,
I have a dictionary of lists of tuples like in the following example:
dict = {1: [(3, 4), (5, 8)],
2: [(5, 4), (21, 3), (19, 2)],
3: [(16, 1), (0, 2), (1, 2), (3, 4)]]
In this case I have three lists inside the dict but this number is
known only at runtime. I have to write a f
Hi,
I wanted to install python, numpy and matplotlib on Linux Ubuntu.
I installed python with the following commands
./configure --enable-unicode=ucs4
make
make install
and then I installed numpy running
python setup.py install
Finally I came to matplotlib, that for the installation requires the
c
gain, I receive the error:
Traceback (most recent call last):
File "numpy/setup.py", line 26, in ?
from numpy.distutils.core import setup
ImportError: No module named numpy.distutils.core
Does anyone know how this module should be installed?
Thanks and regards
Cesco
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I have a binary file containing 1000 floating point numbers. I want to
load that file into an array. A way to do it could be the following:
>>> import array
>>> data = array.array('f')
>>> f = open('FileName.bin', 'rb')
>>> data.fromfile(f, 1000)
Now I have the following problem: if I don't
19 matches
Mail list logo