Re: import in code

2018-07-21 Thread dieter
Abdur-Rahmaan Janhangeer writes: > i have found some reputable books that include import within code > > with ... > import x > > if ... > import y > > def ... > import z > > according to me they should be placed at the top. but an advantage of it is > optimisation where you only load

Re: print & string formatting

2018-07-21 Thread Cameron Simpson
On 21Jul2018 21:33, Sharan Basappa wrote: I get a lot confused while using print functions in Python. For example, I get the same results for the following code: str = "one two three" Pleasetry not to name variables after builtin classes ("str" is the name of Python's string class). prin

Re: import in code

2018-07-21 Thread Abdur-Rahmaan Janhangeer
> > > apart from circular imports? > sorry your last mail was sent to spam by gmail. now seeing it . thank you ! -- Abdur-Rahmaan Janhangeer https://github.com/abdur-rahmaanj Mauritius -- https://mail.python.org/mailman/listinfo/python-list

Re: import in code

2018-07-21 Thread Abdur-Rahmaan Janhangeer
On Sun, Jul 22, 2018 at 8:49 AM Cameron Simpson wrote: > On 22Jul2018 14:45, Cameron Simpson wrote: > >Circular imports: 2 codependent modules. apart from circular imports? -- Abdur-Rahmaan Janhangeer https://github.com/abdur-rahmaanj Mauritius -- https://mail.python.org/mailman/listinfo/pyt

Re: print & string formatting

2018-07-21 Thread Chris Angelico
On Sun, Jul 22, 2018 at 2:53 PM, Abdur-Rahmaan Janhangeer wrote: > *Folks,I get a lot confused while using print functions in Python.For > example, I get the same results for the following code:str = "one two > three"print strprint "%s" %(str)So, what is the need to use the second > method which I

Re: functions vs methods

2018-07-21 Thread dieter
Sharan Basappa writes: > Is there a difference between functions and methods in Python. Somewhat simplified: a method is a function with the method's associated object implicitly passed as first argument. For a Python defined method "m", you can get the corresponding function via "m.__func__" (

Re: print & string formatting

2018-07-21 Thread Abdur-Rahmaan Janhangeer
*Folks,I get a lot confused while using print functions in Python.For example, I get the same results for the following code:str = "one two three"print strprint "%s" %(str)So, what is the need to use the second method which I see being used in many programs I am referring to* well 1) that is more

Re: import in code

2018-07-21 Thread Cameron Simpson
On 22Jul2018 14:45, Cameron Simpson wrote: Circular imports: 2 codependent modules. If you have: module A: import B module B: import B That won't work: the second import (whichever it turns out to be) will fail. One workaround is to make one of the modules put off the import. A better

Re: import in code

2018-07-21 Thread Cameron Simpson
On 22Jul2018 06:43, Abdur-Rahmaan Janhangeer wrote: i have found some reputable books that include import within code with ... import x if ... import y def ... import z according to me they should be placed at the top. but an advantage of it is optimisation where you only load modu

print & string formatting

2018-07-21 Thread Sharan Basappa
Folks, I get a lot confused while using print functions in Python. For example, I get the same results for the following code: str = "one two three" print str print "%s" %(str) So, what is the need to use the second method which I see being used in many programs I am referring to -- https:/

Re: functions vs methods

2018-07-21 Thread Sharan Basappa
Thanks a lot. On Sunday, 22 July 2018 04:02:23 UTC+5:30, Rick Johnson wrote: > On Saturday, July 21, 2018 at 2:06:21 PM UTC-5, Sharan Basappa wrote: > > Is there a difference between functions and methods in Python. > > Generally speaking, functions and methods are basically two > words describi

Make, Sphinx and Windows

2018-07-21 Thread Abdur-Rahmaan Janhangeer
normally when you use make with sphinx, it should build and tell you errors (so that reviewers don't have to correct it manually) i have been doing some contribs to french docs translation but my make is a bit crazy : https://www.pythonmembers.club/wp-content/uploads/2018/07/make-win.png any idea

import in code

2018-07-21 Thread Abdur-Rahmaan Janhangeer
i have found some reputable books that include import within code with ... import x if ... import y def ... import z according to me they should be placed at the top. but an advantage of it is optimisation where you only load modules if necessary so, import within code can be call

Re: Edit with IDLE pull down menu

2018-07-21 Thread MRAB
On 2018-07-22 00:44, no@none.invalid wrote: On Sat, 21 Jul 2018 14:34:15 -0700 (PDT), Rick Johnson wrote: This is really the code I keep copying. import random from random import randint a = [5, 10, 15, 20, 25, 30, 35, 40] b = ["Rock","Paper","Scissors","Lizard ","Spock"] I am lazy and don't

Re: Cookies not showing up in environ

2018-07-21 Thread Jon Ribbens
On 2018-07-21, abc abc wrote: >> I think one of the main issues is that you don't seem to have decided >> whether you're writing a WSGI application or a Django application. > > Yes, I suppose I thought Django had to use wsgi to process requests, > I didn't know there were 'two' options here. Djan

Re: Edit with IDLE pull down menu

2018-07-21 Thread no
On Sat, 21 Jul 2018 14:34:15 -0700 (PDT), Rick Johnson wrote: This is really the code I keep copying. import random from random import randint a = [5, 10, 15, 20, 25, 30, 35, 40] b = ["Rock","Paper","Scissors","Lizard ","Spock"] I am lazy and don't type well, so I leave out some details when p

Re: Cookies not showing up in environ

2018-07-21 Thread abc abc
> I think one of the main issues is that you don't seem to have decided > whether you're writing a WSGI application or a Django application. Yes, I suppose I thought Django had to use wsgi to process requests, I didn't know there were 'two' options here. Does your example represent one or the ot

Re: Cookies not showing up in environ

2018-07-21 Thread abc abc
> I think one of the main issues is that you don't seem to have decided > whether you're writing a WSGI application or a Django application. Yes, I suppose I thought Django had to use wsgi to process requests, I didn't know there were 'two' options here. Does your example represent one or the ot

Re: functions vs methods

2018-07-21 Thread Lele Gaifax
Sharan Basappa writes: > Refer to the following lines: > 1) len(list) > 2) list.append() > > In the first case, len is a function that python provides to which list can > be passed and in the second case, append is a method within list class? > > If my interpretation is correct, why not make le

functions vs methods

2018-07-21 Thread Sharan Basappa
Is there a difference between functions and methods in Python. For example, this is the text from tutorialpoint on Python: Python includes the following list functions - cmp, len etc. Python includes following list methods - append, count A related question. Refer to the following lines: 1) len

Re: pattern block expression matching

2018-07-21 Thread Dan Sommers
On Sat, 21 Jul 2018 17:37:00 +0100, MRAB wrote: > On 2018-07-21 15:20, aldi.kr...@gmail.com wrote: >> Hi, >> I have a long text, which tells me which files from a database were >> downloaded and which ones failed. The pattern is as follows (at the end of >> this post). Wrote a tiny program, but

Re: Edit with IDLE pull down menu

2018-07-21 Thread no
On Sat, 21 Jul 2018 08:52:45 -0700 (PDT), Rick Johnson wrote: >n...@none.invalid wrote: >> Terry Reedy wrote: > >[...] > >> You seem to be able to directly affect Python development. >> If that is true, maybe you could remove the pull down >> redundancy from one menu and add a pull down optio

Re: [OT] Bit twiddling homework

2018-07-21 Thread Peter J. Holzer
On 2018-07-20 19:13:44 +1000, Chris Angelico wrote: > On Fri, Jul 20, 2018 at 7:00 PM, Brian Oney via Python-list > wrote: > > That's right I had forgotten about that. Thank you for the quick > > answer.Some fun:$ ipythonPython 2.7.13 (default, Nov 24 2017, 17:33:09) > > ...In [1]: j = 16; i = 1

Re: Getting installed version

2018-07-21 Thread Peter J. Holzer
On 2018-07-20 08:04:33 +0200, Cecil Westerhof wrote: > I can get the installed version of a package with: > pip2 show cryptography | awk '/^Version: / { print $2 }' > > But I was wondering if there is a better way. Using pip probably is the most reliable way (for packages installed via pip).

Re: pattern block expression matching

2018-07-21 Thread Peter Otten
MRAB wrote: > On 2018-07-21 15:20, aldi.kr...@gmail.com wrote: >> Hi, >> I have a long text, which tells me which files from a database were >> downloaded and which ones failed. The pattern is as follows (at the end >> of this post). Wrote a tiny program, but still is raw. I want to find >> term "

Re: pattern block expression matching

2018-07-21 Thread MRAB
On 2018-07-21 15:20, aldi.kr...@gmail.com wrote: Hi, I have a long text, which tells me which files from a database were downloaded and which ones failed. The pattern is as follows (at the end of this post). Wrote a tiny program, but still is raw. I want to find term "ERROR" and go 5 lines abov

Re: Non-GUI, single processort inter process massaging - how?

2018-07-21 Thread Chris Green
Steven D'Aprano wrote: > On Sat, 21 Jul 2018 09:07:23 +0100, Chris Green wrote: > > [...] > > I want to be able to interrogate the server process from several client > > processes, some will interrogate it multiple times, others once only. > > They are mostly (all?) run from the command line (ba

pattern block expression matching

2018-07-21 Thread aldi . kraja
Hi, I have a long text, which tells me which files from a database were downloaded and which ones failed. The pattern is as follows (at the end of this post). Wrote a tiny program, but still is raw. I want to find term "ERROR" and go 5 lines above and get the name with suffix XPT, in this first

Re: Cookies not showing up in environ

2018-07-21 Thread Jon Ribbens
On 2018-07-20, abc abc wrote: > Well, I'm so messed up between so many sources and tutorials I don't > know which way is up. I think one of the main issues is that you don't seem to have decided whether you're writing a WSGI application or a Django application. WSGI: def application(enviro

Re: Non-GUI, single processort inter process massaging - how?

2018-07-21 Thread Steven D'Aprano
On Sat, 21 Jul 2018 09:07:23 +0100, Chris Green wrote: [...] > I want to be able to interrogate the server process from several client > processes, some will interrogate it multiple times, others once only. > They are mostly (all?) run from the command line (bash). This sounds like a good appro

Re: Better way / regex to extract values form a dictionary

2018-07-21 Thread Ganesh Pal
> The dictionary is irrelevant to your question. It doesn't matter whether > the path came from a dict, a list, read directly from stdin, an > environment variable, extracted from a CSV file, or plucked directly from > outer space by the programmer. The process remains the same regardless of > wher

Re: Better way / regex to extract values form a dictionary

2018-07-21 Thread Steven D'Aprano
On Sat, 21 Jul 2018 17:07:04 +0530, Ganesh Pal wrote: > I have one of the dictionary values in the below format > > '/usr/local/ABCD/EDF/ASASAS/GTH/HELLO/MELLO/test04_Failures.log' > '/usr/local/ABCD/EDF/GTH/HEL/OOLO/MELLO/test02_Failures.log' > '/usr/local/ABCD/EDF/GTH/BEL/LO/MELLO/test03_Failur

Re: Better way / regex to extract values form a dictionary

2018-07-21 Thread Paul Moore
def return_filename_test_case(filepath): filename = os.path.basename(filepath) testcase = filename.partition('_')[0] return filename, testcase On 21 July 2018 at 12:37, Ganesh Pal wrote: > I have one of the dictionary values in the below format > > '/usr/local/ABCD/EDF/ASASAS/GTH/HELL

Better way / regex to extract values form a dictionary

2018-07-21 Thread Ganesh Pal
I have one of the dictionary values in the below format '/usr/local/ABCD/EDF/ASASAS/GTH/HELLO/MELLO/test04_Failures.log' '/usr/local/ABCD/EDF/GTH/HEL/OOLO/MELLO/test02_Failures.log' '/usr/local/ABCD/EDF/GTH/BEL/LO/MELLO/test03_Failures.log' I need to extract the file name in the path example, say

Re: try except inside a with open

2018-07-21 Thread Cameron Simpson
Please try to preserve the attribution lines of previous authors. The inner quote below comes from Steven D'Aprano. On 21Jul2018 15:13, Ganesh Pal wrote: (1) Since this function always returns True (if it returns at all), what is the point? There's no point checking the return result, since it

Re: try except inside a with open

2018-07-21 Thread Ganesh Pal
> > > > (1) Since this function always returns True (if it returns at all), what > is the point? There's no point checking the return result, since it's > always true, so why bother returning anything? > > If I don't return anything from a function it returns None. But would it be better if for

Non-GUI, single processort inter process massaging - how?

2018-07-21 Thread Chris Green
I have a need to allow short-lived 'client' processes to interrogate a single long-lived 'server' process on a small system (specifically a BeagleBone Black). The server process reads values from external hardware and this needs to be done by a single process to ensure that it works as intended an