Re: [Tutor] Convert tuple within tuple into single tuple

2017-01-11 Thread Peter Otten
ramakrishna reddy wrote: > Hi All, > > Is there any way to convert x = (1, 2, 3, (4, 5)) to x = (1, 2, 3, 4, 5) > in python 2.7 Is the structure of x always the same? Then you can build a new tuple from >>> x[:-1] # all items but the last (1, 2, 3) and >>> x[-1] # the last item (4, 5)

Re: [Tutor] Convert tuple within tuple into single tuple

2017-01-11 Thread Emile van Sebille
On 01/10/2017 10:31 PM, ramakrishna reddy wrote: Hi All, Is there any way to convert x = (1, 2, 3, (4, 5)) to x = (1, 2, 3, 4, 5) in python 2.7 Almost: # /usr/bin/env python Python 2.7.3 (default, Sep 22 2012, 02:37:18) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license"

Re: [Tutor] Convert tuple within tuple into single tuple

2017-01-11 Thread Alan Gauld via Tutor
On 11/01/17 06:31, ramakrishna reddy wrote: > Hi All, > > Is there any way to convert x = (1, 2, 3, (4, 5)) to x = (1, 2, 3, 4, 5) in > python 2.7 You can write a function(*) to flatten the data structure, but you need to be careful and think through how you expect it to handle strings, say...

Re: [Tutor] Importing classes

2017-01-11 Thread Alan Gauld via Tutor
On 11/01/17 02:53, kay Cee wrote: > Is there a proper way to import a class from a module? If so, please tell. The most common way is probably: >>> from mymodule import Myclass >>> myobject = Myclass() but its just as good to do >>> import mymodule >>> myobject = mymodule.Myclass() --

[Tutor] Importing classes

2017-01-11 Thread kay Cee
Is there a proper way to import a class from a module? If so, please tell. Thank You, Unee0x ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

[Tutor] Convert tuple within tuple into single tuple

2017-01-11 Thread ramakrishna reddy
Hi All, Is there any way to convert x = (1, 2, 3, (4, 5)) to x = (1, 2, 3, 4, 5) in python 2.7 Thanks in advance Ram. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] small remark

2017-01-11 Thread Alan Gauld via Tutor
On 10/01/17 17:56, adil gourinda wrote: >When I was surfing in “Python Library” I made some observations and I want > to share them That's good and as a place to discuss those observations the tutor list is a suitable forum. However, if you want the proposals considered for actual