[Tutor] introspection

2015-04-20 Thread Alex Kleider
Does python provide the introspective ability to retrieve the name to which an object is bound? For example: $ python3 Python 3.4.0 (default, Apr 11 2014, 13:05:18) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. a = 69 print("Identifier <{}> is bound

Re: [Tutor] introspection

2015-04-20 Thread Alex Kleider
On 2015-04-20 09:15, Joel Goldstick wrote: On Mon, Apr 20, 2015 at 11:24 AM, Alex Kleider wrote: Does python provide the introspective ability to retrieve the name to which an object is bound? For example: $ python3 Python 3.4.0 (default, Apr 11 2014, 13:05:18) [GCC 4.8.2] on linux Type

Re: [Tutor] bin to dec conversion puzzlement

2015-04-20 Thread Alex Kleider
On 2015-04-20 09:21, Alan Gauld wrote: On 20/04/15 08:44, Jim Mooney wrote: I can't seem to get my head around this 'simple' book example of binary-to-decimal conversion, which goes from left to right: B = '11011101' I = 0 while B: I = I * 2 + int(B[0]) B = B[1:] ... Both methods wo

Re: [Tutor] introspection

2015-04-20 Thread Alex Kleider
On 2015-04-20 13:24, Ben Finney wrote: Alex Kleider writes: Does python provide the introspective ability to retrieve the name to which an object is bound? Objects aren't bound to names. So, no. The binding from a reference (a name is a reference) to objects is one-way. See this exce

Re: [Tutor] introspection

2015-04-21 Thread Alex Kleider
On 2015-04-20 22:21, Danny Yoo wrote: What's supposed to happen in this situation? ## class Person(object): def __init__(self): pass j = Person() john = j jack = j ## What single name should we get back from t

Re: [Tutor] introspection

2015-04-21 Thread Alex Kleider
On 2015-04-21 16:48, Cameron Simpson wrote: But it would not be schizophrenic to write a function that returned a name arbitrarily, by inspecting locals(). It depends whether you only need a name, or if you need "the" name. In my use case there'd probably be only one name for the given object

Re: [Tutor] introspection

2015-04-21 Thread Alex Kleider
On 2015-04-21 16:38, Ben Finney wrote: That hope is understandable. Your "understanding" is appreciated. It is also easy to be confused So true, but with the help of "Python Tutors" things are being rectified! about why such a feature doesn't exist; So why not arbitrary objects?

Re: [Tutor] Pun panic

2015-04-22 Thread Alex Kleider
On 2015-04-22 05:40, Ben Finney wrote: Albert-Jan Roskam writes: - Original Message - > From: Ben Finney > You'll need a working implementation first. Put it on BullCodes > https://bull.codes/> for bonus Python-based free-software > repository hosting points! Is bull.codes better tha

Re: [Tutor] Pun panic

2015-04-22 Thread Alex Kleider
On 2015-04-22 12:22, Ben Finney wrote: Alex Kleider writes: On 2015-04-22 05:40, Ben Finney wrote: > http://mako.cc/writing/hill-free_tools.html> > > Kallithea (which is what powers BullCodes) is free software, meaning > anyone is free to see how it works and change it an

Re: [Tutor] Introductory questions on test-driven development and implementing Git version control.

2015-04-25 Thread Alex Kleider
On 2015-04-25 08:34, boB Stepp wrote: On Sat, Apr 25, 2015 at 3:21 AM, Alan Gauld wrote: Having looked at this thread and its early responses I think it would be good to break it up into its two natural parts. TDD and version control are pretty much separate concepts and should be on separate t

Re: [Tutor] Questions (and initial responses) on using version control: Why cannot I push my single (master) branch to origin without an error occurring?

2015-04-30 Thread Alex Kleider
On 2015-04-30 20:39, boB Stepp wrote: I created my remote repository on, say my C-drive, with "git init". I then copied and pasted a file to that location and put it under version control with "git add filename.py". Next I went to my E-drive, which is where I intend to be my working directories.

Re: [Tutor] key detection

2015-05-05 Thread Alex Kleider
On 2015-05-05 15:36, Alan Gauld wrote: On 05/05/15 22:30, Jim Mooney Py3.4.3winXP wrote: Can python detect a keypress? The following works for my (on my Ubuntu platform) system although probably won't be of much use on a Redmond OS. #!/usr/bin/env python3 # file: 'readchar.py' """ Provides re

Re: [Tutor] introspection

2015-05-07 Thread Alex Kleider
On 2015-04-21 16:48, Cameron Simpson wrote: But it would not be schizophrenic to write a function that returned a name arbitrarily, by inspecting locals(). It depends whether you only need a name, or if you need "the" name. Write yourself a "find_name_from_locals(local_map, value)" function tha

Re: [Tutor] introspection

2015-05-07 Thread Alex Kleider
On 2015-05-07 19:10, Dave Angel wrote: def get_name(localmap, item): """As suggested. Returns 'a' name, not necessarily 'the' name.""" for name in localmap: if localmap[name] == item: This is not likely to be what was intended. You want if localmap[name] is

Re: [Tutor] introspection

2015-05-07 Thread Alex Kleider
On 2015-05-07 20:45, Dave Angel wrote: You also only showed it working on module globals. (For code at top-level, locals() returns the same as globals() ) You could also try it inside functions, where locals() really makes sense as a name. And you could try it in a nested function where there

Re: [Tutor] split a string inside a list

2015-05-09 Thread Alex Kleider
On 2015-05-08 20:24, Kayla Hiltermann wrote: hi, i am trying to make a pythagorean triples checker (a^2 + b^2 = c^2). the user enters three sides to a triangle and my code determines if it is a pythagorean triple (aka right triangle) or not. i have the entire code pretty much done, except i want

Re: [Tutor] Help Learn python - Step by Step

2015-05-09 Thread Alex Kleider
On Sat, May 9, 2015 at 3:23 AM, acolta wrote: Hi guys, I want to start coding in python. My background is Linux/Bash/Perl (begginner). My appreciate if somebody will recommend books/tutorials + exercises to practice. I first cut my Python teeth using http://www.greenteapress.com/thinkpyt

[Tutor] reading lines from a list of files

2015-05-11 Thread Alex Kleider
Is there a better (more 'Pythonic') way to do the following? for f_name in f_names: with open(f_name, 'r') as f: for line in f: As always, thank you, tutors, for all you are doing. AlexK ___ Tutor maillist - Tutor@python.org

Re: [Tutor] reading lines from a list of files

2015-05-12 Thread Alex Kleider
On 2015-05-11 23:48, Peter Otten wrote: Alex Kleider wrote: Is there a better (more 'Pythonic') way to do the following? for f_name in f_names: with open(f_name, 'r') as f: for line in f: There's the fileinput module <https:/

Re: [Tutor] reading lines from a list of files

2015-05-13 Thread Alex Kleider
On 2015-05-11 23:48, Peter Otten wrote: Alex Kleider wrote: Is there a better (more 'Pythonic') way to do the following? for f_name in f_names: with open(f_name, 'r') as f: for line in f: There's the fileinput module <https:/

Re: [Tutor] reading lines from a list of files

2015-05-14 Thread Alex Kleider
On 2015-05-14 00:15, Laura Creighton wrote: In a message of Wed, 13 May 2015 22:27:11 -0700, Alex Kleider writes: As a follow up question: The following seems to work- for f_name in list_of_file_names: for line in open(f_name, 'r'): process(line) but s

Re: [Tutor] reading lines from a list of files

2015-05-14 Thread Alex Kleider
On 2015-05-14 00:01, Alan Gauld wrote: On 14/05/15 06:27, Alex Kleider wrote: The following seems to work- for f_name in list_of_file_names: for line in open(f_name, 'r'): process(line) but should I be worried that the file doesn't get explicitly c

Re: [Tutor] reading lines from a list of files

2015-05-14 Thread Alex Kleider
On 2015-05-13 23:24, Danny Yoo wrote: As a follow up question: The following seems to work- for f_name in list_of_file_names: for line in open(f_name, 'r'): process(line) but should I be worried that the file doesn't get explicitly closed? It depends on context. Pers

Re: [Tutor] string delimiters

2015-06-03 Thread Alex Kleider
On 2015-06-03 12:53, Alan Gauld wrote: ... If this is really about parsing dates and times have you looked at the datetime module and its parsing/formatting functions (ie strptime/strftime)? I asssume strftime gets its name from 'string from time.' What about strptime? How did that get its name

Re: [Tutor] string delimiters

2015-06-03 Thread Alex Kleider
On 2015-06-03 15:13, Mark Lawrence wrote: 'f' for format, 'p' for parse, having originally come from plain old C. More here https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior So I was wrong about the 'f' as well as having no clue about the 'p'! Thank you very much

[Tutor] python 3.4 documentation

2015-06-14 Thread Alex Kleider
I'm using python 3.4 on an ubuntu 14.4 LTS OS and frequently find myself 'off line'. I'd like to download the standard library documentation to have at hand on my hard drive. I tried prompt> wget -r https://docs.python.org/3/library/index.html but links appear to be broken. I'd be grateful for a

Re: [Tutor] python 3.4 documentation

2015-06-14 Thread Alex Kleider
On 2015-06-14 12:36, Hilton Fernandes wrote: Hello, Alex ! I believe that maybe in the page https://docs.python.org/3/download.html Thank you Hilton, Laura and Peter for pointing me in the right direction. Being 'off line' will no longer be such a hardship.

Re: [Tutor] python 3.4 documentation

2015-06-14 Thread Alex Kleider
On 2015-06-14 17:13, Laura Creighton wrote: In a message of Sun, 14 Jun 2015 15:50:38 -0700, Alex Kleider writes: On 2015-06-14 12:36, Hilton Fernandes wrote: Hello, Alex ! I believe that maybe in the page https://docs.python.org/3/download.html Thank you Hilton, Laura and Peter for

Re: [Tutor] python 3.4 documentation

2015-06-15 Thread Alex Kleider
On 2015-06-14 20:49, Steven D'Aprano wrote: The Python interactive interpreter comes with a powerful interactive help system. At the Python prompt, you can enter: help() help("keyword") # e.g. "raise" help(any_object) to get help and documentation. Thank you for this tip. I sort of was

Re: [Tutor] python and Beautiful soup question

2015-06-21 Thread Alex Kleider
On 2015-06-21 15:55, Mark Lawrence wrote: On 21/06/2015 21:04, Joshua Valdez wrote: I'm having trouble making this script work to scrape information from a series of Wikipedia articles. What I'm trying to do is iterate over a series of wiki URLs and pull out the page links on a wiki portal c

Re: [Tutor] Pep 8, about indentation

2015-08-07 Thread Alex Kleider
On Aug 7, 2015 1:18 AM, Cameron Simpson wrote: > > > However, when _editing_ I tell vi that when I press TAB it is to insert > enough > SPACE characters to get to the next 4 column position. How do you do that? I've got vim set up so a CTRL-T while in insert mode does that (and CTRL-D does

Re: [Tutor] Pep 8, about indentation

2015-08-07 Thread Alex Kleider
On 2015-08-07 20:56, Cameron Simpson wrote: On 07Aug2015 12:19, Alex Kleider wrote: On Aug 7, 2015 1:18 AM, Cameron Simpson wrote: However, when _editing_ I tell vi that when I press TAB it is to insert enough SPACE characters to get to the next 4 column position. How do you do that? I&#x

Re: [Tutor] Pep 8, about indentation

2015-08-10 Thread Alex Kleider
On 2015-08-10 08:33, David Rock wrote: You might want to add softtabstop as well. set softtabstop=4 It's very handy for allowing the delete key to go back TAB number of spaces (ie, deletes those 4 spaces you just inserted). I got it working but the key needs to be the 'backspace' key, not t

Re: [Tutor] Help

2015-08-10 Thread Alex Kleider
On 2015-08-10 11:13, Emile van Sebille wrote: On 8/10/2015 10:07 AM, Alan Gauld wrote: PS. What is SDSU? San Diego State University I'd guess. Emile South Dakota State is the other possibility. ___ Tutor maillist - Tutor@python.org To unsubscr

Re: [Tutor] cannot get a label message to display immediately

2015-08-14 Thread Alex Kleider
On 2015-08-14 09:32, Bill Allen wrote: I am working in Tkinter. The scenario is that I click a button that starts a function running. No problem there. However, the function may take some time to run and I do not want the user to be worried. I am wanting to immediately set a label when

Re: [Tutor] Where should unit test files go in a project directory structure and some related questions?

2015-08-16 Thread Alex Kleider
On 2015-08-16 01:28, Alan Gauld wrote: Here is my default structure project - doc project documents: contracts reqs, designs, test specs etc - man(*) user docs - bin(*) the master exe or main.py type files - lib(*) the shipping libraries - src the code -- lang folder per langu

Re: [Tutor] Where should unit test files go in a project directory structure and some related questions?

2015-08-16 Thread Alex Kleider
On 2015-08-16 10:45, Alan Gauld wrote: Thee are several options. 1) create links from, main to the test files needed 2) alter sys.path so imports can see the test folder 3) alter the PYTHONPATH environment var I suspect in this case the easiest solution is a link Thanks Alan. Creating a li

Re: [Tutor] Where should unit test files go in a project directory structure and some related questions?

2015-08-16 Thread Alex Kleider
On 2015-08-16 12:45, Laura Creighton wrote: We have a new mechanism for test discovery in 2.7 and 3.x https://docs.python.org/3/library/unittest.html see 26.3.3 It's been backported. see: https://pypi.python.org/pypi/unittest2 Also, if you are on Python2 and you put your tests in a test subdi

Re: [Tutor] pip install in a virtualenv *without* internet?

2015-08-19 Thread Alex Kleider
On 2015-08-18 19:32, Mike C. Fletcher wrote: To install without going out to the internet, you can use these arguments: pip install --no-index --find-links=/path/to/download/directory For this to work, /path/to/download/directory would, I assume, first have to be populated. I further

Re: [Tutor] pip install in a virtualenv *without* internet?

2015-08-19 Thread Alex Kleider
On 2015-08-19 04:28, Albert-Jan Roskam wrote: Date: Wed, 19 Aug 2015 02:27:41 -0700 From: aklei...@sonic.net To: tutor@python.org Subject: Re: [Tutor] pip install in a virtualenv *without* internet? On 2015-08-18 19:32, Mike C. Fletcher wrote: > To install without going out to the internet, you

Re: [Tutor] Do not understand why test is running.

2015-08-21 Thread Alex Kleider
On 2015-08-20 23:16, Peter Otten wrote: Yea, breaking things is an art form ;) $ python3 -m unittest -h usage: python3 -m unittest [-h] [-v] [-q] [-f] [-c] [-b] [tests [tests ...]] . For test discovery all test modules must be importable from the top level directory of the proje

[Tutor] how to unittest cli input

2015-10-10 Thread Alex Kleider
'] = input("Enter your first name: ") ret['last'] = input("Enter your last name: ") ret['phone'] = input("Your mobile phone #: ") return ret def main(): print(collect_data()) if __name__ == "__main__": main() The foll

Re: [Tutor] how to unittest cli input

2015-10-11 Thread Alex Kleider
On 2015-10-10 18:10, Cameron Simpson wrote: On 10Oct2015 17:41, Alex Kleider wrote: I'm tOn 2015-10-10 18:10, Cameron Simpson wrote: On 10Oct2015 17:41, Alex Kleider wrote: I'm trying to follow a test driven development paradigm (using unittest)

Re: [Tutor] how to unittest cli input

2015-10-12 Thread Alex Kleider
On 2015-10-11 14:52, Cameron Simpson wrote: Minor remark: I would write "if src is not None:". In principle the empty string is also "falsey" like None, making your plain "if src:" slightly unreliable. Be precise! 'precise' is good! Any comments about when/if to use 'if src != None:' vs 'if s

Re: [Tutor] how to unittest cli input

2015-10-13 Thread Alex Kleider
On 2015-10-13 12:11, Danny Yoo wrote: ## def make_ask(f, l, p): d = {'Enter your first name: ' : f, 'Enter your last name: ' : l, 'Your mobile phone #: ' : p} return d.get ## This last line got my attention ("a dict has no

Re: [Tutor] how to unittest cli input

2015-10-14 Thread Alex Kleider
On 2015-10-13 14:44, Alex Kleider wrote: On 2015-10-13 12:11, Danny Yoo wrote: ## def make_ask(f, l, p): d = {'Enter your first name: ' : f, 'Enter your last name: ' : l, 'Your mobile phone #: ' : p} return d.get

Re: [Tutor] how to unittest cli input

2015-10-14 Thread Alex Kleider
On 2015-10-14 11:29, Danny Yoo wrote: ## def make_ask(f, l, p): d = {'Enter your first name: ' : f, 'Enter your last name: ' : l, 'Your mobile phone #: ' : p} return d.get ## This is an example of a 'closure' is it not? Y

Re: [Tutor] how to unittest cli input

2015-10-14 Thread Alex Kleider
On 2015-10-14 12:27, Peter Otten wrote: Alex Kleider wrote: On 2015-10-13 14:44, Alex Kleider wrote: On 2015-10-13 12:11, Danny Yoo wrote: ## def make_ask(f, l, p): d = {'Enter your first name: ' : f, 'Enter your last name: ' : l,

Re: [Tutor] how to unittest cli input

2015-10-15 Thread Alex Kleider
On 2015-10-14 11:29, Danny Yoo wrote: ## def make_ask(f, l, p): d = {'Enter your first name: ' : f, 'Enter your last name: ' : l, 'Your mobile phone #: ' : p} return d.get ## This is an example of a 'closure' is it not? Y

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Alex Kleider
On 2015-10-17 19:49, Steven D'Aprano wrote: which will work from your package's callers, and from within the package itself provided the top level directory can be found within Python's path. Within the package you can also use relative imports, see the docs for more detail. How does one arra

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Alex Kleider
On 2015-10-18 08:07, Alex Kleider wrote: On 2015-10-17 19:49, Steven D'Aprano wrote: which will work from your package's callers, and from within the package itself provided the top level directory can be found within Python's path. Within the package you can also use relati

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Alex Kleider
On 2015-10-18 10:26, Alan Gauld wrote: On 18/10/15 16:33, Alex Kleider wrote: How does one arrange so "the top level directory _can_ be found within Python's path."? Is the answer to include the following at the beginning of each file? if not 'path/to/top/level/p

Re: [Tutor] accessing modules found throughout a package?

2015-10-19 Thread Alex Kleider
On 2015-10-18 18:01, Steven D'Aprano wrote: On Sun, Oct 18, 2015 at 08:07:07AM -0700, Alex Kleider wrote: On 2015-10-17 19:49, Steven D'Aprano wrote: >which will work from your package's callers, and from within the >package >itself provided the top level directory can

Re: [Tutor] Working collaboratively (was: accessing modules found throughout a package?)

2015-10-19 Thread Alex Kleider
On 2015-10-19 12:37, Ben Finney wrote: Alex Kleider writes: I'm a long way from distributing packages! You can keep working at your own pace, and that's good. But even better, I would strongly recommend that you work with other people early and frequently. Programming is funda

Re: [Tutor] Working collaboratively

2015-10-19 Thread Alex Kleider
On 2015-10-19 13:08, Emile van Sebille wrote: This looks like the list of identified issues: https://bitbucket.org/pypa/pypi/issues Browse through and see if anything looks interesting/doable. On 2015-10-19 13:34, Mark Lawrence wrote: How about https://mail.python.org/mailman/listinfo/co

Re: [Tutor] Working collaboratively

2015-10-19 Thread Alex Kleider
On 2015-10-19 15:18, Emile van Sebille wrote: On 10/19/2015 3:04 PM, Alex Kleider wrote: On 2015-10-19 13:08, Emile van Sebille wrote: This looks like the list of identified issues: https://bitbucket.org/pypa/pypi/issues Browse through and see if anything looks interesting/doable. On

Re: [Tutor] Working collaboratively

2015-10-20 Thread Alex Kleider
On 2015-10-20 01:02, Alan Gauld wrote: On 20/10/15 07:33, Alex Kleider wrote: Look closely at what the return value is called in each case. And see how it compares to the names in the signature. OOPS! Should have run over them with diff _before_ posting rather than after. Sorry about that

Re: [Tutor] Create complex dictionary :p:

2015-10-22 Thread Alex Kleider
On 2015-10-22 14:50, Thomas C. Hicks wrote: On 10/23/2015 05:19 AM, jarod_v6--- via Tutor wrote: Hi!!I would like to prepare a dictionary with complex structure: complex = {name ="value",surname="po",age=poi) What is the most pythonic way to build a dictionary of dictionary?thanks for any

Re: [Tutor] Messy - Very Messy string manipulation.

2015-10-28 Thread Alex Kleider
On 2015-10-28 08:09, Vusa Moyo wrote: Hi Guys, I've written a script to remove vowels from a string/sentence. the while loop I'm using below is to take care of duplicate vowels found in a sentence, ie anti_vowel('The cow moos louder than the frog') It works, but obviously its messy and n00b

Re: [Tutor] Messy - Very Messy string manipulation.

2015-10-28 Thread Alex Kleider
On 2015-10-28 09:37, Peter Otten wrote: Vusa Moyo wrote: I've written a script to remove vowels from a string/sentence. the while loop I'm using below is to take care of duplicate vowels found in a sentence, ie anti_vowel('The cow moos louder than the frog') It works, but obviously its mes

[Tutor] interface

2015-12-14 Thread Alex Kleider
So far all my python programming has been done using print for output and (raw)input whenever user input is required. I'd like to learn how to provide a graphical interface. There are several choices with pros and cons to each but an alternative more general approach might be to use a web based

Re: [Tutor] interface

2015-12-14 Thread Alex Kleider
Thank you, gentlemen (Alan, Ben, Mark,) for your advice. The consensus seems to be in favour of tkinter so I'll head in that direction. Cheers, Alex ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.pytho

Re: [Tutor] interface

2015-12-18 Thread Alex Kleider
On 2015-12-16 17:42, boB Stepp wrote: On Mon, Dec 14, 2015 at 10:08 PM, Alex Kleider wrote: Thank you, gentlemen (Alan, Ben, Mark,) for your advice. The consensus seems to be in favour of tkinter so I'll head in that direction. If you are into books, "Programming Python, 4th ed

Re: [Tutor] interface

2015-12-18 Thread Alex Kleider
On 2015-12-18 14:13, Mark Lawrence wrote: On 18/12/2015 18:38, Alex Kleider wrote: Another issue about which I'd like to hear comments has to do with how the imports are done. Roseman indicates that from tkinter import * from tkinter import ttk is the generally accepted way of

Re: [Tutor] interface

2015-12-19 Thread Alex Kleider
On 2015-12-18 17:22, Alan Gauld wrote: FWIW My recent book Python Projects includes coverage of both ttk and Tix as well as core tkinter. But it's only designed to be a taster, it's not a complete reference. It's more about the general approach to putting a UI on an app than about any specific t

Re: [Tutor] interface

2015-12-20 Thread Alex Kleider
On 2015-12-20 06:11, Alan Gauld wrote: On 20/12/15 02:21, Alex Kleider wrote: First I've heard of Tix! A potentially useful set of extra widgets on top of Tkinter. Unfortunately the Tkinter port of the original Tcl/Tk TIX package is incomplete and only reliable for about half the ext

Re: [Tutor] Using python 3 on Ubuntu 14.04

2015-12-23 Thread Alex Kleider
On 2015-12-23 14:58, Jim Byrnes wrote: I am in the process of moving from unbutu 12.04 to 14.04. I was doing some testing and got this: jfb@Jims-1404:~$ cd MyProgs jfb@Jims-1404:~/MyProgs$ cd passwords jfb@Jims-1404:~/MyProgs/passwords$ python3 passwords.py Traceback (most recent call last): F

[Tutor] method, type?

2016-01-05 Thread Alex Kleider
ove them. get_line_item works as I wanted but it's clearly not the usual type of method and I don't know how to categorize it. It's an instance creator- is there a better term? Is this 'Pythonic' code? """ as_always = """Thanks, Alex Kleider

Re: [Tutor] method, type?

2016-01-05 Thread Alex Kleider
Hoping this helps rather than confuses, Cameron Simpson It is no more confusing than what I had already read about static and class methods. I guess I was hoping for an easy explanation but such a thing probably doesn't exist. I'll have to slog through the explanation. Thank you for takin

Re: [Tutor] method, type?

2016-01-07 Thread Alex Kleider
Thank you to all who contributed to this thread. It has helped me immensely and I enjoyed some of the spirited discussion. Some of my notes follow (in case corrections are in order:-) my_notes = """ @staticmethod def s_method(param_but_no_self_or_cls): # An ordinary functi

Re: [Tutor] Organizing files

2016-01-11 Thread Alex Kleider
On 2016-01-11 04:51, Rene Werner wrote: Hello list, right now I am working on a couple of programming-related challenges. The challenges are sorted into problem sets, where each set contains a number of problems. Because a lot of these problems rely on code that is often the same, I have p

Re: [Tutor] s.insert(i, x) explanation in docs for Python 3.4 confusing to me

2016-01-16 Thread Alex Kleider
On 2016-01-16 16:08, Alan Gauld wrote: On 16/01/16 23:56, Alan Gauld wrote: On 16/01/16 22:39, boB Stepp wrote: So in this model of understanding negative list indexing, should it be: mylist = [ 100, 200, 300, 400, 500 ] ^^^^^ ^ -5 -4 -3 -2 -1 ?

Re: [Tutor] s.insert(i, x) explanation in docs for Python 3.4 confusing to me

2016-01-16 Thread Alex Kleider
On 2016-01-16 18:02, Cameron Simpson wrote: On 16Jan2016 18:43, boB Stepp wrote: This led me to try: mylist[:None] [100, 200, 300, 400, 500] So, in effect, None is acting as a place holder for that final position in slices. Also, I would never have thought to be able to use a logical "or"

Re: [Tutor] s.insert(i, x) explanation in docs for Python 3.4 confusing to me

2016-01-17 Thread Alex Kleider
On 2016-01-17 02:18, Cameron Simpson wrote: On 16Jan2016 22:42, Alex Kleider wrote: On 2016-01-16 18:02, Cameron Simpson wrote: much like writing a function "def f(x, y=None)"; None is a sentinel value - specially recognised as nor in the normal domain for that value. Can

Re: [Tutor] s.insert(i, x) explanation in docs for Python 3.4 confusing to me

2016-01-17 Thread Alex Kleider
me to use it to advantage as you describe. Another "Ah, Ha!" experience. Alex On 2016-01-17 13:48, Cameron Simpson wrote: On 17Jan2016 10:49, Alex Kleider wrote: Can you please clarify the last bit: "specially recognised as nor in the normal domain for that value." s/nor/no

[Tutor] mock

2016-01-22 Thread Alex Kleider
Some weeks (perhaps months) ago, I posted a question about testing and got many responses but had trouble grasping the concepts so I settled on the suggestion that I thought would be the easiest to implement (using unittest.mock.) Here it is- """ from Peter Otten: I find Ben's example instructive

Re: [Tutor] Enumerate vs DictReader object manipulation:

2016-02-03 Thread Alex Kleider
On 2016-02-03 13:24, Ben Finney wrote: You have discovered the difference between an iterable (an object you can iterate over with ‘for’), versus a sequence (an object whose items remain in place and can be iterated many times). Every sequence is an iterable, but not vice versa. File objects

Re: [Tutor] Enumerate vs DictReader object manipulation:

2016-02-04 Thread Alex Kleider
On 2016-02-04 01:46, Oscar Benjamin wrote: You can see an explanation of the different collection terminology here: https://docs.python.org/2/library/collections.html#collections-abstract-base-classes A dict is a Mapping and a set is a Set. Both also comes under the categories Sized, Iterable

Re: [Tutor] Recommendations for best tool to write/run Python

2016-03-02 Thread Alex Kleider
I've not noticed anyone mention vimtutor which might be helpful. On a Mac or Linux system, from the command line simply type "vimtutor" and with in 1/2 to 1 hour you'll know enough to use vim _and_ be in a position to decide if it's the editor for you. I've been told vim can also be had on the

[Tutor] Object-Oriented Analysis by Peter Coad & Edward Yourdon

2016-03-23 Thread Alex Kleider
The above cited book was mentioned in a recent thread (by Alan I think.) I acquired the book but it isn't at all what I expected and I've no use for it. If he or anyone else would like it, I'm happy to send it along. Just let me know an address[1] to which to send it. Cheers, Alex [1] I'm happy

Re: [Tutor] Detect the folder of a file

2016-04-26 Thread Alex Kleider
On 2016-04-26 16:16, Oliver Bestwalter wrote: sys.executable '/home/obestwalter/.pyenv/versions/3.4.4/envs/tmp/bin/python3.4' Not sure if this helps but perhaps: alex@X301:~/Py$ which python /usr/bin/python alex@X301:~/Py$ . venv/bin/activate (venv)alex@X301:~/Py$ which python /home/alex/P

Re: [Tutor] "List" object is not callable

2016-04-30 Thread Alex Kleider
On 2016-04-30 11:51, Jason N. via Tutor wrote: Hello, I found this simple script online but when I execute it I get the following error: "TypeError: 'list' object is not callable" Here is the code sample:import subprocess ls_output= subprocess.check_output(['dir']) It works on my system: Ubun

Re: [Tutor] Study Tips

2016-05-30 Thread Alex Kleider
On 2016-05-30 12:02, boB Stepp wrote: ... Are you totally new to programming in *any* language? If yes, you have much more to learn than *just* a programming language. I am going to assume that you are very new to programming in general. Forgive me if I am mistaken! But if you are, then some

Re: [Tutor] OT: Recommendations for a Linux distribution to dual-boot with Win7-64 bit

2016-06-28 Thread Alex Kleider
On 2016-06-27 20:48, Steven D'Aprano wrote: Also Debian. Not Ubuntu. Can you elaborate why you specifically exclude Ubuntu? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/list

Re: [Tutor] OT: Recommendations for a Linux distribution to dual-boot with Win7-64 bit

2016-06-28 Thread Alex Kleider
On 2016-06-28 11:46, David Rock wrote: Here’s my take on a lot of this (it’s similar to what’s been said already, so this is more of a general philosophy of distros). Very interesting reading for which I thank you. I'd be interested in knowing if you'd make a distinction between 'the latest

[Tutor] project directory structure

2016-08-25 Thread Alex Kleider
I'm still struggling with what is the best way to set up a project directory. All the sources I've read seem to agree that one should have a top level project directory under which one might expect to find the following: COPYING.txt # or LICENSE.txt README.rst setup.py and if the pr

Re: [Tutor] project directory structure

2016-08-25 Thread Alex Kleider
On 2016-08-25 21:27, Ben Finney wrote: That's exactly the wrong thing to do. Your shebang line should *not* assume a custom location of the Python interpreter. It's the responsibility of the operating system or virtualenv to provide the Python interpreter command in a standard place. Instead

Re: [Tutor] project directory structure

2016-08-27 Thread Alex Kleider
On 2016-08-26 21:58, Ben Finney wrote: Alex Kleider writes: Am I to assume that if I have activated a virtualenv, then the following shebang #!/usr/bin/env python will use the python specified in the venv/bin/? Yes, the purpose of that shebang is to tell the OS that *whichever* ‘python

Re: [Tutor] project directory structure

2016-08-28 Thread Alex Kleider
On 2016-08-27 15:23, c...@zip.com.au wrote: On 27Aug2016 09:06, Alex Kleider wrote: On 2016-08-26 21:58, Ben Finney wrote: Alex Kleider writes: Am I to assume that if I have activated a virtualenv, then the following shebang #!/usr/bin/env python will use the python specified in the venv

Re: [Tutor] Error: 'IndexedVar' object is not callable

2016-09-09 Thread Alex Kleider
On 2016-09-09 11:50, Pooja Bhalode wrote: Hi everyone, I was getting this error which read ' 'IndexedVar' object is not callable ' for a variable type. You haven't provided much information but it seems to me you are calling IndexedVar as though it were a function but it probably isn't a f

Re: [Tutor] Error: 'IndexedVar' object is not callable

2016-09-09 Thread Alex Kleider
On 2016-09-09 18:13, Steven D'Aprano wrote: Please read this article first for how you can improve the chances of getting good answers to your questions: http://sscce.org/ In addition to the link Seven provides above, I've also found the following to be worth perusing: http://www.catb.org/es

Re: [Tutor] Python help

2016-10-16 Thread Alex Kleider
On 2016-10-15 15:48, Nicholas Hopkins wrote: Hello Please tell me what is wrong with my code and how I can put an if else statement inside of another if else statement This is my code: path = input('Which path number will you take?') if path == '1': print('You took the first path')

[Tutor] run local script on a remote machine

2016-10-26 Thread Alex Kleider
I've got three files as follows: 1: #!/usr/bin/env python3 # # file: experiment.py # # A simple python program that takes parameters. import sys info = sys.argv[1:] print(info) with open("/home/alex/junk.txt", 'w') as file_object: for item in info: file_object.write(''.join((item,'\

Re: [Tutor] run local script on a remote machine

2016-10-27 Thread Alex Kleider
On 2016-10-27 00:57, Wolfgang Maier wrote: The structure of the command you are trying to execute would require you to set the "shell" argument of subprocess.call to True. Specifically, the "<" redirection operator is shell functionality. Thank you Wolfgang. Simply eliminating the call to shl

Re: [Tutor] run local script on a remote machine

2016-10-27 Thread Alex Kleider
On 2016-10-27 00:22, Cameron Simpson wrote: On 26Oct2016 10:44, Alex Kleider wrote: command = ( "ssh -p22 alex@10.10.10.10 python3 -u - one two three < {}" .format(script)) ret = subprocess.call(shlex.split(command)) This is not fine. .. http://bobby-tables.com/

Re: [Tutor] how to move an executable into path

2016-11-27 Thread Alex Kleider
On 2016-11-27 16:26, Steven D'Aprano wrote: snip.. I fully admit some snark about Firefox. snip.. I've been using Firefox on Ubuntu for years and haven't recognized any difficulties although I don't use it for much other than email, searching, and occasionally shopping. I would be intere

Re: [Tutor] help :making window

2016-12-31 Thread Alex Kleider
On 2016-12-31 09:35, Joel Goldstick wrote: Semicolon (;) isn't used in python as a statement separator alex@X301n3:/mnt$ python3 Python 3.4.3 (default, Nov 17 2016, 01:11:57) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information. gee = "really"; print(gee)

Re: [Tutor] Basic Tutorial for Python

2017-02-06 Thread Alex Kleider
On 2017-02-06 08:13, Hüseyin Ertuğrul wrote: Hello all, I am a system engineer and I want to learn python language. I don't know any program language and I need tutorial for beginner or for dummies. By the way I want to see basic example codes for practice. What is your suggestion for that case.

Re: [Tutor] Error when trying to use classes

2017-02-07 Thread Alex Kleider
On 2017-02-07 07:34, Rafael Skovron wrote: I'm trying to learn how to use Classes but I keep getting NameErrors no matter what code I put into the script. Any ideas why? Assuming the code you've edited using vim is in a file mymodule.py And after invoking the interpreter you issue the follow

Re: [Tutor] Test for type(object) == ???

2017-02-10 Thread Alex Kleider
On 2017-02-10 17:34, boB Stepp wrote: I was playing around with type() tonight. . I've also "played around" with this subject- Here's a source: http://stackoverflow.com/questions/152580/whats-the-canonical-way-to-check-for-type-in-python ... and a successful experiment: alex@X301n3:~$

  1   2   3   >