lbolla wrote:
It looks like Perl ;-)
A positive proof that you can write perl code in Python. I, for
instance, have had my brain warped by C and tend to write C-like code in
Python. That's only half a joke, sadly. I'm trying to change my habits
but it's hard.
Regards,
mk
--
http://mail.p
nn wrote:
Oh my! You could have at least used some "if else" to make it a little
bit easier on the eyes :-)
That's my entry into """'Obfuscated' "Python" '"''code''"'
'"contest"'""" and I'm proud of it. ;-)
Regards,
mk
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 5, 1:26 pm, mk wrote:
> Sneaky Wombat wrote:
> > [ 'VLAN4065',
> > 'Interface',
> > 'Gi9/6',
> > 'Po2',
> > 'Po3',
> > 'Po306',
> > 'VLAN4068',
> > 'Interface',
> > 'Gi9/6',
> > 'VLAN4069',
> > 'Interface',
> > 'Gi9/6',]
>
> Hey, I just invented a cute ;-) two-liner using list co
mk wrote:
> Sneaky Wombat wrote:
> > [ 'VLAN4065',
> > 'Interface',
> > 'Gi9/6',
> > 'Po2',
> > 'Po3',
> > 'Po306',
> > 'VLAN4068',
> > 'Interface',
> > 'Gi9/6',
> > 'VLAN4069',
> > 'Interface',
> > 'Gi9/6',]
>
> Hey, I just invented a cute ;-) two-liner using list comprehensions:
>
>
Sneaky Wombat wrote:
[ 'VLAN4065',
'Interface',
'Gi9/6',
'Po2',
'Po3',
'Po306',
'VLAN4068',
'Interface',
'Gi9/6',
'VLAN4069',
'Interface',
'Gi9/6',]
Hey, I just invented a cute ;-) two-liner using list comprehensions:
# alist = list above
tmp, dk = [], {}
[(x.startswith('VLAN') and
lbolla writes:
> for k, g in groupby(clean_up(data) , key=lambda s: s.startswith('VLAN')):
> if k:
> key = list(g)[0].replace('VLAN','')
This is the nicest solution, I think. Mine was more cumbersome.
--
http://mail.python.org/mailman/listinfo/python-list
Man, deja-vu, I could have sworn I read this thread months ago...
On Thu, Mar 4, 2010 at 2:18 PM, nn wrote:
>
>
> lbolla wrote:
> > On Mar 4, 3:57 pm, Sneaky Wombat wrote:
> > > [ {'vlan_or_intf': 'VLAN2021'},
> > > {'vlan_or_intf': 'Interface'},
> > > {'vlan_or_intf': 'Po1'},
> > > {'vlan_o
lbolla wrote:
> On Mar 4, 3:57 pm, Sneaky Wombat wrote:
> > [ {'vlan_or_intf': 'VLAN2021'},
> > {'vlan_or_intf': 'Interface'},
> > {'vlan_or_intf': 'Po1'},
> > {'vlan_or_intf': 'Po306'},
> > {'vlan_or_intf': 'VLAN2022'},
> > {'vlan_or_intf': 'Interface'},
> > {'vlan_or_intf': 'Gi7/33'},
>
On Mar 4, 3:57 pm, Sneaky Wombat wrote:
> [ {'vlan_or_intf': 'VLAN2021'},
> {'vlan_or_intf': 'Interface'},
> {'vlan_or_intf': 'Po1'},
> {'vlan_or_intf': 'Po306'},
> {'vlan_or_intf': 'VLAN2022'},
> {'vlan_or_intf': 'Interface'},
> {'vlan_or_intf': 'Gi7/33'},
> {'vlan_or_intf': 'Po1'},
> {'v
On Mar 4, 10:55 am, mk wrote:
> Sneaky Wombat wrote:
> > I was going to write a def to loop through and look for certain pre-
> > compiled regexs, and then put them in a new dictionary and append to a
> > list,
>
> regexes are overkill in this case I think.
>
> > [ 'VLAN4065',
> > 'Interface',
>
Sneaky Wombat wrote:
I was going to write a def to loop through and look for certain pre-
compiled regexs, and then put them in a new dictionary and append to a
list,
regexes are overkill in this case I think.
[ 'VLAN4065',
'Interface',
'Gi9/6',
'Po2',
'Po3',
'Po306',
'VLAN4068',
'Int
[ {'vlan_or_intf': 'VLAN2021'},
{'vlan_or_intf': 'Interface'},
{'vlan_or_intf': 'Po1'},
{'vlan_or_intf': 'Po306'},
{'vlan_or_intf': 'VLAN2022'},
{'vlan_or_intf': 'Interface'},
{'vlan_or_intf': 'Gi7/33'},
{'vlan_or_intf': 'Po1'},
{'vlan_or_intf': 'Po306'},
{'vlan_or_intf': 'VLAN2051'},
{'v
12 matches
Mail list logo