[Tutor] help using f2py

2010-01-13 Thread Jose Amoreira
rors (see below the error output). I'm not sure if this has any relevance but if I change argument x to a real scalar (instead of an array), then f2py executes fine and the python module is generated. I just don't get it! Can anybody explain me what I am doing wrong, please? Thanks

Re: [Tutor] string to list

2010-02-10 Thread Jose Amoreira
ty is to use the eval function. Look at this snippet from an idle session: >>> s="[(1,2),(3,4)]" >>> lst=eval(s) >>> lst [(1, 2), (3, 4)] >>> lst[0] (1, 2) >>> Hope this helped Jose Amoreira __

Re: [Tutor] Looking for duplicates within a list

2010-06-11 Thread Jose Amoreira
On Friday, June 11, 2010 02:57:34 pm Ken G. wrote: > I have been working on this problem for several days and I am not making > any progress. I have a group of 18 number, in ascending order, within a > list. They ranged from 1 to 39. Some numbers are duplicated as much as > three times or as few

Re: [Tutor] (no subject)

2010-06-12 Thread Jose Amoreira
On Friday, June 11, 2010 10:12:27 pm Advertising Department wrote: > #!/Library/Frameworks/Python.framework/Versions/Current/bin/pythonw > """still thinking in imperative" > """ > > ## obviously this is a bad construct. > ## Can someone suggest a pythonesque way of doing this? > > > def getid():

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Jose Amoreira
like Python, it smells like Python, it even runs as Python, if you import random from random beforehand. Python really is executable pseudo code! Cheers Jose Amoreira ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] variable numbers of for loops

2010-11-23 Thread Jose Amoreira
Hi, This is a somewhat algorithmic question, not strictly pythonic. I was writing a program to generate all possible n-letter words with letters taken from an alphabet (I mean, if the alphabet is ['a','b'] the one-letter words are 'a' and 'b', the two letter words are 'aa', 'ab', 'ba', 'bb' and

Re: [Tutor] variable numbers of for loops

2010-11-23 Thread Jose Amoreira
On Tuesday, November 23, 2010 02:01:40 pm Mac Ryan wrote: > The code you wrote generates programs like: > > for l0 in alphabet: > for l1 in alphabet: > for l2 in alphabet: > word = "".join([eval("l"+str(i)) for i in range(n)]) > listOfWords.append(word) > > wh

[Tutor] namespaces and global

2009-10-14 Thread Jose Amoreira
Hello I'm new to this list. I tried to find the answer to my question but found nothing I could really use. I'm sorry if this is a FAQ. I want to use a variable defined in an interactive session with the python interpreter inside a function imported from a module. For instance, imagine that my

Re: [Tutor] namespaces and global

2009-10-14 Thread Jose Amoreira
y, thanks again! Best Regards, Jose On Wednesday 14 October 2009 06:18:28 pm Alan Gauld wrote: > "Jose Amoreira" wrote > > > Of course I could redefine my module function, including the parameter a > > in > > the list of arguments, but I'd rather not. > >

Re: [Tutor] OT: Writing code while tired, counterproductive?

2009-11-14 Thread Jose Amoreira
choir, all sorts of crazy things. That's definitely the time to STOP!, and get some real sleep. Cheers, Jose Amoreira ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Unexpected Result in Test Sequence

2009-11-16 Thread Jose Amoreira
Hi! Everytime your program calls function p, list1 is appended to. It keeps on getting bigger and bigger. The function adds all the elements of the list, but the total is divided by 1000, even if the list is already much longer that 1000! And there's another thing. When var1 and var2 are intege

[Tutor] Iterating over two sequences in "parallel"

2009-11-28 Thread Jose Amoreira
both lists, which may not be convenient. Of course we can make backup copies of the lists if needed, but we are then recovering the previous method ugliness... Do you guys have any suggestions regarding this? Thanks Jose Amoreira ___ Tutor maillist

Re: [Tutor] Iterating over two sequences in "parallel"

2009-11-28 Thread Jose Amoreira
Yes, Robert, that does it! Thanks a lot! Have a nice weekend! Jose On Saturday 28 November 2009 10:54:56 am Robert Johansson wrote: > Hi! > I want to process corresponding elements of two lists, sequentially. Call > the > lists list1 and list2, and assume they have equal lengths. I can do > someth

[Tutor] How to vectorize a constant function?

2011-02-25 Thread Jose Amoreira
Hello! In "A Primer on Scientific Programming with Python", they define a vectorized function as a scalar function that, when called with a vector argument, returns a vector with the values of the function for each of the values stored in the argument vector. I am trying to define a constant ve

Re: [Tutor] A question about sys.argv

2011-11-01 Thread Jose Amoreira
HiOn Tuesday, November 01, 2011 01:55:18 PM Joel Goldstick wrote: > On Tue, Nov 1, 2011 at 9:48 AM, Jefferson Ragot wrote: > > In a Vista command prompt if I typed this: > > >>> python somescript.py filename > > > > Will sys.argv[1] return a valid path or just the filename? > > If it ju

[Tutor] tkfiledialogs and hidden files

2011-11-07 Thread Jose Amoreira
Hello! Is there any way to configure tkFileDialogs so that they don't display hidden files? Thanks. Ze Amoreira ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] tkfiledialogs and hidden files

2011-11-08 Thread Jose Amoreira
On Tuesday, November 08, 2011 12:38:19 PM Dave Angel wrote: > On 11/07/2011 09:45 PM, Jose Amoreira wrote: > > Hello! > > Is there any way to configure tkFileDialogs so that they don't display > > hidden files? > > Thanks. > > Ze Amoreira > > I can'

[Tutor] two-dimensional color map

2012-02-09 Thread Jose Amoreira
Hello I'm trying to plot a false-color map of a two dimensional function. My main problem is that the function I want to plot depends also on time, and I wish to show the plot as the function evolves, in real time. My first (and only, so far) idea on how to achieve this was to iterate the comput

[Tutor] two-dimensional color map

2012-02-09 Thread Jose Amoreira
I'm so, so sorry! When editing my script before posting it, I accidently deleted a line activating matplotlib interactive mode. The correct listing is the one below. Hello I'm trying to plot a false-color map of a two dimensional function. My main problem is that the function I want to plot dep

Re: [Tutor] two-dimensional color map

2012-02-09 Thread Jose Amoreira
On Thursday, February 09, 2012 10:45:35 AM Nate Lastname wrote: > Have you considered pygame and its surfarray module? Thanks, Nate. I haven't, but I will. Ze___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://ma

Re: [Tutor] Solve wave equation

2012-02-24 Thread Jose Amoreira
On Thursday, February 23, 2012 12:57:39 PM David Craig wrote: > Hi, > I am trying to write some code that will solve the 2D wave equation by > the finite difference method, but it just returns an array full of zeros > and NaN's. Not sure where I am going wrong, the code is attached so if > could so

[Tutor] Where to put small auxiliary function

2012-07-20 Thread Jose Amoreira
Hi. This is a question about style. I have a class definition that calls a small auxiliary function. Because this function isn't used anywhere else, I'd like to include it inside the class definition. However, if I do that, I'll have to use "self" in the call argument, which is (I think) rather awk

Re: [Tutor] Where to put small auxiliary function

2012-07-20 Thread Jose Amoreira
Hi Mark, Thanks. > [SNIP] >> Let me give an example: >> >> def is_odd(k): >> if k % 2 == 0: >> return False >> else: >> return True > > > I'll point out before anyone else does that you can write this function as a > one line return. I'll leave you to work out how. Pe

Re: [Tutor] a puzzle about -3**2 vs (-3)**2

2015-07-31 Thread Jose Amoreira
Hello! On 07/31/2015 01:58 AM, D Wyatt wrote: I just read in a book a little while ago that ** trumps a negative sign? I am struggling with the audacity of that as -1 is negative 1, NOT minus 1. I'm not sure about what you mean by "trumps", but the square of negative one is positive one (nega

Re: [Tutor] a puzzle about -3**2 vs (-3)**2

2015-07-31 Thread Jose Amoreira
On 07/31/2015 11:36 AM, Alan Gauld wrote: On 31/07/15 10:55, Jose Amoreira wrote: Given the precedence rules already mentioned by Alan and Todd, the results of the operations you showed us are exactly as expected. You'll get the same results if you try with a pocket calculator or usin

[Tutor] list of references to object properties

2013-01-18 Thread Jose Amoreira
Hello Suppose I have a list l_obj of similar objects. Is there any way I can generate a list l_prp of references to a given property of those objects in such a way that, if change the value of one element in l_prp, the corresponding object in l_obj gets its property updated, and vice-versa? Let giv

Re: [Tutor] list of references to object properties

2013-01-18 Thread Jose Amoreira
Thanks, Peter. I was trying to avoid the regenerate step for updating. But maybe I can restructure my code and objects to make this simpler. Before that I'll try this view approach. Thanks again Ze On Fri, Jan 18, 2013 at 11:37 AM, Peter Otten <__pete...@web.de> wrote: > Jose

Re: [Tutor] list of references to object properties

2013-01-19 Thread Jose Amoreira
27;t like it. It'd be better (no duplication) if it was just a list of references to the values stored in the planet objects, I think. But I see your point. Thanks again, Jose Amoreira ___ Tutor maillist - Tutor@python.org To unsubscribe or change

[Tutor] Slices of lists of lists

2014-03-28 Thread Jose Amoreira
13] In [7]: l[:][1] Out[7]: [21, 22, 23] Why is this so? Thanks, Jose Amoreira ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Slices of lists of lists

2014-03-28 Thread Jose Amoreira
Jose, Just for clarity, are you trying to access a particular *column* in your last example? Bob Yes, that's it! I wanted to say "column", not "row" in my last example. Sorry about that! Thanks Jose ___ Tutor maillist - Tutor@python.org To unsu

Re: [Tutor] Slices of lists of lists

2014-03-28 Thread Jose Amoreira
On 03/28/2014 10:32 AM, Alan Gauld wrote: No, standard slices on the first element will give you sublists of the first row. Python doesn't have any concept of that second dimension, it only sees a list of items. The fact those items are themselves lists is purely incidental to the interpreter.

[Tutor] Question about style

2014-07-16 Thread Jose Amoreira
Hello I wrote a function that, given a list of numbers, finds clusters of values by proximity and returns a reduced list containing the centers of these clusters. However, I find it rather unclear. I would appreciate any comments on how pythonic my function is and suggestions to improve its re

Re: [Tutor] Question about style

2014-07-16 Thread Jose Amoreira
Hi! On 07/16/2014 10:14 PM, Wolfgang Maier wrote: careful here: you just stored a tuple instead of a list; doesn't matter for your current implementation, but may bite you at some point. Oh, you're right. Silly mistake, even if harmless for the application I have in mind. else:

Re: [Tutor] Question about style

2014-07-17 Thread Jose Amoreira
Hello, On 07/17/2014 12:05 AM, Alan Gauld wrote: Just throwing this idea in without really thinking about it... Would itertools.groupby work? It takes a sorted collection and groups the items found based on a key function. If the key function deemed two items identical if they were within dist

[Tutor] Surprising behaviour of optional argument

2014-07-17 Thread Jose Amoreira
Hello I stumbled on something I found surprising. I'm using standard python (cpython, I guess) 2.7 on openSuse 13.1. Consider the function In [2]: def f(x,y=[]): ...: print y ...: y.append(x) ...: return x This is the output of repeated calls to this function: In [3]: f(

Re: [Tutor] Surprising behaviour of optional argument

2014-07-17 Thread Jose Amoreira
Hi On 07/17/2014 06:34 PM, Danny Yoo wrote: Yeah; the default value is not reevaluated between calls. It's a common gotcha. Here are a few links to read more: http://effbot.org/zone/default-values.htm http://docs.python-guide.org/en/latest/writing/gotchas/#mutable-default-arguments Good