Controlling the passing of data

2016-04-28 Thread Sayth Renshaw
Hi This file contains my biggest roadblock with programming and that's the abstract nature of needing to pass data from one thing to the next. In my file here I needed to traverse and modify the XML file I don't want to restore it or put it in a new variable or other format I just want to

Big World, Big Data, Big Mind : Spark | Scala | Python

2016-04-28 Thread Apporva Jain
Become proficient in both Scala and python to implement programming skills on Apache spark and have independent understanding of all three platforms Objectives: Understand the difference between Apache Spark and Hadoop Learn Scala and its programming implementation Implement Spark on a cluster

Re: Dunder docs again (was Pythonic style)

2016-04-28 Thread MRAB
On 2016-04-28 12:45, Rustom Mody wrote: On Thursday, April 28, 2016 at 4:46:43 PM UTC+5:30, MRAB wrote: On 2016-04-28 06:16, Rustom Mody wrote: > On Thursday, April 28, 2016 at 9:26:21 AM UTC+5:30, Chris Angelico wrote: >> My rule of thumb is: Dunders are for defining, not for calling. It's >>

Dunder docs again (was Pythonic style)

2016-04-28 Thread Rustom Mody
On Thursday, April 28, 2016 at 4:46:43 PM UTC+5:30, MRAB wrote: > On 2016-04-28 06:16, Rustom Mody wrote: > > On Thursday, April 28, 2016 at 9:26:21 AM UTC+5:30, Chris Angelico wrote: > >> My rule of thumb is: Dunders are for defining, not for calling. It's > >> not a hard-and-fast rule, but it'll

Re: Pythonic style

2016-04-28 Thread MRAB
On 2016-04-28 06:16, Rustom Mody wrote: On Thursday, April 28, 2016 at 9:26:21 AM UTC+5:30, Chris Angelico wrote: My rule of thumb is: Dunders are for defining, not for calling. It's not a hard-and-fast rule, but it'll get you through 99%+ of situations. Neat and clever. Should get in the

Re: Dictionary is really not easy to handle

2016-04-28 Thread jfong
I was overwhelmed that three gurus inspire me in three different ways in their own flavour:-) That's really appreciated! Now I understand why it's so, thanks to all of you. To Peter: > With that information, can you predict what > for k, v in {(1, 2): "three"}: print(k, v) > will print?

Re: for loop in python

2016-04-28 Thread BartC
On 28/04/2016 10:34, g.v.aar...@skct.edu.in wrote: start_list = [5, 3, 1, 2, 4] square_list = [] # Your code here! for square_list in start_list: x = pow(start_list, 2) square_list.append(x) square_list.sort() print square_list TypeError: unsupported operand type(s) for ** or pow():

[issue22234] urllib.parse.urlparse accepts any falsy value as an url

2016-04-28 Thread Antti Haapala
Antti Haapala added the comment: I do not believe there is code that would depend on `urlparse(urlstring={})` *not* throwing an error, since `{}` obviously is neither a URL, nor a string. Further down the documentation explicitly states that > The URL parsing functions were originally

[issue24114] ctypes.utils uninitialized variable 'paths'

2016-04-28 Thread Kees Bos
Kees Bos added the comment: It's not entirely theoretical to me. I inherited some solaris boxes that cannot be properly maintained anymore and that have a clre program that dumps core. Hence no valid output and running into uninitialized 'paths'. The patch from Xiang Zhang will fix that.

Re: Dictionary is really not easy to handle

2016-04-28 Thread Steven D'Aprano
On Thu, 28 Apr 2016 06:27 pm, jf...@ms4.hinet.net wrote: > I have a dictionary like this: > dct ={1: 'D', 5: 'A', 2: 'B', 3: 'B', 4: 'E'} > > The following code works: > for k in dct: print(k, dct[k]) > ... > 1 D > 2 B > 3 B > 4 E > 5 A When you iterate over the dictionary, you get

Re: for loop in python

2016-04-28 Thread Peter Otten
g.v.aar...@skct.edu.in wrote: > start_list = [5, 3, 1, 2, 4] > square_list = [] > > # Your code here! > for square_list in start_list: You are iterating over start_list, that's OK. But you are assigning the current value to square_list, a variable name that you already use for the list where

[issue24434] ItemsView.__contains__ does not mimic dict_items

2016-04-28 Thread Xiang Zhang
Changes by Xiang Zhang : -- nosy: +xiang.zhang ___ Python tracker ___ ___ Python-bugs-list

[issue26358] mmap.mmap.__iter__ is broken (yields bytes instead of ints)

2016-04-28 Thread Xiang Zhang
Changes by Xiang Zhang : -- nosy: +xiang.zhang ___ Python tracker ___ ___ Python-bugs-list

Re: for loop in python

2016-04-28 Thread Steven D'Aprano
On Thu, 28 Apr 2016 07:34 pm, g.v.aar...@skct.edu.in wrote: > start_list = [5, 3, 1, 2, 4] > square_list = [] Here you set square_list to a list. > # Your code here! > for square_list in start_list: .^ Here you set square_list to each item of the start_list. So the first time

for loop in python

2016-04-28 Thread g . v . aarthi
start_list = [5, 3, 1, 2, 4] square_list = [] # Your code here! for square_list in start_list: x = pow(start_list, 2) square_list.append(x) square_list.sort() print square_list TypeError: unsupported operand type(s) for ** or pow(): 'list' and 'int' Please provide me the solution for

[issue24114] ctypes.utils uninitialized variable 'paths'

2016-04-28 Thread Xiang Zhang
Xiang Zhang added the comment: Simply add one line to make the function theoretically more robust. -- nosy: +xiang.zhang Added file: http://bugs.python.org/file42637/issue24114.patch ___ Python tracker

Re: Dictionary is really not easy to handle

2016-04-28 Thread Peter Otten
jf...@ms4.hinet.net wrote: > I have a dictionary like this: > dct ={1: 'D', 5: 'A', 2: 'B', 3: 'B', 4: 'E'} > > The following code works: > But...this one? > for k,v in dct: print(k,v) > ... > Traceback (most recent call last): > File "", line 1, in > TypeError: 'int' object is

[issue26869] unittest longMessage docs

2016-04-28 Thread Thomas Guettler
Thomas Guettler added the comment: Thank you for understanding my concern. > The standard failure message for each *assert method* contains useful > information about the objects involved. For example the message from > assertEqual shows the repr of the two unequal objects. It is usually

Re: Dictionary is really not easy to handle

2016-04-28 Thread Rustom Mody
On Thursday, April 28, 2016 at 1:57:40 PM UTC+5:30, jf...@ms4.hinet.net wrote: > I have a dictionary like this: > > >>> dct ={1: 'D', 5: 'A', 2: 'B', 3: 'B', 4: 'E'} > > The following code works: > > >>> for k in dct: print(k, dct[k]) > ... > 1 D > 2 B > 3 B > 4 E > 5 A > > and this one too: >

do_POST not working on http.server with python

2016-04-28 Thread Rahul Raghunath
0 down vote favorite I'm trying to create a simple http server with basic GET and POST functionality. The program is supposed to GET requests by printing out a simple webpage that greets a user and askes how he would rather be greeted. When the user enters a greeting of his choice,

Dictionary is really not easy to handle

2016-04-28 Thread jfong
I have a dictionary like this: >>> dct ={1: 'D', 5: 'A', 2: 'B', 3: 'B', 4: 'E'} The following code works: >>> for k in dct: print(k, dct[k]) ... 1 D 2 B 3 B 4 E 5 A and this one too: >>> for k,v in dct.items(): print(k,v) ... 1 D 2 B 3 B 4 E 5 A But...this one? >>> for k,v in dct:

[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-28 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > It seems that the patch also introduces a segfault if PyLong_FromSsize_t() > returns NULL. Good catch Stefan! Py_XDECREF ahould be used instead of Py_DECREF in _PyModule_AddObject(). -- ___ Python tracker

[issue26860] os.walk and os.fwalk yield namedtuple instead of tuple

2016-04-28 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Sorry, but I disagree with Raymond in many points. > Classes are normally named with CamelCase. Also, "walk_result" or > "WalkResult" seems like an odd name that doesn't really fit. DirEntry or > DirInfo is a better match (see the OP's example, "for

[issue26853] missing symbols in curses and readline modules on android

2016-04-28 Thread Xavier de Gaye
Xavier de Gaye added the comment: Thanks Chi Hsuan Yen and Stefan. Indeed the --with-termlib configure option documentation states: "When building the ncurses library, organize this as two parts: the curses library (libncurses) and the low-level terminfo library (libtinfo)". Using

Re: Python Madlibs.py code and error message

2016-04-28 Thread Steven D'Aprano
On Thursday 28 April 2016 17:08, Stephen Hansen wrote: > On Wed, Apr 27, 2016, at 11:55 PM, Ben Finney wrote: >> Stephen Hansen writes: >> >> > On Wed, Apr 27, 2016, at 10:32 PM, Ben Finney wrote: >> > > Better: when you have many semantically-different values, use named >> > >

Re: Python Madlibs.py code and error message

2016-04-28 Thread Ben Finney
Stephen Hansen writes: > On Wed, Apr 27, 2016, at 11:55 PM, Ben Finney wrote: > > Everything I described above works fine in Python 2. > > This response is completely unhelpful. I'll let the OP be the judge of that. > The OP is using Python 2, and using %-formatting, and so you

Re: Python Madlibs.py code and error message

2016-04-28 Thread Stephen Hansen
On Wed, Apr 27, 2016, at 11:55 PM, Ben Finney wrote: > Stephen Hansen writes: > > > On Wed, Apr 27, 2016, at 10:32 PM, Ben Finney wrote: > > > Better: when you have many semantically-different values, use named > > > (not positional) parameters in the format string. […] > > > >

[issue26873] xmlrpclib raises when trying to convert an int to string when unicode is available

2016-04-28 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you. Your server produces a response containing nonstandard type tag "ex:nil" [1]. authorityROLE_USER fromDate userId15 xmlrpclib is unable to handle this tag, and error handling is poor. xmlrpclib can handle only standard types and "nil"

Re: Python Madlibs.py code and error message

2016-04-28 Thread Ben Finney
Stephen Hansen writes: > On Wed, Apr 27, 2016, at 10:32 PM, Ben Finney wrote: > > Better: when you have many semantically-different values, use named > > (not positional) parameters in the format string. […] > > > >

Re: Python Madlibs.py code and error message

2016-04-28 Thread Stephen Hansen
On Wed, Apr 27, 2016, at 10:32 PM, Ben Finney wrote: > Stephen Hansen writes: > > > The error message means there's a mismatch between the number of > > formatting instructions (ie, %s) and arguments passed to formatting. I > > leave it to you to count and find what's

[issue26860] os.walk and os.fwalk yield namedtuple instead of tuple

2016-04-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: Classes are normally named with CamelCase. Also, "walk_result" or "WalkResult" seems like an odd name that doesn't really fit. DirEntry or DirInfo is a better match (see the OP's example, "for dir_entry in walk_it: ...") The "versionchanged" should be a

[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2016-04-28 Thread Martin Panter
Martin Panter added the comment: I am realizing that many people like to use find_library() as a way of converting a portable name like “magic” (from building with -lmagic) into a platform-specific name (libmagic.so.1, libmagic.dylib, magic.dll, etc), and then pass this to LoadLibrary() or

Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-28 Thread Ethan Furman
On 04/27/2016 09:06 PM, Christopher Reimer wrote: On 4/27/2016 8:52 PM, Michael Torrie wrote: In fact if it were me I would save game state to some kind of ini file, which would mean manually going through each object and writing out the relevant data to the ini file using the right syntax.

<    1   2