[Tutor] calling global in funtions.

2014-02-25 Thread Santosh Kumar
All, Requirement : i want to call a variable assigned outside a function scope anytime within the function. I read "global" is a way. a) Case I looks fine. b) Case II is bombing out. Is this how it works or please correct me if i am wrong. case I: In [17]: a = 10 In [19]: def fun_local():

[Tutor] viewkeys,viewvalues,viewitems : Use Cases

2014-02-25 Thread Santosh Kumar
All, I defined a dictionary a below. In [14]: a = {'a':1,'b':2,'c':3} In [15]: type(a) Out[15]: dict Funtion associated with dictionaries. In [11]: print a.viewkeys() dict_keys(['a', 'c', 'b']) In [12]: print a.viewvalues() dict_values([1, 3, 2]) In [13]: print a.viewitems() dict_items([('a'

Re: [Tutor] When to use multiprocessing Managers?

2014-02-25 Thread Steven D'Aprano
On Tue, Feb 25, 2014 at 02:55:31PM -0800, Danny Yoo wrote: > I believe James is referring to: > > http://docs.python.org/2/library/queue.html > > but I am not sure yet. Let's hear back from him to clarify what he's > looking at. I think both the subject line and the description is fairly c

Re: [Tutor] When to use multiprocessing Managers?

2014-02-25 Thread Danny Yoo
I believe James is referring to: http://docs.python.org/2/library/queue.html but I am not sure yet. Let's hear back from him to clarify what he's looking at. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: htt

Re: [Tutor] When to use multiprocessing Managers?

2014-02-25 Thread Steven D'Aprano
On Tue, Feb 25, 2014 at 10:52:19AM +, James Chapman wrote: > Hello tutors > > I'm curious about managers and when to use them. [...] I have absolutely no idea about multiprocessing managers, sorry, but a few seconds googling found these: http://stackoverflow.com/questions/740848/python-good

Re: [Tutor] subprocess.call list vs. str argument

2014-02-25 Thread eryksun
On Tue, Feb 25, 2014 at 4:54 PM, Dave Angel wrote: > CreateProcess has its own design bobbles as well. For example, if > you forget to put quotes around the program name, it will > happily try to add ".exe" to *multiple* places in the hopes that > one of them will work. > > Adding a file c:\prog

Re: [Tutor] subprocess.call list vs. str argument

2014-02-25 Thread Dave Angel
eryksun Wrote in message: > > > FYI, in Windows the situation is different. CreateProcess takes a > string argument, so the setup code changes to the following: > > > It's fine to use a string for args in Windows, and you may need to if > the program parses the command line differently than l

Re: [Tutor] subprocess.call list vs. str argument

2014-02-25 Thread Danny Yoo
See the comment about 'args' in: http://docs.python.org/2/library/subprocess.html#frequently-used-arguments which says: """args is required for all calls and should be a string, or a sequence of program arguments. Providing a sequence of arguments is generally preferred, as it allows the mod

Re: [Tutor] subprocess.call list vs. str argument

2014-02-25 Thread eryksun
On Tue, Feb 25, 2014 at 2:52 PM, Albert-Jan Roskam wrote: > Here is why I used "shell=True" before. Is it related to the > file paths? > > cmd = (r'sphinx-apidoc ' >r'-f -F ' >r'-H "%(title)s" ' >r'-A "%(author)s" ' >r'-V "%(version)s" ' >

Re: [Tutor] subprocess.call list vs. str argument

2014-02-25 Thread Dave Angel
Albert-Jan Roskam Wrote in message: > > > - Original Message - > >> From: Danny Yoo >> To: Peter Otten <__pete...@web.de> >> Cc: Python Tutor Mailing List >> Sent: Monday, February 24, 2014 11:01 PM >> Subject: Re: [Tutor] subprocess.call list vs. str argument >> >> Last comment (ap

Re: [Tutor] subprocess.call list vs. str argument

2014-02-25 Thread Albert-Jan Roskam
- Original Message - > From: Danny Yoo > To: Peter Otten <__pete...@web.de> > Cc: Python Tutor Mailing List > Sent: Monday, February 24, 2014 11:01 PM > Subject: Re: [Tutor] subprocess.call list vs. str argument > > Last comment (apologies for being so fragmented!).  I don't know why

[Tutor] When to use multiprocessing Managers?

2014-02-25 Thread James Chapman
Hello tutors I'm curious about managers and when to use them. For example, I see they offer a Queue() for sharing a Q between processes, but if I create a Q in the parent process and pass it down to child processes, then they can put messages into that Q just fine, and I presume the same thing for

Re: [Tutor] Why does the last loop not work?

2014-02-25 Thread spir
On 02/25/2014 01:59 AM, Gregg Martinson wrote: I am trying to generate a list of teams using objects that I collect into a list that I can cycle through. But when I run the last loop there is nothing produced. Look at your last line of code: x.print_team This is just the _name_ of the m

Re: [Tutor] Why does the last loop not work?

2014-02-25 Thread Alan Gauld
On 25/02/14 00:59, Gregg Martinson wrote: there is nothing produced. I am pretty sure it has to do with my syntax for the list and the substitution of a a local variable Chris has answered your question but there are a couple of general points on your code below... def header (r): prin

Re: [Tutor] Why does the last loop not work?

2014-02-25 Thread Chris “Kwpolska” Warrick
On Tue, Feb 25, 2014 at 1:59 AM, Gregg Martinson wrote: > # problem is that myTeams has no value outside of the loop > for x in myTeams: > x.print_team No, that is not the problem. The problem is, you’re missing parentheses there and are not executing the print_team method, just referring to

[Tutor] Why does the last loop not work?

2014-02-25 Thread Gregg Martinson
I am trying to generate a list of teams using objects that I collect into a list that I can cycle through. But when I run the last loop there is nothing produced. I am pretty sure it has to do with my syntax for the list and the substitution of a a local variable but I can't figure out how to mak