Re: How to make subprocess run for 60 sec?

2014-12-12 Thread Dan Stromberg
On Fri, Dec 12, 2014 at 12:48 AM, Robert Clove wrote: > Hi All, > > I have the following python script that runs. > I want is to run the subprocess to run for 60 sec and then send the SIGINT > signal to subprocess and write the output in file. > > #!/usr/bin/python > import os > import subprocess

Re: suggestions for VIN parsing

2014-12-25 Thread Dan Stromberg
On Thu, Dec 25, 2014 at 4:02 PM, Vincent Davis wrote: > I would like to parse the VIN, frame and engine numbers found on this page > (below). I don't really know any regex, I have looked a little at pyparsing. > I have some other similar numbers to. I am looking for suggestions, which > "tool" sho

Re: Socket programming

2015-01-03 Thread Dan Stromberg
On Sat, Jan 3, 2015 at 3:43 AM, pramod gowda wrote: > Hi i am learning socket programming, This "works" on Linux Mint 17.1. Server: #!/usr/local/cpython-3.4/bin/python import socket server_socket = socket.socket() #server_name = '192.168.2.2' server_socket.setsockopt(socket.SOL_SOCKET, socket.

Re: surprise - byte in set

2015-01-03 Thread Dan Stromberg
On Sat, Jan 3, 2015 at 10:50 AM, patrick vrijlandt wrote: > Hello list, > > Let me first wish you all the best in 2015! > > Today I was trying to test for occurrence of a byte in a set ... In the last case, the set has integers in it. Try: b'b'[0] in set(b'abc') -- https://mail.python.org/mail

Re: Help with map python 2

2015-01-04 Thread Dan Stromberg
I'm partial to: #!/usr/local/cpython-3.4/bin/python def gen_series(top=None): ''' Generate the numbers from 2 to top, with alternating signs. If top is None, generate forever. If top is an integer, generate from 2 to top. ''' sign = 1 if top is None: number = 2

Re: If you were starting a project with XML datasource using python

2015-01-05 Thread Dan Stromberg
On Mon, Jan 5, 2015 at 3:54 AM, flebber wrote: > Hi > > I need some advice on managing data in the form of xml. I will have to > repeatedly import a small xml file but with many complex attributes. If I have a choice, I choose JSON over XML. If stuck with XML, I like xmltodict: https://pypi.pyt

Re: DICOM to jpg

2015-01-11 Thread Dan Stromberg
On Sun, Jan 11, 2015 at 5:01 AM, Abdul Abdul wrote: > Hello, > > Is there a way to convert a DICOM file to an image using Python? > > Thanks. Does GDCM do what you need? http://gdcm.sourceforge.net/wiki/index.php/Main_Page -- https://mail.python.org/mailman/listinfo/python-list

Re: Compiling multiple python scripts into an exe file

2015-01-14 Thread Dan Stromberg
On Tue, Jan 13, 2015 at 10:53 PM, dieter wrote: > no nein writes: > >> Basically, is it possible to compile multiple unrelated python scripts into >> a single exe file, so when execute it several python programs are run at >> once. > > These are two distinct problems: > > * for doing things

Re: Concerning Dictionaries and += in Python 2.x

2015-01-19 Thread Dan Stromberg
On Mon, Jan 19, 2015 at 4:12 PM, Luke Tomaneng wrote: > I have been having a bit of trouble with the things mentioned in the title. I > have written the following script for a Codecademy course: > stock = { > "banana": 6, > "apple": 0, > "orange": 32, > "pear": 15 > } > > prices =

Re: Trees

2015-01-19 Thread Dan Stromberg
On Mon, Jan 19, 2015 at 2:06 PM, Zachary Gilmartin wrote: > Why aren't there trees in the python standard library? Trees are kind of specialized datastructures; no one type of tree solves all tree-related problems suitably well. I think probably the most common need for a tree is implementing a

Re: Trees

2015-01-19 Thread Dan Stromberg
On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence wrote: > On 20/01/2015 00:49, Dan Stromberg wrote: >> >> On Mon, Jan 19, 2015 at 2:06 PM, Zachary Gilmartin >> wrote: >>> >>> Why aren't there trees in the python standard library? >> >> >

Re: Trees

2015-01-20 Thread Dan Stromberg
On Tue, Jan 20, 2015 at 5:22 PM, Joshua Landau wrote: > On 20 January 2015 at 04:21, Dan Stromberg wrote: >> On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence >> wrote: >>> >>> I don't know if you've seen this http://kmike.ru/python-data-structures/ bu

Re: Check for running DHCP daemon?

2015-01-21 Thread Dan Stromberg
On Wed, Jan 21, 2015 at 3:06 PM, Jason Bailey wrote: > So I've got this python 3 script that needs to know if there is a running > DHCP daemon (ISC DHCP server) on the local system. Is there a clean way to > do this that (1) doesn't require me to do syscalls to local utilities (like > ps, top, etc

Benchmarking some modules - strange result

2015-01-24 Thread Dan Stromberg
Hi folks. I've been benchmarking some python modules that are mostly variations on the same theme. For simplicity, let's say I've been running the suite of performance tests within a single interpreter - so I test one module thoroughly, then move on to the next without exiting the interpreter. I

Re: Benchmarking some modules - strange result

2015-01-24 Thread Dan Stromberg
On Sat, Jan 24, 2015 at 6:24 PM, Chris Angelico wrote: > On Sun, Jan 25, 2015 at 1:11 PM, Dan Stromberg wrote: >> For simplicity, let's say I've been running the suite of performance >> tests within a single interpreter - so I test one module thoroughly, >> t

Re: Benchmarking some modules - strange result

2015-01-24 Thread Dan Stromberg
On Sat, Jan 24, 2015 at 6:37 PM, Chris Angelico wrote: > On Sun, Jan 25, 2015 at 1:36 PM, Dan Stromberg wrote: >> On Sat, Jan 24, 2015 at 6:24 PM, Chris Angelico wrote: >>> On Sun, Jan 25, 2015 at 1:11 PM, Dan Stromberg wrote: >>>> For simplicity, let's

Re: ANN: Python Job Board - Call for volunteers

2014-03-05 Thread Dan Stromberg
I hope this means there'll soon be an option to restrict ads seen by some form of postal code or phone area code (with telecommute hopefully being an optional wildcard). On Thu, Feb 27, 2014 at 6:59 AM, M.-A. Lemburg wrote: > [Please help spread the word by forwarding to other relevant mailing li

Re: Assertions are bad, m'kay?

2014-03-07 Thread Dan Stromberg
On Fri, Mar 7, 2014 at 3:11 AM, Steven D'Aprano wrote: > > Assertions are not bad! They're just misunderstood and abused. > You should read this guy's blog post on when to use assert: > > http://import-that.dreamwidth.org/676.html Nice article. BTW, what about: if value >= 3: raise Asserti

Re: Balanced trees (was: Re: Tuples and immutability)

2014-03-08 Thread Dan Stromberg
On Sat, Mar 8, 2014 at 12:34 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> I already mentioned this earlier in the thread, but a balanced binary >> tree might implement += as node insertion and then return a different >> object if the balancing causes the root node to change. > > True. > > Speaking

Re: Balanced trees

2014-03-08 Thread Dan Stromberg
On Sat, Mar 8, 2014 at 1:21 PM, Marko Rauhamaa wrote: > If I had to choose between a hash table and AVL (or RB) tree in the > standard library, it would definitely have to be the latter. It is more > generally usable, has fewer corner cases and probably has an equal > performance even in hash tabl

How is unicode implemented behind the scenes?

2014-03-08 Thread Dan Stromberg
OK, I know that Unicode data is stored in an encoding on disk. But how is it stored in RAM? I realize I shouldn't write code that depends on any relevant implementation details, but knowing some of the more common implementation options would probably help build an intuition for what's going on i

Re: Balanced trees

2014-03-09 Thread Dan Stromberg
On Sun, Mar 9, 2014 at 1:27 AM, Marko Rauhamaa wrote: > Dan Stromberg : > >> On Sat, Mar 8, 2014 at 1:21 PM, Marko Rauhamaa wrote: >>> If I had to choose between a hash table and AVL (or RB) tree in the >>> standard library, it would definitely have to be the la

Re: Balanced trees

2014-03-09 Thread Dan Stromberg
On Sun, Mar 9, 2014 at 2:32 PM, Marko Rauhamaa wrote: > Dan Stromberg : > >> This is not just a detail: O(1) tends to be beat O(logn) pretty easily >> for large n. > > There is no O(1) hash table. http://stackoverflow.com/questions/2771368/can-hash-tables-really-be-o1 --

Re: Balanced trees

2014-03-09 Thread Dan Stromberg
On Sun, Mar 9, 2014 at 2:43 PM, Marko Rauhamaa wrote: > Dan Stromberg : > >> On Sun, Mar 9, 2014 at 2:32 PM, Marko Rauhamaa wrote: >>> There is no O(1) hash table. >> >> http://stackoverflow.com/questions/2771368/can-hash-tables-really-be-o1 > > Please elab

Re: Balanced trees

2014-03-10 Thread Dan Stromberg
On Mon, Mar 10, 2014 at 6:59 AM, Roy Smith wrote: > On the other hand, log n, for n = 1 million, is just 20. It's not hard > to imagine a hash function which costs 20x what a node traversal does, > in which case, the log n lookup is ahead for all n < 1 million. FWIW, both the hash table and the

Re: What does gc.get_objects() return?

2014-03-12 Thread Dan Stromberg
On Wed, Mar 12, 2014 at 12:34 PM, Jurko Gospodnetić wrote: > Hi all. > > I was wondering if someone could explain gc.get_objects() in a bit more > detail to me. > > Does it return a list of 'all objects known to Python'? Only some of them? > Which does it return? Which it does not? > > For

Re: Balanced trees

2014-03-13 Thread Dan Stromberg
On Thu, Mar 13, 2014 at 4:57 PM, Steven D'Aprano wrote: > On Mon, 10 Mar 2014 19:34:48 +0200, Marko Rauhamaa wrote: > >>> With a high level language like Python, using the provided hash table >>> will almost always cream any hand-built tree, no matter how >>> advantageous the data is to the tree.

Re: Balanced trees

2014-03-18 Thread Dan Stromberg
On Mon, Mar 17, 2014 at 3:05 PM, Marko Rauhamaa wrote: > Joshua Landau : > >> The thing we really need is for the blist containers to become stdlib >> (but not to replace the current list implementation). > > Very interesting. Downloaded blist but didn't compile it yet. It *could* > be the missing

Re: Balanced trees

2014-03-18 Thread Dan Stromberg
On Tue, Mar 18, 2014 at 1:55 PM, Marko Rauhamaa wrote: > Dan Stromberg : > >> The results are at >> http://stromberg.dnsalias.org/~strombrg/python-tree-and-heap-comparison/2014-03/ > > Unfortunately I'm having a hard time understanding the results. > > The 50/5

Re: Balanced trees

2014-03-18 Thread Dan Stromberg
On Tue, Mar 18, 2014 at 3:03 PM, Marko Rauhamaa wrote: > Dan Stromberg : > For a proper comparison, I'd like a fixed, identical dataset and set of > operations run against each data structure. > > How about this test program: I used to do essentially this, but it was

Re: Controlling buffer alignment in file.read()

2014-03-18 Thread Dan Stromberg
On Tue, Mar 18, 2014 at 1:23 PM, Haralanov, Mitko wrote: > Hi all, > > I am using Python to read from a binary device file which requires that all > read sizes are in 8byte multiples and the user's buffer is 8byte aligned. > > I am currently using a file object and the file.read() method. However

Re: Balanced trees

2014-03-19 Thread Dan Stromberg
On Wed, Mar 19, 2014 at 7:16 PM, Rhodri James wrote: > 65536 is a suspiciously round number. You might want to double- > check that there's no 16-bit overflow causing something unexpected. It's because I'm using powers of 2. All the numbers in the report are round in hex. -- https://mail.pytho

Re: running python 2 vs 3

2014-03-20 Thread Dan Stromberg
On Thu, Mar 20, 2014 at 8:21 AM, Marko Rauhamaa wrote: > notbob : > >> I've installed python 3.3 on my Slack box, which by default comes with >> python 2.7. I know how to fire up the different IDLE environments, but >> how do I differentiate between the scripts? IOW, up till now, I've >> used .py

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-27 Thread Dan Stromberg
On Fri, Mar 21, 2014 at 1:42 PM, vasudevram wrote: > Can anyone - maybe one of the Python language core team, or someone with > knowledge of the internals of Python - can explain why this code works, and > whether the different occurrences of the name x in the expression, are in > different sco

Re: Recording instruction/data flow for a python script/program.

2014-04-02 Thread Dan Stromberg
Google is your friend: https://docs.python.org/2/library/trace.html On Wed, Apr 2, 2014 at 4:02 PM, Skybuck Flying wrote: > Hello, > > Is there a way for a python script's execution to be capture in an > instruction/data flow log ? > > Since python is an interpreter this should be easy to do ? >

Re: random.seed question (not reproducing same sequence)

2014-04-15 Thread Dan Stromberg
You could easily provide your own random number generator, if you don't need cryptographic-strength random numbers. EG: http://stromberg.dnsalias.org/svn/lcgrng/trunk/lcgrng.py That way you can be certain nothing else is using it. On Tue, Apr 15, 2014 at 8:54 AM, Nick Mellor wrote: > Hi guys,

Re: using smtp in python

2013-10-22 Thread Dan Stromberg
On Tue, Oct 22, 2013 at 11:00 AM, wrote: > I'm trying to send an email using python. The mail content is taken from > file and subject of the mail is name of the file. The program is invoked as > ./mailclient.py -f -d > -i -s > . > How to i use server ip address and the mail id to send th

Re: Will Python 3.x ever become the actual standard?

2013-10-23 Thread Dan Stromberg
On Wed, Oct 23, 2013 at 4:57 AM, wrote: > I am starting to have doubts as to whether Python 3.x will ever be > actually adopted by the Python community at large as their standard. Years > have passed, and a LARGE number of Python programmers has not even bothered > learning version 3.x. Why am I

Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread Dan Stromberg
xz compression is pretty hard, if a little bit slow. Also, if you want really stellar compression ratios and you don't care about time to compress, you might check out one of the many paq implementations. I have a module that does xz compression in 4 different ways: http://stromberg.dnsalias.org/

Re: "Backward"-Iterator - Beginners question

2013-10-31 Thread Dan Stromberg
On Thu, Oct 31, 2013 at 2:29 PM, Ulrich Goebel wrote: > Hallo, > > I'm locking for an "iterator" type with not only the .next() method, but > with a .previous(), .first() and .last() method, so that I can through it > from the beginning or from the end, and in both directions, even > alternately

Re: Automation

2013-11-03 Thread Dan Stromberg
On Sun, Nov 3, 2013 at 8:19 AM, Renato Barbosa Pim Pereira < renato.barbosa.pim.pere...@gmail.com> wrote: > I have one .xls file with the values of PV MV and SP, I wanna to calculate > Kp Ki Kd with python from this file, can anyone give me any suggestion > about how can I do this? From now, thank

Statically linking part of a C extension module?

2015-03-23 Thread Dan Stromberg
Hi folks. I want to build a pair of wheels - one for numpy, one for scipy. And I want to statically link atlas (with blas and lapack) into these wheels. I don't want to statically link numpy or scipy into the Python interpreter. The goal is to decrease the frequency with which new wheels need t

Daylight savings time question

2015-03-24 Thread Dan Stromberg
Is there a way of "adding" 4 hours and getting a jump of 5 hours on March 8th, 2015 (due to Daylight Savings Time), without hardcoding when to spring forward and when to fall back? I'd love it if there's some library that'll do this for me. #!/usr/bin/python import pytz import datetime def main

Re: Daylight savings time question

2015-03-24 Thread Dan Stromberg
e') main() On Tue, Mar 24, 2015 at 3:24 PM, Dan Stromberg wrote: > Is there a way of "adding" 4 hours and getting a jump of 5 hours on > March 8th, 2015 (due to Daylight Savings Time), without hardcoding > when to spring forward and when to fall back? I'd love

Pep 484 Type Hint Checker - Python releases supported?

2015-05-28 Thread Dan Stromberg
I believe I heard that the PEP 484 type checker is to go into CPython 3.5. Since type annotations have been there since 3.0, is it at all likely that CPython versions < 3.5 will also be supported by this checker? Thanks! -- https://mail.python.org/mailman/listinfo/python-list

Re: Accessing DataSocket Server with Python

2015-05-28 Thread Dan Stromberg
I have no idea about the protocol used by NI DataSockets, but you might be able to reverse engineer the protocol by using the official client with a sniffer. Also, be aware that TCP/IP guarantees that you get the correct data in the correct order, but it doesn't guarantee anything about the sizes

Re: How to check in script if Python or Jython is used

2015-06-22 Thread Dan Stromberg
IMO, it's usually better to test for features and use them if they are present, than to build a list of features available in specific interpreters. I see it as analogous to the difference between huge C #ifdef's on OS, and autoconf. On Sun, Jun 21, 2015 at 1:12 AM, Cecil Westerhof wrote: > I in

Looking up a dictionary _key_ by key?

2015-06-23 Thread Dan Stromberg
I know that sounds strange: usually we look up values by key, not keys. But suppose you have a strange key type that despite being "equal", is not identical in some fields, and you need to see those fields. Is there a way of getting the key used by the dictionary, short of storing a reference to

Re: Looking up a dictionary _key_ by key?

2015-06-23 Thread Dan Stromberg
On Tue, Jun 23, 2015 at 5:33 PM, Ben Finney wrote: > Dan Stromberg writes: > >> Is there a way of getting the key used by the dictionary, short of >> storing a reference to it in the value, or using a second dictionary? > > The dictionary knows its keys and can provide t

http.server.BaseHTTPRequestHandler basic auth logout? Django authentication system for REST interface?

2014-06-06 Thread Dan Stromberg
I have some code for a web server. Right now, it uses BaseHTTPRequestHandler with Basic Auth, but we want to be able to log out, and there doesn't appear to be a general way to log out of something using Basic Auth, short of turning to unportable JavaScript. And this needs first and foremost to b

Decorating one method of a class C with another method of class C?

2014-06-06 Thread Dan Stromberg
Is there a way of decorating method1 of class C using method2 of class C? It seems like there's a chicken-and-the-egg problem; the class doesn't seem to know what "self" is until later in execution so there's apparently no way to specify @self.method2 when def'ing method1. -- https://mail.python.

Re: Decorating one method of a class C with another method of class C?

2014-06-08 Thread Dan Stromberg
On 6/6/14, Ben Finney wrote: > Dan Stromberg writes: > >> Is there a way of decorating method1 of class C using method2 of class >> C? > > Can you give a concrete example (i.e. not merely hypothetical) where > this would be a useful feature (i.e. an actual improvemen

Re: PEP8 and 4 spaces

2014-07-06 Thread Dan Stromberg
On Thu, Jul 3, 2014 at 10:31 AM, Tobiah wrote: > Coworker takes PEP8 as gospel and uses 4 spaces > to indent. I prefer tabs. I recently converted from tabs to spaces. I probably still have some code that uses tabs, but most of my personal stuff has been converted. I like tabs. Tabs work bette

Re: open() and EOFError

2014-07-07 Thread Dan Stromberg
On 7/7/14, Mark Lawrence wrote: > On 07/07/2014 09:09, Chris Angelico wrote: >> On Mon, Jul 7, 2014 at 6:00 PM, Steven D'Aprano >> wrote: >>> How do people feel about code like this? >>> >>> try: >>> name = input("Enter file name, or Ctrl-D to exit") >>> # On Windows, use Ctrl-Z [enter]

Re: Python top learning language

2014-07-08 Thread Dan Stromberg
On Tue, Jul 8, 2014 at 12:19 PM, candide wrote: > http://www.infoworld.com/d/application-development/python-bumps-java-top-learning-language-245774 As a sort of nano-celebration, here's a blast from Python's past (May, 1997): https://web.archive.org/web/19970501011626/http://www.python.org/ -- h

Solution-resistant AttributeError: 'modle' object has no attribute...

2014-07-10 Thread Dan Stromberg
Hi folks. I'm having trouble with a strange AttributeError. I'm using RQ (Redis Queue) and Django, both of which are new to me, so perhaps they are somehow relevant. Anyway, the traceback looks like: Traceback (most recent call last): File "/home/ec2-user/miniconda/envs/sciencedb/lib/python2.

Re: Solution-resistant AttributeError: 'modle' object has no attribute...

2014-07-10 Thread Dan Stromberg
On Thu, Jul 10, 2014 at 9:41 AM, Dan Stromberg wrote: > Hi folks. > > I'm having trouble with a strange AttributeError. I'm using RQ (Redis > Queue) and Django, both of which are new to me, so perhaps they are > somehow relevant. > > Anyway, the traceback looks

Re: Python 3 is killing Python

2014-07-12 Thread Dan Stromberg
On Wed, May 28, 2014 at 12:23 PM, Larry Martell wrote: > Somthing I came across in my travels through the ether: > > https://medium.com/@deliciousrobots/5d2ad703365d/ Hey kids, maybe if we all chant this enough times, we can make it true! Wouldn't that be fun? -- https://mail.python.org/mailman

Re: codingbat question broken?

2014-07-12 Thread Dan Stromberg
This runs on 2.7 or 3.4, unmodified (other than the #!): #!/usr/local/cpython-2.7/bin/python #!/usr/local/cpython-3.4/bin/python def lucky_sum(*list_): lucky_total = 0 for element in list_: if element == 13: break lucky_total += element return lucky_total

Re: What Next After Python Basics

2014-07-13 Thread Dan Stromberg
On Sun, Jul 13, 2014 at 1:16 PM, Orochi wrote: > Hi, > I am beginner in Python > I have Completed Basic Python Course from Codecademy.com . > Now that I have a hands on the basics what is the next thing I should do. > I mean should I learn more or start a small Project(Any Ideas are Welcomed) > o

Re: Python 3 is killing Python

2014-07-17 Thread Dan Stromberg
On Thu, Jul 17, 2014 at 7:49 PM, alex23 wrote: > On 17/07/2014 1:14 PM, Steven D'Aprano wrote: >> >> There will never be a Python 2.8. When push comes to shove, the people >> bitching about Python 3 will not do the work necessary to fork Python 2.7 >> and make a version 2.8. > > > +1 > > The idea

Re: Is it possible to install Python on a network?

2014-07-22 Thread Dan Stromberg
On Tue, Jul 22, 2014 at 5:41 PM, roys2005 wrote: > > Emile, thanks for the quick response. > > Does this mean Python cannot be or should not be installed at a central > location? > If so, what is the root cause for this? Back when I was a sysadmin, I would install CPython to a few different NFS

Re: Is it possible to install Python on a network?

2014-07-23 Thread Dan Stromberg
On Wed, Jul 23, 2014 at 7:15 AM, roys2005 wrote: > > Dan, > > Thanks for the information. So, one option is to build Python > from source code to be able to install "/where/ever/..." > > I still wonder why there is no distribution package for *ix that > contains binaries/libraries that can

Re: Prob. Code Downloaded for Programming the Semantic Web (python code)

2014-07-25 Thread Dan Stromberg
On Fri, Jul 25, 2014 at 5:21 PM, Skip Montanaro wrote: >> OK, Eclipse with PyDev doesn't like this first line, with the function: >> def add(self, (sub, pred, obj)): >> >> It complains about the parentheses just before sub. > > Seems like this code is Python 2.x. For me, this code ran on all of 2

Re: What meaning of this ""hello %s you are %s years old" % x"

2014-07-27 Thread Dan Stromberg
On Sun, Jul 27, 2014 at 11:49 AM, fl wrote: > In Python, when should you use lists and when tuples? > > Sometimes you don't have a choice, for example if you have > > "hello %s you are %s years old" % x > then x must be a tuple. > > But if I am the one who designs the API and gets to choose the da

Re: NameError: name 'requests' is not defined ?

2014-07-27 Thread Dan Stromberg
On Sun, Jul 27, 2014 at 8:52 PM, 水静流深 <1248283...@qq.com> wrote: > there is a simple file `mydown.py` saved in `D:\Python34\Lib\site-packages` > there is only one line in mydown.py . > > import requests > > > > C:\Users\pengsir>d:\Python34\python > Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 1

Re: How to loop through nodes of xml through xslt

2014-07-30 Thread Dan Stromberg
On Wed, Jul 30, 2014 at 5:16 AM, varun bhatnagar wrote: > Hi, > > I have two xml files. > I am trying to fetch an output file which looks like this: > > Output.xml > The number of Procedure tag () can be different every time. So I > have to read this tag every time from each xml and then merge i

Re: What is best way to learn Python for advanced developer?

2014-07-30 Thread Dan Stromberg
I like to think of pylint as an expert system about how to write better Python. Some of the warnings are pointless (superfluous-parens really bugs me), but much of it is quite valuable. And for the -really- pointless stuff, you can create a pylintrc to ignore them forever. Personally, I prefer t

Re: How to loop through nodes of xml through xslt

2014-07-31 Thread Dan Stromberg
t. > Is there any way out to achieve this? > > Thanks, > BR, > Varun > > > On Thu, Jul 31, 2014 at 5:47 AM, Dan Stromberg wrote: >> >> On Wed, Jul 30, 2014 at 5:16 AM, varun bhatnagar >> wrote: >> > Hi, >> > >> > I

Re: Dict when defining not returning multi value key error

2014-07-31 Thread Dan Stromberg
On Thu, Jul 31, 2014 at 4:24 AM, Dilu Sasidharan wrote: > Hi, > > I am wondering why the dictionary in python not returning multi value key > error when i define something like > > p = {'k':"value0",'k':"value1"} > > key is string immutable and sometimes shares same id. > > also if the key is immu

Re: Dict when defining not returning multi value key error

2014-07-31 Thread Dan Stromberg
On Thu, Jul 31, 2014 at 8:08 PM, Dan Stromberg wrote: >> p = {'1':"value0",'1.0':"value1"} > For 1 and 1.0 - they simply hash differently. Dictionaries are > resizeable hash tables. I removed some quotes, and noticed that 1 and 1.0 hash t

web2py and python3

2014-08-13 Thread Dan Stromberg
I heard there was a presentation about web2py in my area tonight. Trying to decide if I wanted to attend, I googled about web2py and python3. I was amazed by what I found. I've never seen a group so opposed to python3. They make the old (and long-since lost) Solaris 2 wars seem tame. I don't th

Re: get the min date from a list

2014-08-14 Thread Dan Stromberg
On Thu, Aug 14, 2014 at 5:44 PM, Mark Lawrence wrote: > I really don't understand why people here are spoon feeding you when you > still insist on top posting. Ever heard the term "manners"? Oh what a > stupid comment, obviously not. > > *plonk* Getting people to stop top-posting is a losing ba

Re: efficient partial sort in Python ?

2014-08-18 Thread Dan Stromberg
On Mon, Aug 18, 2014 at 10:18 AM, Chiu Hsiang Hsu wrote: > I know that Python use Timsort as default sorting algorithm and it is > efficient, > but I just wanna have a partial sorting (n-largest/smallest elements). Perhaps heapq with Pypy? Or with nuitka? Or with numba? -- https://mail.python

Re: efficient partial sort in Python ?

2014-08-19 Thread Dan Stromberg
On Tue, Aug 19, 2014 at 12:37 PM, Chiu Hsiang Hsu wrote: > On Tuesday, August 19, 2014 5:42:27 AM UTC+8, Dan Stromberg wrote: >> On Mon, Aug 18, 2014 at 10:18 AM, Chiu Hsiang Hsu wrote: >> >> > I know that Python use Timsort as default sorting algorithm and it is >&

Re: efficient partial sort in Python ?

2014-08-19 Thread Dan Stromberg
On Tue, Aug 19, 2014 at 4:05 PM, Dan Stromberg wrote: > When you use heapq, are you putting all the values in the heap, or > just up to n at a time (evicting the worst value, one at a time as you > go)? If you're doing the former, it's basically a heapsort which > proba

Re: efficient partial sort in Python ?

2014-08-19 Thread Dan Stromberg
On Tue, Aug 19, 2014 at 4:10 PM, Dan Stromberg wrote: > On Tue, Aug 19, 2014 at 4:05 PM, Dan Stromberg wrote: >> When you use heapq, are you putting all the values in the heap, or >> just up to n at a time (evicting the worst value, one at a time as you >> go)? If you'

Re: how to copy emails into local directory?

2014-08-20 Thread Dan Stromberg
On Wed, Aug 20, 2014 at 5:09 AM, luofeiyu wrote: > i want to copy all the emails in the gmailbox of > "[Gmail]/&kc2JgQ-" (the important mailbox in my gmail" > into local directory "g:\emails",how can i do that in python code? You could also try http://wiki.vpslink.com/Mount_a_Gmail_Account_as

Re: 'is not' or '!='

2014-08-21 Thread Dan Stromberg
On Mon, Aug 18, 2014 at 1:35 PM, ElChino wrote: > A newbie question to you; what is the difference between statements like: > if x is not None: > and > if x != None: > > Without any context, which one should be preferred? > IMHO, the latter is more readable. You've got some good answers. I'd li

Re: what do you get with 1 divide by 998001, interesting results

2014-08-21 Thread Dan Stromberg
Amusing. It works in hexadecimal too: numerator = 1 denominator = 0xffe001 shift = int(16 ** 30) print(hex(int(numerator * shift / denominator))) -- https://mail.python.org/mailman/listinfo/python-list

Re: Global indent

2014-08-22 Thread Dan Stromberg
On Fri, Aug 22, 2014 at 11:44 AM, Neil D. Cerutti wrote: > On 8/22/2014 2:19 PM, Seymore4Head wrote: >> >> Is there a way to indent everything again? >> >> Say I have a while statement with several lines of code and I want to >> add a while outside that. That means indenting everything. Is there

Re: Global indent

2014-08-22 Thread Dan Stromberg
On Fri, Aug 22, 2014 at 1:16 PM, Neil D. Cerutti wrote: >> Emacs and vim both have huge learning curves that I've decided aren't >> worth climbing. Notepad++ is an excellent GUI text editor for Windows. >> Geany is nearly as good, and runs on anything. > > > They do have a very long learning incl

Re: proposed syntax for multiline anony-functions (hopefully?)

2014-08-22 Thread Dan Stromberg
On Thu, Aug 21, 2014 at 12:55 AM, wrote: > Hi, just wanting to do a shot in the dark,but maybe this syntax is Pythonic > (in a "we-are-all-grown-ups" fashion, ahem)enough to get its way into the > language > this is what yours truly thinks: don't we all know that ":" means the next > token mus

Re: proposed syntax for multiline anony-functions (hopefully?)

2014-08-22 Thread Dan Stromberg
On Thu, Aug 21, 2014 at 12:55 AM, wrote: > Hi, just wanting to do a shot in the dark,but maybe this syntax is Pythonic > (in a "we-are-all-grown-ups" fashion, ahem)enough to get its way into the > language > this is what yours truly thinks: don't we all know that ":" means the next > token mus

Re: Media Conversion Using Python - Converting MP3 to Other Formats

2014-08-25 Thread Dan Stromberg
On Mon, Aug 25, 2014 at 9:04 AM, Mark Lawrence wrote: > On 25/08/2014 16:28, Parth Trivedi wrote: >> >> Dear All, >> >> I need some help of yours. I want to convert audio in MP3 format to >> other formats including uncompressed raw format, WAV etc. and I am using >> python 2.7. Is there any built-

Re: python string, best way to concat

2014-08-27 Thread Dan Stromberg
On Wed, Aug 27, 2014 at 1:31 PM, wrote: > > Hi, > > Sorry about the simple question but I am very new to Python. > > Anyway, I have a function that will be used to call a stored procedure and > I need to format the string with the correct number of parameter markers for > the ODBC driver,

Re: Distinguishing between maildir, mbox, and MH files/directories?

2014-08-31 Thread Dan Stromberg
On Sun, Aug 31, 2014 at 11:45 AM, Tim Chase wrote: > Tinkering around with a little script, I found myself with the need > to walk a directory tree and process mail messaged found within. > Sometimes these end up being mbox files (with multiple messages > within), sometimes it's a Maildir structur

Re: Prime testing [was Re: My backwards logic]

2014-09-07 Thread Dan Stromberg
On Sun, Sep 7, 2014 at 11:53 AM, Peter Pearson wrote: > On Sat, 6 Sep 2014 12:53:16 +0200, Manolo Martínez wrote: >> On 09/06/14 at 08:38pm, Steven D'Aprano wrote: >>> But even that's not how the specialists do it. If you want to check whether >>> (say) 2**3000+1 is prime, you don't want to use tr

Re: String representations of numbers and approximate equality

2014-09-24 Thread Dan Stromberg
On Wed, Sep 24, 2014 at 9:54 AM, Chris Angelico wrote: > Yes, it's another "how can I see if two numbers are approximately > equal" thread, but this time I have a concrete definition of > "approximately equal"... and they're Decimals, not floats. > > I have a number of files (this is an ongoing th

Re: Obscuring Python source from end users

2014-10-01 Thread Dan Stromberg
On Mon, Sep 29, 2014 at 4:47 AM, Steven D'Aprano wrote: > norman.i...@gmail.com wrote: > >> Hello list >> >> Python 3.4 applies. >> >> I have a project that involves distributing Python code to users in an >> organisation. Users do not interact directly with the Python code; they >> only know this

Re: How to show a dictionary sorted on a value within its data?

2014-10-02 Thread Dan Stromberg
On Thu, Oct 2, 2014 at 12:15 PM, Ian Kelly wrote: > On Thu, Oct 2, 2014 at 10:33 AM, wrote: >> Ah, so at least there is a reason for it, I'm far from being a >> mathematician though so it's not particularly obvious (for me anyway). > > You're not alone; a lot of people find the terminology not i

Re: "High water" Memory fragmentation still a thing?

2014-10-04 Thread Dan Stromberg
On Fri, Oct 3, 2014 at 1:01 PM, Skip Montanaro wrote: > On Fri, Oct 3, 2014 at 1:36 PM, Croepha > wrote: > >> Long running Python jobs that consume a lot of memory while >> running may not return that memory to the operating system >> until the process actually terminates, even if everything is >

Re: python on Linux

2014-10-09 Thread Dan Stromberg
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')

Re: How to select every other line from a text file?

2014-10-13 Thread Dan Stromberg
On Mon, Oct 13, 2014 at 10:38 AM, Rff wrote: > Hi, > I have a text file. Now it is required to select every other line of that > text to > generate a new text file. I have read through Python grammar, but still lack > the > idea at the beginning of the task. Could you tell me some methods to g

Re: Is there an easy way to control indents in Python

2014-10-14 Thread Dan Stromberg
On Tue, Oct 14, 2014 at 7:13 PM, ryguy7272 wrote: > I'm just learning Python. It seems like indents are EXTREMELY important. I > guess, since there are no brackets, everything is controlled by indents. > Well, I'm reading a couple books on Python now, and in almost all of the > examples they

Re: Question About Running Python code

2014-10-15 Thread Dan Stromberg
On Wed, Oct 15, 2014 at 3:50 PM, ryguy7272 wrote: > I'm trying to run this script (using IDLE 3.4) > I would be most appreciative if someone could respond to a few questions. > > The error that I get is this. > 'invalid syntax' You may get better help if you give the context of this message. >

Re: Import Doesn't Import

2014-10-15 Thread Dan Stromberg
On Wed, Oct 15, 2014 at 5:40 PM, ryguy7272 wrote: > > ImportError: No module named 'urllib2' http://stackoverflow.com/questions/2792650/python3-error-import-error-no-module-name-urllib -- https://mail.python.org/mailman/listinfo/python-list

Re: Import Doesn't Import

2014-10-15 Thread Dan Stromberg
On Wed, Oct 15, 2014 at 5:44 PM, ryguy7272 wrote: > Either this is the most brilliant thing ever invented, or it's the biggest > piece of shit ever invented. I just can't tell. All I know for sure, is > that it doesn't do ANYTHING that I tell it to do. Maybe you should decide whether you wan

Re: Flush stdin

2014-10-18 Thread Dan Stromberg
On Sat, Oct 18, 2014 at 6:11 PM, Nobody wrote: > On Sat, 18 Oct 2014 12:32:07 -0500, Tim Chase wrote: > >> On 2014-10-18 17:55, Nobody wrote: >>> On Fri, 17 Oct 2014 12:38:54 +0100, Empty Account wrote: >>> >>> > I am using netcat to listen to a port and python to read stdin and >>> > print to the

Re: Flush stdin

2014-10-18 Thread Dan Stromberg
On Sat, Oct 18, 2014 at 6:34 PM, Dan Stromberg wrote: >> Once the "nc" process actually write()s the data to its standard >> output (i.e. desriptor 1, not the "stdout" FILE*) > I'm not sure why you're excluding stdout, but even if nc is using > file

<    3   4   5   6   7   8   9   10   11   >