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
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
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
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
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
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
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
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
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).
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
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
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
'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
13 matches
Mail list logo