Reputation: 115531
I'm writing a Sublime2 plugin and fighting a bit.
Code is:
def run(self, edit):
self.edit = edit
self.view.window().show_input_panel("New Controller and View Path (ex: client_area/index )", "", self.trigger, None, None)
def trigger(self, user_entry):
formatted_entry = user_entry.encode('utf-8')
print formatted_entry.__class__
print formatted_entry
if formatted_entry.slice('/')[0] == '':
#some code
Output is:
<type 'str'>
client_area/index
Traceback (most recent call last):
File "./PluginName.py", line 27, in trigger
AttributeError: 'str' object has no attribute 'slice'
How is it I get 'str' object has no attribute 'slice'
? (Python version is 2.6)
Upvotes: 5
Views: 20732
Reputation: 1
$
slice() method doesn't works with pandas.Series so first we have to convert it into
StringMethods by using .str then we can apply slice notation.
s=pd.Series(["2020", "2010", "2013"]) s 0 2020 1 2010 2 2013 dtype: object s.slice() # doesn't work s.str.slice(2,4).astype(int) 0 20 1 10 2 13 dtype: int32
Upvotes: 0