In article
[email protected] wrote (in part):
[mass snippage]
>What I mean is that I see regexes as being an extremely small,
>highly restricted, domain specific language targeted specifically
>at describing text patterns. Thus they do that job better than
>than trying to describe patterns implici
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 06/06/2011 01:50 AM, okay zed wrote:
> the link: http://okayzed.github.com/dmangame/introduction.html
>
> dmangame is a game about writing AI for a simple strategy game.
Looks fun! I play a bit of Core War, so this should pose a similar but
new ch
It is not so hard to decide whether using RE is a good thing or not.
When the speed is important and every millisecond counts, RE should be used
only when there is no other faster way, because usually RE is less faster
than using other core Perl/Python functions that can do matching and
replac
On Mon, Jun 6, 2011 at 6:51 PM, Octavian Rasnita wrote:
> It is not so hard to decide whether using RE is a good thing or not.
>
> When the speed is important and every millisecond counts, RE should be used
> only when there is no other faster way, because usually RE is less faster
> than using ot
Am 04.06.2011 20:27 schrieb TommyVee:
I'm using the SimPy package to run simulations. Anyone who's used this
package knows that the way it simulates process concurrency is through
the clever use of yield statements. Some of the code in my programs is
very complex and contains several repeating se
On 6/06/2011 2:54 AM, Massi wrote:
Hi everyone, I'm writing a script which implement a windows service
with the win32serviceutil module. The service works perfectly, but now
I would need to install several instances of the same service on my
machine for testing purpose.
This is hard since the ser
> f = lambda x, n, acc=[]: f(x[n:], n, acc+[(x[:n])]) if x else acc
> Packing tail recursion into one line is bad for both understanding and
> refactoring. Use better names and a docstring gives
>
> def group(seq, n):
>'Yield from seq successive disjoint slices of length n plus the
> re
On 2011-06-03, Chris Torek wrote:
>>> The definition is entirely arbitrary.
>>
>>I don't agree, but even if was entirely arbitrary, that doesn't make
>>the decision meaningless. IEEE-754 says it's True, and standards
>>compliance is valuable. Each country's decision to drive on the
>>right/left
On 2011-06-03, Nobody wrote:
>>> This would produce the same end result as raising an exception
>>> immediately, but would reduce the number of isnan() tests.
>>
>> I've never found the number of isnan() checks in my code to be an
>> issue -- there just arent that many of them, and when they are
For any significant language feature (take recursion for example)
there are these issues:
1. Ease of reading/skimming (other's) code
2. Ease of writing/designing one's own
3. Learning curve
4. Costs/payoffs (eg efficiency, succinctness) of use
5. Debug-ability
I'll start with 3.
When someone of K
On Sun, 05 Jun 2011 23:03:39 -0700, [email protected] wrote:
> Thus what starts as
> if line.startswith ('CUSTOMER '):
> try:
> kw, first_initial, last_name, code, rest = line.split(None, 4)
> ...
> often turns into (sometimes before it is written) something like
> m = re.match
could be the ACM queue challenge and google's ai challenge, they've
had games in the past with somewhat similar mechanics
On Jun 5, 11:10 pm, James Mills wrote:
> On Mon, Jun 6, 2011 at 3:50 PM, okay zed wrote:
> > the link:http://okayzed.github.com/dmangame/introduction.html
>
> > dmangame i
On Mon, Jun 6, 2011 at 9:29 AM, Steven D'Aprano
wrote:
> [...]
>> I would expect
>> any regex processor to compile the regex into an FSM.
>
> Flying Spaghetti Monster?
>
> I have been Touched by His Noodly Appendage!!!
Finite State Machine.
--
http://mail.python.org/mailman/listinfo/python-list
On 2011-06-06, [email protected] wrote:
> On 06/03/2011 02:49 PM, Neil Cerutti wrote:
> Can you find an example or invent one? I simply don't remember
> such problems coming up, but I admit it's possible.
>
> Sure, the response to the OP of this thread.
Here's a recap, along with two candidate solu
Hi,
I'd like to simplify the following string formatting:
solo = 'Han Solo'
jabba = 'Jabba the Hutt'
print "{solo} was captured by {jabba}".format(solo=solo, jabba=jabba)
# Han Solo was captured by Jabba the Hutt
What I don't like here is this: "solo=solo, jabba=jabba", i.e. the
same thing is re
On Mon, Jun 6, 2011 at 9:15 AM, Jabba Laci wrote:
> Hi,
>
> I'd like to simplify the following string formatting:
>
> solo = 'Han Solo'
> jabba = 'Jabba the Hutt'
> print "{solo} was captured by {jabba}".format(solo=solo, jabba=jabba)
> # Han Solo was captured by Jabba the Hutt
>
> What I don't li
On Mon, Jun 6, 2011 at 10:08 AM, Neil Cerutti wrote:
> import re
>
> print("re solution")
> with open("data.txt") as f:
> for line in f:
> fixed = re.sub(r"(TABLE='\S+)\s+'", r"\1'", line)
> print(fixed, end='')
>
> print("non-re solution")
> with open("data.txt") as f:
> for l
> Currently i am importing the Database into CSV file using csv module,
>in csv file i need to change the column width according the size of
>the data. i need to set different column width for different columns
>pleas let me know how to achieve this
If you are using xlwt:
sheet.col(9).width = 3200
On 6/6/2011 9:42 AM, [email protected] wrote:
f = lambda x, n, acc=[]: f(x[n:], n, acc+[(x[:n])]) if x else acc
Packing tail recursion into one line is bad for both understanding and
refactoring. Use better names and a docstring gives
def group(seq, n):
'Yield from seq successive disjoin
On 2011-06-06, Ian Kelly wrote:
> On Mon, Jun 6, 2011 at 10:08 AM, Neil Cerutti wrote:
>> import re
>>
>> print("re solution")
>> with open("data.txt") as f:
>> ? ?for line in f:
>> ? ? ? ?fixed = re.sub(r"(TABLE='\S+)\s+'", r"\1'", line)
>> ? ? ? ?print(fixed, end='')
>>
>> print("non-re solutio
On Jun 5, 11:33 pm, Terry Reedy wrote:
> On 6/5/2011 5:31 AM, Alain Ketterlin wrote:
>
> > writes:
>
> > f = lambda x, n, acc=[]: f(x[n:], n, acc+[(x[:n])]) if x else acc
>
> f=lambda ... statements are inferior for practical purposes to the
> equivalent def f statements because the resultin
Ian Kelly wrote:
On Mon, Jun 6, 2011 at 10:08 AM, Neil Cerutti wrote:
import re
print("re solution")
with open("data.txt") as f:
for line in f:
fixed = re.sub(r"(TABLE='\S+)\s+'", r"\1'", line)
print(fixed, end='')
print("non-re solution")
with open("data.txt") as f:
for l
On Mon, Jun 6, 2011 at 11:17 AM, Neil Cerutti wrote:
> I wrestled with using addition like that, and decided against it.
> The 7 is a magic number and repeats/hides information. I wanted
> something like:
>
> prefix = "TABLE='"
> start = line.index(prefix) + len(prefix)
>
> But decided I searc
On Sun, Jun 5, 2011 at 3:34 AM, Peter Irbizon wrote:
> Hello, thanks, Unfortunatelly I don't understand how xml should resolve my
> issue. My problem is:
> I am trying to use aes256 cbc on python and php to decrypt "textstring". But
> results are not the same in php and python. Any idea why? passw
On Mon, Jun 6, 2011 at 11:48 AM, Ethan Furman wrote:
> I like the readability of this version, but isn't generating an exception on
> every other line going to kill performance?
I timed it on the example data before I posted and found that it was
still 10 times as fast as the regex version. I di
On Fri, Jun 3, 2011 at 1:17 PM, Raymond Hettinger wrote:
> Thanks for all the feedback on the earlier post.
>
> I've updated the recipe to use a cleaner API, simpler code,
> more easily subclassable, and with optional optimizations
> for better cache utilization and speed:
>
> http://code.actives
Seems to work using 2.7 but not 3.2. On 3.2 it just closes all my python
sessions. Is this a bug? Can someone point me to a "How To" on using a local
printer in windows?
Thanks!
--
http://mail.python.org/mailman/listinfo/python-list
On 2011-06-06, Ian Kelly wrote:
> Fair enough, although if you ask me the + 1 is just as magical
> as the + 7 (it's still the length of the string that you're
> searching for). Also, re-finding the opening ' still repeats
> information.
Heh, true. I doesn't really repeat information, though, as i
On Mon, 6 Jun 2011 12:15:35 -0400, Jabba Laci wrote in
Message-Id: :
> solo = 'Han Solo'
> jabba = 'Jabba the Hutt'
> print "{solo} was captured by {jabba}".format(solo=solo, jabba=jabba)
> # Han Solo was captured by Jabba the Hutt
How about:-
print "%s was captured by %s" % (solo, jabba)
--
ht
On Mon, Jun 6, 2011 at 9:35 AM, Prasad, Ramit wrote:
>> Currently i am importing the Database into CSV file using csv module,
>>in csv file i need to change the column width according the size of
>>the data. i need to set different column width for different columns
>>pleas let me know how to achi
Steve Crook wrote:
On Mon, 6 Jun 2011 12:15:35 -0400, Jabba Laci wrote in
Message-Id: :
solo = 'Han Solo'
jabba = 'Jabba the Hutt'
print "{solo} was captured by {jabba}".format(solo=solo, jabba=jabba)
# Han Solo was captured by Jabba the Hutt
How about:-
print "%s was captured by %s" % (solo
-
Dense and complex REs are quite powerful, but may also contain
and hide programming mistakes. The ability to describe what is
intended -- which may differ from what is written -- is useful.
--
On Mon, Jun 6, 2011 at 10:15 AM, Jabba Laci wrote:
> Hi,
>
> I'd like to simplify the following string formatting:
>
> solo = 'Han Solo'
> jabba = 'Jabba the Hutt'
> print "{solo} was captured by {jabba}".format(solo=solo, jabba=jabba)
> # Han Solo was captured by Jabba the Hutt
>
> What I don't l
> print "{} was captured by {}".format(solo, jabba)
Is this Python2.7 specific?
Python 2.6.x :
>>>print "{} was captured by {}".format('t1', 't2')
ValueError: zero length field name in format
Ramit
This communication is for informational purposes only. It is not
intended as an offer or soli
Prasad, Ramit wrote:
print "{} was captured by {}".format(solo, jabba)
Is this Python2.7 specific?
Python 2.6.x :
print "{} was captured by {}".format('t1', 't2')
ValueError: zero length field name in format
Apparently it is 2.7 and greater -- my apologies for not specifying that.
~Ethan~
>>> Currently i am importing the Database into CSV file using csv module,
>>>in csv file i need to change the column width according the size of
>>>the data. i need to set different column width for different columns
>>>pleas let me know how to achieve this
>xlwt is a package for editing Excel
On 03/06/2011 03:58, Chris Torek wrote:
-
This is a bit surprising, since both "s1 in s2" and re.search()
could use a Boyer-Moore-based algorithm for a sufficiently-long
fixed string, and the time required should be proportional to that
needed to
On Mon, 06 Jun 2011 00:55:18 +, Steven D'Aprano wrote:
> And thus we come back full circle. Hundreds of words, and I'm still no
> closer to understanding why you think that "NAN == NAN" should be an
> error.
Well, you could try improving your reading comprehension. Counselling
might help.
On Jun 6, 7:41 pm, geremy condra wrote:
> On Sun, Jun 5, 2011 at 3:34 AM, Peter Irbizon wrote:
> > Hello, thanks, Unfortunatelly I don't understand how xml should resolve my
> > issue. My problem is:
> > I am trying to use aes256 cbc on python and php to decrypt "textstring". But
> > results are
Hello, I am trying to make nice icons for my program. I compiled it with
py2exe but problem is that exe icon in Win 7/vista is not very nice (it
looks like win7 takes 32x32 instead of 248x248icon)
I used png2ico to pack icon file: png2ico icon.ico png248x248.png
png32x32.png png16x16.png
Any idea
Hello, I am trying to make nice icons for my program. I compiled it
with py2exe but problem is that exe icon in Win 7/vista is not very
nice (it looks like win7 takes 32x32 instead of 248x248icon)
I used png2ico to pack icon file: png2ico icon.ico png248x248.png
png32x32.png png16x16.png
Any idea
On Mon, 06 Jun 2011 12:52:31 -0400, Terry Reedy wrote:
> Let me add something not said much here about designing functions: start
> with both a clear and succinct definition *and* test cases. (I only
> started writing tests first a year ago or so.)
For any non-trivial function, I usually start b
On Mon, 06 Jun 2011 23:14:15 +0100, Nobody wrote:
> On Mon, 06 Jun 2011 00:55:18 +, Steven D'Aprano wrote:
>
>> And thus we come back full circle. Hundreds of words, and I'm still no
>> closer to understanding why you think that "NAN == NAN" should be an
>> error.
>
> Well, you could try imp
On Mon, Jun 6, 2011 at 4:19 PM, miamia wrote:
> php I am trying to use is here:
> http://code.google.com/p/antares4pymes/source/browse/trunk/library/System/Crypt/AES.php?r=20
That library does not appear to be doing CBC as far as I can tell.
Maybe they will agree if you use EBC instead?
> BLOCK_
Steven D'Aprano writes:
> On Mon, 06 Jun 2011 12:52:31 -0400, Terry Reedy wrote:
>
> > Let me add something not said much here about designing functions: start
> > with both a clear and succinct definition *and* test cases. (I only
> > started writing tests first a year ago or so.)
>
> For any no
Steven D'Aprano wrote:
For any non-trivial function, I usually start by writing the
documentation (a docstring and doctests) first. How else do you know what
the function is supposed to do if you don't have it documented?
Yes. In my early years I was no different than any other hacker in terms
Chris Rebert writes:
> print "{solo} was captured by {jabba}".format(**locals()) # RIGHT
I tend to use ‘u"foo {bar} baz".format(**vars())’, since ‘vars’ can also
take the namespace of an object. I only need to remember one “give me
the namespace” function for formatting.
> You must use prefix-*
On Mon, Jun 6, 2011 at 6:11 PM, Ben Finney wrote:
>> You must use prefix-** in the call to unpack the mapping as keyword
>> arguments. Note that using locals() like this isn't best-practice.
>
> Who says so, and do you find their argument convincing? Do you have a
> reference for that so we can se
On Mon, Jun 6, 2011 at 6:11 PM, Ben Finney wrote:
> Chris Rebert writes:
>
>> print "{solo} was captured by {jabba}".format(**locals()) # RIGHT
>
> I tend to use ‘u"foo {bar} baz".format(**vars())’, since ‘vars’ can also
> take the namespace of an object. I only need to remember one “give me
> th
Hello,
Is there a library or regex that can determine if a string is a fqdn
(fully qualified domain name)? I'm writing a script that needs to add
a defined domain to the end of a hostname if it isn't already a fqdn
and doesn't contain the defined domain.
Thanks.
--
http://mail.python.org/mailman
On Tue, Jun 7, 2011 at 9:44 AM, Steven D'Aprano
wrote:
> Thank you for your concern about my mental health.
Mental health? You're a programmer. It's far too late to worry about that.
My name is Chris, and I'm a programmer. It started when I was just a
child - my parents thought it would be alrig
On 6/6/2011 1:29 PM, rusi wrote:
On Jun 5, 11:33 pm, Terry Reedy wrote:
Let me add something not said much here about designing functions: start
with both a clear and succinct definition *and* test cases. (I only
started writing tests first a year ago or so.)
I am still one year in the futu
Eric wrote:
Is there a library or regex that can determine if a string is a fqdn
(fully qualified domain name)? I'm writing a script that needs to add
a defined domain to the end of a hostname if it isn't already a fqdn
and doesn't contain the defined domain.
You might try the os module and the
On 6/6/2011 12:52 PM, Terry Reedy wrote:
def group(seq, n):
'Yield from seq successive disjoint slices of length n & the remainder'
if n<=0: raise ValueError('group size must be positive')
for i in range(0,len(seq), n):
yield seq[i:i+n]
for inn,out in (
(('',1), []), # no input, no output
#(('a
Our client, part of one of the largest Telcos in the world is
currently on the hunt for what they describe as a Python Senior
Developer/Team Lead/Systems Archtiect, for their Singapore office.
This particular part of the organisation has offices around the world
servicing world wide brand-name cli
On Tue, Jun 7, 2011 at 10:40 AM, Eric wrote:
> Hello,
>
> Is there a library or regex that can determine if a string is a fqdn
> (fully qualified domain name)? I'm writing a script that needs to add
> a defined domain to the end of a hostname if it isn't already a fqdn
> and doesn't contain the de
En Fri, 03 Jun 2011 21:02:56 -0300, Nobody escribió:
On Fri, 03 Jun 2011 22:08:16 +0200, Wilbert Berendsen wrote:
I find myself all over the place associating objects with each other
using
dicts as caches:
The general concept is called "memoization". There isn't an
implementation
in th
Rob writes:
> Our client, part of one of the largest Telcos in the world is
> currently on the hunt for what they describe as a Python Senior
> Developer/Team Lead/Systems Archtiect, for their Singapore office.
Please don't use this forum for job seeking or advertisements.
The Python Job Board
On Tue, 07 Jun 2011 10:11:01 +1000, Ben Finney wrote:
> Chris Rebert writes:
>
>> print "{solo} was captured by {jabba}".format(**locals()) # RIGHT
>
> I tend to use ‘u"foo {bar} baz".format(**vars())’, since ‘vars’ can also
> take the namespace of an object. I only need to remember one “give m
En Sat, 28 May 2011 14:05:16 -0300, Steven D'Aprano
escribió:
On Sat, 28 May 2011 09:39:08 -0700, John Nagle wrote:
Python allows patching code while the code is executing.
Can you give an example of what you mean by this?
If I have a function:
def f(a, b):
c = a + b
d = c*3
On Jun 6, 2011, at 8:40 PM, Eric wrote:
> Hello,
>
> Is there a library or regex that can determine if a string is a fqdn
> (fully qualified domain name)? I'm writing a script that needs to add
> a defined domain to the end of a hostname if it isn't already a fqdn
> and doesn't contain the defin
"Gabriel Genellina" writes:
> En Fri, 03 Jun 2011 21:02:56 -0300, Nobody escribió:
>
> > On Fri, 03 Jun 2011 22:08:16 +0200, Wilbert Berendsen wrote:
> >
> >> I find myself all over the place associating objects with each
> >> other using dicts as caches:
> >
> > The general concept is called "m
University of Washington Marketing and the Seattle Plone Gathering host
the inaugural Seattle PyCamp 2011 at The Paul G. Allen Center for
Computer Science & Engineering on Monday, August 29 through Friday,
September 2, 2011.
Register today at http://trizpug.org/boot-camp/seapy11/
For beginner
On Mon, 06 Jun 2011 17:40:29 -0700, Eric wrote:
> Is there a library or regex that can determine if a string is a fqdn
> (fully qualified domain name)? I'm writing a script that needs to add
> a defined domain to the end of a hostname if it isn't already a fqdn
> and doesn't contain the defined do
On Tue, Jun 7, 2011 at 3:23 PM, Nobody wrote:
> [1] If a hostname ends with a dot, it's fully qualified.
>
Outside of BIND files, when do you ever see a name that actually ends
with a dot?
ChrisA
--
http://mail.python.org/mailman/listinfo/python-list
En Mon, 06 Jun 2011 14:48:26 -0300, Steve Oldner
escribió:
Seems to work using 2.7 but not 3.2. On 3.2 it just closes all my
python sessions. Is this a bug? Can someone point me to a "How To" on
using a local printer in windows?
It's a bug. Starting IDLE from the command line, one can
>On Tue, Jun 7, 2011 at 3:23 PM, Nobody wrote:
>> [1] If a hostname ends with a dot, it's fully qualified.
[otherwise not, so you have to use the resolver]
In article ,
Chris Angelico wrote:
>Outside of BIND files, when do you ever see a name that actually ends
>with a dot?
I type them in this
67 matches
Mail list logo