Re: Beginner - GUI devlopment in Tkinter - Any IDE with drag and drop feature like Visual Studio?
Why Thinter? You can try wxpython. -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Sun, 21 Jul 2013 18:28:27 -0600, Michael Torrie wrote: >The Sendmail MTA has been ported to many platforms including windows. >But... Thanks for the tip. Since I couldn't find a good, basic, native Windows app, I was indeed about to look at eg. Exim + Cygwin, and resort to a Linux appliance if none footed the bill. >> I'm not sure my ISP blocks outbound port 25 connections. I'll >> experiment with a small Linux box. > >Having spent a long time managing e-mail servers, everything Ivan said >in his reply is true as well. I had forgotten a lot of that since I >haven't been running my own mail server (MTA or server part) in a while. Indeed, I had forgotten about some MTAs refusing incoming e-mails from other ISP's customer hosts. I'll experiment. >But then how would it know that legit-looking e-mails aren't in fact >SPAM? It generally does a good job, but every once in a while, some perfectly good e-mail I'm sending is flagged as SPAM. To keep all my e-mails in the same client, I'd rather use a local MTA than sending the e-mail from Gmail. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Sun, 21 Jul 2013 21:01:09 + (UTC), Grant Edwards wrote: >Unless you've got a static IP address, a domain name, and a valid MX >record that will match up when they do a reverse DNS lookup, it's >pretty unlikely that you're going to have much luck running an SMTP >server. Most other SMTP servers are probably going to ignore or >reject your attempts to transfer mail from your own SMTP server. I had forgotten about this. I'll give a try, and see how it goes. >I'd recommend postfix or exim if I was going to try to do it, but I >think they're Unix-only. Thanks for the tip. Looks like Exim is available on Windows through Cygwin http://blogostuffivelearnt.blogspot.fr/2012/07/smtp-mail-server-with-windows.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Sun, 21 Jul 2013 21:01:09 + (UTC), Grant Edwards wrote: >Unless you've got a static IP address, a domain name, and a valid MX >record that will match up when they do a reverse DNS lookup, it's >pretty unlikely that you're going to have much luck running an SMTP >server. Most other SMTP servers are probably going to ignore or >reject your attempts to transfer mail from your own SMTP server. Incidently, how do ISP MTAs find whether the remote MTA is legit or running on some regular user's computer? 1. Query Reverse DNS for IP 2. Find domain 3. Query DNS for MX 4. ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Mon, Jul 22, 2013 at 10:11 PM, Gilles wrote: > On Sun, 21 Jul 2013 18:28:27 -0600, Michael Torrie > wrote: >>Having spent a long time managing e-mail servers, everything Ivan said >>in his reply is true as well. I had forgotten a lot of that since I >>haven't been running my own mail server (MTA or server part) in a while. > > Indeed, I had forgotten about some MTAs refusing incoming e-mails from > other ISP's customer hosts. I'll experiment. One thing to check when you change how you send mail is your SPF record. I run the mail server for kepl.com.au and have set its SPF to: "v=spf1 ip4:122.107.147.136 ip4:203.214.67.43 ip4:192.168.0.0/16 -all" If your SPF is as strict as mine (and if it's not, please make it so, for the sake of the rest of the world!), you'll want to check it before you start sending mail directly from your own computer. Otherwise your mail _will_ be rejected as spam. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner - GUI devlopment in Tkinter - Any IDE with drag and drop feature like Visual Studio?
@Chris “Kwpolska” Warrick Yeah, as I mentioned I was able to use it to create .py files and the GUI ran. But when I made the .exe from the .py using cxfreeze it created exe but the GUI did not run. -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Mon, 22 Jul 2013 22:29:42 +1000, Chris Angelico wrote: >One thing to check when you change how you send mail is your SPF >record. I run the mail server for kepl.com.au and have set its SPF to: > >"v=spf1 ip4:122.107.147.136 ip4:203.214.67.43 ip4:192.168.0.0/16 -all" > >If your SPF is as strict as mine (and if it's not, please make it so, >for the sake of the rest of the world!), you'll want to check it >before you start sending mail directly from your own computer. >Otherwise your mail _will_ be rejected as spam. Thanks for the tip. I didn't know about SPF http://en.wikipedia.org/wiki/Sender_Policy_Framework -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Mon, Jul 22, 2013 at 10:38 PM, Gilles wrote: > On Mon, 22 Jul 2013 22:29:42 +1000, Chris Angelico > wrote: >>One thing to check when you change how you send mail is your SPF >>record. I run the mail server for kepl.com.au and have set its SPF to: >> >>"v=spf1 ip4:122.107.147.136 ip4:203.214.67.43 ip4:192.168.0.0/16 -all" >> >>If your SPF is as strict as mine (and if it's not, please make it so, >>for the sake of the rest of the world!), you'll want to check it >>before you start sending mail directly from your own computer. >>Otherwise your mail _will_ be rejected as spam. > > Thanks for the tip. I didn't know about SPF > http://en.wikipedia.org/wiki/Sender_Policy_Framework It's a great way of detecting legit vs forged mail. If anyone tries to send mail purporting to be from [email protected] and the receiving mail server is checking SPF records, it'll be rejected after one cheap DNS lookup. It's a simple and cacheable way to ask the owning server, "Is this guy allowed to send mail for you?". (The 192.168 block in my SPF record above is permitted to allow some intranet conveniences; omit it unless you need it.) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Mon, 22 Jul 2013 08:11:25 -0400, Gilles wrote: On Sun, 21 Jul 2013 18:28:27 -0600, Michael Torrie wrote: The Sendmail MTA has been ported to many platforms including windows. But... Thanks for the tip. Since I couldn't find a good, basic, native Windows app, I was indeed about to look at eg. Exim + Cygwin, and resort to a Linux appliance if none footed the bill. try http://emailrelay.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Play Ogg Files
On 07/21/2013 10:10 AM, Stefan Behnel wrote:
Devyn Collier Johnson, 20.07.2013 14:25:
On 07/20/2013 12:21 AM, Stefan Behnel wrote:
Devyn Collier Johnson, 20.07.2013 03:06:
I am making a chatbot that I host on Launchpad.net/neobot. I am currently
converting the engine from BASH code to Python3. I need to convert this for
cross-platform compatibility. I do not need to use Mplayer; I just show the
below code to give others a better idea what I am doing. I would prefer to
be Python3 independent; I do not want to use the system shell. I am fine
with using Python3 modules like Pygame (if there is a py3 module). As long
as the code is fast, efficient, and simple without depending on the system
shell or external apps, that would be nice. I also need the code to execute
while the rest of the script continues running.
jobs = multiprocessing.Process(SEND = subprocess.getoutput('mplayer
-nogui -nolirc -noar -quiet ./conf/boot.ogg')) #Boot sound#
Well, since you mentioned it already, have you actually looked at pygame?
It should be able to do what you want. There's also pyaudio, which is more
specialised to, well, audio. A web search for python and ogg might provide
more.
Thanks Stefan! I have not heard of Pyaudio; I will look into that. As for
Pygame, I have not been able to find any good documentation for playing
audio files.
A quick duckduckgo search gave me this, at least:
http://www.pygame.org/docs/ref/mixer.html
Plus, I recently learned that Pygame is not Python3 compatible.
Looks like it's your lucky day:
http://www.pygame.org/wiki/FrequentlyAskedQuestions#Does%20Pygame%20work%20with%20Python%203?
Stefan
Thanks!
DCJ
--
http://mail.python.org/mailman/listinfo/python-list
Re: Play Ogg Files
On 07/21/2013 01:50 AM, Chris Angelico wrote: On Sun, Jul 21, 2013 at 3:39 PM, David Hutto wrote: With linux you can have your package listed in synaptic, and can use with a sudo apt-get install whatever ogg player like ogg123, and windows I don't work with that much, but I'm pretty sure I've played .wav files from the command line before while working with cross platform just for practice, so with python 3 you can use what's available in the system with an if command. Correction: "With Debian-based Linux distributions, you can etc etc" - aptitude is Debian's package manager, it's not something you'll find on other Linuxes. And the exact packages available depend on your repositories; again, most Debian-derived Linux distros will most likely have ogg123, but it's not guaranteed. However, it's reasonably likely that other package managers and repositories will have what you're looking for. ChrisA Good point, Chris. I do not want to make coding specifically for each package manager for many of the different distros. I follow the KISS princlple (Keep It Simple Stupid) when programming. Making a cross-platform/universal way to play an ogg file is better than being specific for each individual system. Remember KISS. Mahalo, DCJ -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On 07/22/2013 06:51 AM, Chris Angelico wrote: >> Thanks for the tip. I didn't know about SPF >> http://en.wikipedia.org/wiki/Sender_Policy_Framework > > It's a great way of detecting legit vs forged mail. If anyone tries to > send mail purporting to be from [email protected] and the receiving > mail server is checking SPF records, it'll be rejected after one cheap > DNS lookup. It's a simple and cacheable way to ask the owning server, > "Is this guy allowed to send mail for you?". (The 192.168 block in my > SPF record above is permitted to allow some intranet conveniences; > omit it unless you need it.) Yes setting SPF records will help your mail be accepted by other servers, but I disagree with your appeal to make mail server SPF handling as strict as your server does. SPF has problems in a number of situations which could cause legitimate mail to be rejected. In my last job I could only use SPF as one spam factor, not as a basis for rejection. -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Tue, Jul 23, 2013 at 12:08 AM, Michael Torrie wrote: > On 07/22/2013 06:51 AM, Chris Angelico wrote: >>> Thanks for the tip. I didn't know about SPF >>> http://en.wikipedia.org/wiki/Sender_Policy_Framework >> >> It's a great way of detecting legit vs forged mail. If anyone tries to >> send mail purporting to be from [email protected] and the receiving >> mail server is checking SPF records, it'll be rejected after one cheap >> DNS lookup. It's a simple and cacheable way to ask the owning server, >> "Is this guy allowed to send mail for you?". (The 192.168 block in my >> SPF record above is permitted to allow some intranet conveniences; >> omit it unless you need it.) > > Yes setting SPF records will help your mail be accepted by other > servers, but I disagree with your appeal to make mail server SPF > handling as strict as your server does. SPF has problems in a number of > situations which could cause legitimate mail to be rejected. In my last > job I could only use SPF as one spam factor, not as a basis for rejection. If legit mail is rejected for failing an SPF check, it's the sending admin's problem, not yours. You should never have problems with it if it's set up correctly. And since rejected mail gets reported to the transmitting MTA, you don't need to drop it in a spambox or anything. It's not spam, it's simply invalid mail (equivalent to something sent to a dud address). ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On 2013-07-22, Gilles wrote: > On Sun, 21 Jul 2013 21:01:09 + (UTC), Grant Edwards > wrote: >>Unless you've got a static IP address, a domain name, and a valid MX >>record that will match up when they do a reverse DNS lookup, it's >>pretty unlikely that you're going to have much luck running an SMTP >>server. Most other SMTP servers are probably going to ignore or >>reject your attempts to transfer mail from your own SMTP server. > > Incidently, how do ISP MTAs find whether the remote MTA is legit or > running on some regular user's computer? > > 1. Query Reverse DNS for IP > 2. Find domain > 3. Query DNS for MX > 4. ? There are a variety of things they check. They've got lists of IP address blocks that they know are residential DSL/cable customers, and sometimes they'll reject mail from those regardless of what you do. Some will compare the reverse-DNS lookup with the headers to make sure you're being honest about things like return-path, some will compare the IP address with the MX record for the domain they got when they did the reverse-lookup-DNS, and they've all probably got a variety of other secret heuristics they use to generate a "SPAM" score. For many years I ran my own SMTP server and had it configured to deliver mail directly to recipients. About 10 years, I had to give up on that because so many SMTP servers were rejecting/ignoring mail I sent. And I did have a static IP with a valid domain and MX record. But it was a residential DSL IP address, and I suspect that was enough to get mail rejected by some servers. -- Grant Edwards grant.b.edwardsYow! Well, O.K. at I'll compromise with my gmail.comprinciples because of EXISTENTIAL DESPAIR! -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On 07/22/2013 06:19 AM, Gilles wrote: > On Sun, 21 Jul 2013 21:01:09 + (UTC), Grant Edwards > wrote: >> Unless you've got a static IP address, a domain name, and a valid MX >> record that will match up when they do a reverse DNS lookup, it's >> pretty unlikely that you're going to have much luck running an SMTP >> server. Most other SMTP servers are probably going to ignore or >> reject your attempts to transfer mail from your own SMTP server. > > Incidently, how do ISP MTAs find whether the remote MTA is legit or > running on some regular user's computer? > > 1. Query Reverse DNS for IP > 2. Find domain > 3. Query DNS for MX > 4. ? My mail server did a number of things: 1. ensure IP address of sending server has a reverse name (domain didn't particularly matter) 2. ensure the HELO address in SMTP matches IP address of sending server 3. check sender IP address against spam blacklists, which includes netblocks of home ISPs, some entire countries, flagged subnets 4. greylist sender IP if the recipient requested it. First connection always fails with a nonfatal server error, next connection must wait at least 5 minutes. If a reconnection happened too quickly, the IP was temporarily black listed. After success, IP address is whitelisted for a time. A commandline MTA will not be able to get through greylisting; only a mail server with queuing could. Spambots tend to give up on the first error, even now. Cheaper targets I guess. 5. spamassassin checked SPF (DNS) and domainkeys (message itself) and weighted the spam factor accordingly I think there were other basic rules that sendmail applied to the sender, but I can't remember all of what they are. This is well and truly off topic now for the python list, though. -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner - GUI devlopment in Tkinter - Any IDE with drag and drop feature like Visual Studio?
On 7/22/13 4:54 AM, Cucole Lee wrote: Why Thinter? You can try wxpython. Well, it's partly a matter of taste, but I for one find wxPython's API...inelegant. -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com -- http://mail.python.org/mailman/listinfo/python-list
Re: could you change PYPI downloads number for not-uploaded packages?
On 2013-07-22 16:44, [email protected] wrote: Hi all, could you change PYPI downloads number for not-uploaded packages from zeros to real posivive numbers? For example, my projects download links are binded to my website , and thus people see misleading zeros, e.g. https://pypi.python.org/pypi/openopt Downloads (All Versions): 0 downloads in the last day 0 downloads in the last week Or, even better, taking into account that some people install packages from subversion/git/etc repository, invoke "+1" when someone runs "python setup.py install" (or "develop") (provided internet connection is present) The maintenance and development of PyPI is discussed on the Distutils-SIG. Please bring your concerns there. http://www.python.org/community/sigs/current/distutils-sig/ In short, if you want to have download counts, you will need to host your package downloads from PyPI itself. There is no good way for PyPI to count downloads from any other source. What you might want to ask for instead is to have the download count not shown when the packages are not hosted on PyPI. That would be a reasonable change that I think the PyPI team would accept. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
could you change PYPI downloads number for not-uploaded packages?
Hi all, could you change PYPI downloads number for not-uploaded packages from zeros to real posivive numbers? For example, my projects download links are binded to my website , and thus people see misleading zeros, e.g. https://pypi.python.org/pypi/openopt Downloads (All Versions): 0 downloads in the last day 0 downloads in the last week Or, even better, taking into account that some people install packages from subversion/git/etc repository, invoke "+1" when someone runs "python setup.py install" (or "develop") (provided internet connection is present) Regards, D. http://openopt.org/Dmitrey -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Tue, Jul 23, 2013 at 12:21 AM, Michael Torrie wrote: > My mail server did a number of things: > 1. ensure IP address of sending server has a reverse name (domain didn't > particularly matter) > 2. ensure the HELO address in SMTP matches IP address of sending server > 3. check sender IP address against spam blacklists, which includes > netblocks of home ISPs, some entire countries, flagged subnets > 4. greylist sender IP if the recipient requested it. First connection > always fails with a nonfatal server error, next connection must wait at > least 5 minutes. If a reconnection happened too quickly, the IP was > temporarily black listed. After success, IP address is whitelisted for > a time. A commandline MTA will not be able to get through greylisting; > only a mail server with queuing could. Spambots tend to give up on the > first error, even now. Cheaper targets I guess. > 5. spamassassin checked SPF (DNS) and domainkeys (message itself) and > weighted the spam factor accordingly > > I think there were other basic rules that sendmail applied to the > sender, but I can't remember all of what they are. This is well and > truly off topic now for the python list, though. And yet off-topic does happen... For what it's worth, here's how my server is set up: 1. A variety of protocol-level checks. If you don't say HELO, for instance, you get rejected. Surprisingly, these simple checks actually keep out a lot of spam - but I've yet to see any legiit mail blocked by them. (Not that I keep logs of these any more. I stopped watching after it looked clean for a while.) And if legit mail is rejected, it'll be resent or bounced by the sending MTA anyway. 2. SPF checks on the MAIL FROM:<> address. Again, if legit mail gets rejected (which would be the fault of the sending domain owner), the server at the previous hop will deal with it. Only hard failures get thrown out; anything else just gets marked (which we usually ignore) and delivered as normal, not even spam-scored. 3. Bayesian spam filter, set very conservatively so we get false negatives but (almost) no false positives. Any spam that gets through these three checks gets delivered, and then the users will drop it in their junk folder. Every week I do a train-and-wipe run across all junk folders, which logs spam counts from our primary mailboxes. Last week's run was 228 spam across the six logged accounts (some of those accounts collect from many addresses), or an average of five false negatives per account per day, and false positives are almost completely unheard-of. Considering how much spam assaults the outside of my fortress's walls, that's a fairly good ratio, I think. SPF for the win. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Tue, Jul 23, 2013 at 2:25 AM, Michael Torrie wrote: > On 07/22/2013 08:15 AM, Chris Angelico wrote: >> If legit mail is rejected for failing an SPF check, it's the sending >> admin's problem, not yours. You should never have problems with it if >> it's set up correctly. And since rejected mail gets reported to the >> transmitting MTA, you don't need to drop it in a spambox or anything. >> It's not spam, it's simply invalid mail (equivalent to something sent >> to a dud address). > > Sure. Tell that to the people you work for who depend on e-mail. When I > was a sysadmin (quite recently), I'd have gotten fired for enforcing > such an arbitrary policy. Indeed when mail wasn't coming through that > someone in the organization was expecting and wanting, regardless of > SPF, it was indeed *my* problem and my job was on the line. BOFH > attitudes simply aren't going to change that reality. Is your job on the line if the sender of that email got the recipient's address right? Is your job on the line if the sender mucked up his SMTP settings and the message didn't even get to your server? Is your job on the line if the email never even got sent? Then why should your job be on the line if the sender violates his own declared protocol? Remember, if you don't publish an SPF record, your emails will be accepted regardless. It's only if you explicitly create that DNS record that ends with "-all" that any of this will happen - which means you *asked* for that mail to be rejected. If you do that and then send mail from a different IP, then I *will* reject it. Accepting mail and just giving it a spam score is *worse*, because the sender won't even know why it didn't get through (what if most of his mail gets accepted, but that one email when he sent a blank body, subject "RE: your invoice", and a zip file attachment, managed to trip the spam cutoff and get dumped?), whereas rejecting will result in a quick and easy bounce, probably within seconds (minutes maybe). I stand by SPF checking. It has never been a problem. If you don't stand by protocols, you weaken those protocols. And speaking of protocols, I'm now going to have to follow the "I'm on an airliner and mobile phones have to be turned off" protocol, as the flight's due to depart shortly. Ah, protocols... some you love, some not so much. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On 7/21/13 10:42 AM, Gilles wrote: Hello Every once in a while, my ISP's SMTP server refuses to send perfectly legit e-mails because it considers them as SPAM. So I'd like to install a dead-simple SMTP server on my XP computer just to act as SMTP backup server. All I'd need is to change the SMTP address in my e-mail client, and off they go. No need for anything else like user authentication or SPAM control. Is there a no-brainer, ready-to-use solution in Python that I could use for this? Thank you. http://www.hmailserver.com -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On 07/22/2013 06:11 AM, Gilles wrote: > On Sun, 21 Jul 2013 18:28:27 -0600, Michael Torrie > wrote: >> The Sendmail MTA has been ported to many platforms including windows. >> But... > > Thanks for the tip. Since I couldn't find a good, basic, native > Windows app, I was indeed about to look at eg. Exim + Cygwin, and > resort to a Linux appliance if none footed the bill. Where did you look? Here's one I found. It's not the real sendmail program, but it implements the interface which is all you need: http://glob.com.au/sendmail/ I just googled for sendmail win32 -- http://mail.python.org/mailman/listinfo/python-list
Re: Homework help requested, thanks to everyone.
John> Another project I thought of was a Pig Latin translator. (But
do kids today
John> even know what Pig Latin is? Am I showing my age?)
Chris> Even if they don't, they'll grok it no problem. It's simple enough.
Google for "Python pig latin" to see a lot of "prior art".
And it might be useful as a step as part of a word-based password generator. :-)
>>> words = open("/usr/dict/words")
>>> words = [word.strip() for word in words if len(word) == 5]
>>> len(words)
2194
>>> import random
>>> random.shuffle(words)
>>> words[0:4]
['live', 'skat', 'levy', 'cove']
>>> [makePigLatin(word) for word in words[0:4]]
['ivelay', 'atskay', 'evylay', 'ovecay']
:-)
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On 07/22/2013 08:15 AM, Chris Angelico wrote: > If legit mail is rejected for failing an SPF check, it's the sending > admin's problem, not yours. You should never have problems with it if > it's set up correctly. And since rejected mail gets reported to the > transmitting MTA, you don't need to drop it in a spambox or anything. > It's not spam, it's simply invalid mail (equivalent to something sent > to a dud address). Sure. Tell that to the people you work for who depend on e-mail. When I was a sysadmin (quite recently), I'd have gotten fired for enforcing such an arbitrary policy. Indeed when mail wasn't coming through that someone in the organization was expecting and wanting, regardless of SPF, it was indeed *my* problem and my job was on the line. BOFH attitudes simply aren't going to change that reality. SPF is just one more of the many things that are contributing overall to absolutely breaking and demise of SMTP. I'm afraid when it does finally cease to work, it's going to be replaced with less open, centrally-controlled messaging systems like facebook. Which is unfortunate. -- http://mail.python.org/mailman/listinfo/python-list
Re: odd behavoiur seen
On 2013-07-22 18:36:41 +, Chris Hinsley said:
Folks, I have this decorator:
def memoize(maxsize):
def _memoize(func):
lru_cache = {}
lru_list = []
Other clues, I use it on a recursive function:
@memoize(64)
def next_move(board, colour, alpha, beta, ply):
if ply <= 0:
return evaluate(board) * colour
for new_board in all_moves(board[:], colour):
score = -next_move(new_board, -colour, -beta, -alpha, ply - 1)
if score >= beta:
return score
if score > alpha:
alpha = score
return alpha
And I notice I don't get the strange problem on a non-recursive
function ! Or at least I don't seam to.
Chris
--
http://mail.python.org/mailman/listinfo/python-list
odd behavoiur seen
Folks, I have this decorator:
def memoize(maxsize):
def _memoize(func):
lru_cache = {}
lru_list = []
def memoizer(*args, **kwargs):
key = str(args) + str(kwargs)
if key in lru_cache:
lru_list.remove(key)
lru_list.append(key)
return lru_cache[key]
print len(lru_list),
if len(lru_list) >= maxsize:
del(lru_cache[lru_list[0]])
del(lru_list[0])
ret = func(*args, **kwargs)
lru_cache[key] = ret
lru_list.append(key)
return ret
return memoizer
return _memoize
I didn't used to do the 'len(lru_list) >= maxsize' just '==' and
noticed it sailing past the max number of entries, so put in the print
statement, and now I see it ocationally printing a value 1 larger than
maxsize !!!
So if I use it as '@memoize(64)' I see some 65's in the output ! I'm at
a loss to explain it, does anyone knows why ? Is it a bug or some
threading issue ? I'm not useing threads BTW, and I've noticed this in
both running it with Python or Pypy.
Best Regards
Chris
--
http://mail.python.org/mailman/listinfo/python-list
How to read a make file in python and access its elements
How to read/load the cmake file in python and access its elements. I have a scenario, where i need to load the make file and access its elements. I have tried reading the make file as text file and parsing it,but its not the ideal solution Please let me know how to load the .mk file and access its elements in python. -- http://mail.python.org/mailman/listinfo/python-list
Re: odd behavoiur seen
Chris Hinsley wrote:
> On 2013-07-22 18:36:41 +, Chris Hinsley said:
>
>> Folks, I have this decorator:
>>
>> def memoize(maxsize):
>> def _memoize(func):
>> lru_cache = {}
>> lru_list = []
>
> Other clues, I use it on a recursive function:
>
> @memoize(64)
> def next_move(board, colour, alpha, beta, ply):
> if ply <= 0:
> return evaluate(board) * colour
> for new_board in all_moves(board[:], colour):
> score = -next_move(new_board, -colour, -beta, -alpha, ply - 1)
> if score >= beta:
> return score
> if score > alpha:
> alpha = score
> return alpha
>
> And I notice I don't get the strange problem on a non-recursive
> function ! Or at least I don't seam to.
That's indeed the problem:
> if len(lru_list) >= maxsize:
> del(lru_cache[lru_list[0]])
> del(lru_list[0])
> ret = func(*args, **kwargs)
> lru_cache[key] = ret
> lru_list.append(key)
You delete a cached item, then call the original function which causes calls
of the decorated function. This causes a length check which sees the already
reduced length and decides that the cache is not yet full.
If you remove the oldest item after calling the original function you should
be OK.
--
http://mail.python.org/mailman/listinfo/python-list
Re: odd behavoiur seen
On 2013-07-22 19:47:33 +, Peter Otten said:
Chris Hinsley wrote:
On 2013-07-22 18:36:41 +, Chris Hinsley said:
Folks, I have this decorator:
def memoize(maxsize):
def _memoize(func):
lru_cache = {}
lru_list = []
Other clues, I use it on a recursive function:
@memoize(64)
def next_move(board, colour, alpha, beta, ply):
if ply <= 0:
return evaluate(board) * colour
for new_board in all_moves(board[:], colour):
score = -next_move(new_board, -colour, -beta, -alpha, ply - 1)
if score >= beta:
return score
if score > alpha:
alpha = score
return alpha
And I notice I don't get the strange problem on a non-recursive
function ! Or at least I don't seam to.
That's indeed the problem:
if len(lru_list) >= maxsize:
del(lru_cache[lru_list[0]])
del(lru_list[0])
ret = func(*args, **kwargs)
lru_cache[key] = ret
lru_list.append(key)
You delete a cached item, then call the original function which causes calls
of the decorated function. This causes a length check which sees the already
reduced length and decides that the cache is not yet full.
If you remove the oldest item after calling the original function you should
be OK.
Ah ! Thank you kindly sir !
Chris
--
http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Mon, 22 Jul 2013 14:19:57 +0200, Gilles wrote: > Incidently, how do ISP MTAs find whether the remote MTA is legit or > running on some regular user's computer? Look up the IP address in a database. If they don't have a database, perform a reverse DNS lookup and reject anything which looks like a typical auto-generated name for a consumer DSL/cable connection. FWIW, I've been running sendmail on my home system (ADSL with static IP) for years, and have had very few problems with mail being rejected. -- http://mail.python.org/mailman/listinfo/python-list
Re: could you change PYPI downloads number for not-uploaded packages?
Robert Kern writes: > On 2013-07-22 16:44, [email protected] wrote: > > For example, my projects download links are binded to my website , > > and thus people see misleading zeros […] > In short, if you want to have download counts, you will need to host > your package downloads from PyPI itself. Also of interest to this group is that PyPI is transitioning to strongly encourage hosting files at PyPI, and installer tools will default to not installing files hosted elsewhere. See PEP 438 “Transitioning to release-file hosting on PyPI” http://www.python.org/dev/peps/pep-0438/> for the details. As Robart said, it's best not discussed here, but at the ‘distutils-sig’ forum http://www.python.org/community/sigs/current/distutils-sig/>. -- \ “I do not believe in immortality of the individual, and I | `\consider ethics to be an exclusively human concern with no | _o__) superhuman authority behind it.” —Albert Einstein, letter, 1953 | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: How to read a make file in python and access its elements
san writes: > I have a scenario, where i need to load the make file and access its > elements. What do you mean by “elements” of a make file? Is that a term with a specific meaning, or do you mean some particular parts of the make file? > I have tried reading the make file as text file and parsing it,but its > not the ideal solution You might be interested in using a library purpose-built for creating a parser http://pyparsing.wikispaces.com/>. I'm not aware of any makefile-syntax-aware tool for Python. Your best option could be to write your own parser using the above library. -- \ “True greatness is measured by how much freedom you give to | `\ others, not by how much you can coerce others to do what you | _o__) want.” —Larry Wall | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: How to read a make file in python and access its elements
On 07/22/2013 03:09 PM, san wrote: How to read/load the cmake file in python and access its elements. I have a scenario, where i need to load the make file and access its elements. I have tried reading the make file as text file and parsing it,but its not the ideal solution Please let me know how to load the .mk file and access its elements in python. First, just what do you mean by "make file"? You refer to cmake, make, and .mk in three places in your message. How about a link to the actual tool you're interested in? And a brief list of the other tools you're using it with. Is this it? http://www.cmake.org/ Once we're talking about the same tool, then the question is what "elements" are you interested in? If your cmake is anything like the traditional make program, the format is deceptively simple, and enormously complex in usage. But I suspect that your cmake has very little to do with Unix make tools. The cmake that I gave the link for uses a CMakeLists file, which looks nothing like a makefile. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Play Ogg Files
On 20/07/2013 10:25 PM, Devyn Collier Johnson wrote:
I have not heard of Pyaudio; I will look into that. As
for Pygame, I have not been able to find any good documentation for
playing audio files. Plus, I recently learned that Pygame is not Python3
compatible.
Another option would be Pyglet, which uses the cross-platform binary
AVBin to provide sound support. It may not provide as much control as
PyAudio, but given your example usage it might be a bit more
straightforward:
pyglet.media.load('boot.ogg', streaming=False).play()
http://www.pyglet.org/doc/programming_guide/simple_audio_playback.html
The latest development release provides support for Python 3:
https://code.google.com/p/pyglet/downloads/list?q=1.2alpha1
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to read a make file in python and access its elements
On 23/07/2013 5:09 AM, san wrote: How to read/load the cmake file in python and access its elements. I have a scenario, where i need to load the make file and access its elements. I have tried reading the make file as text file and parsing it,but its not the ideal solution Please let me know how to load the .mk file and access its elements in python. Take a look at pymake: "make.py (and the pymake modules that support it) are an implementation of the make tool which are mostly compatible with makefiles written for GNU make." http://hg.mozilla.org/users/bsmedberg_mozilla.com/pymake/ There is a parser.py file which might be useful to you. -- http://mail.python.org/mailman/listinfo/python-list
How to tick checkboxes with the same name?
I faced a problem: to implement appropriate search program I need to tick few
checkboxes which turned out to have the same name (name="a",
id="a1","a2","a3","a4"). Set_input('a', True) does not work (I use Grab
library), this command leads to the error "checkboxgroup must be set to a
sequence". I don't understand what the sequence actually is, so I'm stuck with
how to tick the checkboxes. It would be really great if someone would help me
with how to handle this question. The code is available here:
view-source:http://zakupki.gov.ru/pgz/public/action/contracts/search/ext/enter
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to tick checkboxes with the same name?
On Tue, Jul 23, 2013 at 12:10 AM, wrote:
> I faced a problem: to implement appropriate search program I need to tick few
> checkboxes which turned out to have the same name (name="a",
> id="a1","a2","a3","a4"). Set_input('a', True) does not work (I use Grab
> library), this command leads to the error "checkboxgroup must be set to a
> sequence". I don't understand what the sequence actually is, so I'm stuck
> with how to tick the checkboxes. It would be really great if someone would
> help me with how to handle this question. The code is available here:
> view-source:http://zakupki.gov.ru/pgz/public/action/contracts/search/ext/enter
> --
> http://mail.python.org/mailman/listinfo/python-list
Have you tried a[0], a[1], etc. for the names?
--
Joel Goldstick
http://joelgoldstick.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to tick checkboxes with the same name?
On Mon, 22 Jul 2013 21:10:18 -0700, malayrev wrote:
> I faced a problem: to implement appropriate search program I need to
> tick few checkboxes which turned out to have the same name (name="a",
> id="a1","a2","a3","a4"). Set_input('a', True) does not work (I use Grab
> library)
Instructions for solving your problem can be found here:
http://sscce.org/
Although it is written for Java, the same ideas will work for Python or
any other programming language.
Have a read of that page, and if it isn't enough to solve your problem
with "Grab" (whatever that is), feel free to come back.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
Re: Play Ogg Files
Devyn, are you just trying to use this in an application? Would a browser
based web app work. I ask because there will still be some sort of DB
interaction, so could it be an option to go with a browser command?
On Mon, Jul 22, 2013 at 8:37 PM, alex23 wrote:
> On 20/07/2013 10:25 PM, Devyn Collier Johnson wrote:
>
>> I have not heard of Pyaudio; I will look into that. As
>> for Pygame, I have not been able to find any good documentation for
>> playing audio files. Plus, I recently learned that Pygame is not Python3
>> compatible.
>>
>
> Another option would be Pyglet, which uses the cross-platform binary AVBin
> to provide sound support. It may not provide as much control as PyAudio,
> but given your example usage it might be a bit more straightforward:
>
>pyglet.media.load('boot.ogg', streaming=False).play()
>
> http://www.pyglet.org/doc/**programming_guide/simple_**audio_playback.html
>
> The latest development release provides support for Python 3:
>
> https://code.google.com/p/**pyglet/downloads/list?q=1.**2alpha1
> --
> http://mail.python.org/**mailman/listinfo/python-list
>
--
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com*
--
http://mail.python.org/mailman/listinfo/python-list
Re: Beginner - GUI devlopment in Tkinter - Any IDE with drag and drop feature like Visual Studio?
There is the matter of how much time you want to put into this. There is the standard gtk library for python, and in the future, as soon as I'm well enough to focus, having recent problems, I'll be using the blender game engine to enhance my software to a 3d graphical form...to make my apps pop. So which tutorials are you willing to take time with, and which are benchmarked the best for your apps? For a 3d trig/quadrant cartesian 3d implementation for practice refresher, I used tkinter, and when using it was slow as hell. SO the question is, have you looked at the individual graphical tutorials for each, and decided on a look, a feel, and a time enhanced optimization yet? In other words, work a little bit with each to see which best fits your needs. -- http://mail.python.org/mailman/listinfo/python-list
PyGLet on Python 3
On 07/21/2013 08:10 PM, Joseph Clark wrote: > John, have you taken a look at pyglet? It's an alternative to pygame and I > found it pretty slick once I got the hang of it. There is a development > version that's compatible with python 3 and I've never had a bug with it. It > wraps OpenGL itself so there are no additional dependencies. > > > // joseph w. clark , phd , visiting research associate > \\ university of nebraska at omaha - college of IS&T > Hi Joe, Thanks for the PyGLet recommendation. I like OpenGL. Unfortunately, I can't seem to get PyGLet to work, even though the pyglet.org front page claims that "the major 1.2alpha1 release brings pyglet to Python 3." I followed the links to this page: https://code.google.com/p/pyglet/downloads/list?q=1.2alpha1 I installed pyglet on my Linux system's Python 3.3 using distutils, as I have done with many other packages. But I can't run test.py, nor can I even get as far as importing pyglet from my Python 3.3 interpreter command line. The obstacle is apparently Python 2.x-style print statements, which are found throughout tests.py and pyglet/__init__.py. Does anyone know an efficient way around this problem? Thanks! -- http://mail.python.org/mailman/listinfo/python-list
tkinter progress bar
Hi, How can I add a tkinter progress bar in python 3.2 to start before a loop and end after it. I am looking for a very simple solution. def MyFunc(): Start progress bar for fileName in fileList: … End progress bar Thanks a lot in advance. -- http://mail.python.org/mailman/listinfo/python-list
