Re: How to set environmental variables for Python

2022-01-17 Thread Cameron Simpson
On 17Jan2022 11:36, Shaozhong SHI wrote: >Set Operation System but not disturbing existing setting. Only to add at >the command line. If you mean: "set on the command line so that I run some script using Python 3.6.1", usually you would just invoke the specific Python 3.6.1 executable. You ca

Re: How to set environmental variables for Python

2022-01-17 Thread Shaozhong SHI
gt; > How do I set environmental variables for Python 3.6.1 to work? > > > Set from Python, or set in the OpSys? > > https://docs.python.org/3/library/os.html?highlight=environment%20variable > > MS-Win: https://docs.python.org/3/using/windows.html#setting-envvars > -- > Regar

Re: How to set environmental variables for Python

2022-01-17 Thread dn via Python-list
On 17/01/2022 22.31, Shaozhong SHI wrote: > I got quite a few version of Python on my machine. > > How do I set environmental variables for Python 3.6.1 to work? Set from Python, or set in the OpSys? https://docs.python.org/3/library/os.html?highlight=environment%20variable MS-W

How to set environmental variables for Python

2022-01-17 Thread Shaozhong SHI
I got quite a few version of Python on my machine. How do I set environmental variables for Python 3.6.1 to work? Regards, David -- https://mail.python.org/mailman/listinfo/python-list

Re: optimization of rule-based model on discrete variables

2021-06-16 Thread Greg Ewing
On 16/06/21 10:51 pm, Elena wrote: sorry I wrote it wrongly, my bad, I will use f just to predict yi from new coming Xi. Then what do you do with the new yi? -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: optimization of rule-based model on discrete variables

2021-06-16 Thread Elena via Python-list
Il Wed, 16 Jun 2021 11:37:42 +1200, Greg Ewing ha scritto: > On 15/06/21 10:07 pm, Elena wrote: >> After the optimization, I will use f just to predict new Xi. > > So you're going to use f backwards? > > I don't see how that will work. Where are you going to find a new yi to > feed into the inve

Re: optimization of rule-based model on discrete variables

2021-06-15 Thread Greg Ewing
On 15/06/21 10:07 pm, Elena wrote: After the optimization, I will use f just to predict new Xi. So you're going to use f backwards? I don't see how that will work. Where are you going to find a new yi to feed into the inverse of f? I think I don't understand what role g plays in all of this.

Re: optimization of rule-based model on discrete variables

2021-06-15 Thread Elena via Python-list
Il Tue, 15 Jun 2021 01:53:09 +, Martin Di Paola ha scritto: > From what I'm understanding it is an "optimization problem" like the > ones that you find in "linear programming". > > But in your case the variables are not Real (they are Integers) and

Re: optimization of rule-based model on discrete variables

2021-06-15 Thread Elena via Python-list
Il Tue, 15 Jun 2021 10:40:05 +1200, Greg Ewing ha scritto: > On 15/06/21 12:51 am, Elena wrote: > Hmmm, so the problem breaks down into two parts: > (1) find a vector Y that minimises g (2) find a set of rules that will > allow you to predict each component of Y from its corresponding X values >

Re: optimization of rule-based model on discrete variables

2021-06-14 Thread Martin Di Paola
From what I'm understanding it is an "optimization problem" like the ones that you find in "linear programming". But in your case the variables are not Real (they are Integers) and the function to minimize g() is not linear. You could try/explore CVXPY (https://www

Re: optimization of rule-based model on discrete variables

2021-06-14 Thread Greg Ewing
On 15/06/21 12:51 am, Elena wrote: I see what you mean, so I try to explain it better: Y is a vector say [y1, y2, ... yn], with large (n>>10), where yi = f(Xi) with Xi = [x1i, x2i, ... x10i] 1<=i<=n. All yi and xji assume discrete values. I already have a dataset of X={Xi} and would like to find

Re: optimization of rule-based model on discrete variables

2021-06-14 Thread Richard Damon
On 6/13/21 12:15 PM, Elena via Python-list wrote: > Hi, I have, say 10 variables (x1 ... x10) which can assume discrete finite > values, for instance [0,1 or 2]. > I need to build a set of rules, such as: > > 1) if x1==0 and x2==1 and x10==2 then y = 1 > 2) if x2==1 and x3==1 a

Re: optimization of rule-based model on discrete variables

2021-06-14 Thread Elena via Python-list
Il Mon, 14 Jun 2021 19:39:17 +1200, Greg Ewing ha scritto: > On 14/06/21 4:15 am, Elena wrote: >> Given a dataset of X={(x1... x10)} I can calculate Y=f(X) where f is >> this rule-based function. >> >> I know an operator g that can calculate a real value from Y: e = g(Y) >> g is too complex to be

optimization of rule-based model on discrete variables

2021-06-14 Thread Elena via Python-list
Hi, I have, say 10 variables (x1 ... x10) which can assume discrete finite values, for instance [0,1 or 2]. I need to build a set of rules, such as: 1) if x1==0 and x2==1 and x10==2 then y = 1 2) if x2==1 and x3==1 and x4==2 and x6==0 then y = 0 3) if x2==0 and x3==1 then y = 2 4) if x6==0 and

Re: optimization of rule-based model on discrete variables

2021-06-14 Thread Greg Ewing
On 14/06/21 4:15 am, Elena wrote: Given a dataset of X={(x1... x10)} I can calculate Y=f(X) where f is this rule-based function. I know an operator g that can calculate a real value from Y: e = g(Y) g is too complex to be written analytically. I would like to find a set of rules f able to minim

Re: musings on static variables

2020-09-16 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > This C program use a local /static/ variable. > > main.c > > #include > > int f( void ) > { static int i = 0; > return i++; } > > int main( void ) > { printf( "%d\n", f() ); > printf( "%d\n", f() ); > printf( "%d\n", f() ); } > > transcri

Re: Calculations and Variables

2019-11-01 Thread Rhodri James
On 01/11/2019 17:07, MRAB wrote: On 2019-11-01 12:36, Rhodri James wrote: On 31/10/2019 20:14, MRAB wrote: On 2019-10-31 18:46, ferzan saglam wrote: The code below which I have written should print the result of 43.6 with the given values I have included at the end of this question, but for s

Re: Calculations and Variables

2019-11-01 Thread MRAB
On 2019-11-01 12:36, Rhodri James wrote: On 31/10/2019 20:14, MRAB wrote: On 2019-10-31 18:46, ferzan saglam wrote: The code below which I have written should print the result of 43.6 with the given values I have included at the end of this question, but for some odd reason I get the result of

Re: Calculations and Variables

2019-11-01 Thread Rhodri James
On 31/10/2019 20:14, MRAB wrote: On 2019-10-31 18:46, ferzan saglam wrote: The code below which I have written should print the result of 43.6 with the given values I have included at the end of this question, but for some odd reason I get the result of 44.44. bill = (input("Enter the total

Re: Calculations and Variables

2019-10-31 Thread MRAB
On 2019-10-31 18:46, ferzan saglam wrote: The code below which I have written should print the result of 43.6 with the given values I have included at the end of this question, but for some odd reason I get the result of 44.44. bill = (input("Enter the total cost of the meal: \n"))

Re: Calculations and Variables

2019-10-31 Thread Gary Herron
On 10/31/19 11:46 AM, ferzan...@gmail.com wrote: The code below which I have written should print the result of 43.6 with the given values I have included at the end of this question, but for some odd reason I get the result of 44.44. bill = (input("Enter the total cost of the meal: \n"))

RE: Calculations and Variables

2019-10-31 Thread David Raymond
9 2:46 PM To: python-list@python.org Subject: Calculations and Variables The code below which I have written should print the result of 43.6 with the given values I have included at the end of this question, but for some odd reason I get the result of 44.44. bill = (input("Enter

Calculations and Variables

2019-10-31 Thread ferzan saglam
The code below which I have written should print the result of 43.6 with the given values I have included at the end of this question, but for some odd reason I get the result of 44.44. bill = (input("Enter the total cost of the meal: \n"))

Re: decorator needs access to variables where it is used.

2019-10-12 Thread Serhiy Storchaka
09.10.19 14:02, Chris Angelico пише: The decorator has full access to the function object, including a reference to that function's module globals. def trace(func): log = func.__globals__["log"] ... proceed as before As long as you can depend on "log" always being a module-level (glob

Re: decorator needs access to variables where it is used.

2019-10-10 Thread Antoon Pardon
On 9/10/19 13:02, Chris Angelico wrote: > On Wed, Oct 9, 2019 at 9:53 PM Antoon Pardon wrote: >> I have some logging utilities so that when I write library code, I just use >> the following. >> >> from logutil import Logger >> >> log = Logger(__name__) > Are you always absolutely consistent with

Re: decorator needs access to variables where it is used.

2019-10-09 Thread Peter Otten
Antoon Pardon wrote: > I have some logging utilities so that when I write library code, I just > use the following. > > from logutil import Logger > > log = Logger(__name__) If logutil is under your control you can make log a callable object with a tracing method: [logutil.py] class Logger:

Re: decorator needs access to variables where it is used.

2019-10-09 Thread Chris Angelico
On Wed, Oct 9, 2019 at 9:53 PM Antoon Pardon wrote: > > I have some logging utilities so that when I write library code, I just use > the following. > > from logutil import Logger > > log = Logger(__name__) Are you always absolutely consistent with this? Do you always have it as a module-level v

decorator needs access to variables where it is used.

2019-10-09 Thread Antoon Pardon
I have some logging utilities so that when I write library code, I just use the following. from logutil import Logger log = Logger(__name__) And from then on I just use log, to do the logging of that module. But now I would like to write a decorator trace, so that a decorated function would lo

Re: How should we use global variables correctly?

2019-08-23 Thread Joel Goldstick
On Fri, Aug 23, 2019 at 4:00 AM Windson Yang wrote: > > Thank you all. I agreed with Frank that > > > It would make sense to use the 'global' keyword if you have a module > with various functions, several of which refer to 'foo', but only one of > which changes the value of 'foo'. > > I also found

Re: How should we use global variables correctly?

2019-08-23 Thread Windson Yang
Thank you all. I agreed with Frank that > It would make sense to use the 'global' keyword if you have a module with various functions, several of which refer to 'foo', but only one of which changes the value of 'foo'. I also found an example in cpython/lib/gettext.py, only 'textdomain function' c

Re: How should we use global variables correctly?

2019-08-23 Thread Cameron Simpson
On 23Aug2019 09:07, Frank Millman wrote: On 2019-08-23 8:43 AM, Windson Yang wrote: In class.py class Example: def __init__(self): self.foo = 1 def bar() return self.foo + 1 Expect the syntax, why using class variable self.foo would be better (or m

Re: How should we use global variables correctly?

2019-08-23 Thread Cameron Simpson
On 23Aug2019 14:43, Windson Yang wrote: I also want to know what is the difference between "using 'global variables' in a py module" and "using a variable in class". For example: In global.py: foo = 1 def bar(): global foo return foo + 1

Re: How should we use global variables correctly?

2019-08-23 Thread Frank Millman
On 2019-08-23 8:43 AM, Windson Yang wrote: I also want to know what is the difference between "using 'global variables' in a py module" and "using a variable in class". For example: In global.py: foo = 1 def bar(): global foo return foo

Re: How should we use global variables correctly?

2019-08-22 Thread Windson Yang
I also want to know what is the difference between "using 'global variables' in a py module" and "using a variable in class". For example: In global.py: foo = 1 def bar(): global foo return foo + 1 In class.py class Exam

Re: How should we use global variables correctly?

2019-08-22 Thread Chris Angelico
On Fri, Aug 23, 2019 at 11:24 AM Windson Yang wrote: > > Thank you all for the great explanation, I still trying to find some good > example to use 'global', In CPython, I found an example use 'global' in > cpython/Lib/zipfile.py > > _crctable = None > def _gen_crc(crc): > for j in

Re: How should we use global variables correctly?

2019-08-22 Thread Windson Yang
Thank you all for the great explanation, I still trying to find some good example to use 'global', In CPython, I found an example use 'global' in cpython/Lib/zipfile.py _crctable = None def _gen_crc(crc): for j in range(8): if crc & 1: crc = (crc >> 1) ^

Re: How should we use global variables correctly?

2019-08-22 Thread Richard Damon
On 8/22/19 12:00 PM, Windson Yang wrote: > I can 'feel' that global variables are evil. I also read lots of articles > proves that (http://wiki.c2.com/?GlobalVariablesAreBad). However, I found > CPython Lib use quite a lot of `global` keyword. So how should we use > `glo

Re: How should we use global variables correctly?

2019-08-22 Thread Chris Angelico
On Fri, Aug 23, 2019 at 10:18 AM Cameron Simpson wrote: > As Michael says, "you can always read from a parent scope if the name > hasn't been used by the local scope". What this means is this: > > _MODULE_LEVEL_CACHE = {} > > def factors_of(n): > factors = _MODULE_LEVEL_CACHE.get(n

Re: How should we use global variables correctly?

2019-08-22 Thread Cameron Simpson
On 22Aug2019 11:12, Michael Torrie wrote: On 8/22/19 10:00 AM, Windson Yang wrote: I can 'feel' that global variables are evil. I also read lots of articles proves that (http://wiki.c2.com/?GlobalVariablesAreBad). However, I found CPython Lib use quite a lot of `global` keyword. So

Re: How should we use global variables correctly?

2019-08-22 Thread Michael Torrie
On 8/22/19 10:00 AM, Windson Yang wrote: > I can 'feel' that global variables are evil. I also read lots of articles > proves that (http://wiki.c2.com/?GlobalVariablesAreBad). However, I found > CPython Lib use quite a lot of `global` keyword. So how should we use > `glo

How should we use global variables correctly?

2019-08-22 Thread Windson Yang
I can 'feel' that global variables are evil. I also read lots of articles proves that (http://wiki.c2.com/?GlobalVariablesAreBad). However, I found CPython Lib use quite a lot of `global` keyword. So how should we use `global` keyword correctly? IIUC, it's fine that we use `global`

Re: How Do You Replace Variables With Their Values?

2019-07-14 Thread Chris Angelico
do you replace a > > > variable with its value". For what i understood with the example values, > > > CrazyVideoGamez wants 3 variables named like the meal-names in > dictionary. > > > Yes, it's not secure unless you work with your own dataset (just like >

Re: How Do You Replace Variables With Their Values?

2019-07-14 Thread Ian Kelly
example values, > > CrazyVideoGamez wants 3 variables named like the meal-names in dictionary. > > Yes, it's not secure unless you work with your own dataset (just like > > sending your own created commands with set=True in subprocess). Yes there > > might be bet

Re: How Do You Replace Variables With Their Values?

2019-07-11 Thread Chris Angelico
On Fri, Jul 12, 2019 at 2:30 PM Aldwin Pollefeyt wrote: > > Wow, I'm so sorry I answered on the question : "How do you replace a > variable with its value". For what i understood with the example values, > CrazyVideoGamez wants 3 variables named like the meal-names in

Re: How Do You Replace Variables With Their Values?

2019-07-11 Thread Aldwin Pollefeyt
Wow, I'm so sorry I answered on the question : "How do you replace a variable with its value". For what i understood with the example values, CrazyVideoGamez wants 3 variables named like the meal-names in dictionary. Yes, it's not secure unless you work with your own datase

Re: How Do You Replace Variables With Their Values?

2019-07-11 Thread Ben Finney
Aldwin Pollefeyt writes: > dinner = {'Starters':['Fried Calamari', 'Potted crab'],'Main > Course':['Fish', 'Meat'], 'Desert':['Cake', 'Banana Split']} > > # Don't ask where I got the dinner from > > for meal in dinner.keys(): > exec(meal.replace(' ','_') + ' = list(dinner[meal])') > > print(S

Re: How Do You Replace Variables With Their Values?

2019-07-11 Thread Chris Angelico
On Fri, Jul 12, 2019 at 4:37 AM Terry Reedy wrote: > > On 7/11/2019 12:51 AM, Aldwin Pollefeyt wrote: > > dinner = {'Starters':['Fried Calamari', 'Potted crab'],'Main > > Course':['Fish', 'Meat'], 'Desert':['Cake', 'Banana Split']} > > > > # Don't ask where I got the dinner from > > > > for meal i

Re: How Do You Replace Variables With Their Values?

2019-07-11 Thread Rhodri James
On 11/07/2019 05:51, Aldwin Pollefeyt wrote: dinner = {'Starters':['Fried Calamari', 'Potted crab'],'Main Course':['Fish', 'Meat'], 'Desert':['Cake', 'Banana Split']} # Don't ask where I got the dinner from for meal in dinner.keys(): exec(meal.replace(' ','_') + ' = list(dinner[meal])') p

Re: How Do You Replace Variables With Their Values?

2019-07-11 Thread Terry Reedy
On 7/11/2019 12:51 AM, Aldwin Pollefeyt wrote: dinner = {'Starters':['Fried Calamari', 'Potted crab'],'Main Course':['Fish', 'Meat'], 'Desert':['Cake', 'Banana Split']} # Don't ask where I got the dinner from for meal in dinner.keys(): exec(meal.replace(' ','_') + ' = list(dinner[meal])')

Re: How Do You Replace Variables With Their Values?

2019-07-11 Thread Aldwin Pollefeyt
dinner = {'Starters':['Fried Calamari', 'Potted crab'],'Main Course':['Fish', 'Meat'], 'Desert':['Cake', 'Banana Split']} # Don't ask where I got the dinner from for meal in dinner.keys(): exec(meal.replace(' ','_') + ' = list(dinner[meal])') print(Starters) print(Main_Course) print(Desert)

Re: How Do You Replace Variables With Their Values?

2019-07-10 Thread Frank Millman
On 2019-07-11 12:43 AM, CrazyVideoGamez wrote: How do you replace a variable with its value in python 3.7.2? For example, say I have: dinner = {'Starters':['Fried Calamari', 'Potted crab'],'Main Course':['Fish', 'Meat'], 'Desert':['Cake', 'Banana Split']} # Don't ask where I got the dinner fr

Re: How Do You Replace Variables With Their Values?

2019-07-10 Thread Ben Finney
Terry Reedy writes: > On 7/10/2019 6:37 PM, CrazyVideoGamez wrote: > > > and I'm just changing it with the code above (you can find that by > > printing it out). How can I make separate lists called 'Starters', > > 'Main Course', and 'Desert'? > > starters = dinner['Starters'] > main_course = din

Re: How Do You Replace Variables With Their Values?

2019-07-10 Thread Terry Reedy
On 7/10/2019 6:37 PM, CrazyVideoGamez wrote: the below twice. Please post just once and be patient for at least a couple of hours -- or days if not subscribed. How do you replace a variable with its value in python 3.7.2? Use the variable (name) in an expression. But this is not what you

How Do You Replace Variables With Their Values?

2019-07-10 Thread CrazyVideoGamez
How do you replace a variable with its value in python 3.7.2? For example, say I have: dinner = {'Starters':['Fried Calamari', 'Potted crab'],'Main Course':['Fish', 'Meat'], 'Desert':['Cake', 'Banana Split']} # Don't ask where I got the dinner from for meal in dinner.keys(): meal = l

How Do You Replace Variables With Their Values?

2019-07-10 Thread CrazyVideoGamez
How do you replace a variable with its value in python 3.7.2? For example, say I have: dinner = {'Starters':['Fried Calamari', 'Potted crab'],'Main Course':['Fish', 'Meat'], 'Desert':['Cake', 'Banana Split']} # Don't ask where I got the dinner from for meal in dinner.keys(): meal = lis

Selection based ob variables issue

2019-02-01 Thread vergos . nikolas
Hello, iam tryting to execute mysql queries based on python variables. name = request.args.get('name') month = request.args.get('month') year = request.args.get('year') try: if '=' not in name + month + y

Re: Deletion of Environmental Variables

2019-01-06 Thread Paul Moore
On Mon, 7 Jan 2019 at 06:37, Terry Reedy wrote: > The pydev recommended way to run pip on windows is > > py -x.y pip > as this installs the package requested into the x.y site-packages > directory. py -3.7 -m pip ... Note the extra -m). Paul -- https://mail.python.org/mailman/listinfo/python

Re: Deletion of Environmental Variables

2019-01-06 Thread Terry Reedy
On 1/6/2019 9:56 PM, Logan Vogelsong wrote: I planned on using python to simulate different cipher to challenge myself, but I kinda deleted my environmental variables to python. I run Windows 10 and wanted to get NumPy and MatPlotLib modules imported to python. Basically, I downloaded python

Deletion of Environmental Variables

2019-01-06 Thread Logan Vogelsong
Hello- I think I subscribed now. I planned on using python to simulate different cipher to challenge myself, but I kinda deleted my environmental variables to python. I run Windows 10 and wanted to get NumPy and MatPlotLib modules imported to python. Basically, I downloaded python 3.7.1

Re: coding style - where to declare variables

2018-07-23 Thread Steven D'Aprano
also include integers. Intuitively, a value is an expression that can not be reduced/executed/simplified any further." [...] > The lambda calculus comment is just an aside. The main point is that you > shouldn't lead people to believe that Python has variables that are any >

Re: coding style - where to declare variables

2018-07-23 Thread Chris Angelico
On Mon, Jul 23, 2018 at 9:39 PM, Steven D'Aprano wrote: > [1] The CPython interpreter uses pointers; the Jython interpreter uses > whatever kind of memory indirection the JVM provides; when I emulate a > Python interpreter using pencil and paper, there's not a pointer in sight > but a lot of copyi

Re: coding style - where to declare variables

2018-07-23 Thread Steven D'Aprano
ntics of the Python language, there are no pointer values, no way to get a pointer to a memory location or a pointer to an object. No expression in Python evaluates to a pointer, no variables hold pointers in Python. The Python language is defined in terms of objects: expressions evaluate to objects,

Re: coding style - where to declare variables

2018-07-23 Thread Marko Rauhamaa
erms to mean > something *almost identical* to what they mean in lambda calculus. > (The only difference I can see is that lambda calculus treats > variables as abstract mathematical entities, while Python and other > programming languages vivify them and give them a concrete > implem

Re: coding style - where to declare variables

2018-07-23 Thread Steven D'Aprano
On Mon, 23 Jul 2018 11:49:37 +0300, Marko Rauhamaa wrote: > People new to Python are unnecessarily confused by talking about names > and binding when it's really just ordinary variables and assignment. It really isn't, not to those people who expect ordinary variables and assi

Re: coding style - where to declare variables

2018-07-23 Thread Ben Bacarisse
Mark Lawrence writes: > On 22/07/18 14:51, Abdur-Rahmaan Janhangeer wrote: >> except local vars >> >> Abdur-Rahmaan Janhangeer >> https://github.com/Abdur-rahmaanJ >> Mauritius >> > > Python doesn't have variables, it has names. I think we shoul

Re: coding style - where to declare variables

2018-07-23 Thread Steven D'Aprano
le" vs. a "non-local > variable". Actually, no, they are called "bound variable" and "free variable" in Python too. https://docs.python.org/3/reference/executionmodel.html See also: http://effbot.org/zone/closure.htm Alas, I don't think Fredrik Lundh got it *quite* ri

Re: coding style - where to declare variables

2018-07-23 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:87zhyitjz2@elektro.pacujo.net... People new to Python are unnecessarily confused by talking about names and binding when it's really just ordinary variables and assignment. It seems to be mostly some sort of marketing lingo that seeks t

Re: coding style - where to declare variables

2018-07-23 Thread Marko Rauhamaa
; “variable” for what is, in Python, an un-typed reference to an object. > > I expect both of these requests to meet with little satisfaction. I'm actually not asking, only wishing. People new to Python are unnecessarily confused by talking about names and binding when it's rea

Re: coding style - where to declare variables

2018-07-23 Thread Ben Finney
Gregory Ewing writes: > Marko is asking us to stop using the word "binding" to refer to > assignment because of the potential confusion with this other meaning. That's about as reasonable as my request that we stop using the term “variable” for what is, in Python, an un-typed reference to an obj

Re: coding style - where to declare variables

2018-07-23 Thread Gregory Ewing
Steven D'Aprano wrote: So let me see if I understand your argument... - we should stop using the term "binding", because it means nothing different from assignment; - binding (a.k.a. "assignment") comes from lambda calculus; - which has no assignment (a.k.a. "binding"). No, that's not what

Re: coding style - where to declare variables

2018-07-22 Thread Marko Rauhamaa
Dennis Lee Bieber : > On Mon, 23 Jul 2018 00:08:00 +0300, Marko Rauhamaa > declaimed the following: > >>I Java terms, all Python values are boxed. That's a very usual pattern >>in virtually all programming languages (apart from FORTRAN). > > FORTRAN, C, COBOL, BASIC, Pascal, ALGOL, BCPL, REX

Re: coding style - where to declare variables

2018-07-22 Thread Abdur-Rahmaan Janhangeer
variables here refers to the user experience of a var np, just a link to the thread/s would mark the end of it Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius -- https://mail.python.org/mailman/listinfo/python-list

Re: coding style - where to declare variables

2018-07-22 Thread Mark Lawrence
On 22/07/18 14:51, Abdur-Rahmaan Janhangeer wrote: except local vars Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius Python doesn't have variables, it has names. Please can we avoid a long meaningless thread on this subject as it's been discussed a trill

Re: coding style - where to declare variables

2018-07-22 Thread Steven D'Aprano
and Python are the ones that are not "common". Indeed. Its not just older languages from the 60s and 70s with value-type variables. Newer languages intended as systems languages, like Rust and Go, do the same. -- Steven D'Aprano "Ever since I learned about confirmation bias

Re: coding style - where to declare variables

2018-07-22 Thread Steven D'Aprano
the stack) and "reference types" (usually objects stored in the heap). C# and other .Net languages often make that distinction: http://net-informations.com/faq/general/valuetype-referencetype.htm Swift is another such language. Other languages which use primarily or exclusively value-types (i.

Re: coding style - where to declare variables

2018-07-22 Thread Steven D'Aprano
cs is defined > using "bound" and "free" variables. Lambda calculus doesn't have > assignment. So let me see if I understand your argument... - we should stop using the term "binding", because it means nothing different from assignment; - binding (a

Re: coding style - where to declare variables

2018-07-22 Thread Marko Rauhamaa
m lambda calculus, whose semantics is defined >> using "bound" and "free" variables. Lambda calculus doesn't have >> assignment. > > Marko, I think the term binding makes sense in python due to how names > work. In python and the following code: > &

Re: coding style - where to declare variables

2018-07-22 Thread Chris Angelico
On Mon, Jul 23, 2018 at 6:14 AM, Marko Rauhamaa wrote: > While FORTRAN or C couldn't operate on functions like this, an assembly > language program could easily. Simply compose a CPU instruction sequence > on the fly, mark it executable and use the "CALL" opcode to transfer > control to your const

Re: coding style - where to declare variables

2018-07-22 Thread Marko Rauhamaa
two to create a third function: def compose(f1, f2): def composition(x): return f1(f2(x)) return composition Here "compose", "composition", "f1" and "f2" are variables: * "compose" gets assigned when the first, outer "

Re: coding style - where to declare variables

2018-07-22 Thread Richard Damon
ntics is defined > using "bound" and "free" variables. Lambda calculus doesn't have > assignment. > > More about variable binding here: https://en.wikipedia.org/wiki/Free_variables_and_bound_variables> > > > Marko Marko, I think the term binding ma

Re: coding style - where to declare variables

2018-07-22 Thread Marko Rauhamaa
r...@zedat.fu-berlin.de (Stefan Ram): >>Rebinding names is near-universal in programming, but usually names >>that are intended to be rebound, such as variables. > > To someone like me who has grown up with a LISP 1 > this is completely natural. > > |>( SETQ A (

Re: coding style - where to declare variables

2018-07-22 Thread Peter J. Holzer
On 2018-07-22 09:36:13 -0400, Richard Damon wrote: > > On Jul 22, 2018, at 8:48 AM, Sharan Basappa > > wrote: > > > > In other programming languages (e.g. C, C++), as a good practice, > > variables are declared right at the start of the program, There is no &q

Re: coding style - where to declare variables

2018-07-22 Thread Abdur-Rahmaan Janhangeer
except local vars Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius -- https://mail.python.org/mailman/listinfo/python-list

Re: coding style - where to declare variables

2018-07-22 Thread Chris Angelico
On Sun, Jul 22, 2018 at 10:48 PM, Sharan Basappa wrote: > In other programming languages (e.g. C, C++), as a good practice, variables > are declared right at the start of the program, irrespective of where it is > normally used. What is the practice in Python? > > I see that, m

Re: coding style - where to declare variables

2018-07-22 Thread Richard Damon
> On Jul 22, 2018, at 8:48 AM, Sharan Basappa wrote: > > In other programming languages (e.g. C, C++), as a good practice, variables > are declared right at the start of the program, irrespective of where it is > normally used. What is the practice in Python? > > I

coding style - where to declare variables

2018-07-22 Thread Sharan Basappa
In other programming languages (e.g. C, C++), as a good practice, variables are declared right at the start of the program, irrespective of where it is normally used. What is the practice in Python? I see that, most of the code, declare variables where it is used and not at the start of the

Re: configparser v/s file variables

2018-06-28 Thread Jim Lee
On 06/28/18 16:44, Steven D'Aprano wrote: I agree with you that it's a bad idea. Aside from the little fact that you described concerns about using Python code for settings as "silly". Umm, no.  I said that worrying about arbitrary code execution in an interpreted language seemed silly. 

Re: configparser v/s file variables

2018-06-28 Thread Steven D'Aprano
On Thu, 28 Jun 2018 10:58:36 -0700, Jim Lee wrote: > On 06/28/18 07:30, Grant Edwards wrote: >> I still maintain it's a bad idea to run arbitrary code found in >> user-edited config files. >> >> There may be cases where somebody has figured out how to muck with a >> config file that's shared among

Re: configparser v/s file variables

2018-06-28 Thread Jim Lee
On 06/28/18 07:30, Grant Edwards wrote: I still maintain it's a bad idea to run arbitrary code found in user-edited config files. There may be cases where somebody has figured out how to muck with a config file that's shared among multiple users, or has tricked somebody into including somethin

Re: configparser v/s file variables

2018-06-28 Thread Jim Lee
trust them not to, there's no point in locking the door to the house when I go out, since they have a key." Not exactly.  The original question was about reading config variables from a file in Python.  That sort of thing didn't suggest (to me) a world-facing web app or other s

Re: configparser v/s file variables

2018-06-28 Thread Grant Edwards
On 2018-06-28, Steven D'Aprano wrote: > So why give them the ability to escalate their privilege to that of > your application (which probably can do lots of things they can't > do) by directly executing Python code they supply? To be fair, that situation isn't common. The vast majority of appl

Re: configparser v/s file variables

2018-06-28 Thread Steven D'Aprano
On Wed, 27 Jun 2018 16:09:09 -0700, Jim Lee wrote: > On 06/27/18 15:19, Steven D'Aprano wrote: >> On Wed, 27 Jun 2018 12:15:23 -0700, Jim Lee wrote: >> >>>   It seems a bit silly to me to worry about arbitrary code >>>   execution in >>> an interpreted language like Python whose default runtim

Re: configparser v/s file variables

2018-06-27 Thread Jim Lee
On 06/27/18 15:19, Steven D'Aprano wrote: On Wed, 27 Jun 2018 12:15:23 -0700, Jim Lee wrote:   It seems a bit silly to me to worry about arbitrary code execution   in an interpreted language like Python whose default runtime execution method is to parse the source code directly.  An attac

Re: configparser v/s file variables

2018-06-27 Thread Steven D'Aprano
On Wed, 27 Jun 2018 12:15:23 -0700, Jim Lee wrote: >   It seems a bit silly to me to worry about arbitrary code execution >   in > an interpreted language like Python whose default runtime execution > method is to parse the source code directly.  An attacker would be far > more likely to simply

Re: configparser v/s file variables

2018-06-27 Thread Abdur-Rahmaan Janhangeer
i think variables also in the case of PORT = 12345 Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ And it doesn't require that the end user have any knowlege of Python > syntax or sematics. > -- https://mail.python.org/mailman/listinfo/python-list

Re: configparser v/s file variables

2018-06-27 Thread Grant Edwards
On 2018-06-27, Jim Lee wrote: >  It seems a bit silly to me to worry about arbitrary code > execution in an interpreted language like Python whose default > runtime execution method is to parse the source code directly.  Maybe it's not a deliberate attack. Good application design is also about

Re: configparser v/s file variables

2018-06-27 Thread Rob Gaddi
On 06/27/2018 12:15 PM, Jim Lee wrote: On 06/27/18 11:45, Abdur-Rahmaan Janhangeer wrote: and that closes it, thanks !!! Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Importing variables from a file is dangerous because it can execute arbitrary code.  It should never be done

Re: configparser v/s file variables

2018-06-27 Thread Jim Lee
On 06/27/18 11:45, Abdur-Rahmaan Janhangeer wrote: and that closes it, thanks !!! Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Importing variables from a file is dangerous because it can execute arbitrary code. It should never be done with files provided by the user. Using

Re: configparser v/s file variables

2018-06-27 Thread Abdur-Rahmaan Janhangeer
and that closes it, thanks !!! Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Importing variables from a file is dangerous because it can execute > arbitrary code. It should never be done with files provided by the > user. > > Using configparser is far, far safer.

Re: configparser v/s file variables

2018-06-27 Thread Grant Edwards
On 2018-06-27, Abdur-Rahmaan Janhangeer wrote: > what is more recommended and why? using configparser for settings or import > variables from file? Importing variables from a file is dangerous because it can execute arbitrary code. It should never be done with files provided by the user.

  1   2   3   4   5   6   7   8   9   10   >