Re: What could cause a plot fail in my code?

2015-12-22 Thread Denis McMahon
managed to reach line 6194 without going through that block. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: return from function

2015-12-22 Thread Denis McMahon
rse back into a function you still need to return the result of the recursion. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-20 Thread Denis McMahon
dent on this course, perhaps they are setting exercises for which they have not previously provided the necessary tuition. If that is the case, I suggest you ask them to reimburse your course fees, and then go and find better tutors. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Hangman Code.

2015-12-17 Thread Denis McMahon
ble value to prompt for the next player. After each player takes a turn, add 1 to the current player. If this is greater than the number of players, set it back to 1. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: How does one distribute Tkinter or Qt GUI apps Developed in Python

2015-12-16 Thread Denis Akhiyarov
On Wednesday, December 16, 2015 at 6:45:50 PM UTC-6, Rick Johnson wrote: > On Wednesday, December 16, 2015 at 6:03:55 PM UTC-6, Bruce Whealton wrote: > > > Surely, one is going to want to create GUI apps for users > > that are not Python Developers. I would not think to ask > > someone to install

Re: Why my image is in bad quality ?

2015-12-16 Thread Denis McMahon
20,height*20), Image.ANTIALIAS) This appears to attempt to extrapolate 400 pixels from each pixel in the original image. That only works on TV crime dramas, you can't do it in real life. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

[issue25841] In FancyURLopener error in example with http address.

2015-12-11 Thread Denis Savenko
New submission from Denis Savenko: In documentation from this page https://docs.python.org/3.5/library/urllib.request.html#examples in examples uses default address to python site with http. ( http://python.org/ ). But now python.org use https. When i try use example in ipython i get I/0

Re: Python variable assigning problems...

2015-12-10 Thread Denis McMahon
e to post a short self contained example of the problem here instead. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a way to set several list elements a same value with one line code

2015-12-03 Thread Denis McMahon
original > tutorial > now). Do you remember there is such a list application? bb = [ for i in range()] will create bb as a list of size whatever elements each of which is eg: >>> bb = [ ['a'] for i in range(4)] >>> bb [['a'], ['a'], ['a'], ['a']] >>> bb = [ 0

Re: filter a list of strings

2015-12-03 Thread Denis McMahon
thing in badthings: if thing in item: return False return True -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: stuff and nonsense

2015-12-02 Thread Denis McMahon
ternet search engines because of the way newsgroups get gated to websites. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: stuff and nonsense

2015-12-02 Thread Denis McMahon
On Thu, 03 Dec 2015 01:46:44 +0100, Laura Creighton wrote: > In a message of Wed, 02 Dec 2015 22:51:13 +0000, Denis McMahon writes: >>On Wed, 02 Dec 2015 11:32:25 -0600, Ian Kelly wrote: >> >>> In what way is discussion of a tangential topic feeding the troll? &g

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-12-01 Thread Denis McMahon
On Tue, 01 Dec 2015 16:18:49 -0500, Terry Reedy wrote: > On 12/1/2015 3:32 PM, Denis McMahon wrote: >> On Tue, 01 Dec 2015 03:32:31 +, MRAB wrote: >> >>> In the case of: >>> >>> tup[1] += [6, 7] >>> >>> what it's t

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-12-01 Thread Denis McMahon
On Tue, 01 Dec 2015 14:44:38 -0600, Ian Kelly wrote: > On Tue, Dec 1, 2015 at 2:32 PM, Denis McMahon <denismfmcma...@gmail.com> > wrote: >> On Tue, 01 Dec 2015 03:32:31 +, MRAB wrote: >> >>> In the case of: >>> >>> tup[1] += [6, 7] &g

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-12-01 Thread Denis McMahon
ot; or "license" for more information. >>> tup = [1,2,3],[4,5,6] >>> tup ([1, 2, 3], [4, 5, 6]) >>> tup[1] [4, 5, 6] >>> tup[1] += [7,8,9] Traceback (most recent call last): File "", line 1, in TypeError: 'tuple' object does not support item assi

Re: New JSON encoding method proposal for custom objects

2015-11-29 Thread Denis McMahon
condly there's no mechanism in json that tells you what class of object you have. So you may have a __json_dumps__ that will dump your object out to a json string representation, but then how does json.loads recognise that it's loading your object to call your object's __json_loads__? --

Re: I can't understand re.sub

2015-11-29 Thread Denis McMahon
rn 'hammer' if match == 'cat': return 'dog' if match == 'tree': return 'fence' return match with open("input.txt","r") as inf, open("output.txt","w") as ouf: line = inf.readline() line = patt.sub(replfunc, line) ouf.write(line) (also not tested) -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Help with this program???

2015-11-27 Thread Denis McMahon
name (first and last), student number, and mark out of 100 for each student; 4. Uses regular expressions or similar mechanisms to ensure the data appears valid. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: reading from a txt file

2015-11-26 Thread Denis McMahon
ine a string? Is it just a line with the spaces removed? >>> "".join("this is a teststring my friends".split(" ")) 'thisisateststringmyfriends' -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Screen scraper to get all 'a title' elements

2015-11-26 Thread Denis McMahon
n you can do this for thing in stuff: print thing (Python 2.7) This may be adaptable to your requirement. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: read 4D binary data

2015-11-26 Thread Denis McMahon
(given by lat and lon) at that time. -- 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
t > 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
sh": 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: How To Create A Endles List Of Lists In Python...???

2015-11-20 Thread Denis McMahon
ion 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: String format - resolve placeholders names

2015-11-20 Thread Denis McMahon
ne) > (' likes ', 'what', '', None) Or even: >>> s = "{who} likes {what}" >>> d = {'who': "Adam", 'what': "ants"} >>> keys = [x[1] for x in string.Formatter().parse(s)] >>> keys ['who', 'what'] then ... for key in keys: i

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

2015-11-18 Thread Denis McMahon
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.find_all('a'): # write link to file -- Denis McMahon, d

Re: Question about math.pi is mutable

2015-11-13 Thread Denis McMahon
d "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
s: 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: new to python, help please !!

2015-11-12 Thread Denis McMahon
cution 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: Getting response by email reply message

2015-11-09 Thread Denis McMahon
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 options in y

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

2015-11-09 Thread Denis McMahon
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: Regular expressions

2015-11-03 Thread Denis McMahon
31 compiled re, true 0.876382112503 char compare, false 0.26283121109 char compare, true 0.263465881348 The compiled re is about 3 times as fast as the uncompiled re. The character comparison is about 3 times as fast as the compiled re. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

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

2015-10-21 Thread Denis McMahon
f 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...@gm

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 <denismfmcma...@gmail.com> 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 >>&

Re: Converting tuple of lists of variable length into dictionary

2015-10-18 Thread Denis McMahon
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

[issue6331] Add unicode script info to the unicode database

2015-10-17 Thread Denis Jacquerye
Changes by Denis Jacquerye <moy...@gmail.com>: -- nosy: +Denis Jacquerye ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6331> ___

[issue22612] Add block info to unicodedata

2015-10-17 Thread Denis Jacquerye
Changes by Denis Jacquerye <moy...@gmail.com>: -- nosy: +Denis Jacquerye ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22612> ___

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: 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: 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: Trouble running

2015-10-07 Thread Denis McMahon
gic 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: Finding Blank Columns in CSV

2015-10-05 Thread Denis McMahon
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: function code snippet that has function calls I have never seen before. How does it work.

2015-10-03 Thread Denis McMahon
, 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://ma

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

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: Question about regular expression

2015-10-01 Thread Denis McMahon
',', 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
= 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 -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.or

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, 0), 'fred': (0, 0)} -- Denis McMahon, denismfmcma...@gmail.com -- https:/

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: 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: Python, convert an integer into an index?

2015-09-23 Thread Denis McMahon
he 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/mail

Re: Einstein's Riddle

2015-09-20 Thread Denis McMahon
ing 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: Add items from a python list to a javascript array

2015-09-19 Thread Denis McMahon
", "/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: How to use the returned telnet object after creating the telnet session.

2015-09-13 Thread Denis McMahon
> > Now in the calling function If I use that object to read or write to > terminal I'm getting ERROR "AttributeError: 'NoneType' object has no > attribute 'read_very_eager'". My best guess would be that something failed and has returned None instead of the object / class you'r

Re: Phone Tree

2015-09-13 Thread Denis McMahon
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: convert element in a list to float

2015-09-13 Thread Denis McMahon
comprehension. >>> def tofloat(x): ... try: ... return float(x) ... except ValueError: ... return None ... >>> l = [ '300', '"N"', '1140', '"E"' ] >>> l = [ tofloat(x) or x for x in l ] >>> l [300.0, '"N"', 1140.0, '"E"'] -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Random MAC generator error

2015-09-12 Thread Denis McMahon
da:a4 00:16:3e:57:be:d2 00:16:3e:6b:e5:ae 00:16:3e:54:0e:f0 00:16:3e:57:5e:50 00:16:3e:21:99:6b 00:16:3e:12:e6:05 00:16:3e:53:02:6d 00:16:3e:79:17:1b 00:16:3e:02:ff:b8 00:16:3e:4e:ff:0d Observation: No point in declaring mac1 as global in the global scope. Is it possible that you've tried to run p

Re: Context-aware return

2015-09-10 Thread Denis McMahon
func() Would you expect the last two calls to func() to return 999 or "Awesome"? Why? What is the material difference if any between interpreter (a) displaying the return value and (b) comparing the return value with another value. Debugging nightmare! -- Denis McMahon, denismfm

Re: Hi am new to python

2015-09-09 Thread Denis McMahon
: s = sum(list_a) print (s) And if you only want to display the answer: print (sum(list_a)) -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Lesson 39 of Learning Python the Hard Way hangs

2015-09-09 Thread Denis McMahon
On Wed, 09 Sep 2015 20:45:57 +, John Gordon wrote: > In any case, I saved your code and ran it, and did not get an error. +1 I think "Execution Succesful!" might be coming from his IDE? -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: python

2015-09-07 Thread Denis McMahon
On Sun, 06 Sep 2015 16:09:42 -0700, babi pepek wrote: > I wand update update There, now you have update. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Can anyone help me run python scripts with http.server?

2015-09-06 Thread Denis McMahon
On Sun, 06 Sep 2015 23:23:14 +1000, Chris Angelico wrote: > WSGIScriptAlias / /path/to/scripts/MinstrelHall/mh.wsgi One wonders if the OP has mod_wsgi installed. https://code.google.com/p/modwsgi/wiki/WhereToGetHelp might be useful too. -- Denis McMahon, denismfmcma...@gmail.com -- ht

Re: How to compare lists

2015-09-01 Thread Denis McMahon
ect, you could come back here and post your code with a description of what you think it should do, what it actually does, and why you think that's wrong, and we'll try and help you fix. What we won't do is write your application from scratch. -- Denis McMahon, denismfmcma...@gmail.com -- ht

Re: Can I download XML data from the web and save, in as CSV or TXT delimitation?

2015-08-19 Thread Denis McMahon
are receiving and how the xml nodes and their attributes and values should be mapped into the csv file you want to create. Unfortunately I don't think that there is a single standard mechanism for doing that bit, although there are some tools and libraries that can help. -- Denis McMahon, denismfmcma

Re: How to model government organization hierarchies so that the list can expand and compress

2015-08-15 Thread Denis McMahon
' ] }, } The multiple parenting means that you need to use something as references. You can't represent the hierarchy as a simple tree, because in a simple tree a node only has one parent. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: AttributeError

2015-08-13 Thread Denis McMahon
position, as well as additional indenting to take account of that addition. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: AttributeError

2015-08-13 Thread Denis McMahon
in each line in the file, and that the hours record always at position Y in the timestamp. You have to replace X and Y in that line with numbers that represent the positions in the lists returned by the relevant split commands of the actual text elements that you want to extract. -- Denis

Re: AttributeError

2015-08-12 Thread Denis McMahon
at position Y in the timestamp. c = [0 for i in range(24)] f = open(filename,'r') for l in f: h = int(l.strip().split()[X].split(':')[Y]) c[h] = c[h] + 1 f.close() for i in range(24): print '{:02d} {}'.format(i, c[i]) -- Denis McMahon, denismfmcma...@gmail.com -- https

Re: AttributeError

2015-08-12 Thread Denis McMahon
On Wed, 12 Aug 2015 09:29:50 -0700, Ltc Hotspot wrote: Using the attached file of a diagram as a frame, why is there an attribute message? Perhaps you should read the message. It's very clear. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python

Re: AttributeError

2015-08-12 Thread Denis McMahon
to floor-scrubbing 101. [1] You have repeatedly ignored advice and instructions that you have been given. This is de-facto proof that you are not capable of learning to program computers. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: AttributeError

2015-08-12 Thread Denis McMahon
), incrementing counts[x] where x is the hour field of the timestamp. Then I'd create a list of tuples: ncounts = [(k,v) for k,v in counts.items()] sort it by the hour field: ncounts.sort(key = lambda x: x[0]) and print it: for x in ncounts: print x[0], x1 -- Denis McMahon, denismfmcma

Re: AttributeError

2015-08-12 Thread Denis McMahon
trying to sort ncount? Do you want results ordered by count? First, change your dictionary into a list of tuples: ncount = [(a,c) for a,c in count.items()] Then sort ncount on the second field of the tuple: ncount.sort(key = lambda x: x[1], reverse=True) print ncount -- Denis McMahon

ANN: Lea 2.1.2

2015-08-04 Thread Pierre Denis
can make your fun less uncertain, Pierre Denis -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/

Re: Logical Query JSON

2015-07-31 Thread Denis McMahon
= json.dumps( { $and:[ { $gt: {age: 5} }, { $not: {name: curly} } ] } ) query '{$and: [{$gt: {age: 5}}, {$not: {name: curly}}]}' -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Logical Query JSON

2015-07-30 Thread Denis McMahon
to see what comes out. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Find Minimum for element in multiple dimensional array

2015-07-23 Thread Denis McMahon
b,38 $ -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: unexpected output while using list(and nested dictionary)

2015-07-22 Thread Denis McMahon
and the main code to work together, but as the existing problem is that they don't seem to work together to create the data structure you expect them to create, that's not going to be a bad thing. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python

flipping string order

2015-07-19 Thread Denis McMahon
On Sun, 19 Jul 2015 17:35:03 +0100, MRAB wrote: rsplit - one line. def lastWordFirst(s): return .join(reversed(s.rsplit( , 1))) -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Need assistance

2015-07-18 Thread Denis McMahon
On Sat, 18 Jul 2015 12:35:10 +0200, Sibylle Koczian wrote: Am 18.07.2015 um 02:40 schrieb Denis McMahon: Having a list of words, get a copy of the list in reverse order. See the reversed function (and maybe the list function). That won't really help, because the desired order

Re: Need assistance

2015-07-17 Thread Denis McMahon
the elements of a list into a string, see the join method of strings. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: normalizing a value

2015-07-01 Thread Denis McMahon
-50 .. 50 if x -50: x = -50.0 ix x = 50: x = 50.0 # step 2, scale x to the range 0 .. 12 x = x * 0.12 + 6.0 If you want an integer value, you need to determine which method is most relevant. I would suggest rounding. -- Denis McMahon, denismfmcma...@gmail.com -- https

Re: how to fix TypeError: format requires a mapping

2015-07-01 Thread Denis McMahon
the structure to json. import json thing = {} msg = {} cols = [] for row in data: col = {} col['x'] = row['timestamp'] col['y'] = row['counter_volume'] cols.append(col) msg['columns'] = cols thing['message'] = msg print thing print json.dumps(thing) -- Denis McMahon

Re: enumerate XML tags (keys that will become headers) along with text (values) and write to CSV in one row (as opposed to stacked values with one header)

2015-06-29 Thread Denis McMahon
On Sun, 28 Jun 2015 17:07:00 -0700, Ned Batchelder wrote: On Sunday, June 28, 2015 at 5:02:19 PM UTC-4, Denis McMahon wrote: things thingstring 3/thing thingstring 2/thing thingstring 1/thing /things Each thing is just a member of the collection things, the xml does not contain

Re: enumerate XML tags (keys that will become headers) along with text (values) and write to CSV in one row (as opposed to stacked values with one header)

2015-06-28 Thread Denis McMahon
On Sun, 28 Jun 2015 09:46:36 +0200, Stefan Behnel wrote: Denis McMahon schrieb am 26.06.2015 um 09:44: xml data is an unordered list, and are trying to assign an order to it. If the xml data was ordered, either each tag would be different, or each tag would have an attribute specifying

Re: enumerate XML tags (keys that will become headers) along with text (values) and write to CSV in one row (as opposed to stacked values with one header)

2015-06-26 Thread Denis McMahon
. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

[issue24504] os.listdir() error if the last folder starts not with the capital letter

2015-06-24 Thread Denis Gordeev
New submission from Denis Gordeev: My code is: mypath = 'Z:\Pr Files\norma' file_list = [ f for f in listdir(mypath) if isfile(join(mypath,f))] Error: Traceback (most recent call last): File C:\Documents and Settings\Administrator\Desktop\uni\click zhenilo workshop\noise.py, line 13

Re: JSON Object to CSV File Troubleshooting

2015-06-23 Thread Denis McMahon
like this I expect a few 10s of $ per hour. There may be a generic method to do what you want involving parsing the xml to a nested dictionary / list data object, and then flattening that object, but I don't see that generating you one line of CSV for each Int32 in MonthDayCount. -- Denis

Re: JSON Object to CSV file

2015-06-21 Thread Denis McMahon
On Sun, 21 Jun 2015 06:57:01 -0700, sahluwalia wrote: On Sunday, 21 June 2015 02:47:31 UTC-4, Denis McMahon wrote: On Wed, 17 Jun 2015 08:00:11 -0700, Saran A wrote: I would like to have this JSON object written out to a CSV file so that the keys are header fields (for each

Re: JSON Object to CSV File Troubleshooting

2015-06-21 Thread Denis McMahon
turn out in a day or so, it's hardly rocket science as long as you have a clear description of what is required. If you don't have a clear description of what is required, you have to keep asking questions until you get one. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org

Re: JSON Object to CSV File Troubleshooting

2015-06-21 Thread Denis McMahon
that they face. I do agree with you Denis that this is an unconventional approach. I was wondering then that perhaps I should add additional functionality at the XML to JSON step? So far, with JSON objects without nested lists (as values) I have been successful with this (the following is rather lengthy

Re: JSON Object to CSV File Troubleshooting

2015-06-21 Thread Denis McMahon
describe it. At least, it seems that every time you do try and describe it either the data format or the task description changes. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: JSON Object to CSV file

2015-06-21 Thread Denis McMahon
seems to have the same key used for two elements at the same level, are you sure this is legal json? -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: JSON Object to CSV File Troubleshooting

2015-06-21 Thread Denis McMahon
, there is little added value in using some arbitrary intermediate format unless you're actually going to use the data in the intermediate format for something other than converting to the final format. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python

Re: How to inverse a particle emitter

2015-06-07 Thread Denis McMahon
environment, then the best place to look is probably forums dedicated to that simulation environment. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: What is considered an advanced topic in Python?

2015-06-01 Thread Denis McMahon
the advanced topic in my system. I don't consider using library x to do y as advanced python, it's just gluing together existing functions with your own basic programming, no matter whether the library is for hardware IO, interfacing to a database etc. -- Denis McMahon, denismfmcma...@gmail.com

Re: Where is 'palindrome' defined?

2015-06-01 Thread Denis McMahon
'something' is not defined means that you might have spelled something differently on the line in the error message to the word you meant, so next time you see this error message you know to carefully check the spellings of function names and variables. -- Denis McMahon, denismfmcma

Re: What use for reversed()?

2015-05-31 Thread Denis McMahon
2014, 19:10:20) [GCC 4.6.3] on linux2 Type help, copyright, credits or license for more information. .join(list(reversed(fred))) 'derf' .join([x for x in reversed(fred)]) 'derf' So reversed can do it, but needs a little help -- Denis McMahon, denismfmcma...@gmail.com -- https

<    1   2   3   4   5   6   7   >