Sorry Daiyue,
Try this correction: I'm writing code without being able to execute it.
> split_on_dbl_dbl_quote = original_list.join('|').split('""')
> remove_dbl_dbl_quotes_and_outer_quotes =
> split_on_dbl_dbl_quote[::2].join('').split('|')
split_on_dbl_dbl_quote =
On Thursday, 3 August 2017 01:05:57 UTC+10, Daiyue Weng wrote:
> Hi, I am trying to removing extra quotes from a large set of strings (a
> list of strings), so for each original string, it looks like,
>
> """str_value1"",""str_value2"",""str_value3"",1,""str_value4"""
>
>
> I like to remove
On Wednesday, 12 July 2017 02:32:29 UTC+10, Ganesh Pal wrote:
> Dear Python friends
>
> I am trying to open a file and check if there is a pattern has changed
> after the task got completed?
>
> file data:
>
>
> #tail -f /file.txt
>
Hi all,
Seemingly simple problem:
There is a case in my code where I know a dictionary has only one item in it. I
want to get the value of that item, whatever the key is.
In Python2 I'd write:
>>> d = {"Wilf's Cafe": 1}
>>> d.values()[0]
1
and that'd be an end to it.
In Python 3:
>>> d =
On Saturday, 30 May 2015 06:39:44 UTC+10, Nick Mellor wrote:
Hi all,
My own solution works but I'm sure it could be simpler or read better. How
would you do it?
Say you've got a list of companies:
Aerosonde Ltd
Amcor
ANCA
Austal Ships
Australia Post
Australian Air Express
Hi all,
My own solution works but I'm sure it could be simpler or read better. How
would you do it?
Say you've got a list of companies:
Aerosonde Ltd
Amcor
ANCA
Austal Ships
Australia Post
Australian Air Express
Australian Defence Industries
Australian Railroad Group
Australian Submarine
Hi guys,
(Python 2.7, Windows 7 64-bit)
Here's a bit of code stress-testing a method addUpdate_special_to_cart. The
test adds and updates random specials (multiple products bundled at an
advantageous price) of various sizes to thousands of shopping carts, then
restocks the whole darn lot. The
Thanks John and others,
Replies much appreciated. I don't know how it could affect the results, but the
function being tested is using redis. And I am running the test code under
PyCharm, so perhaps using the module-level random number generator wasn't such
a good idea. Live and learn.
In
Hi Victor,
I use PyCharm which is set up by default to warn when line length exceeds 120
chars, not 80. Perhaps times have changed?
I often break comprehensions at the for, in and else clauses. It's often not
for line length reasons but because it's easier to follow the code that way. I
have
Hi all,
It might be a risk that we create some hairy or subtle semantics, but perhaps
this idea has legs. The 'pythonic' syntax is very attractive.
# skip the silence at the start
data = (amp for amp in signal from abs(amp) 0.05)
# drop files that are less than 600 bytes
# (already sorted
On Friday, 27 September 2013 00:39:30 UTC+10, Nick Mellor wrote:
[snip]
for x in xs:
if not emit:
if cond(x):
emit = True
else:
yield e(x)
Oops!
for x in xs:
if not emit:
if cond(x):
emit = True
yield e(x)
else
Thanks Alex!
Nick
--
http://mail.python.org/mailman/listinfo/python-list
Hi all,
event['Items'] is an exhausted (all used up) iterable.
Now I do the following (lines 142-4):
event.update({'Attributes': filtered_attributes})
del event['Items']
yield event
and get a KeyError on the del statement. 'Items' is a key in the event
Hi Piterr,
It's interesting how strong our habits are, isn't it? It's most likely you've
just got a bit of culture shock.
I've used C# quite a bit as well as Python. I like them both.
What I like about Python is how it manages to be clear and terse at the same
time.
if (flag==1) {
code
}
06:25:50 UTC+11, Rick Johnson wrote:
Nick Mellor thebalancepro at gmail.com writes:
I'm looking for a fairly undetailed simulation of the human body walking and
standing. Has anyone had a go at
this in cgkit or similar?
Hi nick, your question contains too many variables
Hi John,
Thanks for the problem. I've been writing Python for about 4 years now and am
beginning to feel like I'm writing much better Python code.
Python does fine on this problem if you play to its strengths. The following
uses dictionary lookups to store previously computed sequence lengths,
Hi all,
I'm looking for a fairly undetailed simulation of the human body walking and
standing. Has anyone had a go at this in cgkit or similar?
Thanks,
Nick
--
http://mail.python.org/mailman/listinfo/python-list
sometimes.)
Best,
Nick
On Friday, 8 February 2013 16:47:03 UTC+11, rh wrote:
On Thu, 7 Feb 2013 04:53:22 -0800 (PST)
Nick Mellor t@gmail.com wrote:
Hi RH,
translate methods might be faster (and a little easier to read) for
your use case. Just precompute and re-use
Hi RH,
translate methods might be faster (and a little easier to read) for your use
case. Just precompute and re-use the translation table punct_flatten.
Note that the translate method has changed somewhat for Python 3 due to the
separation of text from bytes. The is a Python 3 version.
from
You can just flatten the list using itertools and collate the results using
defaultdict:
import itertools
from collections import defaultdict
sequence =
((0,'a','b'),(1,'c','d'),(2,'e','f'),(3,'g','h'),(1,'i','j'),(2,'k','l'),(4,'m','n'),(2,'o','p'),(4,'q','r'),(5,'s','t'))
# flatten the list
Python 3 version:
from collections import defaultdict
data =
((0,'a','b'),(1,'c','d'),(2,'e','f'),(3,'g','h'),(1,'i','j'),(2,'k','l'),(4,'m','n'),(2,'o','p'),(4,'q','r'),(5,'s','t'))
register = defaultdict(list)
for number, *letters in data:
register[number].extend(letters)
final = []
for
Oops! Not that sort stability is used in this algorithm. Was thinking of
something else :-)
N
On Thursday, 7 February 2013 10:25:36 UTC+11, Nick Mellor wrote:
Python 3 version:
from collections import defaultdict
data =
((0,'a','b'),(1,'c','d'),(2,'e','f'),(3,'g','h'),(1,'i
Hi,
I've got a unit test that will usually succeed but sometimes fails. An
occasional failure is expected and fine. It's failing all the time I want to
test for.
What I want to test is on average, there are the same number of males and
females in a sample, give or take 2%.
Here's the unit
Hi Sia,
Here's another variation. It's within my tolerance for readability :-) and also
quick, if that's an issue. It does 100,000 of your longer string in a couple of
seconds on my venerable laptop.
It handles only single-digit numbers. For multi-digit, I'd be inclined to have
a look at
Hi Sia,
Find a multi-digit method in this version:
from string import maketrans
from itertools import takewhile
def is_digit(s): return s.isdigit()
class redux:
def __init__(self):
intab = '+-'
outtab = ' '
self.trantab = maketrans(intab, outtab)
def
version on my hardware (about
25,000 per second.)
Nick
On Monday, 7 January 2013 14:40:02 UTC+11, Nick Mellor wrote:
Hi Sia,
Find a multi-digit method in this version:
from string import maketrans
from itertools import takewhile
def is_digit(s): return s.isdigit
Oops!
You skip 2 + 11 characters, 2 digits in 12 and 11 letters following. And
incidentally in:
should read:
You skip 2 + 11 characters, 2 digits in 11 and 11 letters following. And
incidentally in:
N
On Saturday, 5 January 2013 19:35:26 UTC+11, Sia wrote:
I have strings such as:
Hi Sia,
Thanks for the problem! I hope you find these examples understandable.
Below, find an inflexible but fairly fast single-digit method and a slower (but
still respectable) multi-digit method that copes with entirely absent digits
after +/- and multi-digit skips such as 12 or 37 or 186
)
On Thursday, 6 December 2012 00:29:13 UTC+11, Neil Cerutti wrote:
On 2012-12-05, Nick Mellor thebalance...@gmail.com wrote:
Hi Terry,
For my money, and especially in your versions, despite several
expert solutions using other features, itertools has it. It
seems to me to need
Neil,
Further down the data, found another edge case:
Spring ONION from QLD
Following the spec, the whole line should be description (description starts at
first word that is not all caps.) This case breaks the latest groupby.
N
--
http://mail.python.org/mailman/listinfo/python-list
Hi Neil,
Nice! But fails if the first word of the description starts with a capital
letter.
Nick
On Wednesday, 5 December 2012 01:23:34 UTC+11, Neil Cerutti wrote:
On 2012-12-04, Nick Mellor thebalance...@gmail.com wrote:
I have a file full of things like this:
CAPSICUM RED
Hi Terry,
For my money, and especially in your versions, despite several expert solutions
using other features, itertools has it. It seems to me to need less nutting out
than the other approaches. It's short, robust, has a minimum of symbols, uses
simple expressions and is not overly clever.
On Nov 27, 3:26 am, Bruno Desthuilliers bruno.
42.desthuilli...@websiteburo.invalid wrote:
Nick Mellor a écrit :
Hi all,
I'm contemplating setting up a Python-powered website for the tourist
industry, which will involve a web service, a good deal of XML
processing, and a Django-powered
Hi all,
I'm contemplating setting up a Python-powered website for the tourist
industry, which will involve a web service, a good deal of XML
processing, and a Django-powered front-end. If the project works, it
could get a lot of traffic. I'm sure it can be done, but I'm looking
to find out more
Thanks Kutlu,
I wasn't aware that Google used Python for running their Google groups
servers. Can you confirm that? The only place
I've seen Google explicitly use Python on their web front end is in
the Google Ads tests.
I am impressed by the responsiveness of lawrence.com, ljworld.com and
Hi all,
I'm pretty sure I'm following all the Python rules: I've put self
before forename to make sure it's treated as a data attribute
(instance variable.) And from within a class, I'm told, you need to
prefix the var with self too. RandomName is a class that I've tested
(and which still works.)
Thanks Chris and John, all workin now. Sorry about proclamation of
innocence-- fruitless morning and 3 hours sleep :-)
Nick
On Mar 3, 12:03 pm, Chris Rebert c...@rebertia.com wrote:
On Mon, Mar 2, 2009 at 4:56 PM, Nick Mellor
nick.mellor.gro...@pobox.com wrote:
Hi all,
I'm pretty sure
On Oct 6, 3:40 am, Gary Herron [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
Hi,
I'm using python to develop some proof-of-concept code for a
cryptographic application. My code makes extended use of python's
native bignum capabilities.
In many cryptographic applications there is
38 matches
Mail list logo