Re: What exactly is a python variable?

2016-11-17 Thread Ben Finney
Ned Batchelder writes: > So it's not a bug, and it also is not a feature. It just is. +1 QotW -- \“A free press is one where it's okay to state the conclusion | `\ you're led to by the evidence.” —Bill Moyers | _o__)

Unable to sniff outgoing traffic using raw sockets in python2.7

2016-11-17 Thread Ayush Aggarwal
Hello, Following is my code : #!/usr/bin/python import socket import struct import binascii rawSocket = socket.socket(socket.PF_PACKET,socket.SOCK_RAW,socket.htons(0x0800)) # use 0x0800 for IPv4 packets , 0x0003 is for sniffing all kinds of packets while True: pkt= rawSocket.recvfrom(2

how to simulate the situation in DNA evolution for finding the minimum population needed and minimum samples selected to mating in order to no extinction in any one of original species and new species

2016-11-17 Thread meInvent bbird
how to simulate the situation in DNA evolution for finding the minimum population needed and minimum samples selected to mating in order to no extinction in any one of original species and new species assume mating are randomly selected to become a couple, how to keep species good which means no

Re: Error in webscraping problem

2016-11-17 Thread Gregory Ewing
stanleydasilv...@gmail.com wrote: I am trying to solve the following problem. Two numbers appear on a website. The user has to enter the gcd (greatest common divisor) and hit the submit button. The catch is that the time limit is far too slow for any human processes -- it must be fully automate

Re: help on "from deen import *" vs. "import deen"

2016-11-17 Thread Michael Torrie
On 11/17/2016 08:41 PM, jf...@ms4.hinet.net wrote: > The fact that most novices will stumble on Python variable many times > until it becomes his "second nature" proves it's different from the > human language:-) The fact is that most novices don't stumble when dealing with Python variables. The n

Re: key and ..

2016-11-17 Thread justin walters
On Thu, Nov 17, 2016 at 7:05 PM, Val Krem via Python-list < python-list@python.org> wrote: > > > Hi all, > Sorry for asking such a basic question butI am trying to merge two > files(file1 and file2) and do some stuff. Merge the two files by the first > column(key). Here is the description of file

Re: help on "from deen import *" vs. "import deen"

2016-11-17 Thread jfong
Michael Torrie at 2016/11/18 11:03:12AM wrote: > >> Python's variables are different from other languages, but in an > >> understandable way. > > > > Unfortunately it's also different from human language. > > How so? I don't find this to be true at all. The fact that most novices will stumble

key and ..

2016-11-17 Thread Val Krem via Python-list
Hi all, Sorry for asking such a basic question butI am trying to merge two files(file1 and file2) and do some stuff. Merge the two files by the first column(key). Here is the description of files and what I would like to do. file1 key c1 c2 1 759 939 2 345 154571 3 251 350711 4 3749

Re: help on "from deen import *" vs. "import deen"

2016-11-17 Thread Michael Torrie
On 11/17/2016 07:23 PM, jf...@ms4.hinet.net wrote: >> Python's variables are different from other languages, but in an >> understandable way. > > Unfortunately it's also different from human language. How so? I don't find this to be true at all. -- https://mail.python.org/mailman/listinfo/pyth

Re: help on "from deen import *" vs. "import deen"

2016-11-17 Thread jfong
Michael Torrie at 2016/11/17 11:38:32PM wrote: > Like I said, whether the names you use are appropriate is completely up > to you. But this statement seems to imply you're still not getting it > and still thinking of variables as boxes like they are in other > languages, rather than labels that ca

Re: help on "from deen import *" vs. "import deen"

2016-11-17 Thread Nathan Ernst
I would also toss in there: never name a script test.py. Causes nothing but trouble, at least in python2. On Nov 17, 2016 8:01 PM, wrote: > Steven D'Aprano at 2016/11/17 4:04:04PM wrote: > > The most important thing you should learn from this thread is: > > > > - avoid using "from module import

Re: help on "from deen import *" vs. "import deen"

2016-11-17 Thread jfong
Steven D'Aprano at 2016/11/17 4:04:04PM wrote: > The most important thing you should learn from this thread is: > > - avoid using "from module import *" as it is usually more trouble > than it is worth. > > > It is confusing and leads to more problems than it solves. If Python was > being >

Re: What exactly is a python variable?

2016-11-17 Thread Ned Batchelder
On Thursday, November 17, 2016 at 8:35:15 PM UTC-5, BartC wrote: > That Py2's dis.dis() accepts a string argument but treats it as compiled > byte-code sounds like a bug. Unless it's a feature. In Python 2, plain-old strings are byte-strings, so there's no way for dis.dis to distinguish between a

RE: how to control formatting of a namedtuple in a list

2016-11-17 Thread Boylan, Ross
Actually, >> print(list(foo, bar)) Traceback (most recent call last): File "", line 1, in TypeError: list() t

Re: What exactly is a python variable?

2016-11-17 Thread BartC
On 18/11/2016 00:47, Steve D'Aprano wrote: On Fri, 18 Nov 2016 12:19 am, BartC wrote: On 17/11/2016 12:20, Steve D'Aprano wrote: In the most recent versions of Python, dis.dis() will also accept a string: py> dis.dis('y = x + 1') 1 0 LOAD_NAME0 (x)

Re: What exactly is a python variable?

2016-11-17 Thread Chris Angelico
On Fri, Nov 18, 2016 at 11:47 AM, Steve D'Aprano wrote: > You may have missed the bit where I said "In the most recent versions". > Python 2.7 will be interpreting the string "y=x+1" as compiled byte-code, > and disassembling it into junk. > Heh. That's a side benefit of the Py3 bytes/unicode spl

Re: What exactly is a python variable?

2016-11-17 Thread Steve D'Aprano
On Fri, 18 Nov 2016 12:19 am, BartC wrote: > On 17/11/2016 12:20, Steve D'Aprano wrote: >> On Thu, 17 Nov 2016 10:37 pm, BartC wrote: > >>> (I don't know how to disassemble code outside a function, not from >>> inside the same program. Outside it might be: 'python -m dis file.py') > >> In the mo

Re: Python does not start

2016-11-17 Thread Terry Reedy
On 11/17/2016 2:59 PM, Jelena Tavcar wrote: How do I find stdlib files? Python coded stdlib files are, at least on Windows, in /Lib -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list

Re: how to control formatting of a namedtuple in a list

2016-11-17 Thread Ethan Furman
On 11/17/2016 04:09 PM, MRAB wrote: On 2016-11-17 23:49, Boylan, Ross wrote: Thank you; I can confirm that overriding __repr__ makes the list display as I wanted. The decision to use repr inside the list seems very odd, given the context, namely formatting something for display or looking f

Re: how to control formatting of a namedtuple in a list

2016-11-17 Thread Ned Batchelder
On Thursday, November 17, 2016 at 6:50:07 PM UTC-5, Boylan, Ross wrote: > Thank you; I can confirm that overriding __repr__ makes the list display as I > wanted. > > The decision to use repr inside the list seems very odd, given the context, > namely formatting something for display or looking f

Re: how to control formatting of a namedtuple in a list

2016-11-17 Thread MRAB
On 2016-11-17 23:49, Boylan, Ross wrote: Thank you; I can confirm that overriding __repr__ makes the list display as I wanted. The decision to use repr inside the list seems very odd, given the context, namely formatting something for display or looking for a simple string representation. It

RE: how to control formatting of a namedtuple in a list

2016-11-17 Thread Boylan, Ross
Thank you; I can confirm that overriding __repr__ makes the list display as I wanted. The decision to use repr inside the list seems very odd, given the context, namely formatting something for display or looking for a simple string representation. It seems more natural to me to use str or, if

Re: how to control formatting of a namedtuple in a list

2016-11-17 Thread Chris Angelico
On Fri, Nov 18, 2016 at 10:04 AM, Boylan, Ross wrote: > Even after defining custom __str__ and __format__ methods they don't affect > the display of objects when they are in a list. Is there a way to change > that, other than explicitly converting each list element to a string? > Yep! Inside a

how to control formatting of a namedtuple in a list

2016-11-17 Thread Boylan, Ross
Even after defining custom __str__ and __format__ methods they don't affect the display of objects when they are in a list. Is there a way to change that, other than explicitly converting each list element to a string? The last line of output below shows that when I format the list I get standa

Re: Python does not start

2016-11-17 Thread Joel Goldstick
On Thu, Nov 17, 2016 at 2:59 PM, Jelena Tavcar wrote: > How do I find stdlib files? > Regards > -- > https://mail.python.org/mailman/listinfo/python-list First of all, your subject line doesn't seem related to your body text. Second of all, stdlib is a C thing as I recall, not python. Can you be

Re: Overlapping co-ordiantes of rectangles fail to print in python

2016-11-17 Thread BartC
On 17/11/2016 14:27, aruns...@gmail.com wrote: I am working with following code in which I am trying to output co ordinates of overlapping rectangles.. However the code fails to output the co ordinates. I am customizing the following code This is the input 1.6 1.2 7.9 3.1 1.2 1.6 3.4 7.2 2.6

python package: financial_life

2016-11-17 Thread martin . pyka
Hi everybody, I recently uploaded a project I am working on for some months. It is called financial_life and the purpose of it is to simulate monetary flows between different accounts (like normal bank accounts, loans etc.). The simulations let you explore different financial strategies and fig

modify screen pop up

2016-11-17 Thread John Zayatz via Python-list
when running pycharm the modify setup window keep coming on the screen. I have uninstalled and reinstalled python and pycharm multiple times. Do you have a solution? Thank You" -- https://mail.python.org/mailman/listinfo/python-list

Python does not start

2016-11-17 Thread Jelena Tavcar
How do I find stdlib files? Regards -- https://mail.python.org/mailman/listinfo/python-list

Can signal.alarm be safely cleared in python?

2016-11-17 Thread Pedro Franco de Carvalho
Assume a python program sets a handler function for the `signal.SIGALRM` signal, and then schedules an alarm in T seconds with `signal.alarm(T)`. Assume the program later cancels any scheduled alarm with `signal.alarm(0)`. Can the program safely assume that after the call to `signal.alarm(0)` com

Re: Overlapping co-ordiantes of rectangles fail to print in python

2016-11-17 Thread Peter Pearson
On Thu, 17 Nov 2016 06:27:49 -0800 (PST), aruns...@gmail.com wrote: > I am working with following code in which I am trying to output co > ordinates of overlapping rectangles.. However the code fails to > output the co ordinates. I am customizing the following code [about 100 lines of code remo

Re: Access to the caller's globals, not your own

2016-11-17 Thread Rob Gaddi
Steven D'Aprano wrote: > On Thursday 17 November 2016 04:52, Rob Gaddi wrote: > >>> import library >>> result = library.make_spam(arg) >>> >>> >>> versus: >>> >>> import library >>> make_spam = library.make_library() >>> result = make_spam(arg) >>> >>> What a drag. >>> >>> >> >> And there you hav

Re: What exactly is a python variable?

2016-11-17 Thread Terry Reedy
On 11/17/2016 12:40 AM, Veek M wrote: In C: int x = 10; results in storage being allocated and type and location are fixed for the life of the program. In Python, x = 10 causes an object '10' to be created but how exactly is 'x' handled? Symbol Table lookup at compile time? Modules and class

Re: How to test for type or instance of dict_values?

2016-11-17 Thread Terry Reedy
On 11/17/2016 9:57 AM, Thorsten Kampe wrote: The code in question is part of an attempt to get the dimensions of multi-dimensional lists, the `isinstance` is there in order to exclude strings. You can do the exclusion directly. """ def dim(seq): dimension = [] while isinstance(seq,

Re: What exactly is a python variable?

2016-11-17 Thread Anton Mamaenko
Just a couple of days ago I was asking myself a similar question, and found this blog article: https://jeffknupp.com/blog/2013/02/14/drastically-improve-your-python-understanding-pythons-execution-model/ Clarified a lot of things to me. , Anton > On 17 Nov 2016, at 16:19, BartC wrote: > >>

Re: help on "from deen import *" vs. "import deen"

2016-11-17 Thread Michael Torrie
On 11/16/2016 07:01 PM, jf...@ms4.hinet.net wrote: > Michael Torrie at 2016/11/16 11:15:11AM wrote: >> ... The globals object is a dictionary and is itself mutable. But >> when we assign a new object to a particular dictionary key, it >> tosses out the old reference and makes the key now refer to

Re: How to test for type or instance of dict_values?

2016-11-17 Thread Thorsten Kampe
* Peter Otten (Thu, 17 Nov 2016 13:38:26 +0100) > > Thorsten Kampe wrote: > > > How can I test for type or instance of dictviews like dict_values? > > Why do you want to? Thanks, for the `collections.abc.ValuesView` tip. The code in question is part of an attempt to get the dimensions of mult

Re: Error in webscraping problem

2016-11-17 Thread Chris Angelico
On Thu, Nov 17, 2016 at 10:55 python-ideas PM, wrote: > I am trying to solve the following problem. Two numbers appear on a website. > The user has to enter the gcd (greatest common divisor) and hit the > submit button. The catch is that the time limit is far too slow for > any human processes

Overlapping co-ordiantes of rectangles fail to print in python

2016-11-17 Thread arunsocs
I am working with following code in which I am trying to output co ordinates of overlapping rectangles.. However the code fails to output the co ordinates. I am customizing the following code This is the input 1.6 1.2 7.9 3.1 1.2 1.6 3.4 7.2 2.6 11.6 6.8 14.0 9.6 1.2 11.4 7.5 9.6 1.7 14.1 2.8

Re: Access to the caller's globals, not your own

2016-11-17 Thread MRAB
On 2016-11-17 05:40, Dan Sommers wrote: On Thu, 17 Nov 2016 16:17:51 +1100, Steven D'Aprano wrote: ... factory functions are great. But I'm saying that as the writer of the library, not the user of the library. Can you imagine expecting users to do this? from math import trig sin = trig.buil

Re: What exactly is a python variable?

2016-11-17 Thread BartC
On 17/11/2016 12:20, Steve D'Aprano wrote: On Thu, 17 Nov 2016 10:37 pm, BartC wrote: (I don't know how to disassemble code outside a function, not from inside the same program. Outside it might be: 'python -m dis file.py') In the most recent versions of Python, dis.dis() will also accept a

Re: How to test for type or instance of dict_values?

2016-11-17 Thread Peter Otten
Thorsten Kampe wrote: > How can I test for type or instance of dictviews like dict_values? Why do you want to? > `isinstance({}.values, dict_values)` gives > `NameError: name 'dict_values' is not defined` You can "fix" this with >>> dict_values = type({}.values()) or, depending on the use ca

How to test for type or instance of dict_values?

2016-11-17 Thread Thorsten Kampe
How can I test for type or instance of dictviews like dict_values? `isinstance({}.values, dict_values)` gives `NameError: name 'dict_values' is not defined` """ >>> type({}.values()) """ Thorsten -- https://mail.python.org/mailman/listinfo/python-list

Re: What exactly is a python variable?

2016-11-17 Thread Steve D'Aprano
On Thu, 17 Nov 2016 10:37 pm, BartC wrote: > Try: > > import dis > > def fn(): > | global x > | x=10 > > dis.dis(fn) > > (I don't know how to disassemble code outside a function, not from > inside the same program. Outside it might be: 'python -m dis file.py') You can use the b

Error in webscraping problem

2016-11-17 Thread stanleydasilva93
I am trying to solve the following problem. Two numbers appear on a website. The user has to enter the gcd (greatest common divisor) and hit the submit button. The catch is that the time limit is far too slow for any human processes -- it must be fully automated. The numbers change each time th

Re: What exactly is a python variable?

2016-11-17 Thread BartC
On 17/11/2016 05:40, Veek M wrote: In C: int x = 10; results in storage being allocated and type and location are fixed for the life of the program. In Python, x = 10 causes an object '10' to be created but how exactly is 'x' handled? Symbol Table lookup at compile time? Is every 'x' being subs

mush 2.4.0 released! - Type-based dependency injection for scripts

2016-11-17 Thread Chris Withers
Hi All, I'm very happy to announce the a new release of Mush, a light weight dependency injection framework aimed at enabling the easy testing and re-use of chunks of code that make up scripts. This release includes: - Add support for cloning depending on what label was used to add callabl

Re: What exactly is a python variable?

2016-11-17 Thread Steven D'Aprano
On Thursday 17 November 2016 16:40, Veek M wrote: > In C: > int x = 10; > results in storage being allocated and type and location are fixed for > the life of the program. > > In Python, > x = 10 > > causes an object '10' to be created but how exactly is 'x' handled? > Symbol Table lookup at com

Re: help on "from deen import *" vs. "import deen"

2016-11-17 Thread Steven D'Aprano
On Thursday 17 November 2016 17:48, jf...@ms4.hinet.net wrote: > Steven D'Aprano at 2016/11/17 12:06:19PM wrote: >> You understand how this works? > > Yes, thank you for your detail explanation. > >> import russia as _tmp >> president = _tmp.president >> del _tmp > > This one I can