Re: h(re) for help, import re - on NameError

2016-09-22 Thread Peter Otten
Veek M wrote: > Is there a way to use .pythonrc.py to provide a help function that > autoloads whatever module name is passed like so: By the way, the current help() already loads a module if you pass its name as a string: $ echo 'print("importing foo")' > foo.py $ python3 Python 3.4.3 (defaul

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Gregory Ewing
eryk sun wrote: if we see a read that returns less than the buffer size but doesn't end on a newline, then for a terminal, and only a terminal, I think we can infer Ctrl+D was typed and handle it as EOF. I don't think it would be wise to rely on that. There is no promise that any given read() c

Re: h(re) for help, import re - on NameError

2016-09-22 Thread Veek M
Chris Angelico wrote: > On Thu, Sep 22, 2016 at 8:10 PM, Veek M wrote: >> Is there a way to use .pythonrc.py to provide a help function that >> autoloads whatever module name is passed like so: >> \>>> h(re) >> >> I tried inheriting site._Helper and overriding __init__ and __call__ >> but that di

Re: Why does the insert after list function fail?

2016-09-22 Thread Jussi Piitulainen
38016226...@gmail.com writes: > A=["1","2","3"] > print(list(map(float,A)).insert(0,1)) > > I want to insert 1 at the head of the list but this gives me a surprise Is it the same surprise that you get from print([1,2,3].insert(0,1))? Or the more advanced surprise from print(A.insert(0,1))? -- h

Automated refactoring tools (was: How to import all things defined the files in a module directory in __init__.py?)

2016-09-22 Thread Ben Finney
Peng Yu writes: > Is there such a good automated tool for python refactoring? This sounds like a job for — Bicycle Repair Man! Watch him extract jumbled code into well ordered classes. Gasp, as he renames all occurrences of a method. Thank You Bicycle Repair Man! http://bicyc

Re: How to import all things defined the files in a module directory in __init__.py?

2016-09-22 Thread Peng Yu
On Thu, Sep 22, 2016 at 8:35 PM, Ben Finney wrote: > Peng Yu writes: > >> On Wed, Sep 21, 2016 at 11:14 PM, Ben Finney >> wrote: >> > [Importing ‘*’ from a module] will also make the names in the code >> > impossible to automatically match against where they came from. >> > Explicit is better t

Re: How to import all things defined the files in a module directory in __init__.py?

2016-09-22 Thread Ben Finney
Peng Yu writes: > On Wed, Sep 21, 2016 at 11:14 PM, Ben Finney > wrote: > > [Importing ‘*’ from a module] will also make the names in the code > > impossible to automatically match against where they came from. > > Explicit is better than implicit; you are proposing to make an > > unknown horde

Re: strings and ints consistency - isinstance

2016-09-22 Thread Steve D'Aprano
On Thu, 22 Sep 2016 11:40 pm, Sayth Renshaw wrote: > True it failed, just actually happy to get it to fail or pass successfully > on int input. But it doesn't. It raises ValueError no matter what you enter. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure e

Re: strings and ints consistency - isinstance

2016-09-22 Thread Larry Hudson via Python-list
On 09/22/2016 06:40 AM, Sayth Renshaw wrote: [snip...] True it failed, just actually happy to get it to fail or pass successfully on int input. Just felt it was a clearer and more consistent approach to verifying input, then most of the varied and rather inconsistent approaches I have seen in

Re: Why does the insert after list function fail?

2016-09-22 Thread Wildman via Python-list
On Thu, 22 Sep 2016 12:29:12 -0700, 380162267qq wrote: > A=["1","2","3"] > print(list(map(float,A)).insert(0,1)) > > I want to insert 1 at the head of the list but this gives me a surprise I am not certain about what you are doing so I might be way off here. The following will insert 1 at the he

Re: Why does the insert after list function fail?

2016-09-22 Thread John Gordon
In <39ec91a8-eeae-489f-9237-9d9a481a8...@googlegroups.com> 38016226...@gmail.com writes: > A=["1","2","3"] > print(list(map(float,A)).insert(0,1)) > I want to insert 1 at the head of the list but this gives me a surprise insert() does not return anything; it modifies the existing list in-place.

Why does the insert after list function fail?

2016-09-22 Thread 380162267qq
A=["1","2","3"] print(list(map(float,A)).insert(0,1)) I want to insert 1 at the head of the list but this gives me a surprise -- https://mail.python.org/mailman/listinfo/python-list

Re: Another å, ä, ö question

2016-09-22 Thread Martin Schöön
Den 2016-09-22 skrev Peter Otten <__pete...@web.de>: > Martin Schöön wrote: >> >> I am not sure I answer your questions since I am not quite sure I >> understand it but here goes: The complete file is UTF-8 encoded as >> that is how Geany is set up to create new files (I just checked). > > When th

Re: I am newbie who can explain this code to me?

2016-09-22 Thread 380162267qq
在 2016年9月20日星期二 UTC-4下午3:11:27,Terry Reedy写道: > On 9/20/2016 9:12 AM, Peter Otten wrote: > > >> 在 2016年9月20日星期二 UTC-4上午8:17:13,BartC写道: > >>> On 20/09/2016 13:12, 38016226...@gmail.com wrote: > >>> d = {} > >>> keys = range(256) > >>> vals = map(chr, keys) > >>> map(operator.setite

Re: automated comparison tool

2016-09-22 Thread Andrew Clark
On Wednesday, September 21, 2016 at 8:26:37 PM UTC-5, Steve D'Aprano wrote: > On Thu, 22 Sep 2016 01:55 am, Andrew Clark wrote: > > > I reinstalled paramiko and now i'm getting a slighty different error but > > still says no cryptography. > > [...] > > > ImportError: No module named 'cryptograph

RE: Any ReST aware editors?

2016-09-22 Thread Gerald Britton
> > I have editors which will use syntax highlighting on .rst files, but I'm > hoping for something a bit smarter. What I'd like is an editor with a > split window, one side showing the rst > that I can edit, the other side showing the formatted text updated as I > type. (Or at least, updated every

Re: Hidding Character as you type

2016-09-22 Thread MRAB
On 2016-09-22 17:16, Andrew Clark wrote: I'm looking for a way to either completely hide character as you type in command line or add * to each character as you for simple password obscurity. I've tried getpass.getpass() however the characters still show up on the screen as you type it. Ca

Re: Hidding Character as you type

2016-09-22 Thread Chris Angelico
On Fri, Sep 23, 2016 at 2:16 AM, Andrew Clark wrote: > I'm looking for a way to either completely hide character as you type in > command line or add * to each character as you for simple password > obscurity. I've tried getpass.getpass() however the characters still show up > on the screen

Re: How to import all things defined the files in a module directory in __init__.py?

2016-09-22 Thread Chris Angelico
On Fri, Sep 23, 2016 at 1:50 AM, Peng Yu wrote: > > This will make refactoring easy. If everything is explicit, when one > do refactoring, at two places need to be changed which can be a > burden. So you want it to be easy to move stuff around between files in a package? Sounds like you don't act

Hidding Character as you type

2016-09-22 Thread Andrew Clark
I'm looking for a way to either completely hide character as you type in command line or add * to each character as you for simple password obscurity. I've tried getpass.getpass() however the characters still show up on the screen as you type it. Can anyone help? I'm using python 2.7 on wind

Re: h(re) for help, import re - on NameError

2016-09-22 Thread Chris Angelico
On Thu, Sep 22, 2016 at 8:10 PM, Veek M wrote: > Is there a way to use .pythonrc.py to provide a help function that > autoloads whatever module name is passed like so: > \>>> h(re) > > I tried inheriting site._Helper and overriding __init__ and __call__ but > that didn't work, also I don't know ho

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread eryk sun
On Thu, Sep 22, 2016 at 3:21 PM, Random832 wrote: > On Thu, Sep 22, 2016, at 09:45, eryk sun wrote: > >> Yes, FileIO.readall continues making read() system calls until it sees >> an empty read. But if we know we're reading from a terminal, we should >> be able to assume that a read either consumes

Re: How to import all things defined the files in a module directory in __init__.py?

2016-09-22 Thread Peng Yu
On Wed, Sep 21, 2016 at 11:14 PM, Ben Finney wrote: > Peng Yu writes: > >> I want to import all the thing (or the ones available in the >> respective __all__) defined in each of the file by putting the >> following lines in __init__.py >> >> from file1 import * >> >> from filen import * >> >

Re: Any ReST aware editors?

2016-09-22 Thread Manolo Martínez
On 09/23/16 at 01:20am, Chris Angelico wrote: > If I were doing this, I'd simply have a script that watches the .rst > file and rebuilds a corresponding output file, which can then be shown > in another window, completely separate to the editor. [when-changed]://github.com/joh/when-changed) is a

Re: Obtain the raw line of text read by CSVDictReader when reporting errors?

2016-09-22 Thread Chris Angelico
On Thu, Sep 22, 2016 at 8:36 PM, Malcolm Greene wrote: > Oscar/MRAB, > >> You could put something between the file and the reader ... > > Thank you both for your suggestions ... brilliant! You guys helped me > solve my problem and gave me an excellent strategy for future scenarios. This is why, d

Re: Another å, ä, ö question

2016-09-22 Thread Chris Angelico
On Thu, Sep 22, 2016 at 10:27 PM, Peter Otten <__pete...@web.de> wrote: > When the encoding used for the file and the encoding used by the terminal > differ the output of non-ascii characters gets messed up. Example script: > > # -*- coding: iso-8859-15 -*- > > print "first unicode:" > print u"Schö

Re: Data Types

2016-09-22 Thread Chris Angelico
On Thu, Sep 22, 2016 at 10:33 PM, BartC wrote: >>> print (10<20)=> True >>> print (type(10<20)) => >> >> >> 10<20 shouldn't be thought of as some alternative value which is a bool, >> any >> more than we should think of 1+1 as being a different value to 2. > > > They're a little di

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Random832
On Thu, Sep 22, 2016, at 09:45, eryk sun wrote: > On Thu, Sep 22, 2016 at 12:40 PM, Gregory Ewing > wrote: > > eryk sun wrote: > >> > >> Actually in a Unix terminal the cursor can also be at > >> the end of a line, but a bug in Python requires pressing Ctrl+D twice > >> in that case. > > > > I wou

Re: Any ReST aware editors?

2016-09-22 Thread Chris Angelico
On Thu, Sep 22, 2016 at 9:13 PM, Steve D'Aprano wrote: > What I'd like is an editor with a split window, one side showing the rst > that I can edit, the other side showing the formatted text updated as I > type. (Or at least, updated every thirty seconds or so.) > If I were doing this, I'd simply

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Veek M
eryk sun wrote: > On Thu, Sep 22, 2016 at 12:40 PM, Gregory Ewing > wrote: >> eryk sun wrote: >>> >>> Actually in a Unix terminal the cursor can also be at >>> the end of a line, but a bug in Python requires pressing Ctrl+D >>> twice in that case. >> >> I wouldn't call that a bug, rather it's a c

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread eryk sun
On Thu, Sep 22, 2016 at 12:40 PM, Gregory Ewing wrote: > eryk sun wrote: >> >> Actually in a Unix terminal the cursor can also be at >> the end of a line, but a bug in Python requires pressing Ctrl+D twice >> in that case. > > I wouldn't call that a bug, rather it's a consequence of > what Ctrl-D

Re: strings and ints consistency - isinstance

2016-09-22 Thread Sayth Renshaw
> > This ends being the code I can use to get it to work, seems clear and > > pythonic, open to opinion on that :-) > > Neither clear, nor Pythonic. Sadly imo clearer than the many hack attempts on SO. > > > answer = input("\t >> ") > > Since input() returns a string in Python 3, this will al

Re: strings and ints consistency - isinstance

2016-09-22 Thread Gregory Ewing
On Wednesday, September 21, 2016 at 11:41:42 PM UTC-4, Sayth Renshaw wrote: answer = input("\t >> ") if isinstance(int(answer), int) is True: raise ValueError("Ints aren't valid input") You seem to be trying to check that the user hasn't entered an integer. But that's a backwards way of loo

Re: Any ReST aware editors?

2016-09-22 Thread José Abílio Matos
On Thursday, September 22, 2016 9:13:02 PM WEST Steve D'Aprano wrote: > I have editors which will use syntax highlighting on .rst files, but I'm > hoping for something a bit smarter. > > What I'd like is an editor with a split window, one side showing the rst > that I can edit, the other side show

Re: Any ReST aware editors?

2016-09-22 Thread Marko Rauhamaa
Steve D'Aprano : > What I'd like is an editor with a split window, one side showing the > rst that I can edit, the other side showing the formatted text updated > as I type. (Or at least, updated every thirty seconds or so.) > > Anybody know anything like that? Open a .rst file in emacs and press

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Gregory Ewing
eryk sun wrote: Actually in a Unix terminal the cursor can also be at the end of a line, but a bug in Python requires pressing Ctrl+D twice in that case. I wouldn't call that a bug, rather it's a consequence of what Ctrl-D does. It doesn't really mean EOF, it means to send whatever the terminal

Re: Data Types

2016-09-22 Thread BartC
On 22/09/2016 02:40, Steve D'Aprano wrote: On Wed, 21 Sep 2016 10:25 pm, BartC wrote: On 21/09/2016 05:03, Cai Gengyang wrote: Are there any other data types that will give you type(A) or type(B) = besides True and False? No types but any variable or expression containing True or False wil

Re: Another å, ä, ö question

2016-09-22 Thread Peter Otten
Martin Schöön wrote: > Den 2016-09-20 skrev Peter Otten <__pete...@web.de>: >> Martin Schöön wrote: >> >>> Den 2016-09-19 skrev Christian Gollwitzer : Am 19.09.16 um 22:21 schrieb Martin Schöön: > I am studying some of these tutorials: > https://pythonprogramming.net/matplotlib-intro-

Re: Any ReST aware editors?

2016-09-22 Thread Jon Ribbens
On 2016-09-22, Yann Kaiser wrote: > On Thu, Sep 22, 2016, 12:59 Jon Ribbens wrote: >> On 2016-09-22, Steve D'Aprano wrote: >> > I have editors which will use syntax highlighting on .rst files, but I'm >> > hoping for something a bit smarter. >> > >> > What I'd like is an editor with a split wind

Re: Any ReST aware editors?

2016-09-22 Thread Yann Kaiser
Does that work with with ReST? On Thu, Sep 22, 2016, 12:59 Jon Ribbens wrote: > On 2016-09-22, Steve D'Aprano wrote: > > I have editors which will use syntax highlighting on .rst files, but I'm > > hoping for something a bit smarter. > > > > What I'd like is an editor with a split window, one s

Re: Any ReST aware editors?

2016-09-22 Thread Jon Ribbens
On 2016-09-22, Steve D'Aprano wrote: > I have editors which will use syntax highlighting on .rst files, but I'm > hoping for something a bit smarter. > > What I'd like is an editor with a split window, one side showing the rst > that I can edit, the other side showing the formatted text updated as

Re: Any ReST aware editors?

2016-09-22 Thread jkn
Hi Steve On Thursday, September 22, 2016 at 12:13:16 PM UTC+1, Steve D'Aprano wrote: > I have editors which will use syntax highlighting on .rst files, but I'm > hoping for something a bit smarter. > > What I'd like is an editor with a split window, one side showing the rst > that I can edit, the

Any ReST aware editors?

2016-09-22 Thread Steve D'Aprano
I have editors which will use syntax highlighting on .rst files, but I'm hoping for something a bit smarter. What I'd like is an editor with a split window, one side showing the rst that I can edit, the other side showing the formatted text updated as I type. (Or at least, updated every thirty sec

Re: Data Types

2016-09-22 Thread Steve D'Aprano
On Thu, 22 Sep 2016 01:46 pm, Sayth Renshaw wrote: > What about 0 or 1 they are true and false like no other numbers? what > category do they fall in with regards to booleans? 0 and 1 are ints: py> type(0) py> type(1) just like 2, 3, 4, -1, -999, 1098765432 etc. But just like 1 == 1.0 (a fl

Re: strings and ints consistency - isinstance

2016-09-22 Thread Steve D'Aprano
On Thu, 22 Sep 2016 01:41 pm, Sayth Renshaw wrote: > This ends being the code I can use to get it to work, seems clear and > pythonic, open to opinion on that :-) Neither clear, nor Pythonic. > answer = input("\t >> ") Since input() returns a string in Python 3, this will always be a string.

Re: Obtain the raw line of text read by CSVDictReader when reporting errors?

2016-09-22 Thread Malcolm Greene
Oscar/MRAB, > You could put something between the file and the reader ... Thank you both for your suggestions ... brilliant! You guys helped me solve my problem and gave me an excellent strategy for future scenarios. Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Re: strings and ints consistency - isinstance

2016-09-22 Thread Ned Batchelder
On Wednesday, September 21, 2016 at 11:41:42 PM UTC-4, Sayth Renshaw wrote: > This ends being the code I can use to get it to work, seems clear and > pythonic, open to opinion on that :-) > > > answer = input("\t >> ") > if isinstance(int(answer), int) is True: > raise ValueError("Ints aren'

h(re) for help, import re - on NameError

2016-09-22 Thread Veek M
Is there a way to use .pythonrc.py to provide a help function that autoloads whatever module name is passed like so: \>>> h(re) I tried inheriting site._Helper and overriding __init__ and __call__ but that didn't work, also I don't know how to deal/trap/catch the NameError (no quotes on h(re))

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Veek M
Ben Finney wrote: > Veek M writes: > >> Ben Finney wrote: >> >> > Since you are writing code into a module file, why not just run the >> > module from that file with the non-interactive Python interpreter? >> > >> It's part of a hexchat plugin/addon.. > > Which tells me that it still isn't app

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Veek M
eryk sun wrote: > On Thu, Sep 22, 2016 at 5:12 AM, Veek M wrote: >> 2. Blank lines in my code within the editor are perfectly acceptable >> for readability but they act as a block termination on cmd line. > > You can write a simple paste() function. For example: > > import sys > paste =

OT-Requirement-Python Developer

2016-09-22 Thread Shimpy Sandhu
Hi folks I am looking for python developer for Ludhiana location. If anyone is interested, please share updated CV at shi...@revinfotech.com Regards Shimpy Sandhu -- https://mail.python.org/mailman/listinfo/python-list

Re: Where is import defined in the source code?

2016-09-22 Thread Lawrence D’Oliveiro
On Thursday, September 22, 2016 at 4:14:16 PM UTC+12, Peng Yu wrote: > > ... I want know where import is defined in the source code. This looks like the code, and this

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Lawrence D’Oliveiro
On Thursday, September 22, 2016 at 5:12:13 PM UTC+12, Veek M wrote: > How do i deal with this - what's the best way to achieve what I'm trying > to do. If you want a scratchpad for trying out Python code, I can recommend Jupyter/IPython . -- https://mail.python.org/mailman/

Re: strings and ints consistency - isinstance

2016-09-22 Thread Lawrence D’Oliveiro
On Thursday, September 22, 2016 at 3:41:42 PM UTC+12, Sayth Renshaw wrote: > if isinstance(int(answer), int) is True: Not sure what the point of this is... -- https://mail.python.org/mailman/listinfo/python-list

Re: Data Types

2016-09-22 Thread Lawrence D’Oliveiro
On Thursday, September 22, 2016 at 3:47:27 PM UTC+12, Sayth Renshaw wrote: > What about 0 or 1 they are true and false like no other numbers? >>> isinstance(1, bool) False >>> isinstance(True, int) True -- https://mail.python.org/mailman/listinfo/python-list

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Steven D'Aprano
On Thursday 22 September 2016 17:42, eryk sun wrote: > On Thu, Sep 22, 2016 at 5:12 AM, Veek M wrote: >> 2. Blank lines in my code within the editor are perfectly acceptable for >> readability but they act as a block termination on cmd line. > > You can write a simple paste() function. For examp

Refer to a numbered heading in ReST

2016-09-22 Thread Steven D'Aprano
I have a ReST (ReStructured Text) document that auto-numbers headings. I have a heading like: My Heading -- which will be given a number like 10.1 (say), except of course I don't know what the number will be until I've compiled the .rst file using Sphinx. Later in the documen

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread eryk sun
On Thu, Sep 22, 2016 at 5:12 AM, Veek M wrote: > 2. Blank lines in my code within the editor are perfectly acceptable for > readability but they act as a block termination on cmd line. You can write a simple paste() function. For example: import sys paste = lambda: exec(sys.stdin.read(),

Re: csjark module

2016-09-22 Thread Peter Otten
bezen...@gmail.com wrote: > On Thursday, September 22, 2016 at 5:51:43 AM UTC+3, beze...@gmail.com > wrote: >> On Wednesday, September 21, 2016 at 10:09:25 PM UTC+3, Peter Otten wrote: >> > bezen...@gmail.com wrote: >> > >> > > On Wednesday, September 21, 2016 at 5:15:38 PM UTC+3, Peter Otten >>

Re: Data Types

2016-09-22 Thread Larry Hudson via Python-list
On 09/20/2016 09:03 PM, Cai Gengyang wrote: [snip...] So for example for "bool" , it only applies to True/False and nothing else? (2 data types), i.e. : Not exactly... bool is the data type (or class), True and False are the only two _values_ (not types). type(True) type(False) [