Re: [Tutor] Newbie help with .pyc
Hey Ken, Steve has just made some innocent fun. He is eager to help the guy. Please don't be so harsh. Sincerely Ashfaq ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] reverse diagonal
>>> revdiag = [M[i][i] for i in [2, 1, 0]] >>> revdiag [9, 5, 1] The reverse diag entries (that you are seeking to get) are not correct. They should be M[0][2], M[1][1], M[2][0]. So the code could be -- revdiag = [] for i in [0, 1, 2]: j = 2 - i revdiag.append( M[i][j] ) I hope it helps. -- Ashfaq ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] FW: (no subject)
Run your code 10,000 times. :) ** ** > > import math > > import random > > random.seed() > > points = [] for i in range(0, 1): x=random.uniform(0,1) y=random.uniform(0,1) points.append ( (x, y) ) I hope it helps. -- Sincerely, Ashfaq ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] FW: (no subject)
Luke, Thanks. The generator syntax is really cool. -- Ashfaq ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [Python2.7] Convert (2,188,1) into (188,1)
Is it a 3-item tuple? On Wed, Jun 28, 2017 at 9:48 PM, Allan Tanaka via Tutor wrote: > Hi. I have array shape like: (2,188,1). I want to make it like this: > (188,1). I try that using .reshape(188,1) but throws an error: total size > of an array must be unchanged > Thank you for the help! > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] dictionaries are same but returning false
Hi Peter, The way you find the issue is really cool! Very cool! :) On Wed, Jul 5, 2017 at 6:10 PM, shubham goyal wrote: > Thank you Peter. > Silly mistakes 😀 > > On Jul 5, 2017 5:10 PM, "Peter Otten" <__pete...@web.de> wrote: > > > shubham goyal wrote: > > > > > null=None > > > x={'_udp_options': None, '_icmp_options': None, 'attribute_map': > > > {'icmp_options': 'icmpOptions', 'protocol': 'protocol', 'source': > > > {'source', > > > 'tcp_options': 'tcpOptions', 'is_stateless': 'isStateless', > > 'udp_options': > > > 'udpOptions'}, '_is_stateless': False, 'swagger_types': > {'icmp_options': > > > 'IcmpOptions', 'protocol': 'str', 'source': 'str', 'tcp_options': > > > 'TcpOptions', 'is_stateless': 'bool', 'udp_options': 'UdpOptions'}, > > > '_protocol': '6', '_source': '0.0.4.0/24', '_tcp_options': { > > > "destination_port_range": { > > > "max": "22", > > > "min": "22" > > > }, > > > "source_port_range": null > > > }} > > > > > > y={'_udp_options': None, '_icmp_options': None, 'attribute_map': > > > {'icmp_options': 'icmpOptions', 'protocol': 'protocol', 'source': > > > {'source', > > > 'tcp_options': 'tcpOptions', 'is_stateless': 'isStateless', > > 'udp_options': > > > 'udpOptions'}, '_is_stateless': False, 'swagger_types': > {'icmp_options': > > > 'IcmpOptions', 'protocol': 'str', 'source': 'str', 'tcp_options': > > > 'TcpOptions', 'is_stateless': 'bool', 'udp_options': 'UdpOptions'}, > > > '_protocol': '6', '_source': '0.0.4.0/24', '_tcp_options': { > > > "destination_port_range": { > > > "max": 22, > > > "min": 22 > > > }, > > > "source_port_range": null > > > }} > > > if x==y: > > > print "true" > > > else: > > > print "false" > > > > > > > > > These dictionaries are same exactly. but its returning false. i don't > > > understand > > > what to do? > > > > Let's narrow down the problem, with the help of the interactive > > interpreter: > > > > >>> changed = [k for k in x if x[k] != y[k]] > > >>> changed > > ['_tcp_options'] > > >>> k, = changed > > > > A closer look: > > > > >>> x[k] > > {'source_port_range': None, 'destination_port_range': {'max': '22', > 'min': > > '22'}} > > >>> y[k] > > {'source_port_range': None, 'destination_port_range': {'max': 22, 'min': > > 22}} > > > > So x uses strings for min/max while y uses integers, and those do not > > compare equal in Python: > > > > >>> 22 == "22" > > False > > > > Once you fix this > > > > >>> x[k]["destination_port_range"]["max"] = 22 > > >>> x[k]["destination_port_range"]["min"] = 22 > > > > you get the expected result: > > > > >>> x == y > > True > > > > > > ___ > > Tutor maillist - Tutor@python.org > > To unsubscribe or change subscription options: > > https://mail.python.org/mailman/listinfo/tutor > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Probably a silly question: how to install lxml?
Hi Mark ModuleNotFoundError means the package is not installed. Can you paste those red error message here? This can shed some light. Sincerely Ashfaq On Thu, Jul 6, 2017 at 5:10 AM Mark at information27.com < m...@information27.com> wrote: > First, I'm not a programmer, but I know a bit about programming techniques. > Had a Python pgm working about a year ago, and now trying to get it > running on a new machine. > On Windows7, SP1, 64-bit, I installed Python 3.6.1. > Tried to run the Python pgm, and it said ModuleNotFoundError: No module > named 'lxml' > Ran "python -m pip install --upgrade lxml" > It looked like it worked, even with several red error messages at the end. > Tried to run the Python pgm again, and it said the same error: > ModuleNotFoundError: No module named 'lxml' > > Can ya' tell me?... How to get past this step? > > Thanks very much. > > -- > > > Mark > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor