Re: Importing variables non-deterministic?

2013-08-19 Thread Antoon Pardon
Op 20-08-13 07:48, Steven D'Aprano schreef: > On Mon, 19 Aug 2013 22:34:00 +0200, Antoon Pardon wrote: > >> Op 19-08-13 19:05, Steven D'Aprano schreef: >> >> >>> I wish Python had stronger support for enforcing constantness, to whit, >>> some way to say "you can't rebind or delete this name once i

Re: Importing variables non-deterministic?

2013-08-19 Thread wxjmfauth
Le mardi 20 août 2013 07:48:37 UTC+2, Steven D'Aprano a écrit : > On Mon, 19 Aug 2013 22:34:00 +0200, Antoon Pardon wrote: > > > > > Op 19-08-13 19:05, Steven D'Aprano schreef: > > > > > > > > >> I wish Python had stronger support for enforcing constantness, to whit, > > >> some way to say

Re: refresing the edited python function

2013-08-19 Thread dieter
Sudheer Joseph writes: > ... > I wonder how the code developers work in this case > every time a function is modified one has to restart the console is a > nightmare... I use the "reload" approach a lot when developing isolated classes or functions and "plone.reload" for

Re: Is this PEP-able? (syntax for functools.partial-like functionality)

2013-08-19 Thread Steven D'Aprano
On Tue, 20 Aug 2013 00:49:16 +0100, Fábio Santos wrote: > I had an idea for a handy syntax which I thought of while designing a > language for fun. This would be a syntax for creating, from a function, > a function which is just like it but with some parameters pre-filled. > The usage is much like

Re: Importing variables non-deterministic?

2013-08-19 Thread Steven D'Aprano
On Mon, 19 Aug 2013 22:34:00 +0200, Antoon Pardon wrote: > Op 19-08-13 19:05, Steven D'Aprano schreef: > > >> I wish Python had stronger support for enforcing constantness, to whit, >> some way to say "you can't rebind or delete this name once it is >> bound". You can do it with attributes, by u

Re: default python os x

2013-08-19 Thread Steven D'Aprano
On Mon, 19 Aug 2013 22:24:46 +0200, Uwe Rangs wrote: > My workflow at the moment is to set a link: mv python python_old > ln -s /usr/local/bin/python3.2 python > > But is this a good idea? You should never change the system Python, since that runs the risk of breaking system tools that expect

Re: make elements of a list twice or more.

2013-08-19 Thread alex23
On 7/08/2013 6:50 PM, liuerfire Wang wrote: > Here is a list x = [b, a, c] (a, b, c are elements of x. Each of them > are different type). Now I wanna generate a new list as [b, b, a, a, c, c]. from itertools import chain new_list = list(chain.from_iterable(zip(x,x))) -- http://mail.python.org

Re: refresing the edited python function

2013-08-19 Thread Roy Smith
In article , Ben Finney wrote: > Developers use the interactive console for exploring, not developing. I am reminded of a (very strange) guy I went to school with. He linked /dev/tty to /dev/tty.c. That allowed him to run "cc /dev/tty.c" and type in the text of a C program to compile. -- h

Re: Importing variables non-deterministic?

2013-08-19 Thread Ben Finney
Antoon Pardon writes: > Op 19-08-13 09:45, Dave Angel schreef: > > Antoon Pardon wrote: > >> I think you are overstating your case. Classes and functions are > >> variables too and in general nobody seems to have a problem with > >> them being global. > > > > It's global *variables* that are to

Re: refresing the edited python function

2013-08-19 Thread Ben Finney
Sudheer Joseph writes: > I wonder how the code developers work in this case every time a > function is modified one has to restart the console is a nightmare... Developers use the interactive console for exploring, not developing. Use it to test, to confirm a suspicion about what a function cal

Is this PEP-able? (syntax for functools.partial-like functionality)

2013-08-19 Thread Fábio Santos
I had an idea for a handy syntax which I thought of while designing a language for fun. This would be a syntax for creating, from a function, a function which is just like it but with some parameters pre-filled. The usage is much like functools.partials, and my proposed syntax is like this: def sp

Re: default python os x

2013-08-19 Thread Joel Goldstick
On Mon, Aug 19, 2013 at 4:14 PM, Uwe Rangs wrote: > Hello, > > how can I change the default version of python with os x 10.7. > > Thanks, > Uwe > > -- > http://mail.python.org/mailman/listinfo/python-list You might want to look at this: http://stackoverflow.com/questions/5846167/how-to-change-d

Re: default python os x

2013-08-19 Thread Uwe Rangs
My workflow at the moment is to set a link: mv python python_old ln -s /usr/local/bin/python3.2 python But is this a good idea? -- Uwe On 2013-08-19 20:14:04 +, Uwe Rangs said: Hello, how can I change the default version of python with os x 10.7. Thanks, Uwe -- http://mail.python.org

Re: Importing variables non-deterministic?

2013-08-19 Thread Antoon Pardon
Op 19-08-13 19:05, Steven D'Aprano schreef: I wish Python had stronger support for enforcing constantness, to whit, some way to say "you can't rebind or delete this name once it is bound". You can do it with attributes, by use of property, or in C extensions, but you cannot do it with top-level

default python os x

2013-08-19 Thread Uwe Rangs
Hello, how can I change the default version of python with os x 10.7. Thanks, Uwe -- http://mail.python.org/mailman/listinfo/python-list

Re: opposite of __init__.py

2013-08-19 Thread Dave Angel
Tamer Higazi wrote: > Hi people! > > I have asked myself a question, if there is a opposite of "__init__.py" > like "__del__.py" ?! Others have answered your question, but I wanted to correct a misunderstanding: > > I want, that when the application ends, certain functions are executed. > I know

Re: Importing variables non-deterministic?

2013-08-19 Thread Antoon Pardon
Op 19-08-13 18:57, Steven D'Aprano schreef: On Mon, 19 Aug 2013 10:16:36 +0200, Antoon Pardon wrote: Op 19-08-13 09:45, Dave Angel schreef: Antoon Pardon wrote: Op 17-08-13 17:01, Steven D'Aprano schreef: And here you re-import the name "y" from struct_global. That rebinds the current modu

Re: Importing variables non-deterministic?

2013-08-19 Thread Antoon Pardon
Op 19-08-13 17:04, Chris Angelico schreef: On Mon, Aug 19, 2013 at 3:55 PM, Antoon Pardon wrote: Pity enough they chose a way that didn't allow programmers to protect names they thought important enough to do so too. As of Python 3, we can redefine something that used to be a keyword, which i

Re: Importing variables non-deterministic?

2013-08-19 Thread Chris Angelico
On Mon, Aug 19, 2013 at 6:16 PM, Steven D'Aprano wrote: > On Mon, 19 Aug 2013 16:57:37 +, Steven D'Aprano wrote: > >> def func(x): >> ... >> >> # later >> save_func = func >> func = lambda x, y: do_stuff(x, 3*y)-4 result = >> something_that_calls_func() >> func = save_func >> >> >> Nasty,

Re: Importing variables non-deterministic?

2013-08-19 Thread Steven D'Aprano
On Mon, 19 Aug 2013 16:57:37 +, Steven D'Aprano wrote: > def func(x): > ... > > # later > save_func = func > func = lambda x, y: do_stuff(x, 3*y)-4 result = > something_that_calls_func() > func = save_func > > > Nasty, horrible code, yes? But it's nasty and horrible because "func" is >

Re: refresing the edited python function

2013-08-19 Thread Sudheer Joseph
- Original Message - > From: Dave Angel > To: python-list@python.org > Cc: > Sent: Monday, 19 August 2013 4:45 PM > Subject: Re: refresing the edited python function > > Sudheer Joseph wrote: > >> Thank you Dieter, >> I never thought it will be so difficult task,

Re: opposite of __init__.py

2013-08-19 Thread Steven D'Aprano
On Mon, 19 Aug 2013 18:48:19 +0200, Tamer Higazi wrote: > Hi people! > > I have asked myself a question, if there is a opposite of "__init__.py" > like "__del__.py" ?! No. If you want to run code when your application is shutting down, run it just before your code finishes: def main(): do_t

Re: Importing variables non-deterministic?

2013-08-19 Thread Steven D'Aprano
On Mon, 19 Aug 2013 09:32:53 +0100, Chris Angelico wrote: > Python does have constants. It just doesn't have interpreter support for > them. Same as private members, in fact. "Constant by convention". I wish Python had stronger support for enforcing constantness, to whit, some way to say "you c

Re: opposite of __init__.py

2013-08-19 Thread Ian Kelly
Yes, see the atexit module: http://docs.python.org/3/library/atexit.html On Mon, Aug 19, 2013 at 10:48 AM, Tamer Higazi wrote: > Hi people! > > I have asked myself a question, if there is a opposite of "__init__.py" > like "__del__.py" ?! > > I want, that when the application ends, certain funct

Re: Importing variables non-deterministic?

2013-08-19 Thread Steven D'Aprano
On Mon, 19 Aug 2013 10:16:36 +0200, Antoon Pardon wrote: > Op 19-08-13 09:45, Dave Angel schreef: >> Antoon Pardon wrote: >> >>> Op 17-08-13 17:01, Steven D'Aprano schreef: And here you re-import the name "y" from struct_global. That rebinds the current module's "y" with whatever v

opposite of __init__.py

2013-08-19 Thread Tamer Higazi
Hi people! I have asked myself a question, if there is a opposite of "__init__.py" like "__del__.py" ?! I want, that when the application ends, certain functions are executed. I know I could make a constructor and a destructor, but I simply want to know if there is a opposite Thanks Tame

Re: Importing variables non-deterministic?

2013-08-19 Thread Chris Angelico
On Mon, Aug 19, 2013 at 3:55 PM, Antoon Pardon wrote: > Pity enough they chose a > way that didn't allow programmers to protect names they thought > important enough to do so too. As of Python 3, we can redefine something that used to be a keyword, which is even stronger than a constant. def pri

Re: Importing variables non-deterministic?

2013-08-19 Thread Antoon Pardon
Op 19-08-13 14:33, Dave Angel schreef: > Antoon Pardon wrote: > >> Op 19-08-13 11:18, Chris Angelico schreef: > >>> The issue >>> was regarding imports, and it's perfectly safe to import a constant, >>> even if the interpreter doesn't protect you from then being a total >>> idiot and changing

Re: Question about crypto

2013-08-19 Thread Anthony Papillion
On 08/18/2013 05:52 PM, Roy Smith wrote: > In article , > Anthony Papillion wrote: > >> I've just started working with the Crypto library and I've already run >> into a wall even though I'm following a tutorial. Basically, I'm trying >> to encrypt a string using AES in CBC mode. Here is the code

Re: Importing variables non-deterministic?

2013-08-19 Thread Dave Angel
Antoon Pardon wrote: > Op 19-08-13 11:18, Chris Angelico schreef: >> The issue >> was regarding imports, and it's perfectly safe to import a constant, >> even if the interpreter doesn't protect you from then being a total >> idiot and changing it. > > Python doesn't have constants, so you sta

Re: Question about crypto

2013-08-19 Thread Anthony Papillion
On 08/18/2013 05:29 PM, Skip Montanaro wrote: >> When I run the code above, I am told that the IV must be 16 bytes long. >> I'm assuming that the IV (I know that means "Initialization Vector") is >> either the key OR something else I can set. But I don't know how or what >> to do. > > Does this St

Re: Importing variables non-deterministic?

2013-08-19 Thread Antoon Pardon
Op 19-08-13 11:18, Chris Angelico schreef: > On Mon, Aug 19, 2013 at 10:03 AM, Antoon Pardon > wrote: >> This is irrelevant. That some context defines a constant, and that you >> can use a variable with the same name as a constant in python, doesn't >> contradict the statement that python (as a la

Re: NodeTransformer: how to remove nodes?

2013-08-19 Thread Peter Otten
Tobias Müller wrote: > I'm facing an issue with NodeTransformer, a tool used for Python AST > manipulations. > > Last week I posted on stackoverflow.com, but there are no responses yet. > Maybe someone reading the mailing list can have a look and leave me a > response here or over there? > > htt

Re: refresing the edited python function

2013-08-19 Thread Dave Angel
Sudheer Joseph wrote: > Thank you Dieter, > I never thought it will be so difficult task, All I was > thinking was that, I just do not know how it is done. I wonder how the code > developers work in this case every time a function is modified one has to > restart the consol

Re: NodeTransformer: how to remove nodes?

2013-08-19 Thread Chris Angelico
On Mon, Aug 19, 2013 at 10:19 AM, Tobias Müller wrote: > Hi > > I'm facing an issue with NodeTransformer, a tool used for Python AST > manipulations. > > Last week I posted on stackoverflow.com, but there are no responses yet. > Maybe someone reading the mailing list can have a look and leave me a

NodeTransformer: how to remove nodes?

2013-08-19 Thread Tobias Müller
Hi I'm facing an issue with NodeTransformer, a tool used for Python AST manipulations. Last week I posted on stackoverflow.com, but there are no responses yet. Maybe someone reading the mailing list can have a look and leave me a response here or over there? http://stackoverflow.com/questions/18

Re: Importing variables non-deterministic?

2013-08-19 Thread Peter Otten
Chris Angelico wrote: > On Mon, Aug 19, 2013 at 10:03 AM, Antoon Pardon > wrote: >> This is irrelevant. That some context defines a constant, and that you >> can use a variable with the same name as a constant in python, doesn't >> contradict the statement that python (as a language) doesn't has

Re: Importing variables non-deterministic?

2013-08-19 Thread Chris Angelico
On Mon, Aug 19, 2013 at 10:03 AM, Antoon Pardon wrote: > This is irrelevant. That some context defines a constant, and that you > can use a variable with the same name as a constant in python, doesn't > contradict the statement that python (as a language) doesn't has > constants. There is nothing

Re: Importing variables non-deterministic?

2013-08-19 Thread Antoon Pardon
Op 19-08-13 10:32, Chris Angelico schreef: > On Mon, Aug 19, 2013 at 9:16 AM, Antoon Pardon > wrote: >> Op 19-08-13 09:45, Dave Angel schreef: >>> Antoon Pardon wrote: I think you are overstating your case. Classes and functions are variables too and in general nobody seems to have a pro

Re: refresing the edited python function

2013-08-19 Thread Sudheer Joseph
Thank you Dieter, I never thought it will be so difficult task, All I was thinking was that, I just do not know how it is done. I wonder how the code developers work in this case every time a function is modified one has to restart the console is a nightmare... Hope one day

Re: Importing variables non-deterministic?

2013-08-19 Thread Chris Angelico
On Mon, Aug 19, 2013 at 9:16 AM, Antoon Pardon wrote: > Op 19-08-13 09:45, Dave Angel schreef: >> Antoon Pardon wrote: >>> I think you are overstating your case. Classes and functions are >>> variables too and in general nobody seems to have a problem with them >>> being global. >>> >> >> It's glo

Re: Importing variables non-deterministic?

2013-08-19 Thread Antoon Pardon
Op 19-08-13 09:45, Dave Angel schreef: > Antoon Pardon wrote: > >> Op 17-08-13 17:01, Steven D'Aprano schreef: >>> >>> And here you re-import the name "y" from struct_global. That rebinds the >>> current module's "y" with whatever value struct_global.y has *now*, >>> rather than a second (or a m

Re: Importing variables non-deterministic?

2013-08-19 Thread Dave Angel
Antoon Pardon wrote: > Op 17-08-13 17:01, Steven D'Aprano schreef: >> >> And here you re-import the name "y" from struct_global. That rebinds the >> current module's "y" with whatever value struct_global.y has *now*, >> rather than a second (or a minute, or an hour) earlier when the first >> i

Re: How to I do this in Python ?

2013-08-19 Thread Steven D'Aprano
On Sun, 18 Aug 2013 22:36:01 +0530, Ganesh Pal wrote: > Please find the comments >>> inline Please don't do that! "Arrows" > are used for quoting in emails. If you prefix your *new* comments using >>> it looks like they were quoted *three messages back*. You should be able to configure your em

Re: Importing variables non-deterministic?

2013-08-19 Thread Antoon Pardon
Op 17-08-13 17:01, Steven D'Aprano schreef: > > And here you re-import the name "y" from struct_global. That rebinds the > current module's "y" with whatever value struct_global.y has *now*, > rather than a second (or a minute, or an hour) earlier when the first > import took place. Obviously a

Re: Encapsulation unpythonic?

2013-08-19 Thread Steven D'Aprano
On Sun, 18 Aug 2013 18:15:10 +0100, Joshua Landau wrote: > On 17 August 2013 17:17, Steven D'Aprano > wrote: >> On Sat, 17 Aug 2013 05:26:32 -0700, fsaldan1 wrote: >>> how do I >>> deal with the fact that other programmers can easily alter the values >>> of members of my classes? >> ... >> If the