Re: Lifetime of a local reference

2019-02-26 Thread Marko Rauhamaa
Alan Bawden : > Marko Rauhamaa writes: >> def fun(): >> f = open("lock") >> flock.flock(f, fcntl.LOCK_EX) >> do_stuff() >> sys.exit(0) >> >> Question: can a compliant Python implementation close f (and, >> consequently, release the file lock) before/while do_s

Re: Multi meaning of label: Doc bug

2019-02-26 Thread Rustom Mody
On Wednesday, February 27, 2019 at 11:12:28 AM UTC+5:30, Rustom Mody wrote: > Ref: This stackexchange post: > https://unix.stackexchange.com/q/503241/323121 > > Context: Theres this guy who's really struggling with disk partitioning LVM > etc concepts. That point is not directly relevant to this

Multi meaning of label: Doc bug

2019-02-26 Thread Rustom Mody
Ref: This stackexchange post: https://unix.stackexchange.com/q/503241/323121 Context: Theres this guy who's really struggling with disk partitioning LVM etc concepts. That point is not directly relevant to this question. My answer on that post tries to clarify that 'label' can mean 3 things at

Re: Quirk difference between classes and functions

2019-02-26 Thread jfong
Chris Angelico於 2019年2月27日星期三 UTC+8上午11時29分04秒寫道: > On Wed, Feb 27, 2019 at 2:21 PM wrote: > > > > Chris Angelico於 2019年2月27日星期三 UTC+8上午9時25分11秒寫道: > > > On Wed, Feb 27, 2019 at 12:21 PM wrote: > > > > > > > > Gregory Ewing at 2019/2/27 AM 5:26:49 wrote: > > > > > Thomas Jollans wrote: > > > > >

Re: Quirk difference between classes and functions

2019-02-26 Thread Chris Angelico
On Wed, Feb 27, 2019 at 2:21 PM wrote: > > Chris Angelico於 2019年2月27日星期三 UTC+8上午9時25分11秒寫道: > > On Wed, Feb 27, 2019 at 12:21 PM wrote: > > > > > > Gregory Ewing at 2019/2/27 AM 5:26:49 wrote: > > > > Thomas Jollans wrote: > > > > > I imagine there's a justification for the difference in behaviou

Re: Quirk difference between classes and functions

2019-02-26 Thread jfong
Chris Angelico於 2019年2月27日星期三 UTC+8上午9時25分11秒寫道: > On Wed, Feb 27, 2019 at 12:21 PM wrote: > > > > Gregory Ewing at 2019/2/27 AM 5:26:49 wrote: > > > Thomas Jollans wrote: > > > > I imagine there's a justification for the difference in behaviour to do > > > > with the fact that the body of a class

Re: Lifetime of a local reference

2019-02-26 Thread Alan Bawden
Marko Rauhamaa writes: > def fun(): > f = open("lock") > flock.flock(f, fcntl.LOCK_EX) > do_stuff() > sys.exit(0) > > Question: can a compliant Python implementation close f (and, > consequently, release the file lock) before/while do_stuff() is > executed? A

Re: Quirk difference between classes and functions

2019-02-26 Thread Chris Angelico
On Wed, Feb 27, 2019 at 12:21 PM wrote: > > Gregory Ewing at 2019/2/27 AM 5:26:49 wrote: > > Thomas Jollans wrote: > > > I imagine there's a justification for the difference in behaviour to do > > > with the fact that the body of a class is only ever executed once, while > > > the body of a functi

Re: Quirk difference between classes and functions

2019-02-26 Thread eryk sun
On 2/26/19, Gregory Ewing wrote: > Thomas Jollans wrote: >> I imagine there's a justification for the difference in behaviour to do >> with the fact that the body of a class is only ever executed once, while >> the body of a function is executed multiple times. > > I suspect there isn't any deep r

Re: Quirk difference between classes and functions

2019-02-26 Thread jfong
Gregory Ewing at 2019/2/27 AM 5:26:49 wrote: > Thomas Jollans wrote: > > I imagine there's a justification for the difference in behaviour to do > > with the fact that the body of a class is only ever executed once, while > > the body of a function is executed multiple times. > > I suspect there i

Re: missing 1 required positional argument error

2019-02-26 Thread Terry Reedy
On 2/26/2019 10:10 AM, vergos.niko...@gmail.com wrote: I'm receiving the following error: Traceback (most recent call last): File "/usr/lib64/python3.6/site-packages/bottle.py", line 862, in _handle return route.call(**args) File "/usr/lib64/python3.6/site-packages/bottle.py", line 17

Re: Lifetime of a local reference

2019-02-26 Thread Tim Daneliuk
On 2/26/19 3:54 PM, Marko Rauhamaa wrote: > Consider this function: > > def fun(): > f = open("lock") > flock.flock(f, fcntl.LOCK_EX) > do_stuff() > sys.exit(0) > > Question: can a compliant Python implementation close f (and, > consequently, release the file l

Re: Lifetime of a local reference

2019-02-26 Thread Chris Angelico
On Wed, Feb 27, 2019 at 9:00 AM Marko Rauhamaa wrote: > Consider this function: > > def fun(): > f = open("lock") > flock.flock(f, fcntl.LOCK_EX) > do_stuff() > sys.exit(0) > > Question: can a compliant Python implementation close f (and, > consequently, release

Lifetime of a local reference

2019-02-26 Thread Marko Rauhamaa
Consider this function: def fun(): f = open("lock") flock.flock(f, fcntl.LOCK_EX) do_stuff() sys.exit(0) Question: can a compliant Python implementation close f (and, consequently, release the file lock) before/while do_stuff() is executed? I couldn't find a

RE: Quirk difference between classes and functions

2019-02-26 Thread Steve
I have been a silent reader on this and am interested in understanding more about the scope of variables in Python. They do not seem to behave as I have experienced in other programming languages. I have used functions in python but was not aware of class. It would benefit me very well if someone

Re: Quirk difference between classes and functions

2019-02-26 Thread Gregory Ewing
Thomas Jollans wrote: I imagine there's a justification for the difference in behaviour to do with the fact that the body of a class is only ever executed once, while the body of a function is executed multiple times. I suspect there isn't any deep reason for it, rather it's just something that

Re: Trying to read in data for a file to a python application

2019-02-26 Thread Paul Sutton
On 26/02/2019 15:51, Paul Sutton wrote: > Hi > > I have been trying to write a small application that is essentially user > information application. > > https://raw.githubusercontent.com/zleap/AboutMe/master/Aboutme.py > > So far I have managed to write the data generated to a file, what I want

Re: Trying to read in data for a file to a python application

2019-02-26 Thread Peter Pearson
On Tue, 26 Feb 2019 15:51:38 +, Paul Sutton wrote: > Hi > > I have been trying to write a small application that is essentially user > information application. > > https://raw.githubusercontent.com/zleap/AboutMe/master/Aboutme.py > > So far I have managed to write the data generated to a file,

Re: How to format a datetime MySQL database field to local using strftime()

2019-02-26 Thread vergos . nikolas
Actually i just found it has a directive: dictrows: Whether or not to support dict-like access to row objects (default: True). so i just did: plugin = bottle_pymysql.Plugin( dbuser='nikos', dbpass='*', dbname='counters', dictrows=False ) and now it works with indexes as integers not as st

Re: missing 1 required positional argument error

2019-02-26 Thread vergos . nikolas
Τη Τρίτη, 26 Φεβρουαρίου 2019 - 5:21:14 μ.μ. UTC+2, ο χρήστης Calvin Spealman έγραψε: > you call it by visiting the route you've mapped to it, so when you run this > app and navigate to the root / URL it gets called. What do you expect this > parameter to be and where did you expect it to come fro

Trying to read in data for a file to a python application

2019-02-26 Thread Paul Sutton
Hi I have been trying to write a small application that is essentially user information application. https://raw.githubusercontent.com/zleap/AboutMe/master/Aboutme.py So far I have managed to write the data generated to a file, what I want to do now, is read this data back in when the user opens

Re: missing 1 required positional argument error

2019-02-26 Thread vergos . nikolas
Τη Τρίτη, 26 Φεβρουαρίου 2019 - 5:21:14 μ.μ. UTC+2, ο χρήστης Calvin Spealman έγραψε: > you call it by visiting the route you've mapped to it, so when you run this > app and navigate to the root / URL it gets called. What do you expect this > parameter to be and where did you expect it to come fro

Re: missing 1 required positional argument error

2019-02-26 Thread Calvin Spealman
you call it by visiting the route you've mapped to it, so when you run this app and navigate to the root / URL it gets called. What do you expect this parameter to be and where did you expect it to come from when you wrote the listall() function? On Tue, Feb 26, 2019 at 10:15 AM wrote: > I'm rec

missing 1 required positional argument error

2019-02-26 Thread vergos . nikolas
I'm receiving the following error: Traceback (most recent call last): File "/usr/lib64/python3.6/site-packages/bottle.py", line 862, in _handle return route.call(**args) File "/usr/lib64/python3.6/site-packages/bottle.py", line 1740, in wrapper rv = callback(*a, **ka) File "/usr/lib6

Re: How to format a datetime MySQL database field to local using strftime()

2019-02-26 Thread vergos . nikolas
Τη Τρίτη, 26 Φεβρουαρίου 2019 - 3:26:29 μ.μ. UTC+2, ο χρήστης vergos@gmail.com έγραψε: > Can you help me rewrite this function, which when iam using 'pymysql' > conncector works normally, it does not when iam using 'bottle_pymysql' > > def coalesce( data ): > newdata = [] > seen

Re: How to format a datetime MySQL database field to local using strftime()

2019-02-26 Thread vergos . nikolas
Can you help me rewrite this function, which when iam using 'pymysql' conncector works normally, it does not when iam using 'bottle_pymysql' def coalesce( data ): newdata = [] seen = {} for host, ref, location, useros, browser, visits, hits, downloads, authuser in data:

Re: Quirk difference between classes and functions

2019-02-26 Thread Thomas Jollans
On 25/02/2019 21.15, Chris Angelico wrote: > On Tue, Feb 26, 2019 at 6:58 AM DL Neil > wrote: >> >> On 26/02/19 5:25 AM, ast wrote: >>> I noticed a quirk difference between classes and functions >>> >>> x=0 >>> >>> class Test: >>> x = x+1 >>> print(x) >>> x = x+1 >>>

Re: Quirk difference between classes and functions

2019-02-26 Thread jfong
ast於 2019年2月26日星期二 UTC+8上午12時25分40秒寫道: > Hello > > I noticed a quirk difference between classes and functions > > >>> x=0 > >>> > >>> class Test: > x = x+1 > print(x) > x = x+1 > print(x) > > 1 > 2 > >>> print(x) > 0 > > Previous code doesn't generate any