Re: help with regex

2014-10-07 Thread Peter Otten
James Smith wrote: > I want the last "1" > I can't this to work: > pattern=re.compile( "(\d+)$" ) match=pattern.match( "LINE: 235 : Primary Shelf Number (attempt 1): 1") print match.group() >>> pattern = re.compile("(\d+)$") >>> match = pattern.search( "LINE: 235 : Primary Shelf N

Re: operator module functions

2014-10-07 Thread Terry Reedy
On 10/7/2014 9:41 PM, Steven D'Aprano wrote: Every Python operator has a function version in the operator module: operator + has function operator.add; operator - has function operator.sub; operator * has function operator.mul; and so forth. Only, that's not quite right... according to the docu

help with regex

2014-10-07 Thread James Smith
I want the last "1" I can't this to work: >>> pattern=re.compile( "(\d+)$" ) >>> match=pattern.match( "LINE: 235 : Primary Shelf Number (attempt 1): 1") >>> print match.group() -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.4.1 on W2K?

2014-10-07 Thread Michael Torrie
On 10/07/2014 02:33 PM, random...@fastmail.us wrote: > On Tue, Oct 7, 2014, at 16:27, Michael Torrie wrote: >> That's really interesting. I looked briefly at the page. How does your >> python extension work with xywrite? Does it manipulate xywrite >> documents or does it tie in at runtime with X

Re: Perl Template Toolkit: Now in spicy new Python flavor

2014-10-07 Thread Chris Angelico
On Wed, Oct 8, 2014 at 12:51 PM, wrote: > Sorry, is anyone else having trouble opening the README.txt? > > On Monday, January 14, 2008 6:00:52 PM UTC-5, eef...@gmail.com wrote: >> I'd like to inform the Python community that the powerful and popular >> Template Toolkit system, previously availabl

Re: Perl Template Toolkit: Now in spicy new Python flavor

2014-10-07 Thread joshua . higgins . pcv
Sorry, is anyone else having trouble opening the README.txt? On Monday, January 14, 2008 6:00:52 PM UTC-5, eef...@gmail.com wrote: > I'd like to inform the Python community that the powerful and popular > Template Toolkit system, previously available only in its original > Perl implementation, is

operator module functions

2014-10-07 Thread Steven D'Aprano
Every Python operator has a function version in the operator module: operator + has function operator.add; operator - has function operator.sub; operator * has function operator.mul; and so forth. Only, that's not quite right... according to the documentation, the "official" functions are actuall

Re: Another time question

2014-10-07 Thread Steven D'Aprano
Seymore4Head wrote: > I never really cared enough to ask anyone, but something like my cable > bill is 98$ a month. Do companies (in general) consider a month every > 30 days or every time the 14th comes around? What does this have to do with Python? Companies do whatever they want. Some of the

Re: ruby instance variable in python

2014-10-07 Thread Steven D'Aprano
flebber wrote: > I thought that it was a shortcut in ruby to negate the other option of > providing another default . I'm afraid I can't work out what that sentence means, "to negate the other option of providing *another* default"? How many defaults are you providing? Then you negate *the option

Re: ruby instance variable in python

2014-10-07 Thread flebber
I thought that it was a shortcut in ruby to negate the other option of providing another default . I don't greatly know ruby but took a guess after reading examples here https://blog.neowork.com/ruby-shortcuts -- https://mail.python.org/mailman/listinfo/python-list

Re: Another time question

2014-10-07 Thread Seymore4Head
On Wed, 8 Oct 2014 10:21:10 +1100, Chris Angelico wrote: >On Wed, Oct 8, 2014 at 10:12 AM, Seymore4Head > wrote: >> I never really cared enough to ask anyone, but something like my cable >> bill is 98$ a month. Do companies (in general) consider a month every >> 30 days or every time the 14th co

Re: How do I check if a string is a prefix of any possible other string that matches a given regex.

2014-10-07 Thread MRAB
On 2014-10-07 22:48, jonathan.slend...@gmail.com wrote: Logically, I'd think it should be possible by running the input string against the state machine that the given regex describes, and if at some point all the input characters are consumed, it's a match. (We don't have to run the regex unti

Re: Another time question

2014-10-07 Thread Chris Angelico
On Wed, Oct 8, 2014 at 10:12 AM, Seymore4Head wrote: > I never really cared enough to ask anyone, but something like my cable > bill is 98$ a month. Do companies (in general) consider a month every > 30 days or every time the 14th comes around? > > I did rent a car once during a time change and I

Another time question

2014-10-07 Thread Seymore4Head
I never really cared enough to ask anyone, but something like my cable bill is 98$ a month. Do companies (in general) consider a month every 30 days or every time the 14th comes around? I did rent a car once during a time change and I only got to keep the car 23 hours. As another side note I ha

Re: How do I check if a string is a prefix of any possible other string that matches a given regex.

2014-10-07 Thread jonathan . slenders
> > Logically, I'd think it should be possible by running the input string > > against the state machine that the given regex describes, and if at some > > point all the input characters are consumed, it's a match. (We don't have > > to run the regex until the end.) But I cannot find any librar

Re: Timezones

2014-10-07 Thread Seymore4Head
On Mon, 6 Oct 2014 13:48:58 +1100, Chris Angelico wrote: >On Mon, Oct 6, 2014 at 1:37 PM, Rustom Mody wrote: >>> My advice is to avoid time zones, they're a real pain, seriously. >> >> What say we send an application to the UN to declare the world flat? > >Easier to simply start scheduling thing

Re: Python 3.4.1 on W2K?

2014-10-07 Thread random832
On Tue, Oct 7, 2014, at 16:27, Michael Torrie wrote: > That's really interesting. I looked briefly at the page. How does your > python extension work with xywrite? Does it manipulate xywrite > documents or does it tie in at runtime with Xywrite somehow? If so, how > does it do this? Crossing t

Re: Python 3.4.1 on W2K?

2014-10-07 Thread Michael Torrie
On 10/05/2014 06:04 PM, Pal Acreide wrote: > BTW, the reason I run VBox is that I belong to a group of diehard > users of the classic DOS word-processor XyWrite. I've devised a way > to use Python as an extension of XyWrite's built-in Programming > Language (XPL): http://users.datarealm.com/xywwweb

Need some direction in completing the exercise below, appreciate any input given, thanks!

2014-10-07 Thread wadson . espindola
The aim of this exercise is to combine the sample database, click tracking information from a test website and application, and information from user's social networks. The sample database contains the following fields and is made up of 500 records. first_name, last_name, company_na

Re: How do I check if a string is a prefix of any possible other string that matches a given regex.

2014-10-07 Thread Ian Kelly
On Tue, Oct 7, 2014 at 10:15 AM, wrote: > Logically, I'd think it should be possible by running the input string > against the state machine that the given regex describes, and if at some > point all the input characters are consumed, it's a match. (We don't have to > run the regex until the e

Re: Python 3.4.1 on W2K?

2014-10-07 Thread Carl Distefano
Tim G.: > Of course, if you're happy to work with a slightly older > version of Python, such as 3.2, then you should be fine. Well, I just installed 3.2.5 in W2K and all of my "stuff" seems to work. I'm a happy camper. Many thanks for the information and link! ChrisA: > Wow. I wonder, since you

Re: How do I check if a string is a prefix of any possible other string that matches a given regex.

2014-10-07 Thread Joshua Landau
On 7 October 2014 17:15, wrote: > Probably I'm turning the use of regular expressions upside down with this > question. I don't want to write a regex that matches prefixes of other > strings, I know how to do that. I want to generate a regex -- given another > regex --, that matches all possib

How do I check if a string is a prefix of any possible other string that matches a given regex.

2014-10-07 Thread jonathan . slenders
Hi everyone, Probably I'm turning the use of regular expressions upside down with this question. I don't want to write a regex that matches prefixes of other strings, I know how to do that. I want to generate a regex -- given another regex --, that matches all possible strings that are a prefi

Muddleheaded use of the "built-in" term

2014-10-07 Thread Marco Buttu
I always thought the builtin objects were those we can get from the `builtins` module, that is those always available. In fact the "Built-in Functions" documentation: https://docs.python.org/3/library/functions.html says: """The Python interpreter has a number of functions and types built int

Re: Muddleheaded use of the "built-in" term

2014-10-07 Thread Chris Angelico
On Wed, Oct 8, 2014 at 12:24 AM, Marco Buttu wrote: > Is it too late for changing the name of the `builtin` namespace in something > like, for instance, `root` namespace, or using the name "core" > (inspect.iscore(), types.CoreFunctionType, ecc.) to indicate "written in C"? Yes, I think it's too

Re: add noise using python

2014-10-07 Thread Chris Angelico
On Wed, Oct 8, 2014 at 12:24 AM, wrote: > can someone teach me how to generate noisy images by applying Gaussian random > noise onto an image? http://www.lmgtfy.com/?q=python+image+gaussian+random+noise ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Muddleheaded use of the "built-in" term

2014-10-07 Thread Marco Buttu
I always thought the builtin objects were those we can get from the `builtins` module, that is those always available. In fact the "Built-in Functions" documentation: https://docs.python.org/3/library/functions.html says: """The Python interpreter has a number of functions and types built int

add noise using python

2014-10-07 Thread mthaqifisa
can someone teach me how to generate noisy images by applying Gaussian random noise onto an image? -- https://mail.python.org/mailman/listinfo/python-list

Re: ruby instance variable in python

2014-10-07 Thread Jussi Piitulainen
flebber writes: > On Monday, 6 October 2014 21:07:24 UTC+11, roro codeath wrote: > > in ruby: > > > > > > module M > > def ins_var > > @ins_var ||= nil > > end ... > I took || to be a ternary. So I assumed your code just sets ins_var > to nil and then is called in module m and supplied a val.

Re: Practice question

2014-10-07 Thread C Smith
Steven D'Aprano wrote: >>With two numbers, 15 and 30, all you really need is five test cases: My solution assumed integers also, but after I posted it, I thought: "What about floating points?" On Tue, Oct 7, 2014 at 1:48 AM, Steven D'Aprano wrote: > On Sun, 05 Oct 2014 20:18:13 -0400, Seymore4He

Re: ruby instance variable in python

2014-10-07 Thread flebber
On Monday, 6 October 2014 21:07:24 UTC+11, roro codeath wrote: > in ruby: > > > module M > def ins_var > @ins_var ||= nil > end > > > def m > @ins_var = 'val' > end > > > def m2 > m > ins_var # => 'val' > end > end > > > in py: > > > # m.py > > > # how to def ins_var > > > def m: >  

Re: Pythonic way to iterate through multidimensional space?

2014-10-07 Thread Ned Batchelder
On 10/7/14 2:10 AM, Gelonida N wrote: Disadvantage of itertools.product() is, that it makes a copy in memory. Reason ist, that itertools also makes products of generators (meaning of objects, that one can't iterate several times through) There are two use cases, that I occasionaly stumble over

Re: Practice question

2014-10-07 Thread Steven D'Aprano
On Sun, 05 Oct 2014 20:18:13 -0400, Seymore4Head wrote: > I think I get it now. You are using a sample of answers. So you could > actually just run through them all. (I haven't tried this yet) > > for x in range(lo,hi) > print((15 <= x < 30) == (15<= x and x <30)) Yes, except using print

Re: Practice question

2014-10-07 Thread Steven D'Aprano
On Sun, 05 Oct 2014 20:07:50 -0400, Seymore4Head wrote: > Here is the exact question, I was trying to post something similar. I > failed. > > http://i.imgur.com/iUGh4xf.jpg Please don't post screen shots if you can avoid it. You almost certainly can copy and paste the text from the web page. A

Re: Syntax Highlighting in a tkinter Text widget

2014-10-07 Thread Nicholas Cannon
Sweet thanks for the help many I am defiantly going to use these. -- https://mail.python.org/mailman/listinfo/python-list

Interesting socket behavior

2014-10-07 Thread Christian Calderon
I noticed that if I make a listening socket using SOCK_STREAM | SOCK_NONBLOCK, that the sockets I get after calling listener.accept() don't have the O_NONBLOCK flag set, but checking the result of gettimeout() on the same sockets gives me 0.0, which means they are non blocking. Why is this the case