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 b

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 wrote: > sorry, just me being stupid :P should have read cl

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 wrote: > I think you want to use combinations_with_replacement: > > >>> var = ['a', 'b', 'c', 'd', 'e

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

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

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: http://hg.python.org/cpython/file/81898

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

2014-07-09 Thread Raúl Cumplido
lt; > http://mail.python.org/pipermail/tutor/attachments/20140709/ccbbee12/attachment-0001.html > > > > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://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] How does this work (iterating over a function)?

2014-07-09 Thread Raúl Cumplido
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 "", line 1, in StopIteration >>> Thanks, Raúl On Wed

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).

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

2014-06-27 Thread Raúl Cumplido
latform-independent) > > Regards, > Albert-Jan > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://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
2:34am') > '0034hr' > > i searched in date module but i am not able to figure out what how to do > this... > > > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > h

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

2011-10-24 Thread Raúl Cumplido
an print the corresponding values by using get() method- > - d.get('a') > -1 > > What if i have to print reverse??? > > ___ > 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://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] jenia. cannot install mysqldb

2011-04-21 Thread Raúl Cumplido
'127.0.0.1', # Set to empty string for > localhost. Not used with sqlite3. > 'PORT': '3306', # Set to empty string for > default. Not used with sqlite3. > > } > } > > > Thank you for your time and kind concern