Re: Pr. Euler 18, recursion problem
process wrote: I am trying to solve project euler problem 18 with brute force(I will move on to a better solution after I have done that for problem 67). http://projecteuler.net/index.php?section=problems&id=18 However I can't get the recursive function right. I always have to use return right? Unless I am printing? So I canät stack to diffferent recursive calls after each other like so: recur_left(t, p) recur_right(t,p+1) Some stuff I have tried: def recur(tree, pos): if not tree: return [] else: return [[tree[0][pos]] + recur(tree[1:], pos)] + \ [[tree[0][pos]] + recur(tree[1:], pos+1)] recur([[1],[2,3],[4,5,6]],0) [[1, [2, [4], [4]], [2, [5], [5]]], [1, [3, [5], [5]], [3, [6], [6 SO it is kind of working, just not exactly like I want. A more easily parseable/readable result would be nice, I want to be able to sum() over each path preferrably. So the result should be: [[1,2,4],[1,2,5],[1,3,5],[1,3,6]] I know conceptually what has to be done. Base case: empty tree, return [] Else: recur to the left and to the right. This is just my opinion, but I felt the non-brute force solution to this problem was actually simpler than trying to define a brute force recursive solution I tried to implement a brute force algorithm at first, until I had an epiphany with regard to how simple the problem actually was. Then I faced palmed. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pr. Euler 18, recursion problem
process wrote: On Oct 6, 8:13 am, Aidan <[EMAIL PROTECTED]> wrote: process wrote: I am trying to solve project euler problem 18 with brute force(I will move on to a better solution after I have done that for problem 67). http://projecteuler.net/index.php?section=problems&id=18 However I can't get the recursive function right. I always have to use return right? Unless I am printing? So I canät stack to diffferent recursive calls after each other like so: recur_left(t, p) recur_right(t,p+1) Some stuff I have tried: def recur(tree, pos): if not tree: return [] else: return [[tree[0][pos]] + recur(tree[1:], pos)] + \ [[tree[0][pos]] + recur(tree[1:], pos+1)] recur([[1],[2,3],[4,5,6]],0) [[1, [2, [4], [4]], [2, [5], [5]]], [1, [3, [5], [5]], [3, [6], [6 SO it is kind of working, just not exactly like I want. A more easily parseable/readable result would be nice, I want to be able to sum() over each path preferrably. So the result should be: [[1,2,4],[1,2,5],[1,3,5],[1,3,6]] I know conceptually what has to be done. Base case: empty tree, return [] Else: recur to the left and to the right. This is just my opinion, but I felt the non-brute force solution to this problem was actually simpler than trying to define a brute force recursive solution I tried to implement a brute force algorithm at first, until I had an epiphany with regard to how simple the problem actually was. Then I faced palmed. But let's say you have [[1],[1,10],[1,2,300],[10,1,1,1]]. you must check all solutions right? there is no pattern. if you start from the bottom and eliminate paths that seem to be losing can you regain that later up in the pyramid if it turns out one side gets bigg again? It's difficult to say much here without giving the answer away... but, yes, you need to check all solutions - it's just that there's a very easy way to do that without having to recurse from the top of the tree to the bottom. Hope that gives you a clue while not fully revealing the answer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Hi, I am getting the following errorTypeError: sort() takes no keyword arguments
gaurav kashyap wrote: Hi all, I am using python version 2.3.in a program , I have called the sort function.Wherein, a.sort(reverse=True) is giving the following error: TypeError: sort() takes no keyword arguments. It works in python 2.4,What can be the alternative in python 2.3 Thanks , Gaurav You could try: >>> a.sort() >>> a = a[::-1] -- http://mail.python.org/mailman/listinfo/python-list
Python, subprocess, dump, gzip and Cron
Hi, I'm having a bit of trouble with a python script I wrote, though I'm not sure if it's related directly to python, or one of the other software packages... The situation is that I'm trying to create a system backup script that creates an image of the system, filters the output though gzip, and then uploads the data (via ftp) to a remote site. The problem is that when I run the script from the command line, it works as I expect it, but when it is run by cron I only get a 20 byte file where the compressed image should be... does anyone have any idea as to why this might be happening? Code follows #!/usr/bin/python from subprocess import PIPE, Popen from ftplib import FTP host = 'box' filename = '%s.img.gz' % host ftp_host = '192.168.1.250' ftpuser, ftppass = 'admin', 'admin' dest_dir = '/share/%s' % host dump = Popen('dump 0uaf - /',shell=True,stdout=PIPE) gzip = Popen('gzip',shell=True,stdin=dump.stdout,stdout=PIPE) ftp = FTP(ftp_host) ftp.login(ftpuser,ftppass) ftp.cwd(dest_dir) ftp.storbinary('STOR %s' % filename,gzip.stdout) ftp.quit() print "Image '%s' created" % filename I appreciate all feedback. Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python, subprocess, dump, gzip and Cron
TT wrote: On Jun 10, 2:37 pm, Aidan <[EMAIL PROTECTED]> wrote: Hi, I'm having a bit of trouble with a python script I wrote, though I'm not sure if it's related directly to python, or one of the other software packages... The situation is that I'm trying to create a system backup script that creates an image of the system, filters the output though gzip, and then uploads the data (via ftp) to a remote site. The problem is that when I run the script from the command line, it works as I expect it, but when it is run by cron I only get a 20 byte file where the compressed image should be... does anyone have any idea as to why this might be happening? Code follows #!/usr/bin/python from subprocess import PIPE, Popen from ftplib import FTP host = 'box' filename = '%s.img.gz' % host ftp_host = '192.168.1.250' ftpuser, ftppass = 'admin', 'admin' dest_dir = '/share/%s' % host dump = Popen('dump 0uaf - /',shell=True,stdout=PIPE) gzip = Popen('gzip',shell=True,stdin=dump.stdout,stdout=PIPE) ftp = FTP(ftp_host) ftp.login(ftpuser,ftppass) ftp.cwd(dest_dir) ftp.storbinary('STOR %s' % filename,gzip.stdout) ftp.quit() print "Image '%s' created" % filename I appreciate all feedback. Thanks in advance. it's possible that the cron doesn't have the environment variables you have, especially $PATH. So the script failed to find the command it need to create the image. *fore head slap* Of course... adding the full path to both those utilities on the Popen lines seems to have fixed it. Thank you very much for your assistance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python, subprocess, dump, gzip and Cron
Sebastian "lunar" Wiesner wrote: Aidan <[EMAIL PROTECTED]> at Dienstag 10 Juni 2008 07:21: TT wrote: On Jun 10, 2:37 pm, Aidan <[EMAIL PROTECTED]> wrote: Hi, I'm having a bit of trouble with a python script I wrote, though I'm not sure if it's related directly to python, or one of the other software packages... The situation is that I'm trying to create a system backup script that creates an image of the system, filters the output though gzip, and then uploads the data (via ftp) to a remote site. The problem is that when I run the script from the command line, it works as I expect it, but when it is run by cron I only get a 20 byte file where the compressed image should be... does anyone have any idea as to why this might be happening? Code follows #!/usr/bin/python from subprocess import PIPE, Popen from ftplib import FTP host = 'box' filename = '%s.img.gz' % host ftp_host = '192.168.1.250' ftpuser, ftppass = 'admin', 'admin' dest_dir = '/share/%s' % host dump = Popen('dump 0uaf - /',shell=True,stdout=PIPE) You should avoid the use of ``shell=True`` here and use a argument list instead: dump = Popen(['dump', '0uaf', '-', '/'], stdout=PIPE) This results in an exception thrown if the executable doesn't exist. This exception can be caught and handle for instance with the logging module. thanks. That exception certainly would have helped me... gzip = Popen('gzip',shell=True,stdin=dump.stdout,stdout=PIPE) Same here, but why don't you use the gzip functionality from the standard library? is there a way I can create a gzip file-like object which can read the output from the dump subprocess, and has a read method which outputs the compressed data, which will not write to disk first? With the above code python doesn't have to write the system image data to disk at all, which helps when there is not enough disk space to hold an intermediate image (at least, that is my understanding of it...). I had a look at the gzip module, but eventually just fell back to using the stdin and stdout of a gzip subprocess. I'd be interested to know how it could be done using the python standard lib though. -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic HTML from Python Script
asdf wrote: I have a python script whose output i want to dynamically display on a webpage which will be hosted using Apache. How do I do that? thanks Well, there's a few ways you could approach it. You could create a cgi program from your script - this is probably the solution you're looking for. You could have the script run periodically and create a static html file in the webroot... this would be acceptable, maybe preferable, if the output from your script doesn't change frequently. There's also more advanced ways you can make python code run in a web-service. Cherrypy comes to mind, as well as the myriad python MVC frameworks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic HTML from Python Script
asdf wrote: Well, there's a few ways you could approach it. You could create a cgi program from your script - this is probably the solution you're looking for. Output from the script does come up very often. There is a new output every 10 secs and it's possible that the script might be run indefinitely. Basically I want all that output displayed in a web browser Well, in that case you could simply append the new output to a static file every 10 seconds, or whenever there is new output. That way, you just need to refresh the static file in your browser to see updates... Given what I understand of your situation, that's how I'd do it. A constantly running CGI app is probably not the best idea, given timeouts and other such constraints you might run into. You could have the script run periodically and create a static html file in the webroot... this would be acceptable, maybe preferable, if the output from your script doesn't change frequently. -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic HTML from Python Script
asdf wrote: On Wed, 11 Jun 2008 11:20:48 +1000, Aidan wrote: asdf wrote: Well, there's a few ways you could approach it. You could create a cgi program from your script - this is probably the solution you're looking for. Output from the script does come up very often. There is a new output every 10 secs and it's possible that the script might be run indefinitely. Basically I want all that output displayed in a web browser Well, in that case you could simply append the new output to a static file every 10 seconds, or whenever there is new output. That way, you just need to refresh the static file in your browser to see updates... Given what I understand of your situation, that's how I'd do it. The problem with this is that browser would have to be refreshed manually every 10 seconds. Unless there is a way to set this in the script itself. You should be able to do that with just: in the section of your page (you can adjust the value of content from 5 to however many seconds you want between refreshes). You could also look at adding some AJAX-yness to your page, and have it query your script for new output every 10 seconds, and then add that content to the existing page... it sounds like this behavior is what you're looking for, but it's slightly harder to pull off than the method mentioned above. A constantly running CGI app is probably not the best idea, given timeouts and other such constraints you might run into. You could have the script run periodically and create a static html file in the webroot... this would be acceptable, maybe preferable, if the output from your script doesn't change frequently. -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic HTML from Python Script
Aidan wrote: asdf wrote: On Wed, 11 Jun 2008 11:20:48 +1000, Aidan wrote: asdf wrote: Well, there's a few ways you could approach it. You could create a cgi program from your script - this is probably the solution you're looking for. Output from the script does come up very often. There is a new output every 10 secs and it's possible that the script might be run indefinitely. Basically I want all that output displayed in a web browser Well, in that case you could simply append the new output to a static file every 10 seconds, or whenever there is new output. That way, you just need to refresh the static file in your browser to see updates... Given what I understand of your situation, that's how I'd do it. The problem with this is that browser would have to be refreshed manually every 10 seconds. Unless there is a way to set this in the script itself. You should be able to do that with just: in the section of your page (you can adjust the value of content from 5 to however many seconds you want between refreshes). To be clear, you can set the content attribute value to any arbitrary integer value. You could also look at adding some AJAX-yness to your page, and have it query your script for new output every 10 seconds, and then add that content to the existing page... it sounds like this behavior is what you're looking for, but it's slightly harder to pull off than the method mentioned above. A constantly running CGI app is probably not the best idea, given timeouts and other such constraints you might run into. You could have the script run periodically and create a static html file in the webroot... this would be acceptable, maybe preferable, if the output from your script doesn't change frequently. -- http://mail.python.org/mailman/listinfo/python-list
Re: Summing a 2D list
Mark wrote: Hi all, I have a scenario where I have a list like this: UserScore 1 0 1 1 1 5 2 3 2 1 3 2 4 3 4 3 4 2 And I need to add up the score for each user to get something like this: UserScore 1 6 2 4 3 2 4 8 Is this possible? If so, how can I do it? I've tried looping through the arrays and not had much luck so far. Any help much appreciated, Mark does this work for you? users = [1,1,1,2,2,3,4,4,4] score = [0,1,5,3,1,2,3,3,2] d = dict() for u,s in zip(users,score): if d.has_key(u): d[u] += s else: d[u] = s for key in d.keys(): print 'user: %d\nscore: %d\n' % (key,d[key]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Summing a 2D list
Mark wrote: John, it's a QuerySet coming from a database in Django. I don't know enough about the structure of this object to go into detail I'm afraid. Aidan, I got an error trying your suggestion: 'zip argument #2 must support iteration', I don't know what this means! well, if we can create 2 iterable sequences one which contains the user the other the scores, it should work the error means that the second argument to the zip function was not an iterable, such as a list tuple or string can you show me the lines you're using to retrieve the data sets from the database? then i might be able to tell you how to build the 2 lists you need. Thanks to all who have answered! Sorry I'm not being very specific! -- http://mail.python.org/mailman/listinfo/python-list
Re: Summing a 2D list
Aidan wrote: Mark wrote: John, it's a QuerySet coming from a database in Django. I don't know enough about the structure of this object to go into detail I'm afraid. Aidan, I got an error trying your suggestion: 'zip argument #2 must support iteration', I don't know what this means! well, if we can create 2 iterable sequences one which contains the user the other the scores, it should work the error means that the second argument to the zip function was not an iterable, such as a list tuple or string can you show me the lines you're using to retrieve the data sets from the database? then i might be able to tell you how to build the 2 lists you need. wait you already did... predictions = Prediction.objects.all() pairs = [(p.predictor.id,p.predictionscore) for p in predictions] those 2 lines will will build a list of user/score pairs. you can then replace the call to zip with pairs any luck? -- http://mail.python.org/mailman/listinfo/python-list
Re: Comments on my first script?
Chris wrote: On Jun 13, 9:38 am, Phillip B Oldham <[EMAIL PROTECTED]> wrote: Thanks guys. Those comments are really helpful. The odd semi-colon is my PHP background. Will probably be a hard habbit to break, that one! ;) If I do accidentally drop a semi-colon at the end of the line, will that cause any weird errors? Also, Chris, can you explain this: a, b = line.split(': ')[:2] I understand the first section, but I've not seen [:2] before. That's slicing at work. What it is doing is only taking the first two elements of the list that is built by the line.split. slicing is a very handy feature... I'll expand on it a little OK so, first I'll create a sequence of integers >>> seq = range(10) >>> seq [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] "take element with index 4 and everything after it" >>> seq[4:] [4, 5, 6, 7, 8, 9] "take everything up to, but not including, the element with index 4" >>> seq[:4] [0, 1, 2, 3] "take the element with index 3 and everything up to, but not including, the element with index 6" >>> seq[3:6] [3, 4, 5] then there's the step argument "take every second element from the whole sequence" >>> seq[::2] [0, 2, 4, 6, 8] "take every second element from the element with index 2 up to, but not including, the element with index 8" >>> seq[2:8:2] [2, 4, 6] Hope that helps. -- http://mail.python.org/mailman/listinfo/python-list
Re: boolian logic
marc wyburn wrote: HI all, I'm a bit stuck with how to work out boolian logic. I'd like to say if A is not equal to B, C or D: do something. I've tried if not var == A or B or C: and various permutations but can't seem to get my head around it. I'm pretty sure I need to know what is calulated first i.e the not or the 'OR/AND's thanks, Marc. You mean like a ternary operation? >>> True and 1 or 0 1 >>> False and 1 or 0 0 This of course depends on the 'true' result also being true.. it fails if it is false... if that's not what you mean, then maybe this is what you want if not var==A or not var==B or not var==C: # do something -- http://mail.python.org/mailman/listinfo/python-list
Re: Decimals in python
[EMAIL PROTECTED] wrote: Hello. New to using Python. Python automatically round off watver i calculate using the floor function. How wud i make the exact value appear? Tried out fabs() in the math library but still confused. Cud some1 elaborate on it. If you're working with integers, the result will always be an integer: >>> a = 10/3 >>> print a 3 How ever if you add a float into the mix: >>> a = 10/3.0 >>> print a 3.3335 HTH -- http://mail.python.org/mailman/listinfo/python-list
Re: Hrounding error
[EMAIL PROTECTED] wrote: Hi, I am new to python. I was messing around in the interperator checking out the floating point handling and I believe I may have found a rounding bug: 234 - 23234.2345 -23000.2344 This is not correct by my calculations. I am using python 2.5.2 in ubuntu 8.04. I am wondering if this is a known bug, or if I am just not understanding some feature of python. Thanks for the help! -Cooper Quintin http://www.bitsamurai.net If you need to round before you display the result, I find the following works: >>> '%.4f' % (234 - 23234.2345) '-23000.2345' The %.4f means that the interpolated value will be treated as a float, rounded to 4 digits after the decimal point. -- http://mail.python.org/mailman/listinfo/python-list
Re: how can i check whether a variable is iterable in my code?
satoru wrote: hi, all i want to check if a variable is iterable like a list, how can i implement this? this would be one way, though I'm sure others exist: if hasattr(yourVar, '__iter__'): # do stuff -- http://mail.python.org/mailman/listinfo/python-list
Re: Python arrays and sting formatting options
Ivan Reborin wrote: Hello everyone, I was wondering if anyone here has a moment of time to help me with 2 things that have been bugging me. 1. Multi dimensional arrays - how do you load them in python For example, if I had: --- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 --- with "i" being the row number, "j" the column number, and "k" the .. uhmm, well, the "group" number, how would you load this ? If fortran90 you would just do: do 10 k=1,2 do 20 i=1,3 read(*,*)(a(i,j,k),j=1,3) 20 continue 10 continue How would the python equivalent go ? 2. I've read the help on the next one but I just find it difficult understanding it. I have; a=2.01 b=123456.789 c=1234.0001 How do you print them with the same number of decimals ? (eg. 2.000, 123456.789, 1234.000) and how do you print them with the same number of significant decimals? (eg. 2.01, 123456.7, 1234.000 - always 8 decimals) ? Is something like this possible (built-in) in python ? Really grateful for all the help and time you can spare. -- Ivan I'm not sure if this is applicable to your multi-dimensional list problem... but it sounded a bit sudoku like (with row, columns and groups) so I thought I'd share a bit of code of developed in regards to solving sudoku puzzles... Given a list of 9 list elements, each with nine elements (lets call it sudoku_grid), the following list comprehensions produce lists of indexes into sudoku grid vgroups = [[(x,y) for y in xrange(9)] for x in xrange(9)] hgroups = [[(x,y) for x in xrange(9)] for y in xrange(9)] lgroups = [[(x,y) for x in xrange(a,a+3) for y in xrange(b,b+3)] for a in xrange(0,9,3) for b in xrange(0,9,3)] where sudoku_grid[y][x] yields the value at position (x,y), assuming the top left corner is indexed as (0,0) HTH -- http://mail.python.org/mailman/listinfo/python-list
Re: Functions continuing to ru after returning something?
Bradley Hintze wrote: I may be having a brain fart, but is it at all possible to have a function first return a value then continue its calculation. Like this simple example: my_var = 5 def my_function(): return my_var my_var +=1 This obviously won't work as written but is there a cleaver way around this. def my_function(): my_var = 5 while my_var <= 10: yield my_var my_var += 1 >>> for x in my_function(): ... print x 5 6 7 8 9 10 >>> -- http://mail.python.org/mailman/listinfo/python-list
Re: EOL created by .write or .encode
Ar an naoià là de mà AibrÃan, scrÃobh Xah Lee: > If you open a file in emacs, it will open fine regardless whether the > EOL is ascii 10 or 13. (unix or mac) This is a nice feature. However, > the what-cursor-position which is used to show cursor position and the > char's ascii code, says the EOL is ascii 10 when it is in fact ascii > 13. This _is_ the right thing to do--thereâs no reason naive programs written in Emacs Lisp should have to worry about different on-disk representations of line-endings. If you want to open a file which uses \015 as its line endings, and have those \015 characters appear in the buffer, open it using a coding system ending in -unix. C-u C-x C-f /path/to/file RET iso-8859-1-unix RET in XEmacs, something I donât know but Iâm certain exists in GNU Emacs. -- âI, for instance, am gung-ho about open source because my family is being held hostage in Rob Maldaâs basement. But who fact-checks me, or Enderle, when we say something in public? No-one!â -- Danny OâBrien -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread termination
G'day,As far as my understanding pertains, the thread dies shortly after the function returns (ends). You can call "return" anywhere within the function and kill the thread in the middle of its execution.On 13 Oct 2006 02:38:28 -0700, Teja <[EMAIL PROTECTED]> wrote: Hi all,Does any one know how to terminate or kill a thread that is startedwith "start_new_thread()" in the middle of its execution?Any pointers?Thanks in advanceTeja.-- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Earthquake and Tornado Forecasting Programs June 13, 2006
In article <[EMAIL PROTECTED]>, CBFalconer wrote: > Oh for a newsreader that can eliminate all such ugly excessively > cross-posted articles lacking follow-ups. PLONK thread is the only > remaining answer. > See my reply posted to alt.disasters.misc and sci.geo.earthquakes for an alternative strategy. But yes, cross-posting like that is highly irritating, which makes the actual purpose of the original posting highly suspect. I don't know which of the comp.lang groups you're coming from, but since any of them could probably be used to write cross-post filtering code ... I'll leave the lot in. -- Aidan Karley, FGS Aberdeen, Scotland Written at Wed, 14 Jun 2006 08:14 +0100, but posted later. -- http://mail.python.org/mailman/listinfo/python-list
Re: enable pop3 for gmail from python
He wants to automate the process of enabling POP access to Gmail, not access his Inbox via POP (which he can already do). That much said, a quick looksee at the Google site shows no mention of an automated method of doing this. That is not to say it is impossible, but it may be infeasible to do as one would have to write login code et al just to be authorised to do it - using one of the more advanced HTTP libraries, most likely. Sorry I couldn't solve the problem directly, but maybe my clarification will help someone who can. ;-) On 12/12/06, Gabriel Genellina <[EMAIL PROTECTED]> wrote: At Sunday 10/12/2006 08:36, radu voicilas wrote: >Hi!I am making a script to connect to my gmail box and grep new >mails.I want to know if i can enable pop from python if it is not >enabled from gmail?I have been searching the python list but i >haven't found an answer to thisonly ways of connecting to the >server wich i already know. >Thank you very much! Have you read http://gmail.google.com/support/bin/answer.py?answer=10350 ? Using poplib you can connect to the gmail pop3 server - what's your problem? -- Gabriel Genellina Softlab SRL __ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ¡gratis! ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Tarfile .bz2
As far as I know, tar.gz and tar.bz2 files work in exactly the same way, but use different algorithms. That is to say, all the files are 'tarballed' together, then the resulting very long string is run through the gz bz2 algorithm and out pops the compressed file. (These compression algorithms work on arbitrary strings, not files per se.) Why are you trying to losslessly compress JPG and PNG files? Chances are you won't be able to compress them any more, but if you're trying to free space, take a looksy at "pngcrush". You'll find it on Google - I don't want to put any hyperlinks in this email lest it is marked as spam. Hope I've helped, Aidan. On 11 Dec 2006 17:32:58 -0800, Jordan <[EMAIL PROTECTED]> wrote: So that would explain why a tar.bz2 archive can't be appended to wouldn't it... And also explain why winrar was so slow to open it (not something I mentioned before, but definitely noticed). I had wondered what it was that made bz2 so much better at compression than zip and rar. Not really on topic anymore but what's the method for tar.gz? And even more off the topic, does anyone know a good lossless compression method for images (mainly .jpg and .png)? Cheers, Jordan Wolfgang Draxinger wrote: > Jordan wrote: > > > When using python to create a tar.bz2 archive, and then using > > winrar to open the archive, it can't tell what the compressed > > size of each > > individual file in the archive is. Is this an issue with > > winrar or is there something that needs to be set when making > > the archive that isn't there by default. > > When compressing a tar archive all files in the archive are > compressed as a whole, i.e. you can only specify a compression > ration for the whole archive and not just for a single file. > > Technically a tar.bz2 is actually a aggregation of multiple files > into a single tar file, which is then compressed. > > This is different to e.g. PKZip in which each file is compressed > individually and the compressed files are then merged into an > archive. > > The first method has better compression ratio, since redundancies > among files are compressed, too, whereas the latter is better if > you need random access to the individual files. > > Wolfgang Draxinger > -- > E-Mail address works, Jabber: [EMAIL PROTECTED], ICQ: 134682867 -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Password, trust and user notification
Hi, As you said yourself -- it's all about trust. If this person knows nothing of programming, then (s)he is obviously at the mercy of the programmers, which is why we have warranties in commerical software, reputuations to uphold in the open source arena and malware elsewhere. ;-) Sure, there will always be people that will abuse your trust and we should all do whatever we can to avoid such people, but realistically the only people writing open-source software of any notability will usually be fairly trustworthy people, even if only out of necessity as their reputation is on the line. Failing that, there's no reason one could not pay an independent third-party code auditor to inspect the code. Such auditors will usually guarantee the safety of products they've investigated, but this comes at a cost. Hope this helps. On 11 Dec 2006 20:16:31 -0800, placid <[EMAIL PROTECTED]> wrote: Hi all, I was going to write this script for a friend that notifies him via logging onto his Gmail account and sending him an email to his work email about some events occurring in the execution of the script. If you enter your password into a script as input how can someone trust the programmer that he will not send a email to himself containing his password? Assuming this person does not know anything about programming and this person knows nothing about programming ethics. This is coming from the fact that i need to notify the user in someway that does not require her to constantly watch the execution of the script, for example when a user signs in to Windows Live Messenger pop up. Cheers 1. http://libgmail.sourceforge.net/ This is the library i use to access a Gmail account via Python -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: speed of python vs matlab.
On 13 Dec 2006 16:07:20 -0800, Chao <[EMAIL PROTECTED]> wrote: I've been trying to develop some numerical codes with python, however got disappointed. A very simple test, a = 1.0 for i in range(1000): for j in range(1000): a = a+1 unfortunately, it took 4.5 seconds to finish(my machines is fine. P4 3.0G, 1G RAM, it varies according to machine configuration, but should be in the same level) for matlab, the same operation took 0.1 seconds, I use numpy & scipy, they solve the problem most of the times, but there are cases you can't avoid loops by vectors. I appreciate the elegancy of python so much, but I guess I have to gave it up in these numerical codes.(image processing algorithms), for application dev/scripting, it's still my first choice. A good news is that the same code takes ruby 9.8 seconds. -- http://mail.python.org/mailman/listinfo/python-list Have you considered looking into Psyco? (http://psyco.sourceforge.net/) For all the numeric operations that image processing algorithms entail, such a tool will probably make a tremendous difference in terms of speed of execution for you. Do yourself a favour and check it out. Hope this helps, Aidan Steele. -- http://mail.python.org/mailman/listinfo/python-list
Re: Password, trust and user notification
On 13 Dec 2006 15:45:09 -0800, placid <[EMAIL PROTECTED]> wrote: Gabriel Genellina wrote: > You DON'T need the password for the receiving account just to send him > an email! > And you don't even need that special Gmail library, smtplib should be > fine. Yes you dont need a password to receive email, but to access Gmail and send an email you do. Yes you do need the Gmail library to access Gmail because the script will run on a computer that doesnt have a smtp server. Is there other way's of notifying the user? Cheers -- http://mail.python.org/mailman/listinfo/python-list What Gabriel said was correct. You can use smtplib to connect to Gmail's SMTP server as the library supports SSL/TLS required by Gmail (see here: http://mail.google.com/support/bin/answer.py?answer=13287&topic=1556) You do not need a local SMTP server to use smtplib, just use the values found in that provided URL. Hope this helps, Aidan Steele. -- http://mail.python.org/mailman/listinfo/python-list
Re: Password, trust and user notification
On 12/14/06, Gabriel Genellina <[EMAIL PROTECTED]> wrote: At Wednesday 13/12/2006 20:45, placid wrote: > > You DON'T need the password for the receiving account just to send him > > an email! > > And you don't even need that special Gmail library, smtplib should be > > fine. > >Yes you dont need a password to receive email, but to access Gmail and >send an email you do. Yes you do need the Gmail library to access Gmail >because the script will run on a computer that doesnt have a smtp >server. > >Is there other way's of notifying the user? Use the standard SMTP class to connect to the destination SMTP server. To determine the right server, issue a DNS request for MX records on the destination domain. (You may have to search for any suitable DNS module since none is available in the standard Python distribution). If you are really too lazy and you *know* the destination will *always* be a gmail account and you don't bother if things go wrong tomorrow, these are some current MX records for gmail.com: While what you said is technically correct, I think you misread their original question. They want to send email *from* the Gmail account *to* the work account. I suggested that he use Gmail's SMTP server to send the email. Aidan Steele. -- http://mail.python.org/mailman/listinfo/python-list
Re: Password, trust and user notification
On 12/14/06, Gabriel Genellina <[EMAIL PROTECTED]> wrote: At Wednesday 13/12/2006 21:44, Aidan Steele wrote: >While what you said is technically correct, I think you misread >their original question. They want to send email *from* the Gmail >account *to* the work account. I suggested that he use Gmail's SMTP >server to send the email. They were concerned about putting sensitive information (password) inside the script, in order to connect to Gmail to send the mail notifications. I say that there is no need to use Gmail smtp services: to send mail *to* [EMAIL PROTECTED], you only have to connect to the right SMTP server for anywhere.com. The *from* email address is irrelevant and can even be faked. Of course a spam filter could block such mails, but you have to test it. -- Gabriel Genellina Softlab SRL __ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ¡gratis! ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar Rather than "could block such mails" [sic], I'm fairly certain any respectable server would drop the mail. The prevalence of SPF and other assorted tools combat this, when used for malicious purposes. Sure, it's worth trying, but I doubt it will work. Good luck to them. ;-) Aidan Steele. -- http://mail.python.org/mailman/listinfo/python-list
Re: Password, trust and user notification
On 14 Dec 2006 15:22:35 -0800, placid <[EMAIL PROTECTED]> wrote: Dennis Lee Bieber wrote: > On Thu, 14 Dec 2006 11:44:14 +1100, "Aidan Steele" <[EMAIL PROTECTED]> > declaimed the following in gmane.comp.python.general: > > > While what you said is technically correct, I think you misread their > > original question. They want to send email *from* the Gmail account *to* the > > work account. I suggested that he use Gmail's SMTP server to send the email. > > > The most confusing thing is that is sounds very much like they want > to use the /recipient's/ Gmail account to send email to the > /recipient's/ work email account -- rather than connecting directly to > the recipient's work account mail server. (Of course, it may be that > their own ISP blocks pass-through SMTP -- that's a different matter) -- Ok, everyone now forget that i even asked about connecting to Gmail and sending an email back to the work email, for some reason you guys are not answering my question. Is there any other way (other than email's !) to notify a user of events within a script? Thanks for all the help. Cheers -- http://mail.python.org/mailman/listinfo/python-list Perhaps by using instant messaging, eg: Jabber? (http:// jabberpy.sourceforge.net/) You could create an account for the daemon/script and have it send messages to the client throughout the script's execution. Fewer security concerns in that setup! Aidan Steele. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.5.1 Not Working
Sent from Yahoo Mail on Android On Fri, 13 May, 2016 at 16:59, Aidan Silcock wrote: HelloI have tried to download python 3.5.1 today and it has downloaded but each time I try to open it it says I need to Modify, Repair or Uninstall the program.I have tried repairing it neumerous times and it will say it was successful but then when I go to open it again it comes up with the same message.Can you help?Aidan -- https://mail.python.org/mailman/listinfo/python-list