Re: Toggle
Rustom Mody wrote: > On Thursday, October 9, 2014 10:26:41 AM UTC+5:30, Steven D'Aprano wrote: >> On Wed, 08 Oct 2014 19:34:30 -0700, Rustom Mody wrote: > >> Color.Red >> print (Color.Red) >> > Color.Red >> > # Not sure what to make of that distinction... > >> That's because the interactive interpreter displays the repr() of objects >> (except for None, which it suppresses), while print outputs the str() of >> them. > > Yeah... > > What I meant to wonder upon was: "Is this behavior what the pro-print or > the anti-print folks like?" > > In any case that the P in REPL is not *exactly* the same as print > (or equivalently the distinction between str and repr) makes for some > intricate noob confusions. > > BTW is there some flag that can make them identical? No flag, but you can tweak that P: >>> import sys >>> sys.displayhook = print >>> "foo" foo >>> def f(): pass ... >>> f() None -- https://mail.python.org/mailman/listinfo/python-list
ANN: python-ldap 2.4.18
Find a new release of python-ldap: http://pypi.python.org/pypi/python-ldap/2.4.18 python-ldap provides an object-oriented API to access LDAP directory servers from Python programs. It mainly wraps the OpenLDAP 2.x libs for that purpose. Additionally it contains modules for other LDAP-related stuff (e.g. processing LDIF, LDAP URLs and LDAPv3 schema). Project's web site: http://www.python-ldap.org/ Ciao, Michael. Released 2.4.18 2014-10-09 Changes since 2.4.17: Lib/ * Fixed raising exception in LDAPObject.read_s() when reading an entry returns empty search result -- https://mail.python.org/mailman/listinfo/python-list
Re: trying idle
On 10/9/2014 2:52 AM, Rustom Mody wrote: Been using emacs for over 20 years and teaching python for 10. And getting fed up that my audience looks at me like Rip van Winkle each time I start up emacs... So trying out Idle... Some specific and some general questions: My audience consists of people having linux and windows and macbooks. Does Idle run on all these? If macbook runs OSX, and the linux has recent tcl/tk installed, the answer should be Yes [Remember seeing some adventures with Tkinter...] One may have to install activestate tkc/tk on mac, depending on osx version. This page has details: https://www.python.org/download/mac/tcltk Particularly with macs my knowledge is at the level: "How the ^%*)( do you right click without a right-click button?" I believe control-click, but Macs users could say better. So I would like to avoid something that is not quite working. Specific: Is there a way to cut-paste a snippet from the interpreter window containing ">>> " "... " into the file window and auto-remove the prompts? [I have a vague recollection of Terry showing somethin...] I doubt I said anything. I have said there is a tracker issue for the feature (something similar to dedent). I would like to add a general facility for users to define reformat/transform functions to do precisely what they want. In particular, what to do with output lines? -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
CLI framework using python
Hi, I need to develop a python CLI framework. For example if i need to set an ip address in linux: ifconfig eth0 172.16.25.125 I should be able to use python to do the above. 1. The user will execute a python script to which i will pass the params eth0 and ip address (something like ifconf.py eth0 172.16.25.125) 2. Within the script i grab the params and do something to the effect of user executing 'ifconfig eth0 172.16.25.125' from the shell. 3. There are other such commands for which i will be using python scripts. I came across pyCLI, but it doesn't have much documentation, so couldn't figure out how to move forward. 4. The CLI framework needs to reuse code so i didn't want to use pure python and develop a framework from scratch. Rather use something like pyCLI/CLIFF. The problem is lack of documentation with examples on how to use the above. Any guidance would be greatly appreciated. Regards & Thanks, Vij -- https://mail.python.org/mailman/listinfo/python-list
Hi Guys... Reading XML using Jython code
Am new to python and Jython... Kindly help me on My issue please ! My Issue is: XML parsing using Jython.. I am sucessfully reading XML file using xml.etree.ElementTree package .. But I have a issue in below scenario . this scenario my code is not working. In my XML file , One main node is there and Multiple child tags are there. But In Child tags , same name repeated twice (like tag repeated twice) This scenario , this package can not read .. How can I read very first come tag (means it should read first come node value only .leave the second come node value) Please help me on this -- https://mail.python.org/mailman/listinfo/python-list
Re: Toggle
On Thursday, October 9, 2014 1:21:49 PM UTC+5:30, Peter Otten wrote: > Rustom Mody wrote: > > BTW is there some flag that can make them identical? > No flag, but you can tweak that P: > >>> import sys > >>> sys.displayhook = print > >>> "foo" > foo > >>> def f(): pass > ... > >>> f() > None Yeah. Thats what I was looking for -- thanks! With print as above: >>> "Hello World\n" Hello World >>> With default displayhook: >>> "Hello World\n" 'Hello World\n' >>> -- https://mail.python.org/mailman/listinfo/python-list
Re: trying idle
On Thu, Oct 9, 2014, at 05:26, Terry Reedy wrote: > On 10/9/2014 2:52 AM, Rustom Mody wrote: > > Particularly with macs my knowledge is at the level: > > "How the ^%*)( do you right click without a right-click button?" > > I believe control-click, but Macs users could say better. Control-click was the canonical way to do it when right click menus were introduced in Mac OS itself. Some programs (notably Netscape) supported them via click-hold before that. And it's been nearly a decade since Apple sold a mouse with no ability to right-click. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to add custom importer after the normal imports
On 10/9/2014 12:44 AM, Ian Kelly wrote: On Wed, Oct 8, 2014 at 4:53 AM, Gelonida N wrote: Hi, I just read about sys.meta_path, which allows to install custom importers *BEFORE* the default importers. However I have a use case where I would like to add a custom importer *AFTER* all other import methods have failed. Does anybody know how to do this. One way of implementing this would be to add the default importer as first entry in sys.meta_path. My only problem is, that I don't know how to create a 'default-importer', such that I can add it into sys.meta_path As of CPython 3.3 the default importers are already in sys.meta_path, so you could just add your custom importer to the end. If you need to support earlier versions or alternate implementations then this may not be reliable. thanks for your answer. I'm using Puthon 2.7 for the given project and there sys.meta_path is []. Just for fun I started Python3.3 and looked at it's meta_path, which contained for example _frozen_importlib.PathFinder Unfortunately python 2.7 does not seem to have the package _frozen_importlib So now the question seems to boil down to looking for the 2.7 equivalent of python 3.3's _frozen_importlib.PathFinder -- https://mail.python.org/mailman/listinfo/python-list
Re: trying idle
On Thursday, October 9, 2014 2:56:56 PM UTC+5:30, Terry Reedy wrote: > > Specific: > > Is there a way to cut-paste a snippet from the interpreter window > > containing ">>> " "... " into the file window and auto-remove the prompts? > > [I have a vague recollection of Terry showing somethin...] > I doubt I said anything. I have said there is a tracker issue for the > feature (something similar to dedent). I would like to add a general > facility for users to define reformat/transform functions to do > precisely what they want. In particular, what to do with output lines? I was looking for something more simplistic: eg in emacs there are rectangle commands; also following MS office there are 'column' commands. Using either of these its a couple of keystrokes/clicks to 'de-prompt' a region/selection all of whose lines start with ">>> " or "... " -- https://mail.python.org/mailman/listinfo/python-list
Numpy, uint64 and Big O notation.
Hey all! I'm trying to find out the best way to multiply an uint64 (numpy). Could someone help me find the best way to achieve that and where can I find the time and space complexity in a Big O notation? -- https://mail.python.org/mailman/listinfo/python-list
Re: trying idle
On Thursday, October 9, 2014 2:56:56 PM UTC+5:30, Terry Reedy wrote: > On 10/9/2014 2:52 AM, Rustom Mody wrote: > > My audience consists of people having linux and windows and macbooks. > > Does Idle run on all these? > If macbook runs OSX, and the linux has recent tcl/tk installed, the > answer should be Yes I get this traceback on closing idle. Otherwise seems to be working. Still... [idle3 on linux] Exception ignored in: > Traceback (most recent call last): File "/usr/lib/python3.4/idlelib/MultiCall.py", line 244, in __del__ self.widget.unbind(self.widgetinst, seq, id) File "/usr/lib/python3.4/tkinter/__init__.py", line 1071, in unbind self.tk.call('bind', self._w, sequence, '') _tkinter.TclError: can't invoke "bind" command: application has been destroyed Exception ignored in: > Traceback (most recent call last): File "/usr/lib/python3.4/idlelib/MultiCall.py", line 244, in __del__ self.widget.unbind(self.widgetinst, seq, id) File "/usr/lib/python3.4/tkinter/__init__.py", line 1071, in unbind self.tk.call('bind', self._w, sequence, '') _tkinter.TclError: can't invoke "bind" command: application has been destroyed Exception ignored in: > Traceback (most recent call last): File "/usr/lib/python3.4/idlelib/MultiCall.py", line 244, in __del__ self.widget.unbind(self.widgetinst, seq, id) File "/usr/lib/python3.4/tkinter/__init__.py", line 1071, in unbind self.tk.call('bind', self._w, sequence, '') _tkinter.TclError: can't invoke "bind" command: application has been destroyed Exception ignored in: > Traceback (most recent call last): File "/usr/lib/python3.4/idlelib/MultiCall.py", line 244, in __del__ self.widget.unbind(self.widgetinst, seq, id) File "/usr/lib/python3.4/tkinter/__init__.py", line 1071, in unbind self.tk.call('bind', self._w, sequence, '') _tkinter.TclError: can't invoke "bind" command: application has been destroyed -- https://mail.python.org/mailman/listinfo/python-list
Re: virtualenv question: include just a few site packages
- Original Message - > From: "Gelonida N" > To: python-list@python.org > Sent: Thursday, 9 October, 2014 12:09:50 AM > Subject: virtualenv question: include just a few site packages > > virtualenv has the switch > --system-site-packages (including all system site pacgaes) > and the switch > --no-site-packages (to expclude all site packages) > > > Does anyone know an easy way to include just a few site-packages? > for example (PySide, but not PyQt) > > The reason I'm asking is following. > Some site packages are sometimes raher huge or sometimes refuse to > compile on certain hosts. > > as these packages are already part of the site packages I'd like to > include them. > > You might wonder why I care whether I have more site packages than I > need. As long as I don't import them, I shouldn't care about it. > If I really wanted to replace a version I could use pip install -U. > > However sometimes I'd like to have a test environment where want to > be > sure, that no module can find certain other modules. so they should > not > be visible. > > at the moment I make some experiments with pyinstaller and the module > pythonqtbindings. and there I'd like to be sure that no PuQt files > end > up in the generated code. > > > The only idea, that I have so far is to > run virutalanv with --system-side-packages and to manually remove > modules I don't want or to > run virtualenv without this switch and to manually add links for site > packages, taht I want. both options don't really feel right for me. > > > Is there any other way? You could build a virtual machine, installing only your VIP modules, and create virtual environment on this virtual machine, using the system site packages. JM -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to add custom importer after the normal imports
On Oct 9, 2014 6:53 AM, "Gelonida N" wrote: > I'm using Puthon 2.7 for the given project and there sys.meta_path is []. > > Just for fun I started Python3.3 and looked at it's meta_path, which contained for example _frozen_importlib.PathFinder > > Unfortunately python 2.7 does not seem to have the package _frozen_importlib > > So now the question seems to boil down to looking for the 2.7 equivalent of python 3.3's _frozen_importlib.PathFinder There is no equivalent. Prior to 3.3 that code was buried deeply in the interpreter and not available to scripts. The reason for the change was to expose more of the import machinery for exactly this kind of manipulation. -- https://mail.python.org/mailman/listinfo/python-list
Re: Toggle
On Thu, 09 Oct 2014 17:57:03 +1300, Gregory Ewing wrote: > Seymore4Head wrote: >> I want to toggle between color="Red" and color="Blue" > > toggle = {"Red": "Blue", "Blue": "Red"} > color = toggle[color] How about a simple colour = 'red' if colour == 'blue' else 'blue' -- The light at the end of the tunnel is the headlight of an approaching train. -- https://mail.python.org/mailman/listinfo/python-list
Re: CLI framework using python
Hello, Go for Optparse.. Look at below docs on how to use it. http://pymotw.com/2/optparse/ Regards, DJ On Thu, Oct 9, 2014 at 5:50 PM, wrote: > Hi, > > I need to develop a python CLI framework. > > For example if i need to set an ip address in linux: > > ifconfig eth0 172.16.25.125 > > I should be able to use python to do the above. > > 1. The user will execute a python script to which i will pass the params > eth0 and ip address (something like ifconf.py eth0 172.16.25.125) > > 2. Within the script i grab the params and do something to the effect of > user executing 'ifconfig eth0 172.16.25.125' from the shell. > > 3. There are other such commands for which i will be using python scripts. > I came across pyCLI, but it doesn't have much documentation, so couldn't > figure out how to move forward. > > 4. The CLI framework needs to reuse code so i didn't want to use pure > python and develop a framework from scratch. Rather use something like > pyCLI/CLIFF. > > The problem is lack of documentation with examples on how to use the above. > > Any guidance would be greatly appreciated. > > Regards & Thanks, > Vij > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Practice question
On Mon, 06 Oct 2014 22:06:09 -0400, Seymore4Head wrote: > On Tue, 7 Oct 2014 01:46:37 + (UTC), Denis McMahon > wrote: > >>On Sun, 05 Oct 2014 19:02:31 -0400, Seymore4Head wrote: >> >>> For the record, I don't want a hint. I want the answer. >>> I see a practice question is similar to this. >>> 15 <= x < 30 And it wants a similar expression that is equivalent. >> >>I think part of the problem here is that you don't understand the >>expression. >> >>The expression: >> >>15 <= x < 30 >> >>contains two conditions: >> >>15 <= x >> >>x < 30 >> >>For the whole expression to be true, both conditions must be true, hence >>the equivalence is: >> >>(15 <= x) and (x < 30) >> >>to test this in python command line, see if the two different >>expressions give the same result for a suitable range of values of x: >> >>for x in range(50): >>if not (15 <= x < 30) == ((15 <= x) and (x < 30)): >>print "discrepancy" >> >>or >> >>for x in range(50): >>if (15 <= x < 30) == ((15 <= x) and (x < 30)): >>print "ok" > > All of the practice questions up to this question had 4 answers. With > each question you could verify the correct answers by just copy and > pasting each choice into Python. > > So when the instructions said I could verify this with Python I assumed > there might be some way to test if the question was == to each answer. no you need to type in each snippet of code & see if they give the same result when run. -- In every non-trivial program there is at least one bug. -- https://mail.python.org/mailman/listinfo/python-list
Re: Numpy, uint64 and Big O notation.
On Thu, Oct 9, 2014 at 8:08 AM, wrote: > I'm trying to find out the best way to multiply an uint64 (numpy). Could > someone help me find the best way to achieve that and where can I find the > time and space complexity in a Big O notation? Multiply it by what? This works fine for me: >>> import numpy >>> x = numpy.uint64(57) >>> x 57 >>> type(x) >>> xx = x * x >>> type(xx) >>> xx 3249 >>> xxx = xx * xx >>> xxx 10556001 >>> = xxx * xxx >>> 111429157112001 >>> type() >>> x = * >>> type(x) >>> x 12238449225650938241 I assume under the covers there must be a Python long somewhere: >>> int(x) 12238449225650938241L I think your question needs to be more concrete. Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: virtualenv question: include just a few site packages
On 10/09/2014 03:19 PM, Jean-Michel Pichavant wrote: - Original Message - virtualenv has the switch --system-site-packages (including all system site pacgaes) and the switch --no-site-packages (to expclude all site packages) Does anyone know an easy way to include just a few site-packages? for example (PySide, but not PyQt) The reason I'm asking is following. Some site packages are sometimes raher huge or sometimes refuse to compile on certain hosts. as these packages are already part of the site packages I'd like to include them. You might wonder why I care whether I have more site packages than I need. As long as I don't import them, I shouldn't care about it. If I really wanted to replace a version I could use pip install -U. However sometimes I'd like to have a test environment where want to be sure, that no module can find certain other modules. so they should not be visible. at the moment I make some experiments with pyinstaller and the module pythonqtbindings. and there I'd like to be sure that no PuQt files end up in the generated code. The only idea, that I have so far is to run virutalanv with --system-side-packages and to manually remove modules I don't want or to run virtualenv without this switch and to manually add links for site packages, taht I want. both options don't really feel right for me. Is there any other way? You could build a virtual machine, installing only your VIP modules, and create virtual environment on this virtual machine, using the system site packages. Yeah that's an option. However I guess in this case it's probably faster to write a script, that 'post-processes' the virtualenv and just deletes files / symlinks, that are not desired. Definitely not elegant, but probably OK. On the other hand a VM migfht help finding out which files to keep. -- https://mail.python.org/mailman/listinfo/python-list
Re: CLI framework using python
On 10/09/2014 05:25 PM, Unix SA wrote: Hello, Go for Optparse.. Look at below docs on how to use it. http://pymotw.com/2/optparse/ For newer projects I'd suggest argparse (part of Python since 2.7 and can be downloaded / installed for 2.5 / 2.6). https://docs.python.org/2.7/library/argparse.html argparse is very powerfull. you might be interested in looking at subparsers. For calling commands in a slightly nicer way than os.system / sybprocess.Popen you might look at sh or plumbum https://pypi.python.org/pypi/sh https://pypi.python.org/pypi/plumbum Regards, DJ On Thu, Oct 9, 2014 at 5:50 PM, mailto:vijna...@gmail.com>> wrote: Hi, I need to develop a python CLI framework. For example if i need to set an ip address in linux: ifconfig eth0 172.16.25.125 I should be able to use python to do the above. 1. The user will execute a python script to which i will pass the params eth0 and ip address (something like ifconf.py eth0 172.16.25.125) 2. Within the script i grab the params and do something to the effect of user executing 'ifconfig eth0 172.16.25.125' from the shell. 3. There are other such commands for which i will be using python scripts. I came across pyCLI, but it doesn't have much documentation, so couldn't figure out how to move forward. 4. The CLI framework needs to reuse code so i didn't want to use pure python and develop a framework from scratch. Rather use something like pyCLI/CLIFF. The problem is lack of documentation with examples on how to use the above. Any guidance would be greatly appreciated. Regards & Thanks, Vij -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Toggle
On Wed, Oct 8, 2014 at 8:34 PM, Rustom Mody wrote: > On Thursday, October 9, 2014 7:12:41 AM UTC+5:30, Ben Finney wrote: >> Seymore4Head writes: > >> > I want to toggle between color="Red" and color="Blue" > >> It's good to cultivate ongoing familiarity with the standard library > > And language. In recent python3: > class Color(Enum): > ... Red = 0 > ... Blue = 1 > ... Color.Red > print (Color.Red) > Color.Red > > # Not sure what to make of that distinction... > c=Color.Red c = Color.Blue if c==Color.Red else Color.Red c > > # Better def toggle(c): return Color.Blue if c==Color.Red else Color.Red > ... toggle(c) > toggle(c) > > > # which means the c has not changed Python enums can have methods and properties, which means that toggle could be implemented as such: >>> class Color(Enum): ... red = 0 ... blue = 1 ... def toggle(self): ... return Color.blue if self is Color.red else Color.red ... >>> Color.blue.toggle() >>> Color.blue.toggle().toggle() (Note the recommended way to compare enum instances is with "is", not "==".) -- https://mail.python.org/mailman/listinfo/python-list
Re: CLI framework using python
On 09-10-14 14:20, vijna...@gmail.com wrote: Hi, I need to develop a python CLI framework. For example if i need to set an ip address in linux: ifconfig eth0 172.16.25.125 I should be able to use python to do the above. 1. The user will execute a python script to which i will pass the params eth0 and ip address (something like ifconf.py eth0 172.16.25.125) 2. Within the script i grab the params and do something to the effect of user executing 'ifconfig eth0 172.16.25.125' from the shell. 3. There are other such commands for which i will be using python scripts. I came across pyCLI, but it doesn't have much documentation, so couldn't figure out how to move forward. 4. The CLI framework needs to reuse code so i didn't want to use pure python and develop a framework from scratch. Rather use something like pyCLI/CLIFF. The problem is lack of documentation with examples on how to use the above. Any guidance would be greatly appreciated. Regards & Thanks, Vij Hi Vij Maybe you can have a look at iPython: http://ipython.org/ipython-doc/stable/interactive/tutorial.html gr Arno -- https://mail.python.org/mailman/listinfo/python-list
Re: Numpy, uint64 and Big O notation.
(For future reference, when responding to answers, it's worthwhile to continue to cc python-list.) On Thu, Oct 9, 2014 at 11:12 AM, Marcos Schratzenstaller < marksabb...@gmail.com> wrote: > The numpy has a function which manipulate 64 bits integers, but I couldn't > find a specific method to multiplicate this kind of objects can not be > manipulated as the same way, so if python is using the correct function > (assuning python is detecting the object, calling the correct function) it > is not a problem, but, where can I find this deep information? Marcos, Yes, the builtin help() function serves as reasonable documentation in this case: >>> help(numpy.int64) Help on class int64 in module numpy: class int64(signedinteger, __builtin__.int) | 64-bit integer. Character code 'l'. Python int compatible. | | Method resolution order: | int64 | signedinteger | integer | number | generic | __builtin__.int | __builtin__.object | | Methods defined here: ... | Methods inherited from generic: | | __abs__(...) | x.__abs__() <==> abs(x) | | __add__(...) | x.__add__(y) <==> x+y ... | __mod__(...) | x.__mod__(y) <==> x%y | | __mul__(...) | x.__mul__(y) <==> x*y ... The __mul__ method implements multiplication. I don't know the specific implementation in numpy, but it's probably little more than a thin wrapper around x * y (with perhaps some type and overflow checking). Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: Toggle
On Thursday, October 9, 2014 9:39:07 PM UTC+5:30, Ian wrote: > On Wed, Oct 8, 2014 at 8:34 PM, Rustom Mody wrote: > > On Thursday, October 9, 2014 7:12:41 AM UTC+5:30, Ben Finney wrote: > >> Seymore4Head writes: > >> > I want to toggle between color="Red" and color="Blue" > >> It's good to cultivate ongoing familiarity with the standard library > > And language. In recent python3: > class Color(Enum): > > ... Red = 0 > > ... Blue = 1 > > ... > Color.Red > print (Color.Red) > > Color.Red > > # Not sure what to make of that distinction... > c=Color.Red > c = Color.Blue if c==Color.Red else Color.Red > c > # Better > def toggle(c): return Color.Blue if c==Color.Red else Color.Red > > ... > toggle(c) > toggle(c) > > # which means the c has not changed > Python enums can have methods and properties, which means that toggle > could be implemented as such: > >>> class Color(Enum): > ... red = 0 > ... blue = 1 > ... def toggle(self): > ... return Color.blue if self is Color.red else Color.red > ... > >>> Color.blue.toggle() > >>> Color.blue.toggle().toggle() Nice! In fact this: > >>> Color.blue.toggle() > > >>> Color.blue.toggle().toggle() > is a nice example of a pattern that is rarely seen: OO syntax, functional (ie non-state-changing) semantics. It would have been even nicer were this acceptable [Its not :-( ] >>> class Color(Enum): ... red = 0 ... blue = 1 ... def toggle(self): ... return blue if self is red else red > (Note the recommended way to compare enum instances is with "is", not "==".) Umm... I know... Im in Lent -- fasting off contentious territories. [You may remember that I'd rather avoid 'is'] -- https://mail.python.org/mailman/listinfo/python-list
[OT] spelling colour / color was Re: Toggle
On 09/10/2014 02:29, Steven D'Aprano wrote: Apart from the horrible spelling of colour :-) I've always spelt colour as "color" when programming and as "colour" when writing language including documentation about software. colour in a programme doesn't seem right. -- https://mail.python.org/mailman/listinfo/python-list
Re: [OT] spelling colour / color was Re: Toggle
On 09/10/14 18:43, mm0fmf wrote: > On 09/10/2014 02:29, Steven D'Aprano wrote: >> Apart from the horrible spelling of colour :-) > > I've always spelt colour as "color" when programming and as "colour" > when writing language including documentation about software. > > colour in a programme doesn't seem right. > Even in British English that is usually spelt 'program' (from the US spelling, of course). Let's not cave in on 'colour' too. It's bad enough that we can't use 'whilst' loops :-). Duncan -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Basics
for i in range(1,10): print (str(i)*i) Seymour, please don't do this. When you "help" someone by just giving him the answer to a homework problem, you get him past his immediate issue of "I need to submit my homework for this problem". That lets him get through his course without understanding the code he's creating (because he's not the one creating it). He'll either run into more trouble before graduating the course, or (far worse) he'll graduate successfully, without having the competence that the course is supposed to teach - and the world will be given a qualified programmer who doesn't know his stuff. That damages the world, damages the reputation of the course, and gives python-list a reputation as a homework assignment solver... none of which I want. I'm pretty sure you don't want it either. So don't do people's homework for them. PLEASE!! Wow. How do you react when someone does something that's actually harmful? I don't think you'd have the words! :) -- https://mail.python.org/mailman/listinfo/python-list
Cant get my tshark pharse to work
Hello All, I am writing some code to get captured wiresahrk pcap file , using popen.subprocess and extract some table csv format related to SMB, but for some reason i can get the csv when using off-course regular cmd line its work The code as follow below , maybe someone with exprience with such can help Please advice Thanks import socket,subprocess import os,time sharkCall = ["tshark","-i" ,"1", "-w",os.getcwd() +'/smbsession.pcap'] sharkProc = subprocess.Popen(sharkCall,executable="C:/Program Files/Wireshark/tshark.exe") localip = socket.gethostbyname(socket.gethostname()) a = 0 while a ==0: a = sharkProc.pid time.sleep(2) ipflt = '' listip = socket.gethostbyname_ex('media.isilon.gefen.local')[2] for ip in listip: ipflt= ipflt+ "ip.addr==" + ip + "||" ipflt = ipflt + "ip.addr==" + localip if ipflt.endswith('||'): ipflt = ipflt[:-2] print (ipflt) b= os.path.getsize("//media.isilon.gofn.local/Media/New Text Document.txt") #statinfo print(b) #time.sleep(2) sharkProc.kill() tsharkCall = ["tshark","-r",'C:/traces_test/smbsession.pcap',"-Y",ipflt,"-T","fields","-e","ip.src","-e","ip.dst","-e","smb.file",\ "-e","smb.path","-e","smb.time","-e","tcp.time_delta", "-E","header=y","-E","separator=,","-E","quote=d","-E","occurrence=f",\ '> '+os.getcwd() +'/tracetemp.csv'] tsharkProc = subprocess.Popen(tsharkCall,executable="C:/Program Files/Wireshark/tshark.exe") a = 0 while a ==0: a = tsharkProc.pid time.sleep(2) print ('Finished') -- https://mail.python.org/mailman/listinfo/python-list
Re: [OT] spelling colour / color was Re: Toggle
On 10 October 2014 05:24, duncan smith wrote: > On 09/10/14 18:43, mm0fmf wrote: > > On 09/10/2014 02:29, Steven D'Aprano wrote: > >> Apart from the horrible spelling of colour :-) > > > > I've always spelt colour as "color" when programming and as "colour" > > when writing language including documentation about software. > > > > colour in a programme doesn't seem right. > > > > Even in British English that is usually spelt 'program' (from the US > spelling, of course). Let's not cave in on 'colour' too. It's bad enough > that we can't use 'whilst' loops :-). > That would be a theatre programme vs a computer program. I try to stick with the current spelling style when modifying existing code - esp. for APIs. It's very annoying to have some methods use "z" and others "s" in the same package. So since I'm currently working for a US company I have to consciously remind myself to use their abominations ;) Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list
Re: trying idle
On 10/9/2014 9:12 AM, Rustom Mody wrote: On Thursday, October 9, 2014 2:56:56 PM UTC+5:30, Terry Reedy wrote: On 10/9/2014 2:52 AM, Rustom Mody wrote: My audience consists of people having linux and windows and macbooks. Does Idle run on all these? If macbook runs OSX, and the linux has recent tcl/tk installed, the answer should be Yes I get this traceback on closing idle. Otherwise seems to be working. [snip] _tkinter.TclError: can't invoke "bind" command: application has been destroyed Are you running 3.4.0? This was a 3.4 regression that was only reported to occur if one opened Idle with a editor window and closed without ever running it. This was fixed in http://bugs.python.org/issue20167 but I believe too late for 3.4.0. If you see this with 3.4.2 (strongly recommended, especially forthcoming OSX) or even 3.4.1, please add a note to the issue with exact details -- how start, what do, how close. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: [OT] spelling colour / color was Re: Toggle
Tim Delaney : > It's very annoying to have some methods use "z" and others "s" in the > same package. "-ize" is standard everywhere in the English-speaking world. Americans insist on "analyze," "paralyze" and "catalyze" but paradoxically also on "lyse". > So since I'm currently working for a US company I have to consciously > remind myself to use their abominations ;) I will use American English instead of my native Finnish in my code so why wouldn't you use American English instead of your native variant of English? It'll also make you get a remote sense of the pain the French are feeling. If it's any consolation, even the Atlanta-based CNN makes their anchors speak standard Hollywoodese. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Toggle
On 10/9/2014 8:42 AM, Rustom Mody wrote: On Thursday, October 9, 2014 1:21:49 PM UTC+5:30, Peter Otten wrote: Rustom Mody wrote: BTW is there some flag that can make them identical? No flag, but you can tweak that P: import sys sys.displayhook = print "foo" foo def f(): pass ... f() None Yeah. Thats what I was looking for -- thanks! With print as above: "Hello World\n" Hello World With default displayhook: "Hello World\n" 'Hello World\n' For anyone wondering, the reason for the default behavior is to avoid ambiguity between ints and strings containing digits. >>> print(123) 123 >>> print('123') 123 >>> '123' '123' -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Basics
On Fri, Oct 10, 2014 at 5:26 AM, Tobiah wrote: >> So don't do people's homework for them. PLEASE!! > > > Wow. How do you react when someone does something that's > actually harmful? I don't think you'd have the words! :) You just saw it. Doing someone's homework *is* harmful. Harms the student, harms the course, harms the industry. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: "High water" Memory fragmentation still a thing?
On 10/8/2014 10:28 AM, bryanjugglercryptograp...@yahoo.com.dmarc.invalid wrote: That doesn't mean to tell a human administrator to regularly restart the server. It's programmatic and it's a reasonably simple and well-established design pattern. I'd call it more a compensation technique than a design pattern*. You know, like rebooting windows routinely. :) Emile *) Alternately known as a workaround or kludge. -- https://mail.python.org/mailman/listinfo/python-list
Re: "High water" Memory fragmentation still a thing?
On Fri, Oct 10, 2014 at 8:39 AM, Emile van Sebille wrote: > On 10/8/2014 10:28 AM, bryanjugglercryptograp...@yahoo.com.dmarc.invalid > wrote: > >> That doesn't mean to tell a human administrator to regularly restart the >> server. It's programmatic and it's a reasonably simple and well-established >> design pattern. > > I'd call it more a compensation technique than a design pattern*. You know, > like rebooting windows routinely. :) > > *) Alternately known as a workaround or kludge. That sounds about right to me. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: [OT] spelling colour / color was Re: Toggle
On 10/9/2014 1:43 PM, mm0fmf wrote: On 09/10/2014 02:29, Steven D'Aprano wrote: Apart from the horrible spelling of colour :-) I've always spelt colour as "color" when programming and as "colour" when writing language including documentation about software. Like it or not, Python uses American English. Searching 'colour' in F:\Python\dev\4\py34\Doc\*.rst ... F:\Python\dev\4\py34\Doc\faq\library.rst: 102: functions from ncurses and SYSV curses such as colour, alternative character set F:\Python\dev\4\py34\Doc\howto\curses.rst: 382: instead of the Canadian/British spelling 'colour'. If you're used to the F:\Python\dev\4\py34\Doc\howto\regex.rst: 1114: Here's a simple example of using the :meth:`sub` method. It replaces colour F:\Python\dev\4\py34\Doc\howto\regex.rst: 1115: names with the word ``colour``:: F:\Python\dev\4\py34\Doc\howto\regex.rst: 1118:>>> p.sub( 'colour', 'blue socks and red shoes') F:\Python\dev\4\py34\Doc\howto\regex.rst: 1119:'colour socks and colour shoes' F:\Python\dev\4\py34\Doc\howto\regex.rst: 1120:>>> p.sub( 'colour', 'blue socks and red shoes', count=1) F:\Python\dev\4\py34\Doc\howto\regex.rst: 1121:'colour socks and red shoes' F:\Python\dev\4\py34\Doc\howto\regex.rst: 1127:>>> p.subn( 'colour', 'blue socks and red shoes') F:\Python\dev\4\py34\Doc\howto\regex.rst: 1128:('colour socks and colour shoes', 2) F:\Python\dev\4\py34\Doc\howto\regex.rst: 1129:>>> p.subn( 'colour', 'no colours at all') F:\Python\dev\4\py34\Doc\howto\regex.rst: 1130:('no colours at all', 0) F:\Python\dev\4\py34\Doc\library\colorsys.rst: 24: http://www.cambridgeincolour.com/tutorials/color-spaces.htm. F:\Python\dev\4\py34\Doc\whatsnew\2.0.rst: 1059: and SYSV curses, such as colour, alternative character set support, pads, and Hits found: 14 most regex examples. colour in a programme doesn't seem right. Perhaps ironically, there are 52 uses of 'colour' in the stdlib, all but 4 in idlelib, and most of those in one file. I just changed all except in the one file. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: [OT] spelling colour / color was Re: Toggle
On Fri, Oct 10, 2014 at 9:53 AM, Terry Reedy wrote: > >> colour in a programme doesn't seem right. > > Perhaps ironically, there are 52 uses of 'colour' in the stdlib, all but 4 > in idlelib, and most of those in one file. I just changed all except in the > one file. I agree, although I wouldn't make the change without good reason (avoiding code churn). The last time I used "COLOUR" in any code was in Q-Basic; I had my own subroutine of that name, which did some processing and then used the built-in COLOR command. In fact, the only reason I used the "non-program" spelling of the word was because BASIC doesn't allow shadowing of commands. (I don't even remember what the COLOUR command did. Probably something like coping with red-block - when a CRT screen starts to die and the red channel isn't functional. Hacks to deal with faults, that's what we do!) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Hi Guys... Reading XML using Jython code
On Thu, 09 Oct 2014 05:30:21 -0700, Venugopal Reddy wrote: > XML parsing using Jython.. > In my XML file , One main node is there and Multiple child tags are > there. But In Child tags , same name repeated twice (like tag > repeated twice) > Please help me on this Normally, when pulling data from an xml document, you'll get a collection of some sort: Are you trying to select every subject of every child, the first subject of every child, the last subject of every child, or some nth subject of every child? You may need to go back to your specification code and look again at how you're specifying which node(s) you want to select. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: trying idle
On Friday, October 10, 2014 2:19:53 AM UTC+5:30, Terry Reedy wrote: > On 10/9/2014 9:12 AM, Rustom Mody wrote: > > On Thursday, October 9, 2014 2:56:56 PM UTC+5:30, Terry Reedy wrote: > >> On 10/9/2014 2:52 AM, Rustom Mody wrote: > >>> My audience consists of people having linux and windows and macbooks. > >>> Does Idle run on all these? > >> If macbook runs OSX, and the linux has recent tcl/tk installed, the > >> answer should be Yes > > I get this traceback on closing idle. Otherwise seems to be working. > [snip] > > _tkinter.TclError: can't invoke "bind" command: application has been > > destroyed > Are you running 3.4.0? This was a 3.4 regression that was only reported > to occur if one opened Idle with a editor window and closed without ever > running it. This was fixed in > http://bugs.python.org/issue20167 > but I believe too late for 3.4.0. If you see this with 3.4.2 (strongly > recommended, especially forthcoming OSX) or even 3.4.1, please add a > note to the issue with exact details -- how start, what do, how close. Added the backtrace there. 3.4.1-1 on debian testing -- https://mail.python.org/mailman/listinfo/python-list
python on Linux
Hi, ALL, When I am on Windows, I can write something like this: sys.path.append('C:\Users\Igor\Documents\MyLib') Now, when I'm on Linux, can I do this: sys.path.append('~/MyLib') ? I.e., will '~' sign be expanded correctly? Thank you. -- https://mail.python.org/mailman/listinfo/python-list
Re: python on Linux
Try: sys.path.append(os.path.expanduser('~/MyLib')) On Thu, Oct 9, 2014 at 9:21 PM, Igor Korot wrote: > Hi, ALL, > When I am on Windows, I can write something like this: > > sys.path.append('C:\Users\Igor\Documents\MyLib') > > Now, when I'm on Linux, can I do this: > > sys.path.append('~/MyLib') > > ? > > I.e., will '~' sign be expanded correctly? > > Thank you. > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: python on Linux
In Igor Korot writes: > sys.path.append('~/MyLib') > I.e., will '~' sign be expanded correctly? Not as written. Use os.path.expanduser() to get user's home directories. -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list
Re: ZMQError: Resource temporarily unavailable
karthik.sha...@gmail.com writes: > I am using zero-mq for IPC between two machines. > > My zmq function is given below > > def recieve_messages(self): > string = self.sub_socket.recv(flags=zmq.NOBLOCK) > print('flow mod messages recieved {}'.format(string)) > > > When I run the program however I get the following error. > > string = self.sub_socket.recv(flags=zmq.NOBLOCK) > File "socket.pyx", line 616, in zmq.core.socket.Socket.recv > (zmq/core/socket.c:5961) > File "socket.pyx", line 650, in zmq.core.socket.Socket.recv > (zmq/core/socket.c:5832) > File "socket.pyx", line 119, in zmq.core.socket._recv_copy > (zmq/core/socket.c:1669) > ZMQError: Resource temporarily unavailable > > > Can someone explain what is likely causing this error. The most likely cause is that you try to receive data while there is none available. Usually, with non blocking operations, you start them only after you know they can succeed. If the operation is impossible, you will get an exception (and "Resource temporarily unavailable" seems a good candidate). -- https://mail.python.org/mailman/listinfo/python-list
Re: "High water" Memory fragmentation still a thing?
Emile van Sebille writes: > On 10/8/2014 10:28 AM, > bryanjugglercryptograp...@yahoo.com.dmarc.invalid wrote: > >> That doesn't mean to tell a human administrator to regularly restart the >> server. It's programmatic and it's a reasonably simple and well-established >> design pattern. > > I'd call it more a compensation technique than a design pattern*. You > know, like rebooting windows routinely. :) > > Emile > > > *) Alternately known as a workaround or kludge. Well, everything has a price. Python does not use memory compaction but places many objects on the heap and therefore, long running processes usually are subject to memory fragmentation. As a consequence, those processes need to be restarted from time to time. Would Python use memory compaction, implementing C extensions would be much more tedious and error prone and there would be less such extensions - limiting the domain where Python is used. One has to choose. People who do not like the choice of the "CPython" implementation (no memory compaction) may look at "Jython" (based on Java, with memory compaction). If they are lucky, all the extensions they need are available there. -- https://mail.python.org/mailman/listinfo/python-list
Re: python on Linux
On 10-10-2014 6:21, Igor Korot wrote: > Hi, ALL, > When I am on Windows, I can write something like this: > > sys.path.append('C:\Users\Igor\Documents\MyLib') While this might work on your system, it may not work on others. - you need to escape the backslashes (or just use forward slashes, they work on windows too) - not all windows installations and versions have their user folders in C:\Users\. On windows too, you'll have to use something like %USERPROFILE% to get to the correct directory if you want it to work correctly in all cases. Irmen -- https://mail.python.org/mailman/listinfo/python-list
Re: "High water" Memory fragmentation still a thing?
On Fri, Oct 10, 2014 at 5:09 PM, dieter wrote: > Python does not use memory compaction but places many objects on the > heap and therefore, long running processes > usually are subject to memory fragmentation. As a consequence, those > processes need to be restarted from time to time. Pike doesn't use memory compaction either, and also places pretty much everything on the heap. Yet its processes don't need to be restarted; in fact, everything's designed around keeping stuff running permanently. As Emile said, it's not a requirement, it's a compensation technique. I've yet to build a Python process that runs for an entire year (as I'm not confident that I can get it so right that I don't need to update any code), so I can't say for sure that it would work, but I do have Python processes running for multiple months without suffering serious fragmentation. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: [OT] spelling colour / color was Re: Toggle
mm0fmf wrote: > On 09/10/2014 02:29, Steven D'Aprano wrote: >> Apart from the horrible spelling of colour :-) > > I've always spelt colour as "color" when programming and as "colour" > when writing language including documentation about software. > > colour in a programme doesn't seem right. "Normal" programmers spell words the same in code as they do outside of code, e.g.: age address length modulo the odd abbreviation like "len", "addr", etc., and coding conventions like camelCase, underscore_words, sHungarianNotation, etc. So if you spell colour with a U outside of code, I would expect you to spell it with a U inside of code too. Unix programmers take every opportunity to obfuscate their code by dropping nouns and consonants, so I'd expect them to spell "colo(u)r" as something like clr, colr, clor, or even clour. Web programmers tend to make random spelling mistakes ("referer"), so I'd expect "coluor", or perhaps "kolour". But I've never come across your convention of spelling it "colour" in documentation and "color" in code before. How very strange. -- Steven -- https://mail.python.org/mailman/listinfo/python-list