Re: [Tutor] lists, name semantics

2015-04-18 Thread Cameron Simpson
"hello"] _replaces_ the reference in "a" with a reference to a new, different, list. Sometimes you want a "deep" copy, where "b" would have got a copy of the iriginal x-y list. See the "copy" module's "deepcopy" function, which supplies thi

Re: [Tutor] lists, name semantics

2015-04-18 Thread Cameron Simpson
On 18Apr2015 23:26, boB Stepp wrote: On Sat, Apr 18, 2015 at 11:08 PM, Cameron Simpson wrote: Sometimes you want a "deep" copy, where "b" would have got a copy of the iriginal x-y list. See the "copy" module's "deepcopy" function, which

Re: [Tutor] lists, name semantics

2015-04-18 Thread Cameron Simpson
On 19Apr2015 15:09, Cameron Simpson wrote: On 18Apr2015 23:26, boB Stepp wrote: On Sat, Apr 18, 2015 at 11:08 PM, Cameron Simpson wrote: Sometimes you want a "deep" copy, where "b" would have got a copy of the iriginal x-y list. See the "copy" module's

Re: [Tutor] introspection

2015-04-21 Thread Cameron Simpson
ocal_map, value)" function that reports. That will (a) get you a partial answer and (b) cement in your mind what is possible and why. Easy and useful! Cheers, Cameron Simpson Technique will get you through times of no strength a lot better than strength will get you through times of no

Re: [Tutor] calling a method directly

2015-04-21 Thread Cameron Simpson
d, you nearly always use the instance technique. Indeed. Not least because (a) you don't always know or even care what class an object is and (b) objects themselves can have callable attributes. Cheers, Cameron Simpson Applications Programming is for dullards who can't do Syst

Re: [Tutor] Is it possible to "backport" the datetime module of Python 3.3 to Python 3.2?

2015-04-21 Thread Cameron Simpson
etime module is probably backward compatible - it has presents features but does not depend on 3.3 aspects of the language, and therefore may well run on 3.2. Cheers, Cameron Simpson The most annoying thing about being without my files after our disc crash was discovering once again how widespread

Re: [Tutor] Please disable “digest mode” before participating

2015-04-26 Thread Cameron Simpson
h may have merely made it look like it worked well. Cheers, Cameron Simpson I swear to god, officer, I'm fixing this bridge. Just go divert traffic. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://ma

Re: [Tutor] Please disable “digest mode” before participating

2015-04-26 Thread Cameron Simpson
il programs. It doesn't cut it for multipoint quote1-reply1 quote2-reply2 messages, but it is a great jumping off point for people new to the method. _If_ the OP has abandoned digest mode, Jim's pointer is very useful. Before then I agree that it is far less so, but that is because di

Re: [Tutor] Function works one time then subsequently fails

2015-04-28 Thread Cameron Simpson
break [...] At a first glance numbers is a global. It is reset to [] at program start, but never again. So you're appending to it forever. I have not investigated further as to how that affects your program's flow. Cheers, Cameron Simpson There are two ways of dealing with thi

Re: [Tutor] Function works one time then subsequently fails

2015-04-28 Thread Cameron Simpson
On 28Apr2015 22:27, Jim Mooney Py3winXP wrote: On 28 April 2015 at 21:27, Cameron Simpson wrote: At a first glance numbers is a global. It is reset to [] at program start, but never again. So you're appending to it forever. I have not investigated further as to how that affects your prog

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-29 Thread Cameron Simpson
ing git in the main areas (/usr, /usr/local, whatever), you may be free to install it in your own home directory. It is just an executable... Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription opti

Re: [Tutor] Fwd: Function works one time then subsequently fails

2015-04-29 Thread Cameron Simpson
On 29Apr2015 08:34, Jim Mooney Py3.4.3winXP wrote: On 28 April 2015 at 22:40, Cameron Simpson wrote: We can pick over your code as well if you like. Should we? Sure, but let me include the full working program after fixup. Although I still have to write another program to feed it random

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-29 Thread Cameron Simpson
On 29Apr2015 22:10, boB Stepp wrote: On Wed, Apr 29, 2015 at 9:40 PM, Cameron Simpson wrote: On 29Apr2015 12:12, boB Stepp wrote: ... (3) install git if needed ... It seems Git is needed, but I am not allowed to install it on the Solaris workstation. So is there a way around this? What

Re: [Tutor] Python property()

2015-05-16 Thread Cameron Simpson
blished till later in the year so not much help to you just now. Personally I wouldn't worry about them until you think you've found a real use for them. There are plenty other things to be doing first! I'm in agreement here. Become comfortable with methods and using them. Until t

Re: [Tutor] ls *.py[co] >> .hidden

2015-05-21 Thread Cameron Simpson
On 21May2015 17:52, Laura Creighton wrote: If you keep appending the results of ls to your .hidden file it will grow to enormous size. [...] sort -u .hidden >newhidden #or whatever you want to call it mv newhidden .hidden Or: sort -u -o .hidden .hidden Cheers, Cameron Simpson [...] p

Re: [Tutor] Is there a way to use "with" across suite boundaries?

2015-05-24 Thread Cameron Simpson
th open("blah", "w") as blahfp: print("header", file=blahfp) print_details(blahfp, ...) print("footer", file=blahfp) def print_details(fp, blah_info): ... loop using blah_info to write data to "fp" Cheers, Cameron Simpson __

Re: [Tutor] Yielding from a with block

2015-05-27 Thread Cameron Simpson
invalid/incorrect final result. So while technically the risk you describe exists, in practice it will almost never occur unless the larger program outcome also results in failure of some kind. Cheers, Cameron Simpson I object to doing things that computers can do. - Olin Shivers ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to close a Tkinter window from a different thread?

2015-05-27 Thread Cameron Simpson
xistence of a running process based on this stored pid, what is the likelihood that the pid will be reassigned to something other than one of my program's windows left open? As discussed above. Possible but unlikely. And if you are the creator of the original process you can control the situa

Re: [Tutor] Generate Prime Numbers

2015-05-29 Thread Cameron Simpson
converting it back to a number. That's crazy! Indeed! Numbers throughout if at all possible. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] unittest with random population data

2015-05-30 Thread Cameron Simpson
it specific tests up the top, and then the random consistency test down the bottom as "test30random_set_equivalence". Cheers, Cameron Simpson MS-Word is Not a document exchange format - Jeff Goldberg http://www.goldmark.org/netrants/no-word/attach.html _

Re: [Tutor] unittest with random population data

2015-06-03 Thread Cameron Simpson
[ I've taken this discussion back to the tutor list. - Cameron ] On 01Jun2015 18:14, Sydney Shall wrote: On 31/05/2015 03:00, Cameron Simpson wrote: You say that your results are "all rather close, consistent with the sigma value I have chosen for the spread of my population

Re: [Tutor] string delimiters

2015-06-03 Thread Cameron Simpson
ed functions, hence the prefix. See "man 3 strptime" and "man 3 strftime". Cheers, Cameron Simpson A program in conformance will not tend to stay in conformance, because even if it doesn't change, the standard will. - Norman Diamond ___

Re: [Tutor] string delimiters

2015-06-03 Thread Cameron Simpson
27;) while pos >= 0: print("pos =", pos) pos = s.find(']', pos + 1) Obviously you could recast that as a generator funciton yielding positions for general purpose use. Cheers, Cameron Simpson Serious error. All shortcuts have disappeared. Scree

Re: [Tutor] line iteration in a file

2015-06-03 Thread Cameron Simpson
ut what is going wrong. If what you display above is accurate then t and q are set for every line read. Another remark, what is the use of your "else: pass" code? Normally one would put some action here, such as raising an exception for the unhandled value or issuing a warning. Chee

tutor@python.org

2015-06-11 Thread Cameron Simpson
before completing your application. Ah, the S-word :-) Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] method conflict?

2015-07-02 Thread Cameron Simpson
en the same method every time, and thus the same id. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] String Problem

2015-07-06 Thread Cameron Simpson
tart here: http://www.crummy.com/software/BeautifulSoup/bs4/doc/ You can install bs4 using pip, or in other ways: http://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-beautiful-soup Cheers, Cameron Simpson 30 years ago, I made some outrageous promises about AI. I didn't

Re: [Tutor] Socket Module

2015-07-12 Thread Cameron Simpson
what I am doing wrong. The top500domains.csv list is attached. Plenty of mailing list software strips attachments. In future, unless the file is large, just append the contents below your message (with some explaination). Cheers, Cameron Simpson Life is uncertain. Eat dessert first. -

Re: [Tutor] _ vs. _name vs. __name vs. name_ vs. __name__ usages

2015-07-27 Thread Cameron Simpson
, but I cannot (yet) bring it to mind. (4) is never required, but is often convenient. And for (5), surely I should never violate this one? It seems that in some future edition of Python they might add any particular __name__ that I might try to use presently in their future version of Python (howeve

Re: [Tutor] Mailbox

2015-07-29 Thread Cameron Simpson
lways be 1. Also, what is the purpose of this line: line = line.split() Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] String Attribute

2015-08-01 Thread Cameron Simpson
On 31Jul2015 17:21, Ltc Hotspot wrote: Mark: Is this any better, message sent from GMail? Regards, Hal Looks better to me. Cheers, Cameron Simpson On Fri, Jul 31, 2015 at 5:02 PM, Mark Lawrence wrote: On 31/07/2015 19:57, ltc.hots...@gmail.com wrote: I believe that this is the third

Re: [Tutor] scratching my head

2015-08-02 Thread Cameron Simpson
and "filenames" instead of "file" and "files": in python 2 "file" is a builtin function (though long deprecated by "open()") and in any case I'd (personally) expect such a name to be an _open_ file. As opposed to "filename", which is

Re: [Tutor] scratching my head

2015-08-02 Thread Cameron Simpson
On 02Aug2015 16:15, Clayton Kirkwood wrote: Behalf Of Cameron Simpson Sent: Sunday, August 02, 2015 3:35 PM [...] Personally I'd be reaching for os.path.splitext. Untested example below: from os.path import splitext for dir_path, directories, files in os.walk(main_dir):

Re: [Tutor] scratching my head

2015-08-03 Thread Cameron Simpson
ibrary, pointing him directly at fnmatch (which I'd entirely forgotten) is the "give a man a fish" approach to help; a magic black box to do the job for him. Besides, I'm not sure fnmatch is much better for his task than the more direct methods be

Re: [Tutor] scratching my head - still

2015-08-04 Thread Cameron Simpson
test here ...: all_filenames.remove(filename) print(all_filenames) You could use a list instead of a set and for small numbers of files be fine. With large numbers of files a set is far faster to remove things from. Cheers, Cameron Simpson In the desert, you can remember your name, 'cause there ain'

Re: [Tutor] Fraction Class HELP ME PLEASE!

2015-08-06 Thread Cameron Simpson
: fail_count += 1 ... more checks ... print(fail_count, "failures") and so forth. This also gets you test code so that you can test your own program for correctness before submitting your assignment. Feel free to return to this list with updated code and new questions. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Fraction Class HELP ME PLEASE!

2015-08-06 Thread Cameron Simpson
eq__(F1, F2)) print("Is F1 different than F2?:", Fraction.__ne__(F1, F2)) print ("Is F1 same as F2?:", Fraction.__is__(F1, F2)) Here you want to avoid this. Firstly, Python has an "is" operator, and it does not have a dunder method. Secondly, in what way does your __is__ differe from __eq__? print("Is:", Fraction.__iadd__(F1, F2)) if __name__ == '__main__': main() Otherwise this is all looking promising. Does it run correctly for you? Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Fraction Class HELP ME PLEASE!

2015-08-07 Thread Cameron Simpson
ld about it. By putting docstrings on your Fraction class and also on each of its methods you make that information available via help() later. Otherwise, good luck. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Pep 8, about indentation

2015-08-07 Thread Cameron Simpson
bedded TAB characters into my text, because they are subject to arbitrary interpreation by others. Cheers, Cameron Simpson I had a *bad* day. I had to subvert my principles and kowtow to an idiot. Television makes these daily sacrifices possible. It deadens the inner core of my being

Re: [Tutor] Pep 8, about indentation

2015-08-07 Thread Cameron Simpson
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've got vim set up so a CTRL-T while in i

[Tutor] [off-topic] vi/vim editor settings (was: Pep 8, about indentation)

2015-08-08 Thread Cameron Simpson
On 07Aug2015 21:50, Alex Kleider wrote: On 2015-08-07 20:56, Cameron Simpson wrote: autoindent: start the next line's text on the same indent as this one expandtab: write spaces instead of a TAB character shiftwidth: how far the < and > shift-text operations move tabstop: the multi

Re: [Tutor] Help

2015-08-10 Thread Cameron Simpson
.py" containing: print("Hello world!") and run it: python foo.py Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help

2015-08-10 Thread Cameron Simpson
On 10Aug2015 18:07, ALAN GAULD wrote: PS. What is SDSU? Google told me San Diego State University. Cheers, Cameron Simpson To be positive: To be mistaken at the top of one's voice. Ambrose Bierce (1842-1914), U.S. author. The Devil's Dictionary

Re: [Tutor] Help

2015-08-10 Thread Cameron Simpson
as a domain name, while San Diego State University actually uses sdsu. Maybe the race _is_ always to the swift. Cheers, Cameron Simpson Airplanes are interesting toys but of no military value. --Marechal Ferdinand Foch, Professor of Strategy, Ecole Superieure de G

Re: [Tutor] a few question about my evolving program

2015-08-11 Thread Cameron Simpson
#x27;218.JPG', 'honda accident 001.jpg', 'honda accident 002.jpg', 'honda accident 003.jpg', 'honda accident 004.jpg', 'honda accident 005.jpg', 'honda accident 006.jpg', 'honda accident 007.jpg',

Re: [Tutor] a few question about my evolving program

2015-08-12 Thread Cameron Simpson
est example rather than an anecdote. We want to be sure that what we're inspecting is what you're inspecting. The other thing we often want is the original problem (which you've described); often people come with their specific solution to a larger problem. Which is fine as long

Re: [Tutor] Python help

2015-08-13 Thread Cameron Simpson
on must be made every time the loop commences. It is not telling you to use Pythons "if" statement. So just putting the correct condition at the top of the "while" loop is what you want. Cheers, Cameron Simpson If you lie to th

Re: [Tutor] Searching through files for values

2015-08-13 Thread Cameron Simpson
y I would have just called it "filename", the singular of your "filenames". Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] SQLite, Python and SQL injection attacks

2015-08-14 Thread Cameron Simpson
). And if the value cannot be transcribed the API should raise an exception. IN this way you know that the structure of the query has been preserved correctly. _And_ you do not need to worry about quoting values (or otherwise transcribing them) correctly; that is a solved and debugged problem.

Re: [Tutor] try and file existence

2015-08-14 Thread Cameron Simpson
d with empty preferences, not an error prefs = {} This bit of code catches _only_ FileNotFoundError on the (presumed) policy that a missing preferences file is ok - your program will proceed with default behaviours - but any _other_ kind of exception is not expected - let your program abor

Re: [Tutor] try and file existence

2015-08-15 Thread Cameron Simpson
ing you can to achieve an effect: stat is smaller than open. Cheers, Cameron Simpson Q: How many user support people does it take to change a light bulb? A: We have an exact copy of the light bulb here and it seems to be working fine. Can you tell me what kind of s

Re: [Tutor] variable naming conventions

2015-08-15 Thread Cameron Simpson
it aligns with your own habits. Ideally, anyway. If you're not invested in another style, and not working in someone else's codebase with its own conventions, try PEP 8. Cheers, Cameron Simpson Oh, what tangled webs we weave, when first we practice to deceive. And when

Re: [Tutor] Using lambda

2015-08-24 Thread Cameron Simpson
inner lambda: >>> g(12) 14 So yes, you can do it. But as you can see it doesn't make for very readable code. Lambdas are ok for small expressions. When things get more complex it is worth breaking them up. Cheers, Cameron Simpson _

Re: [Tutor] Query regarding loop problem

2015-08-29 Thread Cameron Simpson
a number: ") else: print ("MyNumber is ", str(myNumber),": Computer number is: ", str(computerNumber)) print ("We have a match.") Looks like you assign the new number to "prompt" instead of to "myNumber". Chee

Re: [Tutor] How to parse a mailing list thread?

2015-09-19 Thread Cameron Simpson
it easily available. If you need to parse email addresses import the "getaddresses" function from the "email.utils" module. Constuct a graph connecting messages with the replies. You're done! Cheers, Cameron Simpson ___ Tut

Re: [Tutor] Exception Handling

2015-10-02 Thread Cameron Simpson
augument Alan's code like this: except (socket.herror, socket.gaierror) as e: newFile.write("No resolution available for %s: %s" % (name, e) + "\n") Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Mutable data type in python

2015-10-02 Thread Cameron Simpson
;seen", then visit any children which are not in "seen". You pass "seen" to the traverse() of each child, so all the function calls share the same "seen" object. So in this case we're using a set. There's any number of different things you might use

Re: [Tutor] how to unittest cli input

2015-10-10 Thread Cameron Simpson
tc ... sys.stdout = ostdout sys.stdin = ostdin Note that this is not thread safe because sys.stdin is a global, but it should work for testing. Anyway, perhap that gives you some way forward. Cheers, Cameron Simpson ___ Tutor maillis

Re: [Tutor] how to unittest cli input

2015-10-11 Thread Cameron Simpson
On 11Oct2015 09:29, Alex Kleider wrote: On 2015-10-10 18:10, Cameron Simpson wrote: However, you'r eusing input(), which unconditionally uses stdin and stdout. In that circumstance I'd consider this: [... temporarily replace stdin and stdout with test data ...] Yes indeed, and

Re: [Tutor] Guidance on using custom exceptions please

2015-10-12 Thread Cameron Simpson
y defines a socket.timeout error that will be raised on a timeout. Just re-use that. That seems reasonable, if he's using the recv timeout facility. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Beautiful Soup

2015-10-12 Thread Cameron Simpson
ading at UP', item.select('.up2')[0].text) Everywhere you have [0] you may get an IndexError if the select returns an empty list, because there will be no element 0. elif item.select('.down2') == item.select('.down2'): I'm c

Re: [Tutor] Guidance on using custom exceptions please

2015-10-13 Thread Cameron Simpson
re descriptive names for local use. If course, if these exceptions are widely used in many contexts (many other code pieces) then you might want to stick with the original names for consistency. Cheers, Cameron Simpson Go not to the elves for counsel, for they will say both no and yes. - Fro

Re: [Tutor] Create complex dictionary

2015-10-22 Thread Cameron Simpson
alue", 'surname': "po", 'age': poi} records['key1'] = complex complex = {'name': "value2", 'surname': "xy", 'age': poi2} records['key2'] = complex Nothing wrong with that if it fi

Re: [Tutor] noob python question

2015-10-25 Thread Cameron Simpson
rect. So please post the code, and the complete error message your computer gives you. Also not that getattr takes a string, per the error message. So to fetch the .foo attribute from some object "o" you would write: attribute = getattr(o, 'foo') Note the qu

Re: [Tutor] How do I (idiomatically) determine when I'm looking at the last entry in a list?

2015-10-28 Thread Cameron Simpson
items: fp.write(sep) fp.write(... column definition for item ...) sep = ',\n ' fp.write('\n);\n') i.e. instead of printing the separator _after_ each item, print it _before_. That way you can special case the first occasion and use a comma for each successive occasion

Re: [Tutor] Unable to retreive the stock code

2015-11-16 Thread Cameron Simpson
l contain a reference to the stock code; since your regexp matches the stock code then stock_code_match.group(0) will return the actual matched text, the stock code. Fix that stuff and see where you are. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python 3.5 console logging

2015-12-01 Thread Cameron Simpson
w significant events (user logged in, did this, was refused that, files opened/closed or stuff like that). You'll need to elaborate a bit more on what you're trying to achieve here. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@pytho

Re: [Tutor] Python 3.5 console logging

2015-12-03 Thread Cameron Simpson
On 01Dec2015 11:31, Laura Creighton wrote: He may be looking for something like the logging facility of Gnu screen. Or the venerable "script" command. But I suspect he wants something else. Cheers, Cameron Simpson The worst tyrannies were the ones where a governance required its

Re: [Tutor] Beginner: Socket object and packets

2015-12-05 Thread Cameron Simpson
call. Then you could inspect the received data and probably have seen the '\r' characters. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] reading an input stream

2015-12-24 Thread Cameron Simpson
er does stuff with the XML (accept chunk, parse, etc). If you need to know where the chunk came from, .put a tuple with the chunk and some context information. Does that help you move forward? Cheers, Cameron Simpson ___ Tutor maillist - T

Re: [Tutor] Read from large text file, find string save 1st string of each line where it appeared.

2015-12-28 Thread Cameron Simpson
On 29Dec2015 03:12, Steven D'Aprano wrote: On Mon, Dec 28, 2015 at 04:50:05PM +0530, sutanu bhattacharya wrote: suppose 61746245 is my searching string. so o/p will be [...] I don't understand the question. What is "o/p"? "output&

Re: [Tutor] method, type?

2016-01-05 Thread Cameron Simpson
to subclass JournalLineItem later. Therefore I would recommend the @classmethod approach. And stylisticly, I would put that up the top, just under __init__. Hoping this helps rather than confuses, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] method, type?

2016-01-06 Thread Cameron Simpson
rom_blah is defined in the superclass, the leading "cls" parameter is the subclass because you invoked it through the subclass, just as you get the leading "self" instance parameter when you invoke an instance method through the instance. Tha

Re: [Tutor] method, type?

2016-01-06 Thread Cameron Simpson
On 07Jan2016 00:06, ALAN GAULD wrote: On 06/01/16 23:00, Cameron Simpson wrote: ... ensures that if you subclass the class, you automatically get a valid constructor as well. Wouldn't it return an instance of the superclass rather than the sub class? You'd need to override it wo

Re: [Tutor] reading an input stream

2016-01-07 Thread Cameron Simpson
ce, so that it behaves like a UNIX read() call and may return a "short" read - less than the maximum supplied. This is what you need to return data as soon as it is received. By contrast, the traditional Python .read() call will try to gather bytes until it has the amount as

Re: [Tutor] reading an input stream

2016-01-07 Thread Cameron Simpson
On 08Jan2016 08:52, Cameron Simpson wrote: [...] Instead, gather the data progressively and emit XML chunks. You've got a TCP stream - the TCPServer class will do an accept and handle you an _unbuffered_ binary stream file from which you can just .read(), ignoring any arbitrary "pac

Re: [Tutor] reading an input stream

2016-01-07 Thread Cameron Simpson
On 07Jan2016 17:22, richard kappler wrote: On Thu, Jan 7, 2016 at 5:07 PM, Cameron Simpson wrote: Just a few followup remarks: This is all Python 3, where bytes and strings are cleanly separated. You've got a binary stream with binary delimiters, so we're reading binary data and

Re: [Tutor] basic threading question

2016-01-07 Thread Cameron Simpson
is no need to kill the Thread here. You can wait for the Thread with T.wait() and probe it with T.is_alive(); see the threading module documentation. BTW, I still recommend you drop use of .recv() and use .read1() to assemble packets. See your main di

Re: [Tutor] method, type?

2016-01-07 Thread Cameron Simpson
rtly because it keeps the constructor inside the class definition, which I find conceptually tidier. Steven DAprano calls it a Python3 regular function/ a Python2 broken method and mentions the Descriptor protocol and how 'methods' are initially simply functions that are then c

Re: [Tutor] method, type?

2016-01-07 Thread Cameron Simpson
sloppiness, my apologies, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Syntax error

2016-01-07 Thread Cameron Simpson
ll the lines). Thanks, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Organizing files

2016-01-11 Thread Cameron Simpson
ok in your python_modules directory for modules ahead of other places and you will not need the symlinks (which are fragile anyway). Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.

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

2016-01-15 Thread Cameron Simpson
#x27; should become the last item in the list. Again, the interpreter help gave what I was expecting. To me it means "insert 'x' so that its index is 'i'". Am I just being dense or are the docs in this instance confusing? They may be a bit confusing, though I

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

2016-01-15 Thread Cameron Simpson
On 15Jan2016 23:05, boB Stepp wrote: On Fri, Jan 15, 2016 at 10:53 PM, Cameron Simpson wrote: things.insert(-1, 'What the heck?!?') things [0, 'Hmm...', 3, 'WhackABunny', 6, 'What the heck?!?', '?'] "...at the index..." to me wo

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

2016-01-16 Thread Cameron Simpson
nor in the normal domain for that value. Cheers, Cameron Simpson Q: How does a hacker fix a function which doesn't work for all of the elements in its domain? A: He changes the domain. - Rich Wareham ___ Tutor maillist - Tutor@python.o

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

2016-01-17 Thread Cameron Simpson
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 you please clarify the last bit: "specially re

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

2016-01-17 Thread Cameron Simpson
and likely so in other Python implementations. Don't forget that because both "self.things" and "things" refer to the same list object (in the example earlier) there's no need to have any final "self.things = things" because both are acting on the same list. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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

2016-01-17 Thread Cameron Simpson
ndirection (using "things" instead of "self.things", etc), because that indirection has a cost that _in this case_ will be large compared to the core operations. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] if request.method == 'GET': NameError: global name 'request' is not defined

2016-01-18 Thread Cameron Simpson
read local global called "request"; simplifies writing handlers as the request information is readily available without having to pass it through function calls. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To u

Re: [Tutor] Simultaneous read and write on file

2016-01-18 Thread Cameron Simpson
g. Whether it is a sensible approach depends very much on what he is doing with his files. He _may_ be safer opening the file twice - once for "rb" and once for "ab" - because he does not have to juggle the modes, but it isn't necessarily what he wants. Cheers, Cameron

Re: [Tutor] Simultaneous read and write on file

2016-01-18 Thread Cameron Simpson
On 18Jan2016 21:07, ALAN GAULD wrote: On 18/01/16 20:43, Cameron Simpson wrote: The + modes are deceptively appealing but they are full of dangers for precisely the reasons you have discovered(*). You very rarely need them and you are better opening/closing the file and using explicit modes to

Re: [Tutor] Simultaneous read and write on file

2016-01-18 Thread Cameron Simpson
x27;w+' truncates the file. """ That's why you lose the file's current content, and, yes, "r+b" would avoid that. And I stand corrected; I should have paid more attention. Thanks! Cheers, Cameron Simpson __

Re: [Tutor] Simultaneous read and write on file

2016-01-18 Thread Cameron Simpson
near homophones, when typing in a hurry. You'll see this in a bunch of my messages. More annoyingly, some are only visible when I reread a posted message instead of when I was proofreading prior to send. [Homonyms mess me up when I'm typing, all sew.]

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-20 Thread Cameron Simpson
_ is doing is what you find unexpected later; defining new attribute values not there before. The only thing special about __init__ is that it is called automatically after an object is created. But that is all. This is not a static language, and __init__ is not defining what fields/attributes the object possesses. It is merely setting some of them. It is executable code, not a static type definition. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Why is the name "self" optional instead of mandatory?

2016-01-20 Thread Cameron Simpson
ssible to read gibberish in any language; most people don't try to. So to repeat my question: why make it mandatory? Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-22 Thread Cameron Simpson
a special operation. To take an anecdote from elsewhere: UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things. - Doug Gwyn There's no need to prevent you setting "sigh_strenght".

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-23 Thread Cameron Simpson
On 23Jan2016 01:52, boB Stepp wrote: On Fri, Jan 22, 2016 at 11:04 PM, Cameron Simpson wrote: On 22Jan2016 22:14, boB Stepp wrote: All you're missing is realising that setting an attribute is not a special operation. I guess no matter how new one is to OOP, one nevertheless brings

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-23 Thread Cameron Simpson
On 23Jan2016 12:55, boB Stepp wrote: On Sat, Jan 23, 2016 at 3:30 AM, Cameron Simpson wrote: On 23Jan2016 01:52, boB Stepp wrote: I guess no matter how new one is to OOP, one nevertheless brings one's preconceptions, however malformed, into the learning process. In my case, one of min

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-23 Thread Cameron Simpson
the better .name syntax: v = dog.__dict__['unique_feature'] v = getattr(dog, 'unique_feature') v = dog.unique_feature from least desired to most desired. BTW, when the attribute exists these all return the same thing, but when the attribute does no exist they a

Re: [Tutor] 2016-02-01 Filter STRINGS in Log File and Pass as VARAIBLE within PYTHON script

2016-02-01 Thread Cameron Simpson
p_addrs.add(word7) After you have read the whole file you will have the desired addresses in the ip_addrs set. Try to put all that together and come back with working code, or come back with completed but not working code and specific questions. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

  1   2   3   4   >