Hi all.
What is the fastest way to do the following:
I have an initial value V and a vector vec of (financial) indexes.
I want to generate a new vector nvec as
V, V*vec[0], V*vec[0]*vec[1], V*vec[0]*vec[1]*vec[2], ...
A numpy vectorized solution would be better.
Thanks
--
https://mail.python.
Às 23:36 de 01-10-2015, Oscar Benjamin escreveu:
>
> On Thu, 1 Oct 2015 21:51 Paulo da Silva <mailto:p_s_d_a_s_i_l_v_a...@netcabo.pt>> wrote:
...
>
> V * np.cumprod(vec)
>
Thank you very much Oscar and Duncan.
I googled a lot for such a function. Unfortunately the
Hi,
Sorry if this is a FAQ, but I have googled and didn't find any
satisfatory answer.
Is there a simple way, preferably multiplataform (or linux), of
generating sinusoidal/square waves sound in python?
Thanks for any answers/suggestions.
--
http://mail.python.org/mailman/listinfo/python-list
Em 30-12-2011 10:05, Dave Angel escreveu:
> On 12/30/2011 02:17 AM, Paulo da Silva wrote:
>> Hi,
>> Sorry if this is a FAQ, but I have googled and didn't find any
>> satisfatory answer.
>>
>> Is there a simple way, preferably multiplataform (or linux), of
Em 30-12-2011 11:23, mblume escreveu:
> Am Fri, 30 Dec 2011 07:17:13 + schrieb Paulo da Silva:
...
> Alternatively you might just generate (t,signal) samples, write them to
> a file and convert them using "sox" (under Linux, might also be available
> under Windows) to
Em 31-12-2011 01:19, K Richard Pixley escreveu:
> On 12/29/11 23:17 , Paulo da Silva wrote:
>> Hi,
>> Sorry if this is a FAQ, but I have googled and didn't find any
>> satisfatory answer.
>>
>> Is there a simple way, preferably multiplataform (or linux), of
Em 30-12-2011 07:17, Paulo da Silva escreveu:
> Hi,
> Sorry if this is a FAQ, but I have googled and didn't find any
> satisfatory answer.
>
> Is there a simple way, preferably multiplataform (or linux), of
> generating sinusoidal/square waves sound in python?
>
...
...
...
both using os module where should I put the "import os"? In both files?
Thanks
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
Paulo da Silva escreveu:
This is to thank all the answers I got so far.
Now I understand perfectly how "import" works.
Regards.
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
Paulo da Silva escreveu:
This is to thank all the answers I got so far.
Now I understand perfectly how "import" works.
Regards.
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
Bruno Desthuilliers escreveu:
> Paulo da Silva a écrit :
...
>>
>> c.py
>> class c:
> class C(object):
>
> 1/ better to stick to naming conventions (class names in CamelCase)
Ok. Thanks.
> 2/ do yourself a favor: use new-style classes
I still have
Hi!
What is the best way to have something like the bisect_left
method on a list of lists being the comparision based on an
specified arbitrary i_th element of each list element?
Is there, for lists, something equivalent to the __cmp__ function for
classes?
Thanks.
--
http://mail.python.org/mai
Gabriel Genellina escreveu:
> En Fri, 09 Mar 2007 17:15:44 -0300, Paulo da Silva
> <[EMAIL PROTECTED]> escribió:
...
>
> lists *are* classes (at least since Python 2.2)
> Inherit from the builtin list, redefine __cmp__(self, other) as
...
Thanks Gabriel. This sounds very n
Gabriel Genellina escreveu:
...
> Just omit the __init__ method, if you don't have anything additional to
> do. The inherited method will be used instead, as always:
Then, if I have something additional, I can do
def __init__(self,l=None):
if l!=None:
shuffle(ixs)
for i in ixs[:n-s]: xl[i]+=1
return xl
# Test it ...
xl=GenRInt(10,50)
print xl,"->",sum(xl)
print
xl=GenRInt(100,1)
print xl,"->",sum(xl)
print
xl=GenRInt(1000,1000)
print xl,"->",sum(xl)
Regards.
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
Paul Rubin escreveu:
> Paulo da Silva <[EMAIL PROTECTED]> writes:
>> May be this is what you want ...
>> I didn't test it enough ... but seems fine.
>
> That's way too complicated. Think about Gerald Flanagan's description
> of the telegraph poles, an
Alberto Vieira Ferreira Monteiro escreveu:
> Hi, I am new to Python, how stupid can be the questions I ask?
>
> For example, how can I add (mathematically) two tuples?
> x = (1,2)
> y = (3,4)
> How can I get z = (1 + 3, 2 + 4) ?
>
> Alberto Monteiro
I think that what you want is numpy.
I don't k
Hi.
I have just seen that csv module, more exactly the Dialect class,
does not have any variable to specify the "floating point" character!
In portuguese this is ','. Not '.'. 3.1415 -> 3,1415.
I think this is also the case of other languages/countries.
If I am correct, i.e. if there is no such po
[EMAIL PROTECTED] escreveu:
> On Mar 12, 4:26 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:
...
>
> locale.setlocale(locale.LC_NUMERIC, 'pt_BR.ISO8859-1')
> csv_writer = csv.writer(open("foo.csv","w"), dialect='excel')
> rows = ((
Diez B. Roggisch escreveu:
> Paulo da Silva schrieb:
...
>> That works but it is a pain to use.
>
> Why? I think it's straightforward.
That is not the point. The problem is to have things generalized.
I have some general purpose tables whose fields format I don't know
i
Diez B. Roggisch escreveu:
> Paulo da Silva wrote:
...
>
> That it does convert non-string-values to strings when writing could be seen
> as convenience, or actual bug as it might cause troubles as you perceived
> them - but the solution would clearly be to get rid of this funct
[EMAIL PROTECTED] escreveu:
> Paulo> That is not the point. The problem is to have things generalized.
>
> Well, perhaps. One of the goals of the csv module was to do things the way
> Excel does things.
It would be nice because many csv users use it to export files to
spreads
I need to make some data representation.
Basically a major window for a 2D chart,
a scrollable window with some few small 2D
graphics. The rest is a normal form with
buttons, labels and entries.
I thought of doing that using Tkinter+pmw+blt.
But now I'm considering use a web solution.
Is there any
):
...
return instance_of_C1
load=staticmethod(load)
This does not seem correct. How can I do it?
Thanks for any help
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
Alex Martelli escreveu:
> Paulo da Silva <[EMAIL PROTECTED]> wrote:
...
>
> E.g.:
>
> class C1(object):
> def __new__(cls, xxx):
> if xxx: return type.__new__(cls, xxx)
> else: return C1.load(xxx)
> @staticmethod
> def load(xx
Hi!
What's wrong with this way of subclassing?
from datetime import date
class MyDate(date):
def __init__(self,year,month=None,day=None):
if type(year) is str:
# The whole date is here as a string
year,month,day=map(int,stri
Miki escreveu:
> Hello Paulo,
>
>> What's wrong with this way of subclassing?
>> ...
> See
> http://sourceforge.net/tracker/index.php?func=detail&aid=1448640&group_id=5470&atid=105470
>
> HTH,
> --
> Miki <[EMAIL PROTECTED]>
>
Paulo da Silva escreveu:
> Alex Martelli escreveu:
>> Paulo da Silva <[EMAIL PROTECTED]> wrote:
>
>
>> E.g.:
>>
>> class C1(object):
>> def __new__(cls, xxx):
>> if xxx: return type.__new__(cls, xxx)
>> else: retu
Paulo da Silva escreveu:
> Paulo da Silva escreveu:
>> Alex Martelli escreveu:
>>> Paulo da Silva <[EMAIL PROTECTED]> wrote:
>>
>>
>>> E.g.:
>>>
>>> class C1(object):
>>> def __new__(cls, xxx):
>>>
Gabriel Genellina escreveu:
> En Fri, 16 Mar 2007 22:05:05 -0300, Paulo da Silva
> <[EMAIL PROTECTED]> escribió:
...
> class C(object):
>
> def __new__(cls, filename=None, foo=None, bar=None):
> if filename is not None:
> return cls.load(filenam
forces to allow __new__ accept
only 1 parameter (cls) which I don't want for the normal
situation.
Thanks for your patience.
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
Arnaud Delobelle escreveu:
> On Mar 17, 9:31 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:
...
>> I used __new__ to
>> subclass date class but now cPickle/pickle loads
>> does not work.
>>
>> from datetime import date
>> import cPickle,string
>>
Arnaud Delobelle escreveu:
> On Mar 17, 11:48 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:
>> Arnaud Delobelle escreveu:> On Mar 17, 9:31 pm, Paulo da Silva <[EMAIL
>> PROTECTED]> wrote:
>
> [snip]
>
>> Thanks. This works exactly the way you wrote.
Bruno Desthuilliers escreveu:
> Paulo da Silva a écrit :
...
>> class MyDate(date):
>> def __new__(cls,year,month=None,day=None):
>> if type(year) is str:
>
> And what if it's a unicode string ?
> The correct idiom here is:
>
ines() first to get it into a list eg
> d = open("file").readlines()
> for n, l in enumerate(d):
> print d[n+1]
>
> thanks
>
for n,l in enumerate(file("file")):
print n,l[:-1] # the :-1 is to drop the \n - print n,l, also works (end
with ',').
HTH
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
Gabriel Genellina escreveu:
> En Wed, 21 Mar 2007 07:51:32 -0300, Bruno Desthuilliers
> <[EMAIL PROTECTED]> escribió:
>
>> Paulo da Silva a écrit :
>>> As a relatively inexperient
>>> in python, how could I know that a 'string' is an instance o
Hi!
I was told in this NG that string is obsolet. I should use
str methods.
So, how do I join a list of strings delimited by a given
char, let's say ','?
Old way:
l=['a','b','c']
jl=string.join(l,',')
New way?
Thanks
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
Mike Kent escreveu:
...
> New way:
> l=['a','b','c']
> jl=','.join(l)
>
I thank you all.
Almost there ...
I tried "".join(l,',') but no success ... :-(
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
"str methods".
I tried that *new* way to do *old* 'string' job. Voila
the reason of my so pertinent question.
I am deeply sorry to have disturbed you in your python's heaven.
Next time I'll read all books available, all texts including
the python formal description before
posting, or perhaps it would be better and more simple if you
just ignore my posts.
Bye.
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
Dustan escreveu:
> On Mar 23, 1:30 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:
>> Mike Kent escreveu:
>> ...
>>
>>> New way:
>>> l=['a','b','c']
>>> jl=','.join(l)
>> I thank you all.
>>
>
Steven D'Aprano escreveu:
> On Fri, 23 Mar 2007 13:15:29 -0700, John Machin wrote:
>
>
> Western civilization is 6,000 years old.
After reading that post I wouldn't talk about
civilization, western or any other :-)
Regards.
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
Dustan escreveu:
> On Mar 24, 7:16 am, Paulo da Silva <[EMAIL PROTECTED]> wrote:
>> Dustan escreveu:
>>
>>
>>
>>> On Mar 23, 1:30 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:
>>>> Mike Kent escreveu:
>>>> ...
>&g
John Machin escreveu:
> On Mar 25, 12:32 am, Paulo da Silva <[EMAIL PROTECTED]> wrote:
>> John Machin escreveu:
..
> What was not obvious was (1) if you have been using Python for a
> while, how you managed to be unaware of str methods (2) if you are a
> newbie, how you m
Paulo da Silva escreveu:
> John Machin escreveu:
>> On Mar 25, 12:32 am, Paulo da Silva <[EMAIL PROTECTED]> wrote:
>>> John Machin escreveu:
> ...
...
> knowledge. If you feel that it is a question that deserves the
> honour of your response, just do it. Write
olution ...
HTH
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
Hi!
In a class C, I may do setattr(C,'x',10).
Is it possible to use getattr/setattr for variables not inside
classes or something equivalent? I mean with the same result as
exec("x=10").
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
7stud escreveu:
> On Apr 2, 10:08 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:
>> Is it possible to use getattr/setattr for variables not inside
>> classes...?
>
> What does the python documentation say about the definition of
> setattr()?
>
I didn't read
Steven Bethard escreveu:
> Paulo da Silva wrote:
...
> If you're at the module level, you can do::
>
> globals()['x'] = 10
>
> If you're inside a function, you probably want to look for another way
> of doing what you're doing.
>
> Wha
xxx_foo=bar. I have written a 1st draft using dicts but this
way it is much easier and readable.
Regards
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
gene tani escreveu:
> On Apr 10, 1:36 am, Passer By <[EMAIL PROTECTED]> wrote:
>> Has any created or not of examples of random sentence generators using
>> n-gram models (or other models might be interesting).
>>
>> I know of one example from a course at MIT, but besides that nothing.
>>
>> Any hel
using, let me call it, "C type code" (stat, chmod,
chown, etc). I would like to hear some opinions on if and how it would
be possible in a more elegant/python way.
Thanks.
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] escreveu:
> On Apr 12, 9:20 am, Paulo da Silva <[EMAIL PROTECTED]> wrote:
>> Hi!
>>
>> I need to process a file to produce another file that *must* have
>> *exactly* the same attributes and permissions of the former. What is the
>> best
[EMAIL PROTECTED] escreveu:
> On Apr 12, 5:19 pm, [EMAIL PROTECTED] wrote:
>> On Apr 12, 4:09 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:
>>
...
>
> After poking around a bit I also discovered the
> shutil module. It looks like you can use
> shutil.copy2. Mor
Jack escreveu:
> I wonder what everybody uses for Python editor/IDE on Linux?
> I use PyScripter on Windows, which is very good. Not sure if
> there's something handy like that on Linux. I need to do some
> development work on Linux and the distro I am using is Xubuntu.
>
>
eric3 is nice and sim
mrstephengross wrote:
> 1 list1 = ['a', 'b', 'c']
> 2 list2 = []
> 3 for item in list1: list2.append(item + 'foo')
>
> Is there a way to express lines 2-3 sort-of ilke this:
>
> list2 = [ for item in list1: item + '
you were asking. When asking about Mac OS X here, you are likely to get
> a lot of generic Unix responses. (Would it have been clearer if he had
> just said "emacs?")
There are several flavors, it's best to specify which one you mean.
People who say Emacs often mean GNU Emacs.
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
Jeff Schwab wrote:
> Paulo da Costa wrote:
>
>> People who say Emacs often mean GNU Emacs.
>
> That's funny; to me, Emacs usually means XEmacs. :)
Which is often a cause of confusion.
Paulo
--
http://mail.python.org/mailman/listinfo/python-list
rsion of the language which can't connect to libraries because
they haven't been ported yet.
Should this be a concern?
Cheers,
--
Paulo Jorge Matos - pocmatos at gmail.com
Webpage: http://www.personal.soton.ac.uk/pocm
--
http://mail.python.org/mailman/listinfo/python-list
ative
code (the usual approach, afaik);
2) You can't sell the bytecode, otherwise you get the client stuck with
a specific python version (given bytecode might vary between versions)
(the alternative);
Cheers,
--
Paulo Jorge Matos - pocmatos at gmail.com
Webpage: http://www.personal.soto
Sebastian Bassi wrote:
> On Tue, Oct 21, 2008 at 2:50 PM, Paulo J. Matos <[EMAIL PROTECTED]> wrote:
>> I was just wondering, if you wish to commercialize an application
>> developed in Python, what's the way to go?
>
> You choose the conditions. Nothing in Python l
Bruno Desthuilliers wrote:
> Paulo J. Matos a écrit :
>> Hi all,
>>
>> I was just wondering, if you wish to commercialize an application
>> developed in Python, what's the way to go?
>> I guess the only way is to sell the source, right?
>
> Nope, why
Grant Edwards wrote:
> On 2008-10-21, Paulo J. Matos <[EMAIL PROTECTED]> wrote:
>> Hi all,
>>
>> I was just wondering, if you wish to commercialize an application
>> developed in Python, what's the way to go?
>> I guess the only way is to sell the sourc
Paulo J. Matos wrote:
> Grant Edwards wrote:
>> On 2008-10-21, Paulo J. Matos <[EMAIL PROTECTED]> wrote:
>>> Hi all,
>>>
>>> I was just wondering, if you wish to commercialize an application
>>> developed in Python, what's the way to g
Hi all,
I am wondering if there is any work on contracts for Python. I could
only find PEP316, however, I am wondering if there is any official
support for it already (tools I mean), and if it is or if it will be
officially supported in any of the next releases of Python.
Cheers,
--
Paulo Jorge
printing 1,2,3,4 but this doesn't happen.
Can someone please explain why and what is going on beneath the veil?
Cheers,
--
Paulo Jorge Matos - pocmatos @ gmail.com
--
http://mail.python.org/mailman/listinfo/python-list
opy of lst without
the first element which is really not good memory-wise.
So, what would be the python way to do it?
Cheers,
--
Paulo Jorge Matos - pocmatos at gmail.com
Webpage: http://www.personal.soton.ac.uk/pocm
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Oct 30, 2008 at 8:42 PM, Arnaud Delobelle
<[EMAIL PROTECTED]> wrote:
> On Oct 30, 8:07 pm, "Paulo J. Matos" <[EMAIL PROTECTED]> wrote:
>> Hi all,
>>
>> I guess this is a recurring issue for someone who doesn't really know
>> the python
Hi all,
What's the best way to know the amount of memory allocated by a
function and the time it took to run? While the latter is simple to
implement using a wrapper function, the former is striking me as
something that needs to be primitive to python. Any tips?
Cheers,
--
Paulo Jorge
x27;s what I should use.
Is that right?
Cheers,
--
Paulo Jorge Matos - pocmatos at gmail.com
Webpage: http://www.personal.soton.ac.uk/pocm
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Nov 3, 2008 at 12:32 PM, Ben Finney
<[EMAIL PROTECTED]> wrote:
> "Paulo J. Matos" <[EMAIL PROTECTED]> writes:
>
>> I am a Python beginner, reading through 2.6 tutorial. I am wondering
>> where are structures?
>
> I'm wondering a more f
On Mon, Nov 3, 2008 at 10:10 PM, Arnaud Delobelle
<[EMAIL PROTECTED]> wrote:
> Ben Finney <[EMAIL PROTECTED]> writes:
>
>> "Paulo J. Matos" <[EMAIL PROTECTED]> writes:
> [...]
>> Okay, you're talking about 'struct' from the C langua
On Mon, Nov 3, 2008 at 10:19 PM, Aaron Brady <[EMAIL PROTECTED]> wrote:
> On Nov 3, 3:45 pm, Ben Finney <[EMAIL PROTECTED]>
> wrote:
>> "Paulo J. Matos" <[EMAIL PROTECTED]> writes:
>>
>> > On Mon, Nov 3, 2008 at 12:32 PM, Ben Finney
>
On Mon, Nov 3, 2008 at 11:47 PM, Joe Strout <[EMAIL PROTECTED]> wrote:
> On Nov 3, 2008, at 4:38 PM, Paulo J. Matos wrote:
>
>> However, I wouldn't dare to say Python needs structures to be a good
>> language, or anything similar. My question was more directed to : if
there any impure Python?
> George
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
>
--
Paulo Jorge Matos - pocmatos at gmail.com
Webpage: http://www.personal.soton.ac.uk/pocm
--
http://mail.python.org/mailman/listinfo/python-list
Hi.
Is there a python library/module to handle both the server and client
sides of dns protocol?
I have googled for it but I only found client side ones (at least from
the superficial readings I did).
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
Em 10-12-2010 02:59, Jean-Paul Calderone escreveu:
> On Dec 9, 8:15 pm, Paulo da Silva
> wrote:
>> Hi.
>>
>> Is there a python library/module to handle both the server and client
>> sides of dns protocol?
>>
>> I have googled for it but I only fo
Hi!
I have a big data structure cpickled into a datafile, by python2.
I tried to unpickle it using python3 but got the followin message:
File "/usr/lib64/python3.1/pickle.py", line 1372, in loads
encoding=encoding, errors=errors).load()
_pickle.UnpicklingError: invalid load key, 'x'.
Is there
Em 02-06-2010 04:48, Paulo da Silva escreveu:
> Hi!
>
> I have a big data structure cpickled into a datafile, by python2.
> I tried to unpickle it using python3 but got the followin message:
> File "/usr/lib64/python3.1/pickle.py", line 1372, in loads
> encoding=e
I need to read text files and process each line using string
comparisions and regexp.
I have a python2 program that uses .readline to read each
line as a string. Then, processing it was a trivial job.
With python3 I got error messagew like:
File "./pp1.py", line 93, in RL
line=inf.readline()
Em 06-06-2010 00:41, Chris Rebert escreveu:
> On Sat, Jun 5, 2010 at 4:03 PM, Paulo da Silva
> wrote:
...
>
> Specify the encoding of the text when opening the file using the
> `encoding` parameter. For Windows-1252 for example:
>
> your_file = open("path/to/file.e
Em 06-06-2010 04:05, John Machin escreveu:
> On Jun 6, 12:14 pm, MRAB wrote:
>> Paulo da Silva wrote:
...
>>> OK! This fixes my current problem. I used encoding="iso-8859-15". This
>>> is how my text files are encoded.
>>> But what about a more ge
I understand the concept of a static method.
However I don't know what is a class method.
Would anybody pls. explain me?
class C:
@classmethod
def ...
...
Thanks
--
http://mail.python.org/mailman/listinfo/python-list
Em 23-08-2010 04:30, James Mills escreveu:
> On Mon, Aug 23, 2010 at 12:49 PM, Paulo da Silva
> wrote:
>> I understand the concept of a static method.
>> However I don't know what is a class method.
>> Would anybody pls. explain me?
>
> Please read this firs
Em 23-08-2010 06:16, Ian Kelly escreveu:
> On Sun, Aug 22, 2010 at 9:53 PM, Paulo da Silva
> wrote:
>> Em 23-08-2010 04:30, James Mills escreveu:
>>> On Mon, Aug 23, 2010 at 12:49 PM, Paulo da Silva
>>> wrote:
>>>> I understand the concept of a static m
Hi!
I have a dir with lots of csv files. These files are updated +- once a
day. I could see that some values are converted, during output, to very
close values but with lots of digits. I understand that is caused by the
internal bits' representation of the float/double values.
Now my question is:
Às 23:29 de 11-03-2017, Erik escreveu:
> Hi Paulo,
>
> On 11/03/17 22:01, Paulo da Silva wrote:
...
>> Now my question is: Is it possible the occurrence of successive
>> cumulative errors? I mean reading a file, adding lines or change few
>> ones but keeping the most o
Hi!
The problem:
import PySide
print(PySide.__version__)
AttributeError: 'module' object has no attribute '__version__'
How can I fix this?
Other PySide examples seem to work fine!
Thanks for any help.
Further information:
/usr/lib64/python3.4/site-packages/PySide contains only .so files
/u
Às 07:55 de 15-07-2017, Paulo da Silva escreveu:
> Hi!
>
> The problem:
>
> import PySide
> print(PySide.__version__)
>
> AttributeError: 'module' object has no attribute '__version__'
>
> How can I fix this?
>
> Other PySide examples s
201 - 288 of 288 matches
Mail list logo