Interesting socket behavior
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? -- https://mail.python.org/mailman/listinfo/python-list
Re: Syntax Highlighting in a tkinter Text widget
Sweet thanks for the help many I am defiantly going to use these. -- https://mail.python.org/mailman/listinfo/python-list
Re: Practice question
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. And if you can't, you can usually re-type the question. It's good practice to strength your typing skills. Screen shots cannot be read by people using a screen reader, or who don't have access to the web (but are reading their mail), or if the host site (in this case, imgur) is down or blocked. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Practice question
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 is probably not the best idea, since you might have dozens of True True True True ... printed, one per line, and if you blink the odd False might have scrolled off screen before you notice. With two numbers, 15 and 30, all you really need is five test cases: - a number lower than the smaller of the two numbers (say, 7); - a number equal to the smaller of the two numbers (that is, 15); - a number between the two numbers (say, 21); - a number equal to the larger of the two numbers (that is, 30); - a number higher than the larger of the two numbers (say, 999); The exact numbers don't matter, so long as you test all five cases. And rather than printing True True True... let's use assert instead: for x in (7, 15, 21, 30, 999): assert (15 <= x < 30) == (15<= x and x <30) If the two cases are equal, assert will do nothing. But if they are unequal, assert will raise an exception and stop, and you know that the two cases are not equivalent and can go on to the next possibility. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Pythonic way to iterate through multidimensional space?
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: One is making the product over lists(), product( list_of_lists ) ex: product( [ [1,2,3], ['A','B'], ['a', 'b', 'c'] ] ) the other one making a product over a list of functions, which will create generators ex: product( [ lambda: [ 'A', 'B' ], lambda: xrange(3) ] ) I personally would also be interested in a fast generic solution that can iterate through an N-dimensional array and which does not duplicate the memory or iterate through a list of generator-factories or however this would be called. itertools.product makes a copy of the sequences passed in, but it is a shallow copy. It doesn't copy the objects in the sequences. It also doesn't store the entire product. If you are calling product(j, k, l, m, n), where len(j)==J, the extra memory is J+K+L+M+N, which is much smaller than the number of iterations product will produce. Are you sure that much extra memory use is a problem? How large are your lists that you are product'ing together? I don't understand your point about a list of functions that create generators? What is the problem there? -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list
Re: ruby instance variable in python
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: > # how to set ins_var > > > def m2: > m() > # how to get ins var 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. Could be wrong. if ins_var is None: ins_var = 'val' -- https://mail.python.org/mailman/listinfo/python-list
Re: Practice question
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, 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 is probably not the best idea, since you might > have dozens of True True True True ... printed, one per line, and if you > blink the odd False might have scrolled off screen before you notice. > > With two numbers, 15 and 30, all you really need is five test cases: > > - a number lower than the smaller of the two numbers (say, 7); > - a number equal to the smaller of the two numbers (that is, 15); > - a number between the two numbers (say, 21); > - a number equal to the larger of the two numbers (that is, 30); > - a number higher than the larger of the two numbers (say, 999); > > > The exact numbers don't matter, so long as you test all five cases. And > rather than printing True True True... let's use assert instead: > > > for x in (7, 15, 21, 30, 999): > assert (15 <= x < 30) == (15<= x and x <30) > > > If the two cases are equal, assert will do nothing. But if they are > unequal, assert will raise an exception and stop, and you know that the > two cases are not equivalent and can go on to the next possibility. > > > -- > Steven > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: ruby instance variable in python
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. Could be > wrong. > > if ins_var is None: > ins_var = 'val' Just out of interest, please, do you think the word 'ternary' is more or less synonymous with 'conditional'? I'm not being sarcastic. This possibility just occurred to me, and the world will begin to make more sense to me if it turns out that there are people who simply do not think 'three' when they think 'ternary'. -- https://mail.python.org/mailman/listinfo/python-list
add noise using python
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
Muddleheaded use of the "built-in" term
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 into it that are always available. They are listed here in
alphabetical order""". The functions in the documentation list, as
expected, are the same functions we get from the `builtins` module.
Now, is `math.sin` builtin? Of course not, because it is not an
attribute of builtins:
>>> import builtins
>>> hasattr(builtins, 'sin')
False
and in fact it is not always available:
>>> sin
Traceback (most recent call last):
...
NameError: name 'sin' is not defined
But what happens if I want to check by using `inspect.isbuiltin`? The
answer surprises me:
>>> import inspect
>>> print(inspect.isbuiltin.__doc__.split('\n')[0])
Return true if the object is a built-in function or method.
>>> import math
>>> inspect.isbuiltin(math.sin)
True
That's because the term "built-in" here means "written in C", as
explained here:
https://docs.python.org/3/library/types.html#types.BuiltinMethodType
So, we have built-in objects that are always available, whose names live
in the builtin namespace, and other built-in objects that do not live in
the builtin namespace :/ By using the same word (built-in) to indicate
either objects written in C or objects referenced by the builtin
namespace could be a bit muddler for everyone, beginner or not. 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"?
--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list
Re: add noise using python
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
Re: Muddleheaded use of the "built-in" term
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 late to change that. But it's no different from any other word that has more than one variant of meaning; you have to cope with the collisions. Is there any situation where it's ambiguous? There are builtin name bindings, and there are built-in functions. The former are provided by the language core and are thus available by default; the latter are provided by the language core and thus do not provide __code__. There's a connection between the meanings, but they aren't identical. What's a function? Obviously something created with def or lambda is. Is a class a function? Is an object with a __call__ method a function? Is a list comprehension a function? In different senses, all of them are; but maybe what you want to ask is not "is this a function" but "is this callable" (list comps aren't), or "does this create a new local scope", or "does this have __code__" or something. Yet the meanings of "function" are all related (mostly by external usage; list comps by internal functionality), so it wouldn't make sense to decry the collisions on that word. I do see your issue, but I don't think this can be changed, nor is worth changing. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Muddleheaded use of the "built-in" term
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 into it that are always available. They are listed here in
alphabetical order""". The functions in the documentation list, as
expected, are the same functions we get from the `builtins` module.
Now, is `math.sin` builtin? Of course not, because it is not an
attribute of builtins:
>>> import builtins
>>> hasattr(builtins, 'sin')
False
and in fact it is not always available:
>>> sin
Traceback (most recent call last):
...
NameError: name 'sin' is not defined
But what happens if I want to check by using `inspect.isbuiltin()`? The
answer surprises me:
>>> import inspect
>>> print(inspect.isbuiltin.__doc__.split('\n')[0])
Return true if the object is a built-in function or method.
>>> import math
>>> inspect.isbuiltin(math.sin)
True
That's because the term "built-in" here means "written in C", as
explained in the doc:
https://docs.python.org/3/library/types.html#types.BuiltinMethodType
So, we have built-in objects that are always available, whose names live
in the builtin namespace, and other built-in objects that do not live in
the builtin namespace :/ By using the same word (built-in) to indicate
either objects written in C or objects referenced by the builtin
namespace could be a bit muddler for everyone, beginner or not. 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 or whatever underlying language"?
--
Marco Buttu
INAF-Osservatorio Astronomico di Cagliari
Via della Scienza n. 5, 09047 Selargius (CA)
Phone: 070 711 80 217
Email: [email protected]
--
https://mail.python.org/mailman/listinfo/python-list
How do I check if a string is a prefix of any possible other string that matches a given regex.
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 prefix of a string that matches the given regex. E.g. You have the regex ^[a-z]*4R$ then the strings "a", "ab", "A4" "ab4" are prefixes of this regex (because there is a way of adding characters that causes the regex to match), but "4a" or "a44" or not. How do I programmatically create a regex that matches "a", "ab", "A4", etc.. but not "4a", "a44", etc.. 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 library that does it... Thanks a lot, if anyone knows the answer to this question! Cheers, Jonathan -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I check if a string is a prefix of any possible other string that matches a given regex.
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 possible strings that are a prefix of a string > that matches the given regex. > [...] > 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 library that does it... How wide a net are you counting "regular expressions" to be? What grammar are you using? -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.4.1 on W2K?
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 already poking around with
> extremely legacy stuff, would it be easier for you to use OS/2
> instead of Win2K? Paul Smedley still produces OS/2 builds of
> Python, and OS/2 itself runs happily under VirtualBox (we have
> an OS/2 VM still on our network here, and I use Python to
> manage its backups). Might not end up any better than your
> current system, but it might be!
That's
actually an interesting idea. OS/2 was our OS of choice in the '90s.
XyWrite ran beautifully under it, and when we needed extensions to the
XyWrite Programming Language (XPL) we used Rexx ("RexXPL"). Since last
year I've been using Python instead ("XPyL"). The fact is, though, most
XyWriters are running XyWrite under Windows, except for the few running
it under Linux. Much of our script development since then has focused on
integrating Xy with Windows, so to revert to OS/2 would be swimming
against the tide. But I may just try it anyway!
Thanks, guys.
Pal A.
--
https://mail.python.org/mailman/listinfo/python-list
Re: How do I check if a string is a prefix of any possible other string that matches a given regex.
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 end.) But I cannot find any library that does it... Strictly speaking, a DFA or NFA always consumes the entire input; the question of interest is whether it halts in an accepting state or not. It would be easy to transform a DFA or NFA in the manner that you want, though. For each non-accepting state, determine whether it has any transitions that lead in one or more steps to an accepting state. Modify the FSM so that each such state is also an accepting state. -- https://mail.python.org/mailman/listinfo/python-list
Need some direction in completing the exercise below, appreciate any input given, thanks!
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_name, address, city, county,
state, zip, phone1, phone2, email, web
Here are the instructions:
1) Download the US500 database from http://www.briandunning.com/sample-data/
2) Use the exchange portion of the telephone numbers (the middle three digits)
as the proxy for "user clicked on and expressed interest in this topic".
Identify groups of users that share topic interests (exchange numbers match).
3) Provide an API that takes an e-mail address an input, and returns the e-mail
addresses of other users that share that interest.
4) Extend that API to return users within a certain "distance" N of that
interest. For example, if the original user has an interest in group 236, and N
is 2, return all users with interests in 234 through 238.
5) Identify and rank the states with the largest groups, and (separately) the
largest number of groups.
6) Provide one or more demonstrations that the API works. These can be via a
testing framework, and/or a quick and dirty web or command line client, or
simply by driving it from a browser and showing a raw result.
I was able to import the data this way, however I know there's a better method
using the CSV module. The code below just reads lines, I'd like to be able to
split each individual field into columns and assign primary and foreign keys in
order to solve the challenge. What's the best method to accomplish this task?
import os, csv, json, re
class fetch500(): # class
instantiation
def __init__(self): # initializes
data import object
US_500file = open('us-500.csv')
us_500list = US_500file.readlines()
for column in us_500list:
print column, # prints
out phone1 array
data_import = fetch500()
print fetch500()
--
https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.4.1 on W2K?
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/xypydoc.htm 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 the divide into a 16-bit app is pretty impressive. I wonder how well your system could be made to work with dosbox. Dosbox runs xywrite on any platform (even non x86 like a tablet). I'm not sure how you'd interface dosbox with python on the host though. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.4.1 on W2K?
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 the divide into a 16-bit app is pretty > impressive. I assume that it uses temporary files (or pipes, don't know if DOS can do this), and that DOS programs can execute windows programs with int 21/4B. -- https://mail.python.org/mailman/listinfo/python-list
Re: Timezones
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 things in UTC. I run an >international Dungeons & Dragons campaign with sessions every Sunday >at 02:00 UTC, and nobody needs to be confused by time zones. (The >server displays UTC time, so it's easy for anyone to see; for >instance, it's now Mon 02:48:09, so session time was about this time >yesterday.) Civil time can do whatever it likes, just as long as >everyone knows that the meeting is based on UTC. > >ChrisA And I just found out there is going to be another Y2K in 2038. I hope I am around to see it. I spend this Y2K in Las Vegas. Las Vegas is one of the last few time zones so TVs everywhere were showing the ringing in of the New Year and nothing was exploding. -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I check if a string is a prefix of any possible other string that matches a given regex.
> > 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 library that does > > it... > > > > Strictly speaking, a DFA or NFA always consumes the entire input; the > > question of interest is whether it halts in an accepting state or not. > > > > It would be easy to transform a DFA or NFA in the manner that you > > want, though. For each non-accepting state, determine whether it has > > any transitions that lead in one or more steps to an accepting state. > > Modify the FSM so that each such state is also an accepting state. Thanks, I'll make every state of the FSM an accepting state. My use case is to implement autocompletion for a regular language. So I think if the input is accepted by the FSM that I build, it's a valid "prefix", and the autocompletion can be generated by looking at which transitions are possible at that point. More pointers are welcome, but I think that I have enough to start the implementation. -- https://mail.python.org/mailman/listinfo/python-list
Another time question
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 have had drug prescripts that were 28 days was considered a month supply. The would be 4 weeks instead of one month. -- https://mail.python.org/mailman/listinfo/python-list
Re: Another time question
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 only got to keep the > car 23 hours. > > As another side note I have had drug prescripts that were 28 days was > considered a month supply. The would be 4 weeks instead of one month. I'm not sure how this connects to Python, but I'll assume for now you're trying to do something up as a script and just haven't told us that bit... With periodic recurring charges, it's common for "month" to mean "calendar month", resetting every Nth of the month (often 1st, but any day works). If your mobile data plan costs $35/month and allows you 7GB/month throughput, both those figures will be per calendar month. For the rest, it depends on what the company's doing. Presumably drug prescriptions are primarily done on a weekly basis; car rentals will be on a daily basis. They're not going to say "cars have to be returned by 8AM, except during DST when they must be returned by 9AM", because that's just messy; so one day a year, you get an extra hour, and one day a year, you lose an hour. If you tell us what the code is you're trying to work on, we might be able to advise more usefully. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I check if a string is a prefix of any possible other string that matches a given regex.
On 2014-10-07 22:48, [email protected] 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 end.) But I cannot find any library that does it... Strictly speaking, a DFA or NFA always consumes the entire input; the question of interest is whether it halts in an accepting state or not. It would be easy to transform a DFA or NFA in the manner that you want, though. For each non-accepting state, determine whether it has any transitions that lead in one or more steps to an accepting state. Modify the FSM so that each such state is also an accepting state. Thanks, I'll make every state of the FSM an accepting state. My use case is to implement autocompletion for a regular language. So I think if the input is accepted by the FSM that I build, it's a valid "prefix", and the autocompletion can be generated by looking at which transitions are possible at that point. More pointers are welcome, but I think that I have enough to start the implementation. If you're not interested in generating an actual regex, but only in matching the prefix, then it sounds like you want "partial matching". The regex module supports that: https://pypi.python.org/pypi/regex -- https://mail.python.org/mailman/listinfo/python-list
Re: Another time question
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 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 have had drug prescripts that were 28 days was >> considered a month supply. The would be 4 weeks instead of one month. > >I'm not sure how this connects to Python, but I'll assume for now >you're trying to do something up as a script and just haven't told us >that bit... > >With periodic recurring charges, it's common for "month" to mean >"calendar month", resetting every Nth of the month (often 1st, but any >day works). If your mobile data plan costs $35/month and allows you >7GB/month throughput, both those figures will be per calendar month. >For the rest, it depends on what the company's doing. Presumably drug >prescriptions are primarily done on a weekly basis; car rentals will >be on a daily basis. They're not going to say "cars have to be >returned by 8AM, except during DST when they must be returned by 9AM", >because that's just messy; so one day a year, you get an extra hour, >and one day a year, you lose an hour. > >If you tell us what the code is you're trying to work on, we might be >able to advise more usefully. > >ChrisA Actually, the simple python code I am working on is not required to consider those complicated questions, but it still causes me to ponder them. -- https://mail.python.org/mailman/listinfo/python-list
Re: ruby instance variable in python
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: ruby instance variable in python
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*, does that mean that you're not actually providing a default? Also, since you haven't quoted the person you are responding to, there is no context to your response. The end result of a confusing sentence with no context is that I have no idea what you are trying to say. Could you try explaining again please? -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Another time question
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 them consider a month to start from the 1st and end at the end of the month, some of them take 30 days from the date you started, some of them 31 days from when you start, or 28 days (four weeks). Some of them have a fixed starting date. Some of them don't. Some bill you fortnightly, or weekly, or yearly. > I did rent a car once during a time change and I only got to keep the > car 23 hours. I'm not sure how that is relevant to either Python or what companies consider a month, but okay. > As another side note I have had drug prescripts that were 28 days was > considered a month supply. The would be 4 weeks instead of one month. Okay. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
operator module functions
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 actually: operator.__add__; operator.__sub__; operator.__mul__; etc., with the underscore-less versions being provided as a convenience. Was anyone aware of this? It came as a surprise to me. Is there anyone who uses or prefers the dunder versions? -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Perl Template Toolkit: Now in spicy new Python flavor
Sorry, is anyone else having trouble opening the README.txt? On Monday, January 14, 2008 6:00:52 PM UTC-5, [email protected] 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 now also available in a beta Python > implementation: > > http://tt2.org/python/index.html > > I created this port both as a fun programming project, and for use in > environments where Perl is not available, for reasons technical, > cultural, or otherwise. The extensive Perl test suites have also been > ported, and most templates require no or very little modification. > > Discussion of the Python implementation should be conducted on the > main Template Toolkit developer mailing list; see the site above for > details. -- https://mail.python.org/mailman/listinfo/python-list
Re: Perl Template Toolkit: Now in spicy new Python flavor
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, [email protected] 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 now also available in a beta Python >> implementation: >> >> http://tt2.org/python/index.html >> >> I created this port both as a fun programming project, and for use in >> environments where Perl is not available, for reasons technical, >> cultural, or otherwise. The extensive Perl test suites have also been >> ported, and most templates require no or very little modification. >> >> Discussion of the Python implementation should be conducted on the >> main Template Toolkit developer mailing list; see the site above for >> details. You're top-posting from Google Groups in response to a six-year-old post. At least you provided us with some context. But you're looking at something pretty ancient, so a more appropriate response would be to first search the web to see if the URL's changed, and if you're still having trouble, to ask (as a brand new thread) something like "I found this from six years ago, does anyone know if it's still active?". We here on comp.lang.python / python-list don't have the power to help you; you need the original author, whose contact details can probably be found by poking around on the web site you quoted the link to. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.4.1 on W2K?
On 10/07/2014 02:33 PM, [email protected] 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 Xywrite somehow? If so, how >> does it do this? Crossing the divide into a 16-bit app is pretty >> impressive. > > I assume that it uses temporary files (or pipes, don't know if DOS can > do this), and that DOS programs can execute windows programs with int > 21/4B. dosemu has the ability to execute linux shell commands, I know. Dosbox does not, unfortunately. It be nice to have such a facility. Then xywrite fans could have xywrite on any platform, not just windows. I suppose one could hack together a way of doing it via the dosbox IPX networking facilities. -- https://mail.python.org/mailman/listinfo/python-list
help with regex
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: operator module functions
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 documentation, the "official" functions are actually: operator.__add__; operator.__sub__; operator.__mul__; etc., with the underscore-less versions being provided as a convenience. Was anyone aware of this? Of course. It has bugged me a bit for years. Messy. Is there anyone who uses or prefers the dunder versions? I don't and don't, and that seems to be true of other core devs: there are no non-test uses of the dunder methods in the stdlib. Grepping /lib/*.py recursively for 'operator.' gives 540 hits, most for operator.someop. Grepping the same for 'operator.__' returns 4 hits for operator.__name__ and .__doc__ (not operators) and these 6 tests: C:\Programs\Python34\Lib\test\test_richcmp.py: 88: "lt": (lambda a,b: a< b, operator.lt, operator.__lt__), C:\Programs\Python34\Lib\test\test_richcmp.py: 89: "le": (lambda a,b: a<=b, operator.le, operator.__le__), C:\Programs\Python34\Lib\test\test_richcmp.py: 90: "eq": (lambda a,b: a==b, operator.eq, operator.__eq__), C:\Programs\Python34\Lib\test\test_richcmp.py: 91: "ne": (lambda a,b: a!=b, operator.ne, operator.__ne__), C:\Programs\Python34\Lib\test\test_richcmp.py: 92: "gt": (lambda a,b: a> b, operator.gt, operator.__gt__), C:\Programs\Python34\Lib\test\test_richcmp.py: 93: "ge": (lambda a,b: a>=b, operator.ge, operator.__ge_ If there a back-compatibility excuse? I cannot remember what operator had in 1.4 or whenever it was added, if after that. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: help with regex
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 Number (attempt 1):
1")
>>> match.group()
'1'
See
--
https://mail.python.org/mailman/listinfo/python-list
