[issue39964] adding a string to a list works differently with x+='' compared to x=x+''
New submission from Richard King : x = ['a'] x += ' ' results in ['a',' '] x = x + ' ' results in an exception: Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate list (not "str") to list It behaves the same in 2.7.15 and 3.7.2. -- components: Windows messages: 364213 nosy: paul.moore, rickbking, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: adding a string to a list works differently with x+='' compared to x=x+'' type: behavior versions: Python 2.7, Python 3.7 ___ Python tracker <https://bugs.python.org/issue39964> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2577] cmd.py should track input file objects so macros with submacros can be easily written
Richard King added the comment: ok, thanks. R. David Murray wrote: > R. David Murray added the comment: > > Since it's been almost a year and the OP hasn't responded with an > updated patch, I'm closing this as out of date. > > -- > nosy: +bitdancer > resolution: -> out of date > status: open -> closed > > ___ > Python tracker > <http://bugs.python.org/issue2577> > ___ > > > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 8.0.238 / Virus Database: 270.11.32/2030 - Release Date: 03/30/09 > 08:40:00 > > -- title: cmd.py should track input file objects so macros with submacros can be easily written -> cmd.py should track input file objects so macros with submacros can be easily written Added file: http://bugs.python.org/file13470/unnamed ___ Python tracker <http://bugs.python.org/issue2577> ___ ok, thanks. R. David Murray wrote: R. David Murray mailto:rdmur...@bitdance.com";><rdmur...@bitdance.com> added the comment: Since it's been almost a year and the OP hasn't responded with an updated patch, I'm closing this as out of date. -- nosy: +bitdancer resolution: -> out of date status: open -> closed ___ Python tracker mailto:rep...@bugs.python.org";><rep...@bugs.python.org> http://bugs.python.org/issue2577";><http://bugs.python.org/issue2577>; ___ No virus found in this incoming message. Checked by AVG - http://www.avg.com";>www.avg.com Version: 8.0.238 / Virus Database: 270.11.32/2030 - Release Date: 03/30/09 08:40:00 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2571] cmd.py always uses raw_input, even when another stdin is specified
Richard King <[EMAIL PROTECTED]> added the comment: There were some other things I wanted too so I just made my own cmd.py. -Rick Raghuram Devarakonda wrote: > Raghuram Devarakonda <[EMAIL PROTECTED]> added the comment: > > Richard, I see the following very clearly mentioned in the doc: > > "If you want a given stdin to be used, make sure to set the instance’s > use_rawinput attribute to False, otherwise stdin will be ignored." > > Even though this seems like unnecessary, at least it is documented. If > you want to push for automatically setting use_rawinput when 'stdin' is > not None, you will need to submit a patch and convince some core > developer to agree with you. > > ___ > Python tracker <[EMAIL PROTECTED]> > <http://bugs.python.org/issue2571> > ___ > > > > No virus found in this incoming message. > Checked by AVG. > Version: 8.0.100 / Virus Database: 270.4.0/1506 - Release Date: 6/17/2008 > 4:30 PM > ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2571> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2571] cmd.py always uses raw_input, even when another stdin is specified
Richard King <[EMAIL PROTECTED]> added the comment: (this is really 2 mails because my home email address was not registered so they were rejected at first) Right - I wasn't too clear. The module stashes stdin, whether from sys or passed in, in self.stdin. When it reads input it uses a flag "raw_input" to determine whether to use raw_input or self.stdin.readline(), but the flag is not reset when a different stdin is passed in, so raw_input is always true. The flag should be True/False, and I didn't think of setting it directly to be honest because it never occurred to me that I should have to do that to get a cmd class that i just instantiated with a different input object to use the one it was created with. I think the flag should be eliminated and replaced with the test self.stdin == sys.stdin anyway. I also entered a feature request to add a stack of stdin's which are stacked when you want to process lines in a file, and then pop off the stack automatically at end of file. This would make it easy to write a command-line tool, like i'm doing, so that any input object could enter commands that change to other input objects and then restore the previous input objectthis would allow for nesting of command files. There would be special conditions for sys.stdin (sys.stdin can only be used if there are no items on the stack). This could all be done outside the module, but it's so easy when it's integrated right in there. I think I understand better what you are getting at, but it makes more sense to me to be explicit in the code and not take advantage of the fact the raw_input always works off sys.stdin. Also, I see now that maybe the idea was to have raw_input be changeable so that you could switch back and forth between "stdin" (whatever that is), and some other input object - I'm having a hard time seeing the usefulness of that, though. Anyway, instantiating a cmd class with a non-stdin input object and then having to set raw_input to False to get it to use that input object seems wrong. does this make sense? -Rick King Daniel Diniz wrote: > Daniel Diniz <[EMAIL PROTECTED]> added the comment: > > I don't think it should stop using raw_input just because you changed > stdin, as you can change it to something that will work with raw_input. > Consider: > >>>> import sys >>>> sys.stdin = open("/dev/tty") >>>> raw_input() >>>> > a > 'a' > > You can tie it to any object (e.g. a GUI input) that supports the file > protocol and keep using raw_input. Or change Cmd.use_rawinput to 0 to > use stdin.readline directly. > > On a related issue. Cmd.use_rawinput should be "True", not 1... > > -- > nosy: +ajaksu2 > > __ > Tracker <[EMAIL PROTECTED]> > <http://bugs.python.org/issue2571> > __ > > > __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2571> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2577] cmd.py should track input file objects so macros with submacros can be easily written
New submission from Richard King <[EMAIL PROTECTED]>: Add an "input" method or property that saves the current input file object and resets the input file object; when input results in an "EOF", the input file object stack is popped and reading continues from there. A modified cmd.py is attached. -- components: Extension Modules files: cmd.py messages: 65128 nosy: rickbking severity: normal status: open title: cmd.py should track input file objects so macros with submacros can be easily written type: feature request versions: Python 2.4 Added file: http://bugs.python.org/file9974/cmd.py __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2577> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2571] cmd.py always uses raw_input, even when another stdin is specified
New submission from Richard King <[EMAIL PROTECTED]>: The module global value use_rawinput is initialized to 1 but not reset when stdin is replaced with a passed-in value. -- components: Extension Modules messages: 65094 nosy: rickbking severity: normal status: open title: cmd.py always uses raw_input, even when another stdin is specified type: behavior versions: Python 2.4 __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2571> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com