Re: [Tutor] unittest for: Raises an exception

2015-02-18 Thread Raúl Cumplido
Hi, When using self.assertRaises like this you should pass a callable (the function you are going to call), but not call the function on the test. The problem is when the function takes arguments. At this point you need to create a callable with the two arguments. That can be done with functools

Re: [Tutor] How can I replicate a list in a for loop

2015-02-04 Thread Raúl Cumplido
I think you want to use combinations_with_replacement: var = ['a', 'b', 'c', 'd', 'e'] length=int(raw_input(enter the length of random letters you need )) enter the length of random letters you need 2 length 2 from itertools import combinations_with_replacement [''.join(s) for s in

Re: [Tutor] How can I replicate a list in a for loop

2015-02-04 Thread Raúl Cumplido
sorry, just me being stupid :P should have read closely what the problem was On Wed, Feb 4, 2015 at 12:54 PM, Raúl Cumplido raulcumpl...@gmail.com wrote: I think you want to use combinations_with_replacement: var = ['a', 'b', 'c', 'd', 'e'] length=int(raw_input(enter the length of random

Re: [Tutor] How can I replicate a list in a for loop

2015-02-04 Thread Raúl Cumplido
There is a repeat argument on the product function that is used exactly for what you want to do: for s in product(var, repeat=2) print ''.join(s) On Wed, Feb 4, 2015 at 1:01 PM, Raúl Cumplido raulcumpl...@gmail.com wrote: sorry, just me being stupid :P should have read closely

Re: [Tutor] Memory management in Python

2014-11-26 Thread Raúl Cumplido
Hi, This web is quite useful to visualize what is happening: http://www.pythontutor.com/visualize.html#mode=edit Step by Step: a=[1,2] You create a list a which contains two objects, in this case two integers (1, 2) l=[a,a] You create a list which contains two objects, which happen to be the

Re: [Tutor] accessing code for built in min()

2014-07-31 Thread Raúl Cumplido
Are you asking for the source code? For the CPython implementation, PyPy, IronPython, Jhyton? For the CPython implementation you can go to the repository: http://hg.python.org/cpython/branches Builtin implementations in C (for 2.7 version) are in the file:

Re: [Tutor] How does this work (iterating over a function)?

2014-07-09 Thread Raúl Cumplido
Hi, Let's see what happens iteration by iteration. First iteration: def fibonacci(max): #using a generator a, b = 0, 1 # The value of a is 0 and b is 1, easy :) while a max: yield a # yield a (0) (yield is a keyword that is used like return but returns a generator). This

Re: [Tutor] How does this work (iterating over a function)?

2014-07-09 Thread Raúl Cumplido
this with the next example: gen = fibonacci(3) gen.next() 0 gen.next() 1 gen.next() 1 gen.next() 2 gen.next() Traceback (most recent call last): File stdin, line 1, in module StopIteration Thanks, Raúl On Wed, Jul 9, 2014 at 4:18 PM, Raúl Cumplido raulcumpl...@gmail.com wrote: Hi, Let's see

Re: [Tutor] How does this work (iterating over a function)?

2014-07-09 Thread Raúl Cumplido
://mail.python.org/mailman/listinfo/tutor -- Raúl Cumplido ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Better way to check *nix remote file age?

2014-06-27 Thread Raúl Cumplido
://mail.python.org/mailman/listinfo/tutor -- Raúl Cumplido ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] 12 hr to 24 hr time conversion

2011-10-26 Thread Raúl Cumplido
this... ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Raúl Cumplido ___ Tutor maillist - Tutor@python.org To unsubscribe

Re: [Tutor] How to print corresponding keys in Dictionary

2011-10-24 Thread Raúl Cumplido
or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Raúl Cumplido ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] jenia. cannot install mysqldb

2011-04-21 Thread Raúl Cumplido
___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Raúl Cumplido ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http