38016226...@gmail.com wrote:
> nums=['3','30','34','32','9','5']
> I need to sort the list in order to get the largest number string:
> '953433230'
>
> nums.sort(cmp=lambda a,b: cmp(a+b, b+a), reverse=True)
>
> But how to do this in python 3?
>
> Thank you
While cmp_to_key is neat doing it by
On 14.10.16 18:40, Lele Gaifax wrote:
Hi all,
trying out pgcli with Python 3.6.0b2 I got an error related to what seem a
different behaviour, or even a bug, of re.sub().
The original intent is to replace spaces within a string with the regular
expression
\s+ (see
https://github.com/dbcli/pgcl
On 14.10.16 20:01, Peter Otten wrote:
Lele Gaifax wrote:
So, how am I supposed to achieve the mentioned intent? By doubling the
escape in the replacement?
If there are no escape sequences aimed to be handled by re.sub() you can
escape the replacement wholesale:
re.sub(r'\s+', re.escape(r'\s+
On 14.10.16 19:15, Chris Angelico wrote:
I wasn't specifically aware that the re module was doing the same
thing, but it'll be from the same purpose and goal. The idea is that,
for instance, Windows path names in non-raw string literals will no
longer behave differently based on whether the path
Serhiy Storchaka wrote:
> On 14.10.16 20:01, Peter Otten wrote:
> def double_bs(s): return "".join(s.split("\\"))
>> ...
> Just use s.replace('\\', r'\\').
D'oh!
--
https://mail.python.org/mailman/listinfo/python-list
Serhiy Storchaka writes:
> Seems the documentation is not accurate. Could you file a report on
> https://bugs.python.org/ ?
Thank you everybody answered!
Here it is: http://bugs.python.org/issue28450
ciao, lele.
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanu
On Thu, 13 Oct 2016 15:06:25 +0100, Daiyue Weng wrote:
> I know that such try-catch usage is generally a bad practice, since it
> can't locate the root of the exceptions.
>
> I am wondering how to correct the code above
Either identify the specific exceptions you're expecting, or if you're
inter
Hi,
Here is the code, which I would like to understand.
>>> l=['a','b','c']
>>> bm=dict.fromkeys(l,['-1','-1'])
>>> u={'a':['Q','P']}
>>> bm.update(u)
>>> bm
{'a': ['Q', 'P'], 'c': ['-1', '-1'], 'b': ['-1', '-1']}
>>> for k in bm.keys():
bm[k].append('DDD')
>>> bm
{'a': ['Q', 'P', 'DDD'], 'c': [
On Sat, Oct 15, 2016 at 11:35 PM, Uday J wrote:
bm=dict.fromkeys(l,['-1','-1'])
When you call dict.fromkeys, it uses the same object as the key every
time. If you don't want that, try a dict comprehension instead:
bm = {x: ['-1', '-1'] for x in l}
This will construct a new list for every k
Uday J writes:
> Hi,
>
> Here is the code, which I would like to understand.
>
l=['a','b','c']
bm=dict.fromkeys(l,['-1','-1'])
u={'a':['Q','P']}
bm.update(u)
bm
> {'a': ['Q', 'P'], 'c': ['-1', '-1'], 'b': ['-1', '-1']}
for k in bm.keys():
> bm[k].append('DDD')
>
Chris Angelico writes:
> On Sat, Oct 15, 2016 at 11:35 PM, Uday J wrote:
> bm=dict.fromkeys(l,['-1','-1'])
>
> When you call dict.fromkeys, it uses the same object as the key every
> time. If you don't want that, try a dict comprehension instead:
s/key/value/
--
https://mail.python.org/mailm
On Sun, Oct 16, 2016 at 3:12 AM, Jussi Piitulainen
wrote:
> Chris Angelico writes:
>
>> On Sat, Oct 15, 2016 at 11:35 PM, Uday J wrote:
>> bm=dict.fromkeys(l,['-1','-1'])
>>
>> When you call dict.fromkeys, it uses the same object as the key every
>> time. If you don't want that, try a dict com
On Sat, 15 Oct 2016 11:35 pm, Uday J wrote:
> Hi,
>
> Here is the code, which I would like to understand.
>
l=['a','b','c']
bm=dict.fromkeys(l,['-1','-1'])
fromkeys() doesn't make a copy of the list each time it is used. It uses the
exact same list each time. Watch:
py> L = []
py> d
On 15.10.2016 18:16, Steve D'Aprano wrote:
# Python 3 only: use a dict comprehension
py> d = {x:[] for x in (1, 2, 3)}
py> d
{1: [], 2: [], 3: []}
dict (and set) comprehensions got backported so this works just as well
in Python 2.7
Wolfgang
--
https://mail.python.org/mailman/listinfo/pytho
在 2016年10月14日星期五 UTC-4下午7:35:08,38016...@gmail.com写道:
> nums=['3','30','34','32','9','5']
> I need to sort the list in order to get the largest number string: '953433230'
>
> nums.sort(cmp=lambda a,b: cmp(a+b, b+a), reverse=True)
>
> But how to do this in python 3?
>
> Thank you
!I learn mo
I have tried to register at https://bugs.python.org/ over a period
of many months, and I never receive the confirmation email to complete
the process. Who can help with this? Thanks.
--Al
--
https://mail.python.org/mailman/listinfo/python-list
On Sun, 16 Oct 2016 07:09 am, Al Schapira wrote:
> I have tried to register at https://bugs.python.org/ over a period
> of many months, and I never receive the confirmation email to complete
> the process. Who can help with this? Thanks.
> --Al
Have you checked your Junk Mail folder?
Unfort
Hello,
is there a way, other than time.sleep(), to be sure that the command
sent through a serial port has been fully executed? I'm interested
specifically in SCPI commands in VA-meters such as Keithley and Tektronix.
Thanks.
--
https://mail.python.org/mailman/listinfo/python-list
c="abcdefghijk"
len=len(c)
n is a int
sb=[[] for i in range(n)]
while (i < len) {
for (int j = 0; j < n && i < len; j++)
sb[j].append(c[i++]);
for (int j = n-2; j >= 1 && i < len; j--) //
sb[j].append(c[i++]);
}
How to translate to python? I tried
On Saturday, October 15, 2016 at 10:14:18 PM UTC-6, Michael Okuntsov wrote:
> Hello,
> is there a way, other than time.sleep(), to be sure that the command
> sent through a serial port has been fully executed? I'm interested
> specifically in SCPI commands in VA-meters such as Keithley and Tektro
20 matches
Mail list logo