Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99913 > unrolled thread
| Started by | Robert <rxjwg98@gmail.com> |
|---|---|
| First post | 2015-12-02 12:37 -0800 |
| Last post | 2015-12-05 22:20 +0000 |
| Articles | 7 — 5 participants |
Back to article view | Back to comp.lang.python
Question about split method Robert <rxjwg98@gmail.com> - 2015-12-02 12:37 -0800
Re: Question about split method Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-02 14:44 -0600
Re: Question about split method Robert <rxjwg98@gmail.com> - 2015-12-02 13:00 -0800
Re: Question about split method Peter Pearson <pkpearson@nowhere.invalid> - 2015-12-05 19:29 +0000
Re: Question about split method Robert <rxjwg98@gmail.com> - 2015-12-05 11:51 -0800
Re: Question about split method Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-12-05 20:27 +0000
Re: Question about split method Erik <python@lucidity.plus.com> - 2015-12-05 22:20 +0000
| From | Robert <rxjwg98@gmail.com> |
|---|---|
| Date | 2015-12-02 12:37 -0800 |
| Subject | Question about split method |
| Message-ID | <169982db-7285-484a-9a48-0d4a2ea7dea1@googlegroups.com> |
Hi,
I learn split method online. When I try to run the line with ss1 beginning,
I don't understand why its output of ss1 and ss2. I have check the help
about split. It looks like that it is a numpy method.
What is the split method parameter (within " ") for?
Thanks,
...............
ss0="1, 2, 4, 8, 16".split(", ")
ss0
Out[2]: ['1', '2', '4', '8', '16']
ss1="1, 2, 4, 8, 16".split(" , ")
ss1
Out[4]: ['1, 2, 4, 8, 16']
ss2="1, 2, 4, 8, 16".split(", ")
ss2
Out[9]: ['1, 2, 4, 8, 16']
help(split)
Help on function split in module numpy.lib.shape_base:
[toc] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2015-12-02 14:44 -0600 |
| Message-ID | <mailman.147.1449089117.14615.python-list@python.org> |
| In reply to | #99913 |
On Wed, Dec 2, 2015 at 2:37 PM, Robert <rxjwg98@gmail.com> wrote:
> Hi,
>
> I learn split method online. When I try to run the line with ss1 beginning,
> I don't understand why its output of ss1 and ss2. I have check the help
> about split. It looks like that it is a numpy method.
> What is the split method parameter (within " ") for?
>
>
> Thanks,
>
>
>
> ...............
> ss0="1, 2, 4, 8, 16".split(", ")
>
> ss0
> Out[2]: ['1', '2', '4', '8', '16']
>
> ss1="1, 2, 4, 8, 16".split(" , ")
>
> ss1
> Out[4]: ['1, 2, 4, 8, 16']
>
> ss2="1, 2, 4, 8, 16".split(", ")
>
> ss2
> Out[9]: ['1, 2, 4, 8, 16']
>
> help(split)
> Help on function split in module numpy.lib.shape_base:
That's just some random function that you've imported into globals by
doing "from numpy import *" or some such. What you're calling in these
examples is a string method, not a global function.
Try help(str.split)
[toc] | [prev] | [next] | [standalone]
| From | Robert <rxjwg98@gmail.com> |
|---|---|
| Date | 2015-12-02 13:00 -0800 |
| Message-ID | <bf1c80c7-89a8-4999-be28-02c5214e9c45@googlegroups.com> |
| In reply to | #99914 |
On Wednesday, December 2, 2015 at 3:45:34 PM UTC-5, Ian wrote:
> On Wed, Dec 2, 2015 at 2:37 PM, Robert <rxjgmail.com> wrote:
> > Hi,
> >
> > I learn split method online. When I try to run the line with ss1 beginning,
> > I don't understand why its output of ss1 and ss2. I have check the help
> > about split. It looks like that it is a numpy method.
> > What is the split method parameter (within " ") for?
> >
> >
> > Thanks,
> >
> >
> >
> > ...............
> > ss0="1, 2, 4, 8, 16".split(", ")
> >
> > ss0
> > Out[2]: ['1', '2', '4', '8', '16']
> >
> > ss1="1, 2, 4, 8, 16".split(" , ")
> >
> > ss1
> > Out[4]: ['1, 2, 4, 8, 16']
> >
> > ss2="1, 2, 4, 8, 16".split(", ")
> >
> > ss2
> > Out[9]: ['1, 2, 4, 8, 16']
> >
> > help(split)
> > Help on function split in module numpy.lib.shape_base:
>
> That's just some random function that you've imported into globals by
> doing "from numpy import *" or some such. What you're calling in these
> examples is a string method, not a global function.
>
> Try help(str.split)
Thanks. I didn't know numpy has been automatically imported, not by me.
And your demo line code is helpful.
[toc] | [prev] | [next] | [standalone]
| From | Peter Pearson <pkpearson@nowhere.invalid> |
|---|---|
| Date | 2015-12-05 19:29 +0000 |
| Message-ID | <dcgs81F9d3fU1@mid.individual.net> |
| In reply to | #99914 |
On Wed, 2 Dec 2015 14:44:30 -0600, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Wed, Dec 2, 2015 at 2:37 PM, Robert <rxjwg98@gmail.com> wrote:
[snip]
>> ss0="1, 2, 4, 8, 16".split(", ")
[snip]
> Try help(str.split)
Or if, like me, you can't remember the magic word "str", ask:
help("".split)
and you know you're asking about the right "split".
--
To email me, substitute nowhere->runbox, invalid->com.
[toc] | [prev] | [next] | [standalone]
| From | Robert <rxjwg98@gmail.com> |
|---|---|
| Date | 2015-12-05 11:51 -0800 |
| Message-ID | <b6d3d045-d5e0-4f2f-87e2-e6fdcd3b7407@googlegroups.com> |
| In reply to | #100043 |
On Saturday, December 5, 2015 at 2:29:28 PM UTC-5, Peter Pearson wrote:
> On Wed, 2 Dec 2015 14:44:30 -0600, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> > On Wed, Dec 2, 2015 at 2:37 PM, Robert <rxjwg98@gmail.com> wrote:
> [snip]
> >> ss0="1, 2, 4, 8, 16".split(", ")
> [snip]
> > Try help(str.split)
>
> Or if, like me, you can't remember the magic word "str", ask:
>
> help("".split)
>
> and you know you're asking about the right "split".
>
> --
> To email me, substitute nowhere->runbox, invalid->com.
Thanks for your smart method.
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2015-12-05 20:27 +0000 |
| Message-ID | <mailman.228.1449347227.14615.python-list@python.org> |
| In reply to | #100046 |
On 05/12/2015 19:51, Robert wrote:
> On Saturday, December 5, 2015 at 2:29:28 PM UTC-5, Peter Pearson wrote:
>> On Wed, 2 Dec 2015 14:44:30 -0600, Ian Kelly <ian.g.kelly@gmail.com> wrote:
>>> On Wed, Dec 2, 2015 at 2:37 PM, Robert <rxjwg98@gmail.com> wrote:
>> [snip]
>>>> ss0="1, 2, 4, 8, 16".split(", ")
>> [snip]
>>> Try help(str.split)
>>
>> Or if, like me, you can't remember the magic word "str", ask:
>>
>> help("".split)
>>
>> and you know you're asking about the right "split".
>>
>> --
>> To email me, substitute nowhere->runbox, invalid->com.
>
> Thanks for your smart method.
>
The even smarter method is:
help(''.split)
as this saves you reaching for the shift key :)
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Erik <python@lucidity.plus.com> |
|---|---|
| Date | 2015-12-05 22:20 +0000 |
| Message-ID | <mailman.231.1449354049.14615.python-list@python.org> |
| In reply to | #100046 |
On 05/12/15 20:27, Mark Lawrence wrote:
> On 05/12/2015 19:51, Robert wrote:
>> On Saturday, December 5, 2015 at 2:29:28 PM UTC-5, Peter Pearson wrote:
>>> On Wed, 2 Dec 2015 14:44:30 -0600, Ian Kelly <ian.g.kelly@gmail.com>
>>> wrote:
>>>> On Wed, Dec 2, 2015 at 2:37 PM, Robert <rxjwg98@gmail.com> wrote:
>>> [snip]
>>>>> ss0="1, 2, 4, 8, 16".split(", ")
>>> [snip]
>>>> Try help(str.split)
>>>
>>> Or if, like me, you can't remember the magic word "str", ask:
>>>
>>> help("".split)
>>>
>>> and you know you're asking about the right "split".
>>>
>>> --
>>> To email me, substitute nowhere->runbox, invalid->com.
>>
>> Thanks for your smart method.
>>
>
> The even smarter method is:
>
> help(''.split)
>
> as this saves you reaching for the shift key :)
... except you're already pressing it for the open parenthesis ... ;)
E.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web