Re: Phone Tree

2015-09-13 Thread Denis McMahon
ut which question leads to which next question. This way also makes for an interesting talking point about separating data and code, especially given the multiple if statements issue. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Add items from a python list to a javascript array

2015-09-19 Thread Denis McMahon
t;/a/b.htm", "/a/c.htm"] page = "\n" fmt = "var frames=Array({});\n" page += fmt.format(",".join(map(lambda x:'"'+x+'"', files))) page += "\n" print page -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Einstein's Riddle

2015-09-19 Thread Denis McMahon
essage, it's going to nuke Beijing and Moscow . (I really really really hope that this is indeed fiction!) -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Python, convert an integer into an index?

2015-09-23 Thread Denis McMahon
and the intent of the question you meant to ask, you might find that the following code does something interesting: x = 9876543210 y = [] while x > 0: y.append(x % 10) x = int(x / 10) y = list(reversed(y)) print y -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org

Re: Learning Modules, Arguments, Parameters (imma noob)

2015-09-25 Thread Denis McMahon
o convert km to miles def convert_km_mi(km): return convert_float_a_b(km, 0.6214) # now call main to kick it all off main() -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Check if a given value is out of certain range

2015-09-29 Thread Denis McMahon
On Tue, 29 Sep 2015 10:16:04 +0530, Laxmikant Chitare wrote: > Is there any similar elegant way to check if a value is out of certain > range? What about: if not (0 < x < 10): -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Error code 0x80070570

2015-09-30 Thread Denis McMahon
On Wed, 30 Sep 2015 23:06:13 +0530, Rusiri Jayalath wrote: > Error code 0x80070570 appears when installing python 3.5.0 (32-bit) > setup for my windows 8.1 system. Please help me to solve this problem. This seems to be a windows error, not a python issue. Try google. -- Denis M

Re: Question about regular expression

2015-09-30 Thread Denis McMahon
) alice tom (1, 4) peter (2) andrew(3,4) janet( 7,6 ) james ( 7 ) mike ( 9 )" d = {'mike': (9, 0), 'janet': (7, 6), 'james': (7, 0), 'jim': (1, 0), 'andrew': (3, 4), 'alice': (0, 0), 'tom': (1, 4), 'peter': (2,

Re: Question about regular expression

2015-10-01 Thread Denis McMahon
= data_tuple Please don't top post. What happens if there's more whitespace than you allow for preceding a '(' or following a ',', or if there's whitespace following '('? -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about regular expression

2015-10-01 Thread Denis McMahon
(a list because I want to be able to modify it) setting d[word][n] = int(num) for each num element (numpatt.match(thing)) with n depending on whether it was the first or second num following the previous word then: d = {x:tuple(d[x]) for x in d} to convert the lists in the new dic to tuples

Re: Question about regular expression

2015-10-02 Thread Denis McMahon
On Wed, 30 Sep 2015 23:30:47 +, Denis McMahon wrote: > On Wed, 30 Sep 2015 11:34:04 -0700, massi_srb wrote: > >> firstly the description of my problem. I have a string in the following >> form: . > > The way I solved this was to: > > 1) replace all the

Re: Python 3.5.0 (32-bit) Setup error

2015-10-02 Thread Denis McMahon
u have given, I have waved my magic wand. If this didn't work, the information you supplied was insufficient. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: function code snippet that has function calls I have never seen before. How does it work.

2015-10-03 Thread Denis McMahon
unB(x, y): return (x-y) # this line # print(funA(4,funB(2,3), funB(3,2))) # can be written as the following 4 lines: a = funB(2, 3) # 2 - 3 -> -1 b = funB(3, 2) # 3 - 2 -> 1 c = funA(4, a, b) # (4 + -1) * 1 -> 3 print(c) # 3 -- Denis McMahon, denismfmcma...@gmail.com -- https

Re: Finding Blank Columns in CSV

2015-10-05 Thread Denis McMahon
i]: if len(row[i]) == 0: flags[i] = True else: blanks = True if not blanks: break -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Trouble running

2015-10-07 Thread Denis McMahon
wand. It should work now. If it still doesn't work, please provide more details about the problem. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: How to repeat a loop once it is finished

2015-10-15 Thread Denis McMahon
t; before you ask questions about it, then that would be even better. > Knowing what piece of code would also help us to help you. As a starter > here is a small piece of code. > > a = 1 > > Is that adequate? If not, perhaps: b = [c for c in range(20)] d = {e:b for e in

Re: How to repeat a loop once it is finished

2015-10-15 Thread Denis McMahon
stop or end to exit: ") print("you entered: ", x) if x in ["stop","quit","end"]: stop = True print("Finished now") -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: pip problem

2015-10-16 Thread Denis McMahon
e all the permissions needed to write to the directories you're asking it to put files in? Did you run the installation process with those permissions? -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Converting tuple of lists of variable length into dictionary

2015-10-18 Thread Denis McMahon
7;, 'c', 'd', 'e'], 'i': ['g', 'h'], 'h': ['g', 'i'], 'm': ['l', 'n', 'o'], 'l': ['m', 'n', 'o'], 'o': ['l', 'm', 'n'], 'n': ['l', 'm', 'o']} The second variant using, m = deepcopy(l).remove(i) fails thus: {'a': None, 'c': None, 'b': None, 'e': None, 'd': None, 'g': None, 'f': None, 'i': None, 'h': None, 'm': None, 'l': None, 'o': None, 'n': None} I'm not sure I understand why after m = deepcopy(l); m.remove(i); m is a different value to that which it as after m = deepcopy(l).remove(i). -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Converting tuple of lists of variable length into dictionary

2015-10-18 Thread Denis McMahon
On Sun, 18 Oct 2015 20:38:26 +, Denis McMahon wrote: > On Sun, 18 Oct 2015 03:17:18 -0700, Beppe wrote: > >> hi to everybody, I must turn a tuple of lists into a dictionary. > > I went down a different path to Peter, and discovered something > perplexing: I just r

Re: If one IF is satisfied, skip the rest in the nest...

2015-10-21 Thread Denis McMahon
if c2: if c3: # c1 && c2 && c3 # 4 second open else: # c1 && c2 # 3 second open else: # only c1 # 2 second open Each condition only gets evaluated once. -- Denis McMahon, denismfmcma.

Re: If one IF is satisfied, skip the rest in the nest...

2015-10-21 Thread Denis McMahon
On Wed, 21 Oct 2015 20:07:21 +, Grant Edwards wrote: > On 2015-10-21, Denis McMahon wrote: >> On Wed, 21 Oct 2015 10:31:04 -0700, bigred04bd3 wrote: >> >>> So here what I have, I have a 3 IF's within the same level. If one IF >>> is satisfied, I

Re: Regular expressions

2015-11-03 Thread Denis McMahon
er() for i in range(100): x = "test *"[-1] == "*" elapsed = timeit.default_timer() - start_time print "char compare, true", elapsed RESULTS: re, false 2.4701731205 re, true 2.42048001289 compiled re, false 0.875837087631 compiled re, true 0.876382112503 char comp

Re: Getting response by email reply message

2015-11-09 Thread Denis McMahon
er, I > can read the messages from there from time to time. Read more carefully! The earlier poster suggested options that would work if you set up your own server, or already had one. You can poll your gmail server using pop3 as the earlier reply suggested. You may need to configure some op

Re: Extracting and summing student scores from a JSON file using Python 2.7.10

2015-11-09 Thread Denis McMahon
rage of', students, 'scores is', sumscore / students It was trivial to generate: Sum of 50 scores is 3028 Average of 50 scores is 60 -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: new to python, help please !!

2015-11-12 Thread Denis McMahon
e, the execution time varies with the size of the datafiles. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: new to python, help please !!

2015-11-12 Thread Denis McMahon
provide executable tools at the OS level which are more efficient than anything you will write in a scripting language. Lesson 1 of computing. Use the right tool for the job. Writing a new program is not always the right tool. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.or

Re: Question about math.pi is mutable

2015-11-13 Thread Denis McMahon
g about supposed "real names". TPEL has been trolling html, php and javascript newsgroups for years, recently he seems to have discovered python newsgroups. :( -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Plotting timeseries from a csv file using matplotlib

2015-11-13 Thread Denis McMahon
for k in keybits: del row[k] plotdata[key] = row This generates a dictionary (plotdata) keyed by the key tuples where the value for each key is a dictionary of 0:0n : value -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread Denis McMahon
ass_='lister-list'): for link in item.find_all('a'): # write link to file # close file Alternatively, use the with form: with open("blah","wb") as text_file: for item in soup.find_all(class_='lister-list'): for link in item

Re: String format - resolve placeholders names

2015-11-20 Thread Denis McMahon
t; ... > ('', 'who', '', None) > (' likes ', 'what', '', None) Or even: >>> s = "{who} likes {what}" >>> d = {'who': "Adam", 'what': "ants"} >>> keys = [

Re: How To Create A Endles List Of Lists In Python...???

2015-11-20 Thread Denis McMahon
for anything useful, because it will just use all the memory up. So perhaps you need to express your question in a better manner. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Returning a result from 3 items in a list

2015-11-24 Thread Denis McMahon
n that > list and returns Jordan's results i.e. (12) ? You open a web browser and google for "python dictionary" -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Getting math scores (Dictionary inside dictionary)

2015-11-24 Thread Denis McMahon
": 13} > } > > How do you get gengyang's maths scores ? I refer to my previous answer. Open a web browser and google "python dictionary" -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.2 has some deadly infection

2014-06-06 Thread Denis McMahon
On Sat, 07 Jun 2014 01:50:50 +1000, Chris Angelico wrote: > Yes and no. "ASCII" means two things: ASCII means: American Standard Code for Information Interchange aka ASA Standard X3.4-1963 > into the lowest seven bits of a byte, with the high byte left clear. high BIT left c

Re: lists vs. NumPy arrays for sets of dates and strings

2014-06-09 Thread Denis McMahon
>>> x['2014-06-05'] array([0, 1]) >>> x {'2014-06-05': array([0, 1])} >>> x['2014-06-05'][0] 0 >>> x['2014-06-05'][1] 1 -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Writing Multiple files at a times

2014-06-29 Thread Denis McMahon
prettify() ) fp.close n += 1 will give you: scraped/body0.htm scraped/body1.htm scraped/body2.htm for as many urls as you have in your url list. (make sure the target directory exists!) -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Writing Multiple files at a times

2014-06-30 Thread Denis McMahon
0 ) print "hello {:0>5d} world".format( 500 ) print "hello {:0>5d} world".format( 5000 ) print "hello {:0>5d} world".format( 5 ) -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Convert Excel Range into python List

2014-07-01 Thread Denis McMahon
On Tue, 01 Jul 2014 03:51:31 -0700, Jaydeep Patil wrote: > How to convert excel range into python list or tuple? > show me example http://lmgtfy.com/?q=convert+excel+range+into+python+list+or+tuple This is an example of how to google a programming question. Learn from it! -- Denis M

Re: Python While loop Takes too much time.

2014-07-01 Thread Denis McMahon
arch for solutions to his problem. If he can't be bothered to try and solve it himslef, I'm nopt going to write his code for him. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Why is regexp not working?

2014-07-05 Thread Denis McMahon
On Fri, 04 Jul 2014 14:27:12 +0200, Florian Lindner wrote: > self.regexps = [r"it (?P\d+) .* dt complete yes | > write-iteration-checkpoint |", > r"it (?P\d+) read ahead" My first thought is what is the effect of '|' as the last char

Re: Saving

2014-07-07 Thread Denis McMahon
you for your time. Write your code in a file and run them from your command line, instead of entering your programs directly into the interpreter. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Writing Python File at Specific Interval

2014-07-09 Thread Denis McMahon
have a string containing your filename, you might use: fp = open( fn, "w" ) fp.write( data ) fp.close() -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie: unexpected indenting error

2014-07-13 Thread Denis McMahon
statements as follows, does the problem persist? for rdiff in range( 450, 600, 100 ): if rdiff >=500: for i in range( 1, 3 ): print rdiff, i elif rdiff >=410: for i in range( 1, 3 ): print i, ridff -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Best place to find sample data

2014-07-26 Thread Denis McMahon
concerned, and the text that's being loaded. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Captcha identify

2014-08-12 Thread Denis McMahon
to help you defeat captchas? -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Captcha identify

2014-08-12 Thread Denis McMahon
be thankful that he's so dumb. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Python in financial services

2014-08-12 Thread Denis McMahon
On Tue, 12 Aug 2014 00:33:11 -0700, Rustom Mody wrote: > Ive been asked to formulate a python course for financial services folk. I wouldn't worry too much about c or c++ interfacing paradigms. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Python in financial services

2014-08-12 Thread Denis McMahon
On Tue, 12 Aug 2014 10:48:14 -0700, Rustom Mody wrote: > However those folks have thousands of lines of C/C++ which they are > porting to python. That begs the question: Why? Seriously, I'd like to know what benefits they expect to achieve by doing so. -- Denis McMahon,

Re: Suitable Python code to scrape specific details from web pages.

2014-08-13 Thread Denis McMahon
: print cell print "+" else: print "HTTP Status", r.status_code -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Captcha identify

2014-08-14 Thread Denis McMahon
ambot, in fact if anything it may damage it. I agree that there are more reasons not to use captcha these days than there are to use them, however I still don't advocate helping spambot bastards defeat them. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Captcha identify

2014-08-14 Thread Denis McMahon
g such requirements. Yes, we understand that your spambot requires to decode captcha. We were just telling you in fairly polite terms that you should fuck off because we have no wish to help you. We tried polite, it didn't work, now I'm trying robustness and profanity. -- Denis McMa

Re: how to change the time string into number?

2014-08-14 Thread Denis McMahon
s] print num Fill in the rest of the months dictionary yourself, it shouldn't be too hard. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: timedelta problem

2014-08-14 Thread Denis McMahon
rror: 'z' is a bad directive in format '%a, %d %b %Y %H:%M:%S %z' > datetime.datetime(2014, 8, 9, 7, 36, 46, > tzinfo=datetime.timezone(datetime.timedelta(-1, 61200))) And this: AttributeError: 'module' object has no attribute 'timezone' -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: timedelta problem

2014-08-15 Thread Denis McMahon
;, 'EEST', 'FET', 'IDT', 'IOT', 'SYOT'], 210: ['IRST'], 240: ['AMT', 'AZT', 'GET', 'GST', 'MSK', 'MUT', 'RET', 'SAMT', 'SCT', 'VOLT'], 270: ['AFT', 'IRDT'], 300: ['AMST', 'HMT', 'MAWT', 'MVT', 'ORAT', 'PKT', 'TFT', 'TJT', 'TMT', 'UZT'], 330: ['IST', 'SLST'], 345: ['NPT'], 360: ['BIOT', 'BST', 'BTT', 'KGT', 'VOST', 'YEKT'], 390: ['CCT', 'MMT', 'MST'], 420: ['CXT', 'DAVT', 'HOVT', 'ICT', 'KRAT', 'OMST', 'THA', 'WIT'], 480: ['ACT', 'AWST', 'BDT', 'CHOT', 'CIT', 'CST', 'CT', 'HKT', 'MST', 'MYT', 'PST', 'SGT', 'SST', 'ULAT', 'WST'], 525: ['CWST'], 540: ['AWDT', 'EIT', 'IRKT', 'JST', 'KST', 'TLT'], 570: ['ACST', 'CST'], 600: ['AEST', 'CHUT', 'DDUT', 'EST', 'PGT', 'VLAT', 'YAKT'], 630: ['ACDT', 'CST', 'LHST'], 660: ['AEDT', 'KOST', 'LHST', 'MIST', 'NCT', 'PONT', 'SAKT', 'SBT', 'VUT'], 690: ['NFT'], 720: ['FJT', 'GILT', 'MAGT', 'MHT', 'NZST', 'PETT', 'TVT', 'WAKT'], 765: ['CHAST'] 780: ['NZDT', 'PHOT', 'TKT', 'TOT'], 825: ['CHADT'], 840: ['LINT'], } I've patched my 2.7 to set a tz string of "UTC[+-]" from the [+-] %z value. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: timedelta problem

2014-08-15 Thread Denis McMahon
On Fri, 15 Aug 2014 07:39:23 +, Denis McMahon wrote: > I've patched my 2.7 to set a tz string of "UTC[+-]" from the > [+-] %z value. ... but that doesn't do much, because time.struct_time in 2.7 doesn't recognise anything that strptime passes in as

Re: timedelta problem

2014-08-15 Thread Denis McMahon
9 Aug 2014 07:36:46 + 2014-08-09 07:36:46+00:00 2014-08-09 07:36:46+00:00 UTC -7 as UTC: 2014-08-09 14:36:46+00:00 2014-08-09 14:36:46+00:00 UTC +7 as UTC: 2014-08-09 00:36:46+00:00 2014-08-09 00:36:46+00:00 UTC as UTC: 2014-08-09 07:36:46+00:00 2014-08-09 07:36:46+00:00 """ -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: how to change the time string into number?

2014-08-15 Thread Denis McMahon
.6.3]' for Python 3.2. Again, I stress, we need to know what version of python you are using to help you! Did you run the code I posted? Did you get the same output as me? If you didn't, what was different. If you did get the same output, what do you think is wrong with it? -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: timedelta problem

2014-08-15 Thread Denis McMahon
On Fri, 15 Aug 2014 09:23:02 -0600, Ian Kelly wrote: > On Fri, Aug 15, 2014 at 1:39 AM, Denis McMahon > wrote: >> On Fri, 15 Aug 2014 10:24:47 +0800, luofeiyu wrote: >> >> On further inspection, it seems that strptime() in 2.7 doesn't handle >> %z at all. I

Re: get the min date from a list

2014-08-15 Thread Denis McMahon
s in some strings, deleted extra spaces in some strings, deleted extraneous information after the tz offset in some strings. When feeding strings to a parsing function such as strptime () it is critically important that the format specifier matches the input data. -- Denis McMahon, denismfmcma...@gmail

Re: Unicode in cgi-script with apache2

2014-08-16 Thread Denis McMahon
passing through a python error message. Is this the complete error message? What happens when you try and access http://[server]/cgi-data/index.html directly in a web browser? You may need to copy the file to a different directory to do this depending on the apache configuration. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Unicode in cgi-script with apache2

2014-08-16 Thread Denis McMahon
ropriate) before calling the python script. I believe that the following line in your httpd.conf may have the required effect. SetEnv PYTHONIOENCODING utf-8 Of course, if the file is not encoded as utf-8, but rather something else, then use that as the encoding in the above suggestions. If th

Re: How to look up historical time zones by date and location

2014-08-18 Thread Denis McMahon
s always noon, and midnight, and everything else at the poles, I just have to live with that. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: How to look up historical time zones by date and location

2014-08-19 Thread Denis McMahon
al time terms, so does he want West Urumqi time, Central Urumqi time or East Urumqi time? -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Collaps arrays/ list of intergers

2014-08-19 Thread Denis McMahon
I don't consider it particularly elegant. :( -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Distinguishing attribute name from varible name to make codes clear and definite

2014-08-21 Thread Denis McMahon
our code. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Very basic question. How do I start again?

2014-08-21 Thread Denis McMahon
tries = tries + 1 print "it took " + tries + " attempts to guess " + choice This simplification doesn't take the calculation of ranges into account, but that's part of "guess the/another answer". -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Python code to distinguish between data having, 2 different formats, in a given cell(MS Excel).

2014-08-23 Thread Denis McMahon
On Sat, 23 Aug 2014 11:56:29 -0700, Ed Joz wrote: > Please suggest a sample python code. while program result not correct: fix program Note - we are not here to write your code for you, but we will try and help you develop your own code to do what you want. -- Denis McMa

Re: error while writing program to send mail.

2014-09-01 Thread Denis McMahon
the filename to generate the subject eg (assuming suitable imports etc) and the message is in a text file called message.txt: msgfile = "message.txt" fp = open( msgfile, "r" ) msg = MIMEText(fp.read()) fp.close() msg['Subject'] = 'The contents of %s'

Re: Python is going to be hard

2014-09-03 Thread Denis McMahon
ine 7, in > print (steve[x]) > IndexError: list index out of range x is the value, not the index Try: steve = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] for x in steve: print (x) or if you want to use the index: for x in range(len(steve)): print (steve[x]) -- Denis McMaho

Re: Storing instances using jsonpickle

2014-09-03 Thread Denis McMahon
On Thu, 04 Sep 2014 00:39:07 +0100, MRAB wrote: > It would add tuples, delimited by (...), which are not used otherwise > (no expressions): I guess <> and () are both unused as delims by json at present. I like the idea of other key types than string. -- Denis McMahon,

Re: I have tried and errored a reasonable amount of times

2014-09-04 Thread Denis McMahon
On Wed, 03 Sep 2014 07:16:34 +, Steven D'Aprano wrote: > Who uses + for disjunction (∨ OR) and concatenation for conjunction (∧ > AND)? That's crazy notation. The way I was taught it in the mid 1980s, a.b === a and b, a+b === a or b. -- Denis McMahon, denismfmcma...@gma

Re: I have tried and errored a reasonable amount of times

2014-09-04 Thread Denis McMahon
On Thu, 04 Sep 2014 21:42:56 +1000, Chris Angelico wrote: > On Thu, Sep 4, 2014 at 9:17 PM, Denis McMahon > wrote: >> On Wed, 03 Sep 2014 07:16:34 +, Steven D'Aprano wrote: >> >>> Who uses + for disjunction (∨ OR) and concatenation for conjunction (∧

Re: My backwards logic

2014-09-06 Thread Denis McMahon
or of n greater than n/2 is n, and 2 is probably the first value you tested. This can speed things up. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: find the error

2014-09-13 Thread Denis McMahon
You are trying to reference more elements than your list contains. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: face detection

2014-09-22 Thread Denis McMahon
?q=best+face+detection+algorithm+python -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: how to write a html to automatically display the dictionary?

2014-09-23 Thread Denis McMahon
t;> > [code] Although your solution will produce valid html, it doesn't produce the specified output. ;) -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: how to write a html to automatically display the dictionary?

2014-09-23 Thread Denis McMahon
e = ( "\n" + "\n".join(["\n" + "\n".join(["{}".format(z[i]) for z in y]) + "\n" for i in range(len(y[0]))]) + "\n" ) print table -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Storage Cost Calculation

2014-09-29 Thread Denis McMahon
abs or Watford Electronics I expect. I also remember soldering switches to TEAC drives from RS to make them 40 / 80 track switchable. Duncan, your name looks mighty familiar . Do you know a Judith? -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Function passed as an argument returns none

2014-10-01 Thread Denis McMahon
s", nonsense( ( 5, "donuts", ) ) ) The above code shows there is no automatic connection between data output carried out within a function and the value (if any) returned by that function. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Looking for volunteers developing wsgi Webmailer Application!

2014-10-04 Thread Denis McMahon
On Sat, 04 Oct 2014 17:52:18 +0200, Tamer Higazi wrote: > I am planing to develop on longer time a n open source Webmailer written > in Python (not 2.7.x) with: Because the world really needs another webmailer spamengine. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.pyth

Re: Issue in printing top 20 dictionary items by dictionary value

2014-10-04 Thread Denis McMahon
that list. now loop through the second list and print results. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Practice question

2014-10-06 Thread Denis McMahon
he two different expressions give the same result for a suitable range of values of x: for x in range(50): if not (15 <= x < 30) == ((15 <= x) and (x < 30)): print "discrepancy" or for x in range(50): if (15 <= x < 30) == ((15 <= x) and (x < 30

Re: Hi Guys... Reading XML using Jython code

2014-10-09 Thread Denis McMahon
nd look again at how you're specifying which node(s) you want to select. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: what is wrong with this script and how do I get the value in a php script

2014-10-12 Thread Denis McMahon
.HIGH: print True else: print False -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: while loop - multiple condition

2014-10-12 Thread Denis McMahon
ding of combinatorial logic, perhaps http://www.ee.surrey.ac.uk/Projects/Labview/boolalgebra/ index.html#booleantheorems will help. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: How to select every other line from a text file?

2014-10-13 Thread Denis McMahon
to output file 4/ close the input file 5/ close the output file Or in several other ways, and once you have an algorithm, you can start coding it (or implementing it in the programming language of your choice, whichever form of words best pleases your perfesser). -- Denis McMahon, denismfmc

Re: Building lists

2014-10-20 Thread Denis McMahon
be a list of dicts. > > Does that help? It think it would be a dict of dicts: shopping = { "store1" : { "item1": price1, "item2": price2, ... }, "store2" : { "item3": price3, "item4": price4, ... }, ... } -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Building lists

2014-10-20 Thread Denis McMahon
string to a tuple such as ( string, number ): >>> x = [ "fred", "jim", "susan" ] >>> x[x.index("jim")] = ( "jim", 11, ) >>> print x ['fred', ('jim', 11), 'susan'] > Do you have to know the n

Re: Lists and arrays

2013-04-23 Thread Denis McMahon
t with individual members arr2 = [ arr1[0], arr1[3], arr1[5] ] # create a new list by adding slices together arr3 = arr1[:1] + arr1[2:4] + arr1[5:] print arr2 # output is: ['a', 1, 3] print arr3 # output is: ['a', 'c', 1, 3] -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way to count sequences

2013-04-25 Thread Denis McMahon
1 times if you want to check that thing is a 2 int tuple then use something like: for thing in mylist: if isinstance( thing, tuple ) and len( thing ) == 2 and isinstance ( thing[0], ( int, long ) ) and isinstance( thing[1], ( int, long) ): if thing in bits:

Re: repeat program

2013-04-29 Thread Denis McMahon
ange and how you change it is probably your homework task, so I really shouldn't tell you any more than that. Also, I might not be right about where you need to make the change, but hey, this is the internet, it must be right, yeah? -- Denis McMahon, denismfmcma...@gmail.com -- http://m

Re: type classobj not defined?

2007-01-03 Thread Denis Kasak
type(b) == classobj > Traceback (most recent call last): > File "", line 1, in ? > NameError: name 'classobj' is not defined You can compare it against the ClassType object located in the types module. > import types > class b: def __init__(self): ...

Re: sudo open() ? (python newbee question)

2005-06-14 Thread Denis WERNERT
The script could be SUID Root, and you could use os.setuid immediately after having performed the task to switch to a non-priviledged user. May be a big security risk, if someone can alter the script, he gains root access to the system... [EMAIL PROTECTED] wrote: > hello, > > i am writing a pyth

Why does list have no 'get' method?

2008-02-06 Thread Denis Bilenko
Why does list have no 'get' method with exactly the same semantics as dict's get, that is "return an element if there is one, but do NOT raise an exception if there is not.": def get(self, item, default = None): try: return self[item] except IndexError:

Re: Why does list have no 'get' method?

2008-02-07 Thread Denis Bilenko
Tim Golden wrote: > Dodging your question slightly (and at the risk of teaching > my grandmother to suck eggs) I sometimes use this idiom for > checking params. Obviously it only goes so far, but it's > fairly compact: > > import os, sys > if __name__ == '__main__': > ARGS = None, "DEV" > f

Re: Why does list have no 'get' method?

2008-02-07 Thread Denis Bilenko
Steve Holden wrote: > These versions differ with respect to treatment of blank lines, which > indicates how easy it is to go astray in this kind of semantic > optimization. Your example simply wouldn't work (though you could patch > it up using "if line is None". (despite the use of short-circuiti

Re: unable to print Unicode characters in Python 3

2009-01-27 Thread Denis Kasak
ckslash. In Python 3.0 you don't need to do this because all strings are "unicode" to start with. I suspect you will see the same error with 2.6 on Windows once you correct this. (note to Giampaolo: sorry, resending this because I accidentally selected "reply" instead of "reply to all") -- Denis Kasak -- http://mail.python.org/mailman/listinfo/python-list

Re: unable to print Unicode characters in Python 3

2009-01-27 Thread Denis Kasak
On Tue, Jan 27, 2009 at 7:08 PM, Thorsten Kampe wrote: > * Denis Kasak (Tue, 27 Jan 2009 14:22:32 +0100) >> On Tue, Jan 27, 2009 at 1:52 PM, Giampaolo Rodola' >> wrote: >> >>>> print unicode('\u20ac') >> > \u20ac >> >> S

Re: Reading text file with wierd file extension?

2009-02-02 Thread Denis Kasak
On Mon, Feb 2, 2009 at 10:43 PM, Lionel wrote: > >>> ResourcefilePath > 'C:\\C8Example1.slc.rsc' > C:\C8Example1.slc.src The extension you used in the interactive shell differs from the one you used in the class code (i.e. "rsc" vs "src"). -

<    1   2   3   4   5   6   >