Re: Building a tree-based readline completer

2013-11-18 Thread Dave Angel
On Mon, 18 Nov 2013 08:55:05 -0800 (PST), roey.k...@gmail.com wrote: On Monday, November 18, 2013 11:54:43 AM UTC-5, roey wrote: Thank you. In looking over these classes, I see though that even them, I would run against the same limitations, though. Please don't double space your quotes.

Re: Data structure question

2013-11-17 Thread Dave Angel
On Mon, 18 Nov 2013 02:03:38 +, Joseph L. Casale jcas...@activenetwerx.com wrote: I have a need for a script to hold several tuples with three values, two text strings and a lambda. I need to index the tuple based on either of the two strings. Normally a database would be ideal but for a

Re: Question regarding 2 modules installed via 'pip'

2013-11-16 Thread Dave Angel
On Sat, 16 Nov 2013 07:15:01 -0800 (PST), Ferrous Cranus nikos.gr...@gmail.com wrote: 'locate pythοn3.4 | rm -rf' will this help or do any accidental damage? The files deleted by the rm -rf have nothing to do with the results of locate. Since you don't understand that , your system is

Re: The Spirit of Python

2013-11-14 Thread Dave Angel
On Thu, 14 Nov 2013 13:11:08 -0500, Roy Smith r...@panix.com wrote: Intriguing subject line but an empty message body. Please post in text not html if you want everyone to see it. Thanks -- DaveA -- https://mail.python.org/mailman/listinfo/python-list

Re: Implementing #define macros similar to C on python

2013-11-14 Thread Dave Angel
On Thu, 14 Nov 2013 18:29:48 -0800 (PST), JL lightai...@gmail.com wrote: One of my favorite tools in C/C++ language is the preprocessor macros. One example is switching certain print messages for debugging use only #ifdef DEBUG_ENABLE DEBUG_PRINT print #else DEBUG_PRINT Is it

Re: The Spirit of Python

2013-11-14 Thread Dave Angel
On Fri, 15 Nov 2013 15:16:09 +1100, Ben Finney ben+pyt...@benfinney.id.au wrote: Dave Angel da...@davea.name writes: On Thu, 14 Nov 2013 13:11:08 -0500, Roy Smith r...@panix.com wrote: Intriguing subject line but an empty message body. Please post in text not html if you want

Re: Please help with this

2013-11-12 Thread Dave Angel
On Tue, 12 Nov 2013 20:18:58 -0800 (PST), saad imran saad.imra...@gmail.com wrote: Could you point out any errors in my code: que1 = 4481 *2 ans1 = 8962 que2 = 457 * 21 ans2 = 9597 These values should all be in a single named structure, probably a list of tuples. Then all that duplicated

Re: Implementing a multivibrator function with python

2013-11-11 Thread Dave Angel
On Mon, 11 Nov 2013 01:41:58 -0800 (PST), JL lightai...@gmail.com wrote: - If the event happens again before the 5secs expire, the high duration will be extended by another 5 secs. This works like a retriggerable multivibrator for those who are into electronics. More precisely a retriggerable

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

2013-11-07 Thread Dave Angel
On Thu, 7 Nov 2013 18:43:17 -0800, Mark Janssen dreamingforw...@gmail.com wrote: I think the idea would be to find the prime factorization for a given number, which has been proven to be available (and unique) for any and every number. Most numbers can compress given this technique. Prime

Re: How to add a current string into an already existing list

2013-11-05 Thread Dave Angel
On Tue, 05 Nov 2013 11:34:53 +0200, Nick the Gr33k nikos.gr...@gmail.com wrote: I see, but because of the traceback not being to express it more easily i was under the impression that data wasn't what i expected it to be. Exactly. So why didn't you act on that impression? Your error message

Re: How to add a current string into an already existing list

2013-11-05 Thread Dave Angel
On Tue, 05 Nov 2013 12:33:49 +0200, Nick the Gr33k nikos.gr...@gmail.com wrote: Στις 5/11/2013 12:20 μμ, ο/η Antoon Pardon έγραψε: Did you read the documentation of fetchone? fetchone is like fetchall except from the fact that the former returned a row of data while the latter returned

Re: How to add a current string into an already existing list

2013-11-05 Thread Dave Angel
On Tue, 05 Nov 2013 14:25:41 +0200, Nick the Gr33k nikos.gr...@gmail.com wrote: i tried inserting a type function to notify me of the datatype of 'data' but that didnt help too. What did that print show ? In what way didn't it help? It said the type was Charles It didn'tprint anything It

Re: how to find out utf or not

2013-11-05 Thread Dave Angel
On Tue, 05 Nov 2013 16:32:57 +0330, Mohsen Pahlevanzadeh moh...@pahlevanzadeh.org wrote: Suppose i have a variable such as : myVar = 'x' May be it initialized with myVar = u'x' or myVar = 'x' So i need determine content of myVar that it's utf-8 or not, how can i do it? Use the type()

Re: How to add a current string into an already existing list

2013-11-05 Thread Dave Angel
On Tue, 5 Nov 2013 09:45:15 -0600, Tim Chase python.l...@tim.thechases.com wrote: You're assigning it to the bound function rather than calling the function. Use the call operator: data = infile.readlines() Thanks for spoiling the lesson. Nicks needs to learn how to debug 4 line

Re: Help me with this code

2013-11-05 Thread Dave Angel
On Tue, 5 Nov 2013 17:51:00 -0800 (PST), chovd...@gmail.com wrote: result += ((-1) ** (k+1))/2*k-1 One of two things are happening here. Maybe both. You're using Python 2.x (and should havesaid so) where integer division is truncated. You're missing around some part of the

Re: how to find out utf or not

2013-11-05 Thread Dave Angel
On 5 Nov 2013 15:30:19 GMT, Neil Cerutti ne...@norwich.edu wrote: On 2013-11-05, Dave Angel da...@davea.name wrote: On Tue, 05 Nov 2013 16:32:57 +0330, Mohsen Pahlevanzadeh May be it initialized with myVar = u'x' or myVar = 'x' My solution assumed he wanted to distinguish between those two

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

2013-11-04 Thread Dave Angel
On Mon, 4 Nov 2013 05:53:28 -0800 (PST), jonas.thornv...@gmail.com wrote: Den lördagen den 2:e november 2013 kl. 22:31:09 UTC+1 skrev Tim Roberts: Here's another way to look at it. If f(x) is smaller than x for every x, that means there MUST me multiple values of x that produce the

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

2013-11-04 Thread Dave Angel
On Mon, 4 Nov 2013 14:34:23 -0800 (PST), jonas.thornv...@gmail.com wrote: e is an approximation... and your idea is not general for any n. e is certainly not an approximation, and I never mentioned n. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list

Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Dave Angel
On 30/10/2013 12:31, jonas.thornv...@gmail.com wrote: No that is not my problem, apparently so it is that the newsreader constructors do not like the competition of Google groups otherwise they would had written the five lines of codes necessary to remove the empty linebreaks. I like

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

2013-10-30 Thread Dave Angel
On 30/10/2013 14:21, jonas.thornv...@gmail.com wrote: I am searching for the program or algorithm that makes the best possible of completly (diffused data/random noise) and wonder what the state of art compression is. I understand this is not the correct forum but since i think i have an

Re: Help with guessing game :D

2013-10-29 Thread Dave Angel
On 29/10/2013 14:05, Robert Gonda wrote: Back to question, name is also not working, I currently have python 3.3.2 and the only to get that work is the write raw_input, I have no idea why, did i do soemthing wrong? Why did you add those two symbols in front of your new text? Each such

Re: First day beginner to python, add to counter after nested loop

2013-10-29 Thread Dave Angel
On 29/10/2013 14:35, jonas.thornv...@gmail.com wrote: (Deleting hundreds of quad-spaced garbage. Please be more considerate of others if you choose to use buggy googlegroups, maybe starting by studying: ) Please indent by 4 columns, not 1. Since indentation is how scope is specified in

Re: Help with guessing game :D

2013-10-29 Thread Dave Angel
On 29/10/2013 15:15, Robert Gonda wrote: (once again deleting all the double-spaced Googlegroups nonsense) Hi dave, yes you was right. I had python 2.7 but I upgraded to python 3 now, thanks for help :) by the way, is this showing normally? No, you're still adding a character before

Re: First day beginner to python, add to counter after nested loop

2013-10-29 Thread Dave Angel
On 29/10/2013 16:11, jonas.thornv...@gmail.com wrote: Den tisdagen den 29:e oktober 2013 kl. 21:08:39 UTC+1 skrev jonas.t...@gmail.com: Den tisdagen den 29:e oktober 2013 kl. 20:24:57 UTC+1 skrev Dave Angel: They could had used print and prinln from basic? I do not want new line

Re: personal library

2013-10-29 Thread Dave Angel
On 29/10/2013 17:29, patrick vrijlandt wrote: Hello list, Python has been a hobby for me since version 1.5.2. Over the years I accumulated quite a lot of reusable code. It is nicely organised in modules, directories and subdirectories. With every project, the library grows and is developed

RE: Using with open(filename, 'ab'): and calling code only if the file is new?

2013-10-29 Thread Dave Angel
On 29/10/2013 21:42, Joseph L. Casale wrote: You forgot the attribution line: Victor says with open(self.full_path, 'r') as input, open(self.output_csv, 'ab') as output: fieldnames = (...) csv_writer = DictWriter(output, filednames) # Call

Re: Running Python programmes

2013-10-28 Thread Dave Angel
On 27/10/2013 11:31, Colin J. Williams wrote: On 27/10/2013 10:32 AM, David wrote: I am an absolute beginner and am working through the book Python Programming for the Absolute Beginner by Michael Dawson. Everything is fine except if I run a scripted programme, or one I have downloaded,

Re: Printing a drop down menu for a specific field.

2013-10-27 Thread Dave Angel
On 27/10/2013 03:31, Nick the Gr33k wrote: Στις 27/10/2013 6:00 πμ, ο/η ru...@yahoo.com έγραψε: snip I read it thoroughly and tested it and it works as it should. I just wanted to mention that the definition of the function coalesce() must come prior of: newdata =

Re: Processing large CSV files - how to maximise throughput?

2013-10-25 Thread Dave Angel
On 25/10/2013 02:13, Chris Angelico wrote: On Fri, Oct 25, 2013 at 2:57 PM, Dave Angel da...@davea.name wrote: But I would concur -- probably they'll both give about the same speedup. I just detest the pain that multithreading can bring, and tend to avoid it if at all possible. I don't have

Re: question

2013-10-24 Thread Dave Angel
On 23/10/2013 16:24, Cesar Campana wrote: Hi! Im installing the python library for the version 2.7 but Im getting the error unable to find vcvarsall.bat I was looking on line but it says is related to Visual Studio...? Can you guys please help me to fix this... The other responses were

Re: Processing large CSV files - how to maximise throughput?

2013-10-24 Thread Dave Angel
On 24/10/2013 21:38, Victor Hooi wrote: Hi, We have a directory of large CSV files that we'd like to process in Python. We process each input CSV, then generate a corresponding output CSV file. input CSV - munging text, lookups etc. - output CSV My question is, what's the most Pythonic

Re: Processing large CSV files - how to maximise throughput?

2013-10-24 Thread Dave Angel
On 24/10/2013 23:35, Steven D'Aprano wrote: On Fri, 25 Oct 2013 02:10:07 +, Dave Angel wrote: If I have multiple large CSV files to deal with, and I'm on a multi-core machine, is there anything else I can do to boost throughput? Start multiple processes. For what you're doing

Re: Python Front-end to GCC

2013-10-22 Thread Dave Angel
On 22/10/2013 08:00, Steven D'Aprano wrote: On Tue, 22 Oct 2013 10:14:16 +0100, Oscar Benjamin wrote: snip Here's an example: responding to a benchmark showing a Haskell compiler generating faster code than a C compiler, somebody re-wrote the C code and got the opposite result:

Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-10-21 Thread Dave Angel
On 21/10/2013 17:19, Peter Cacioppi wrote: Just because the CPython implementation does something doesn't mean If you're going to drop messages in here with no context, you'd be better off just putting it in a bottle and tossing it into the sea. Include a quote from whomever you're responding

Re: Python Front-end to GCC

2013-10-21 Thread Dave Angel
On 22/10/2013 00:24, Mark Janssen wrote: A language specification in BNF is just syntax. It doesn't say anything about semantics. So how could this be used to produce executable C code for a program? BNF is used to produce parsers. But a parser isn't sufficient. A C program is just syntax

Re: Receiving 'NAMEERROR:name' when I try and execute my code in DEBUG mode

2013-10-18 Thread Dave Angel
On 18/10/2013 13:02, telconsta...@gmail.com wrote: Hey John, Thanks for the response. I really don't know why I didn't think about that. I decided to add the following statement: print root When I RUN, this is what I get: C:\My Documents\Netbeans\Mytests When I debug, this is what I

Re: Searching for a list of strings in a file with Python

2013-10-14 Thread Dave Angel
On 14/10/2013 01:34, Starriol wrote: Hi guys, I'm trying to search for several strings, which I have in a .txt file line by line, on another file. So the idea is, take input.txt and search for each line in that file in another file, let's call it rules.txt. So far, I've been able to do

Re: ANN: CUI text editor Kaa 0.0.4

2013-10-11 Thread Dave Angel
On 11/10/2013 07:09, Atsuo Ishimoto wrote: Hi, I've just released Kaa 0.0.4 to PyPI. https://pypi.python.org/pypi/kaaedit/ Kaa is a easy yet powerful text editor for console user interface, What's a console user interface? That's what Windows calls a DOS box. But otherwise you seem

Re: class implementation

2013-10-08 Thread Dave Angel
On 8/10/2013 04:20, markot...@gmail.com wrote: I cant just subclassing doesent work. I can't parse that sentence. It seem the init method of the source class also calls out another class. And the problem is, i can subclass the other class to with the required function but the end result is

Re: converting letters to numbers

2013-10-08 Thread Dave Angel
On 8/10/2013 10:28, kjaku...@gmail.com wrote: I have to define a function add(c1, c2), where c1 and c2 are capital letters; the return value should be the sum (obtained by converting the letters to numbers, adding mod 26, then converting back to a capital letter). All I have so far is:

Re: howto check programs and C libraries

2013-10-04 Thread Dave Angel
On 4/10/2013 05:30, David Palao wrote: Hello, I'm in charge of preparing a computer room for the practices of introduction to programming. One of the tasks is checking that from all the computers in the room one can execute some programs and link (and compile) against some libraries. My

Re: Multiple scripts versus single multi-threaded script

2013-10-03 Thread Dave Angel
On 3/10/2013 12:50, Chris Angelico wrote: On Fri, Oct 4, 2013 at 2:41 AM, Roy Smith r...@panix.com wrote: The downside to threads is that all of of this sharing makes them much more complicated to use properly. You have to be aware of how all the threads are interacting, and mediate access

Re: PyDoc_STRVAR error in msvc compile

2013-10-02 Thread Dave Angel
On 2/10/2013 06:01, Robin Becker wrote: On 02/10/2013 10:00, Robin Becker wrote: On 01/10/2013 18:26, MRAB wrote: On 01/10/2013 17:41, Robin Becker wrote: .. I've tried it in a minimal console program, and it seems to work for me. thanks for the test. I thought this might be an

Re: PyDoc_STRVAR error in msvc compile

2013-10-02 Thread Dave Angel
On 2/10/2013 07:28, Robin Becker wrote: The actual is this code from _renderPM.c https://bitbucket.org/rptlab/reportlab/src/fa65fe72b6c2aaecb7747bf14884adb996d8e87f/src/rl_addons/renderPM/_renderPM.c?at=default PyDoc_STRVAR(__DOC__, Helper extension module for renderPM.\n\ \n\ Interface

Re: Stop posting HTML [was Re: I haev fixed it]

2013-10-02 Thread Dave Angel
On 1/10/2013 23:33, Michael Torrie wrote: On 10/01/2013 08:40 PM, Steven D'Aprano wrote: On Tue, 01 Oct 2013 22:02:36 -0400, Joel Goldstick wrote: On Tue, Oct 1, 2013 at 9:52 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Joel, you've been asked repeatedly to please stop

Re: Tail recursion to while iteration in 2 easy steps

2013-10-02 Thread Dave Angel
On 2/10/2013 21:24, Steven D'Aprano wrote: On Wed, 02 Oct 2013 18:17:06 -0400, Terry Reedy wrote: CPython core developers have be very conservative about what tranformations they put into the compiler. (1,2,3) can always be compiled as a constant, and so it is. [1,2,3] might or might not be

Re: class implementation

2013-09-30 Thread Dave Angel
On 30/9/2013 08:41, markot...@gmail.com wrote: under variables, i mean, the int's and lists and strings and floats that the parent class uses. IF in parent class there is variable called location, then can i use the same variable in my sub class. Python doesn't actually have variables, but

Re: Python Unit Tests

2013-09-30 Thread Dave Angel
On 30/9/2013 15:54, melw...@gmail.com wrote: Lol, im starting to get the hang out of, onto the next hurdle, i looked up the error and it says the data is none? Traceback (most recent call last): File guess.py, line 34, in module main(random.randint(1, 10)) File guess.py, line 27,

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Dave Angel
On 29/9/2013 03:35, Νίκος wrote: ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or os.environ.get('REMOTE_ADDR', Cannot Resolve) ) try: gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') city = gi.time_zone_by_addr( ipval ) host = socket.gethostbyaddr( ipval ) [0]

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Dave Angel
On 29/9/2013 06:17, Νίκος wrote: Στις 29/9/2013 12:50 μμ, ο/η Dave Angel έγραψε: ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or os.environ.get('REMOTE_ADDR', Cannot Resolve) ) try: gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') city = gi.time_zone_by_addr( ipval

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Dave Angel
On 29/9/2013 06:24, Νίκος wrote: snip except Exception as e: === except socket.gaierror as e: which cannot handle unicore realted errors and the exact same error appeared with my ip address involved at the error log. so, the question that arises again and reamins is how come 'host'

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Dave Angel
On 29/9/2013 07:14, Νίκος wrote: Dave's way though seems better. Assign the vars default string and if they get re-assinged correctly that would be ideal, otherwise we have already given them the defaults. ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or os.environ.get('REMOTE_ADDR',

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Dave Angel
On 29/9/2013 07:25, Νίκος wrote: Thank you for being willing to look this further. Willing, but probably not able. I think I know a lot about the language, and less about the libraries. I know very little about the administration side of internet use. The reference to /etc/hosts is only a

Re: Python Unit Tests

2013-09-28 Thread Dave Angel
On 28/9/2013 00:52, melw...@gmail.com wrote: Hey, What version of Python are you using? I'll assume 2.7, but you really should specify it (and any other meaningful environment dependencies) in your original query, the beginning of your thread. For 2.7, the docs for unittest are at:

Re: card dealer

2013-09-28 Thread Dave Angel
On 28/9/2013 06:31, Ned Batchelder wrote: snip I've thought that way about it too: there are so many shuffles any way, it won't be a problem. But think about it like this: if you shuffle a deck of 52 cards with a default Python random object, then once you have dealt out only 28

Re: Weird bahaviour from shlex - line no

2013-09-28 Thread Dave Angel
On 28/9/2013 02:26, Daniel Stojanov wrote: Can somebody explain this. The line number reported by shlex depends on the previous token. I want to be able to tell if I have just popped the last token on a line. I agree that it seems weird. However, I don't think you have made clear why it's

Re: Neurolab // No module named ..

2013-09-28 Thread Dave Angel
On 28/9/2013 10:55, FiveHydroxy Tryptamine wrote: Hiya A word of warning, I am a complete beginner. My problem goes like this:: I've been trying to import neurolab as nl(a neural network library)and I keep getting the No module named.. error in my Python 2.7.3 shell. There is definitely

Re: Help me with Python please (picture)

2013-09-28 Thread Dave Angel
On 28/9/2013 12:17, dvgh...@gmail.com wrote: On Saturday, September 28, 2013 12:43:42 AM UTC, jae...@gmail.com wrote: Can't seem to be getting an output. snip Overall I wrote my own version of the code and this is what I got: ** import string import random

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Dave Angel
On 27/9/2013 05:19, Νίκος wrote: Στις 27/9/2013 1:55 πμ, ο/η Dave Angel έγραψε: Simply assign the default values BEFORE the try block, and use pass as the except block. That still doesn't get around the inadvisability of putting those 3 lines in the try block. You still haven't dealt

Re: card dealer

2013-09-27 Thread Dave Angel
On 27/9/2013 06:24, markot...@gmail.com wrote: from random import * from math import floor kaarte_alles = 52 kaart_tõmmatud = [False for i in range(52)] mast = [ärtu, ruutu, poti, risti] aste = [äss, kaks, kolm, neli,viis, kuus, \ seitse, kaheksa, üheksa, kümme, soldat,\

Re: card dealer

2013-09-27 Thread Dave Angel
On 27/9/2013 07:26, Dave Angel wrote: On 27/9/2013 06:24, markot...@gmail.com wrote: I sent the previous message long before I had finished. If you had created your global list containing list(range(52)), then you could do nearly your entire program with one call to random.sample. http

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Dave Angel
On 27/9/2013 07:15, Νίκος wrote: Στις 27/9/2013 1:43 μμ, ο/η Dave Angel έγραψε: snip ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or os.environ.get('REMOTE_ADDR', Cannot Resolve) ) city = Άγνωστη Πόλη host = Άγνωστη Προέλευση try: city = gi.time_zone_by_addr( ipval

Re: card dealer

2013-09-27 Thread Dave Angel
On 27/9/2013 12:10, Denis McMahon wrote: On Fri, 27 Sep 2013 12:08:33 +, Dave Angel wrote: i recall writing a shuffle function in C decades ago, which took an array of (52) unique items and put them in random order. Whenever I tried to write shuffles I came up against a fairly

Re: Free Proxy site 2014

2013-09-27 Thread Dave Angel
On 27/9/2013 10:44, 23alagmy wrote: Free Proxy site 2014 search is the first proxy supports proxy access blocked sites, browsing, and downloads without restrictions and also conceal your identity Pencah by 100% from the sites you visit deleted link Sure, I'm going to trust going to a

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Dave Angel
On 27/9/2013 18:06, Νίκος wrote: city = Άγνωστη Πόλη host = Άγνωστη Προέλευση If they were to have the same string assigned to them it should be okey but they do not. Or perhaps you can even still think of writing the above into 1-liner whatsoever! I already did earlier in this

Re: Help me with Python please (picture)

2013-09-27 Thread Dave Angel
On 27/9/2013 20:43, jae...@gmail.com wrote: http://imgur.com/E6vrNs4 Can't seem to be getting an output. Please compose a text message containing a description of the environment, the (small) code, and the expected results. This is a text mailing list, and posting transient images on

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Dave Angel
On 26/9/2013 06:51, Νίκος wrote: SNIP socket.gethostbyaddr( os.environ.get('HTTP_CF_CONNECTING_IP') or os.environ.get('REMOTE_ADDR') or Άγνωστη Προέλευση )[0] Traceback (most recent call last): File stdin, line 1, in module socket.gaierror: [Errno -2] Name or service not known You

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Dave Angel
On 26/9/2013 09:34, Νίκος wrote: Στις 26/9/2013 3:53 μμ, ο/η Antoon Pardon έγραψε: Op 26-09-13 14:39, Νίκος schreef: Yes, you are right, in my shell it fails too givign the same error message as yours, while on the other had in the websste is working. Can you explain this please? why

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Dave Angel
On 26/9/2013 12:58, Νίκος wrote: snip But actually i have 2 variables that relay on a proper ip address. ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or os.environ.get('REMOTE_ADDR', UnKnown Origin) ) try: gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') city =

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Dave Angel
On 26/9/2013 18:14, Νίκος wrote: Στις 26/9/2013 11:16 μμ, ο/η Denis McMahon έγραψε: On Thu, 26 Sep 2013 19:58:02 +0300, Νίκος wrote: except socket.gaierror as e: city = host = UnKnown Origin But then what if in case of an error i needed different string set to be assigned on city and

Re: How to quickly search over a large number of files using python?

2013-09-25 Thread Dave Angel
On 25/9/2013 04:41, dwivedi.dev...@gmail.com wrote: Hi all, I am a newbie to python. I have about 500 search queries, and about 52000 files in which I have to find all matches for each of the 500 queries. How should I approach this? Seems like the straightforward way to do it would be

Re: removing BOM prepended by codecs?

2013-09-25 Thread Dave Angel
On 25/9/2013 06:38, J. Bagg wrote: So it is just a random sequence of junk. It will be a matter of finding the real start of the record (in this case a %) and throwing the junk away. Please join the list. Your present habit of starting a new thread for each of your messages is getting old.

Re: Extracting lines from text files - script with a couple of 'side effects'

2013-09-25 Thread Dave Angel
On 25/9/2013 16:06, mstagliamonte wrote: Dear All, Here I am, with another newbie question. I am trying to extract some lines from a fasta (text) file which match the headers in another file. i.e: Fasta file: header1|info1:info2_info3 general text header2|info1:info2_info3 general text

Re: Understanding how is a function evaluated using recursion

2013-09-25 Thread Dave Angel
On 25/9/2013 19:24, Arturo B wrote: Hi, I'm doing Python exercises and I need to write a function to flat nested lists as this one: [[1,2,3],4,5,[6,[7,8]]] To the result: [1,2,3,4,5,6,7,8] So I searched for example code and I found this one that uses recursion (that I don't

Re: removing BOM prepended by codecs?

2013-09-24 Thread Dave Angel
On 24/9/2013 09:01, J. Bagg wrote: Why would you start a new thread? just do a Reply-List (or Reply-All and remove the extra names) to the appropriate message on the existing thread. I'm using: outputfile = codecs.open (fn, 'w+', 'utf-8', errors='strict') That won't be adding a BOM. It

Re: Help with python functions?

2013-09-23 Thread Dave Angel
On 23/9/2013 18:55, kjaku...@gmail.com wrote: On Monday, September 23, 2013 9:56:45 AM UTC-4, Steven D'Aprano wrote: On Mon, 23 Sep 2013 05:57:34 -0700, kjakupak wrote: Now you're done! On to the next function... -- Steven def temp(T, from_unit, to_unit):

Re: Help with python functions?

2013-09-23 Thread Dave Angel
On 23/9/2013 21:23, kjaku...@gmail.com wrote: On Monday, September 23, 2013 8:07:44 PM UTC-4, Dave Angel wrote: I didn't see any spec that said Python 3.x. in version 2.x, this would be incorrect. -- DaveA It's for Python 3.2 Then I'd have a comment saying so, right

Re: Directory Web Site

2013-09-22 Thread Dave Angel
On 22/9/2013 21:14, worthingtonclin...@gmail.com wrote: Was hoping to get some tips or advice on scripting a program that would sort through my many links on my directory website and print out to me the ones that are broken or no longer functioning so that I could fix or remove them from

Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

2013-09-21 Thread Dave Angel
On 21/9/2013 02:07, William Bryant wrote: In addition to Steven's comments: def median(): medlist = List medlist.sort() You have just altered the original list. Perhaps sorting it is harmless, but below you actually remove elements from it. One way to avoid that is to use the

Re: Beginner - GUI devlopment in Tkinter - Any IDE with drag and drop feature like Visual Studio?

2013-09-21 Thread Dave Angel
On 21/9/2013 03:19, shubhx...@gmail.com wrote: i am very confuse about gui development in python .. i installed qt creator .. but it has no option for python.. how can i bulit any app using drag n drop facilities ... i am trying wxpython .. plz help me . how i use wxpython .. plzz help

Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

2013-09-21 Thread Dave Angel
On 21/9/2013 12:18, MRAB wrote: On 21/09/2013 13:53, Dave Angel wrote: [snip] Taking Steven's suggested code, and changing it so it uses a COPY of the global list; def median(): # Relies on the global variable called List. # assumes there is at least one number in that list

Re: building an online judge to evaluate Python programs

2013-09-20 Thread Dave Angel
On 20/9/2013 13:28, Jabba Laci wrote: Hi, In our school I have an introductory Python course. I have collected a large list of exercises for the students and I would like them to be able to test their solutions with an online judge ( http://en.wikipedia.org/wiki/Online_judge ). At the

Re: Print statement not printing as it suppose to

2013-09-20 Thread Dave Angel
On 20/9/2013 17:57, Sam wrote: print(\nThe total amount required is , total ) ('\nThe total amount required is ', 3534) === the problem is obviously on the last print statement that is supposed to print the outut Others have pointed out the version discrepancy. But I'll also ask what

Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

2013-09-19 Thread Dave Angel
On 19/9/2013 14:46, William Bryant wrote: the word 'def' has squiggily lines but the program works fine. It says: Syntax Error: expected an indented block. - why? The direct answer is that your terminal program must be broken. it should not use squiggly lines for any purposes. But perhaps

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-19 Thread Dave Angel
On 19/9/2013 11:53, Neil Cerutti wrote: On 2013-09-18, Dave Angel da...@davea.name wrote: On 18/9/2013 17:40, Neil Hodgson wrote: Dave Angel: So is the bug in Excel, in Windows, or in the Python library? Somebody is falling down on the job; if Windows defines the string as ending

Re: *.csv to *.txt after adding columns

2013-09-18 Thread Dave Angel
On 17/9/2013 22:28, Bryan Britten wrote: Dave - I can't print the output because there are close to 1,000,000 records. It would be extremely inefficient and resource intensive to look at every row. Not if you made a sample directory with about 3 files, each containing half a dozen lines

Re: Remove \n, from tuple.

2013-09-18 Thread Dave Angel
On 18/9/2013 01:12, Venkat Addala wrote: Hi all, I have a tuple in this format, which is retrived using MySQLdb, now i want to remove \n and extra spaces in this. 13L, 'ssDsC', 'CEs5s1, DsC', 'srylscetsmight\nghtscetylsse', '3', '3q25.1', 151531861L, 151546276L, '+', '1 kjafhkfhlad\fdfdsdf

Re: iterating over a file with two pointers

2013-09-18 Thread Dave Angel
On 18/9/2013 07:21, Chris Angelico wrote: On Wed, Sep 18, 2013 at 9:12 PM, nikhil Pandey nikhilpande...@gmail.com wrote: hi, I want to iterate over the lines of a file and when i find certain lines, i need another loop starting from the next of that CERTAIN line till a few (say 20) lines

Re: linregress and polyfit

2013-09-18 Thread Dave Angel
On 18/9/2013 09:38, chitt...@uah.edu wrote: Thanks - that helps ... but it is puzzling because np.random.normal(0.0,1.0,1) returns exactly one and when I checked the length of z, I get 21 (as before) ... I don't use Numpy, so this is just a guess, plus reading one web page. According

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread Dave Angel
On 18/9/2013 15:40, MRAB wrote: On 18/09/2013 20:28, stephen.bou...@gmail.com wrote: Thanks to everyone for their help. Using everyone's suggestions, this seems to work: import win32clipboard, win32con def getclipboard(): win32clipboard.OpenClipboard() s =

Re: iterating over a file with two pointers

2013-09-18 Thread Dave Angel
On 18/9/2013 10:36, Roy Smith wrote: Dave Angel da...@davea.name wrote (and I agreed with): I'd suggest you open the file twice, and get two file objects. Then you can iterate over them independently. On Sep 18, 2013, at 9:09 AM, Oscar Benjamin wrote: There's no need to use OS resources

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread Dave Angel
On 18/9/2013 17:40, Neil Hodgson wrote: Dave Angel: So is the bug in Excel, in Windows, or in the Python library? Somebody is falling down on the job; if Windows defines the string as ending at the first null, then the Python interface should use that when defining the text defined

Re: Tryign to send mail via a python script by using the local MTA

2013-09-18 Thread Dave Angel
On 18/9/2013 18:31, Dennis Lee Bieber wrote: On Tue, 17 Sep 2013 18:34:50 -0400, William Ray Wing w...@mac.com declaimed the following: I think you need to read up on some of the most basic fundamentals of tcp/ip networking, i.e., the basis of the global internet. EVERY network packet

Re: Having both if() and for() statements in one liner

2013-09-17 Thread Dave Angel
On 17/9/2013 09:21, Ferrous Cranus wrote: I just want to say tot he program that that only run the for statement if and only if person=='George' I dont see nay reason as to why this fails perhaps like: for times in range(0, 5) if person=='George': but that fails too... there must be

Re: *.csv to *.txt after adding columns

2013-09-17 Thread Dave Angel
On 17/9/2013 21:42, Bryan Britten wrote: Hey, gang, I've got a problem here that I'm sure a handful of you will know how to solve. I've got about 6 *.csv files that I am trying to open; change the header names (to get rid of spaces); add two new columns, which are just the results of a

Re: import problem

2013-09-16 Thread Dave Angel
On 16/9/2013 00:05, Mohsen Pahlevanzadeh wrote: thank you, you gave me how to get fish instead of fish, it's very better. I'd suggest you make a diagram showing each file and indicate what files it imports by an arrow. If any arrows form a circle, you (may) have recursive imports. You should

Re: How do I calculate a mean with python?

2013-09-16 Thread Dave Angel
On 16/9/2013 19:33, William Bryant wrote: Hey I am new to python so go easy, but I wanted to know how to make a program that calculates the maen. List = [15, 6, 6, 7, 8, 9, 40] def mean(): global themean, thesum for i in List: thecount = List.count(i) thesum =

Re: How to get time (milisecond) of a python IO execution

2013-09-15 Thread Dave Angel
On 14/9/2013 22:59, Tal Bar-Or wrote: Hi All i am trying to test measure some IO execution in milliseconds , but bit confuse about best method achive that under windows 7 Measuring any performance can be tricky, and I/O in particular. Windows will cache the recently used file information,

Re: Python GUI?

2013-09-15 Thread Dave Cook
, not frameworks in the sense of, say, Django. Enthought has some interesting GUI framework projects which I haven't tried: http://code.enthought.com/projects/ Dabo would be another example. Dave Cook -- https://mail.python.org/mailman/listinfo/python-list

Re: Monitor key presses in Python?

2013-09-14 Thread Dave Angel
On 14/9/2013 14:10, eamonn...@gmail.com wrote: I didnt wanna say that, in case people threw a fit and stuff. So yeah, how would I monitor the key presses? There's a huge difference between monitoring key presses within your own process, and intercepting them system-wide. if you need to see

<    4   5   6   7   8   9   10   11   12   13   >