Re: pygame - importing GL - very bad...

2013-01-04 Thread Dave Angel
On 01/04/2013 08:10 PM, someone wrote: > On 01/03/2013 03:09 PM, Mike C. Fletcher wrote: >> > >> PyOpenGL's current approach is mostly attempting to maintain backward >> compatibility with the older revisions. wxPython actually rewrote its >> whole interface to go from * imports into namespaced l

Re: pygame - importing GL - very bad...

2013-01-05 Thread Dave Angel
On 01/05/2013 05:49 AM, someone wrote: > On 01/05/2013 02:30 AM, Dave Angel wrote: > >> >> Function objects are enormously useful, as you get more adept at using >> Python. > > Ok, I'll look forward to that. Recently I had some problems with > pass-by-val

Re: Couting the number of lines of code of a python program

2013-01-05 Thread Dave Angel
On 01/05/2013 10:17 AM, chaouche yacine wrote: > > > Here is my implementation : > > defcount_loc(lines):nb_lines =0docstring =Falseforline inlines:line > =line.strip()ifline ==""\ orline.startswith("#")\ ordocstring > andnot(line.startswith('"""')orline.startswith("'''"))\ > or(line.startswi

Re: reduce expression to test sublist

2013-01-05 Thread Dave Angel
On 01/05/2013 01:25 PM, Asim wrote: > Hi All > > The following reduce expression checks if every element of list lst1 is > present in list lst2. It works as expected for integer lists but for lists > of strings, it always returns False. > >reduce( lambda x,y: (x in lst2) and (y in lst2), lst

Re: reduce expression to test sublist

2013-01-05 Thread Dave Angel
On 01/05/2013 04:55 PM, Terry Reedy wrote: > On 1/5/2013 1:58 PM, Dave Angel wrote: > >> If you're trying to make a faster loop, then I suggest you look into set >> differences. Turn both lists into sets, and subtract them. Something >> like (untested): >>

Re: Over 30 types of variables available in python ?

2013-01-06 Thread Dave Angel
On 01/06/2013 06:12 PM, chaouche yacine wrote: > booleans > ints, floats, longs, complexes > strings, unicode strings > lists, tuples, dictionaries, dictionary views, sets, frozensets, buffers, > bytearrays, slices > functions, methods, code objects,modules,classes, instances, types, nulls > (the

Re: "Gangnam Style" in line for UK dictionary inclusion

2013-01-07 Thread Dave Angel
On 01/07/2013 08:22 AM, GadgetSteve wrote: > On Monday, January 7, 2013 12:50:00 PM UTC, Constantine wrote: >> Trying to get control: >> http://AboutToTrashYou.invalid/2892929384736760/news.yahoo.com/Whatever-you-like-it-wont&44work134517741.html > And this has to do with python how? When r

Re: Over 30 types of variables available in python ?

2013-01-07 Thread Dave Angel
On 01/07/2013 09:32 AM, marduk wrote: > So I guess if one *really* wanted to compare C variables to Python > variables, you could say that all python variables are of type void* > except Python does all mallocs/frees and the casting for you. A better analogy would be to C++, and all names would be

Re: Difference between these two lists?

2013-01-07 Thread Dave Angel
On 01/07/2013 08:00 PM, andydtay...@gmail.com wrote: > Hi, > > Python newbie here again - this is probably a quick one. What's the > difference between the lines I've numbered 1. and 2. below, which produce the > following results: > > Results: > 1. [ANG, BAR, BPK, CTN, QGH, QHD, KXX] > 2. ['ANG

Re: Calculate Big Number

2013-01-07 Thread Dave Angel
On 01/07/2013 07:44 PM, Nac Temha wrote: > Hello, > How to *quickly* calculate large numbers. For example (10**25) * (2**50) > 11258999068426240L > > Since all of the terms are const, you could just use print "11258999068426240L" Or if you hav

Re: Calculate Big Number

2013-01-07 Thread Dave Angel
On 01/07/2013 08:22 PM, Nac Temha wrote: > Thanks for reply. I wonder how quickly calculate big numbers. Can you > explain me as theoretical? Because this numbers overflow size of integer > and double. Please don't top-post. It makes the context totally out of order. Python automatically promotes

Re: Calculate Big Number

2013-01-07 Thread Dave Angel
(forwarding the private reply to the group) On 01/07/2013 09:03 PM, Nac Temha wrote: > Thanks. I using version 2.7 .I want to understand how to handling big > number. Just want to know logic. Without going into further details but I > want to learn logic of this issue. How to keep datas in pytho

Re: comparison between non-comparable objects

2013-01-07 Thread Dave Angel
On 01/08/2013 12:28 AM, Kelvin Li wrote: > The language reference says: > > "...the choice whether one object [of built-in type] is considered > smaller or larger than another one is made arbitrarily..." When quoting some online source, please give a reference link. It took me a while to find the

Re: How to get the selected text of the webpage in chrome through python ?

2013-01-08 Thread Dave Angel
On 01/08/2013 07:38 AM, Dennis Lee Bieber wrote: > On Mon, 7 Jan 2013 20:20:28 -0800 (PST), iMath > declaimed the following in gmane.comp.python.general: > >> How to get the selected text of the webpage in chrome through python ? > Chrome is a browser, is it not... If you want to get the tex

ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes

2013-01-08 Thread Dave Cinege
ng to generate output or command lines for external programs, or wish you had a dictionary that could act (sort of) like a class, Thesaurus may be for you. #!/usr/bin/env python """ thesaurus.py 2012-09-13 Copyright (c) 2012 Dave Cinege Licence: python, Copyright notice may not be al

Re: socket.makefile raises ValueError when mode = 'rt'

2013-01-09 Thread Dave Angel
On 01/09/2013 08:22 AM, Antoon Pardon wrote: > This is using python 3.2. > > I am writing somekind of wrapper around the ftplib. So > that you can work with it as if you are working with > local files. > > The idea is that you start with making a connection like > > rmt = FTP(...) > > and then do s

Re: Previous Question Answered - Thank You All For Your Replies

2013-01-09 Thread Dave Angel
On 01/09/2013 12:11 PM, Reed, Kevin wrote: > Hello, > > My question concerning wiki.python.org unavailability has been answered. > Thank you all for your assistance! You guys are awesome! > > For those of you who don't know, here's the info. > > http://mail.python.org/pipermail/python-list/2013-

Re: new to python and programming at large.

2013-01-09 Thread Dave Angel
On 01/09/2013 05:28 PM, kwakukwat...@gmail.com wrote: > thanks for ur help I wz able to do it.but I wish to expand it by asking a > user to input a number for the sqrt to be calculated it I dd it this way but > its not working. > > > from math import sqrt > number = raw_input('enter a number:') >

Re: Best way to do this? List loop (matrix?) iteration

2013-01-09 Thread Dave Angel
On 01/09/2013 06:24 PM, andydtay...@gmail.com wrote: > Thanks for your help - this is what I did - though it's probably obvious to > most people reading this. > >for rowcount in range (0, stn_count): > row_durations.append(stn_list_short[rowcount]) > for colcount in range (0, stn_c

Re: Getting audio input and processing it?

2013-01-09 Thread Dave Angel
On 01/09/2013 07:20 PM, Michael Curry wrote: > I've been working on a Morse Code translator, I've made it work so that you > can input English and it will translate it to Morse and play the Audio. I now > want to add a feature to the program that takes audio input, processes it and > then output

Re: subprocess.Popen and multiprocessing fails to execute external program

2013-01-09 Thread Dave Angel
On 01/09/2013 11:08 PM, Niklas Berliner wrote: > I have a pipline that involves processing some data, handing the data to an > external program (t_coffee used for sequence alignments in bioinformatics), > and postprocessing the result. Since I have a lot of data, I need to run my > pipeline in para

Re: pylint or similar to test version-specific language constructs?

2013-01-11 Thread Dave Angel
On 01/11/2013 03:29 AM, The Night Tripper wrote: > Gisle Vanem wrote: > >> "jkn" wrote: >> >>>I have to write python code which must run on an old version of >>> python (v2.4) as well as a newer (v2.7). I am using pylint and would >>> like to check if is possible to check with pylint the use o

Re: Multiple disjoint sample sets?

2013-01-11 Thread Dave Angel
On 01/11/2013 09:36 AM, MRAB wrote: > On 2013-01-11 14:15, Roy Smith wrote: >> I have a list of items. I need to generate n samples of k unique items >> each. I not only want each sample set to have no repeats, but I also >> want to make sure the sets are disjoint (i.e. no item repeated between >

Re: pylint or similar to test version-specific language constructs?

2013-01-11 Thread Dave Angel
On 01/11/2013 10:37 AM, Steven D'Aprano wrote: > On Fri, 11 Jan 2013 10:06:30 -0500, Dave Angel wrote: > >> > >> Not sure what you mean by beforehand. Don't you run all your unit tests >> before putting each revision of your code into production? So run t

Re: Problem with importing in Python

2013-01-11 Thread Dave Angel
On 01/11/2013 05:17 PM, su29090 wrote: > I'm trying to import a python file it keeps saying: > > ImportError: cannot import name Circle > > Here is the file I'm trying to import: > > Circle.py > > import math > > class circle: > #Construct a circle object > def __init__(self, radius = 1): >

Re: Problem with importing in Python

2013-01-11 Thread Dave Angel
On 01/11/2013 11:37 PM, Tim Roberts wrote: > Dave Angel wrote: >> As Adnan has pointed out, Python is case insensitive. > That's not really what you meant to say... Nope. I meant Python is case sensitive. Thanks for the catch. I think the rest of my discourse made it clear

Re: For Loop in List

2013-01-13 Thread Dave Angel
On 01/13/2013 07:45 AM, subhabangal...@gmail.com wrote: > Dear Group, > > I have a list like, > list1=[1,2,3,4,5,6,7,8,9,10,11,12] What version of Python? > Now, if I want to take a slice of it, I can. > It may be done in, list2=list1[:3] print list2 > [1, 2, 3] > > If I want to it

Re: Thought of the day

2013-01-14 Thread Dave Angel
On 01/13/2013 11:16 PM, Steven D'Aprano wrote: > A programmer had a problem, and thought Now he has "I know, I'll solve > two it with threads!" problems. > > ++10 I've been thinking about threads lately, and have come to the tentative conclusion that they're a solution which has outlived its use

Re: Thought of the day

2013-01-14 Thread Dave Angel
On 01/14/2013 09:44 AM, Dan Sommers wrote: > On Mon, 14 Jan 2013 00:31:59 -0500, Dave Angel wrote: > >> On 01/13/2013 11:16 PM, Steven D'Aprano wrote: >>> A programmer had a problem, and thought Now he has "I know, I'll solve >>> two it with threads

Re: Thought of the day

2013-01-15 Thread Dave Angel
On 01/14/2013 09:18 AM, Chris Angelico wrote: > On Tue, Jan 15, 2013 at 1:15 AM, Tim Chase > wrote: >> A newbie programmer had a problem and thought >> >> >> >> "I'll solve it by posting on >> >> >> >> python-list@python.org and on Google Groups". >> >> >> >> And now we have the problem of two thr

Re: Using inner dict as class interface

2013-01-16 Thread Dave Angel
On 01/16/2013 09:42 AM, Florian Lindner wrote: Hello, I have a: class C: def __init__(self): d = dict_like_object_created_somewhere_else() def some_other_methods(self): pass class C should behave like a it was the dict d. So I could do: Is it a specific requirement that

Re: Any built-in ishashable method ?

2013-01-18 Thread Dave Angel
On 01/18/2013 05:36 AM, Jean-Michel Pichavant wrote: Hello people, Is there any built-in way to know if an object is a valid dictionary key ? From what I know, the object must be hashable, and from the python doc, an object is hashable if it has the __hash__ and (__cmp__ or __eq__) methods. h

Re: Uniquely identifying each & every html template

2013-01-18 Thread Dave Angel
On 01/18/2013 03:48 PM, Ferrous Cranus wrote: I use this .htaccess file to rewrite every .html request to counter.py # = RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f RewriteRul

Re: Any built-in ishashable method ?

2013-01-19 Thread Dave Angel
On 01/18/2013 07:06 AM, Peter Otten wrote: Jean-Michel Pichavant wrote: That brings me to another question, is there any valid test case where key1 != key2 and hash(key1) == hash(key2) ? Or is it some kind of design flaw ? I don't think there is a use case for such a behaviour other than anno

Re: Uniquely identifying each & every html template

2013-01-19 Thread Dave Angel
On 01/19/2013 03:39 AM, Ferrous Cranus wrote: Τη Σάββατο, 19 Ιανουαρίου 2013 12:09:28 π.μ. UTC+2, ο χρήστης Dave Angel έγραψε: I don't understand the problem. A trivial Python script could scan through all the files in the directory, checking which ones are missing the identifier

Re: Help splitting CVS data

2013-01-20 Thread Dave Angel
On 01/20/2013 05:04 PM, Garry wrote: I'm trying to manipulate family tree data using Python. I'm using linux and Python 2.7.3 and have data files saved as Linux formatted cvs files The data appears in this format: Marriage,Husband,Wife,Date,Place,Source,Note0x0a Note: the Source field or the No

Re: To make a method or attribute private

2013-01-20 Thread Dave Angel
On 01/20/2013 06:14 PM, alex23 wrote: On Jan 20, 7:23 pm, Chris Angelico wrote: On Sun, Jan 20, 2013 at 8:17 PM, iMath wrote: so what is your opinion about single leading underscore and private methods or attributes? Didn't this get discussed recently? http://mail.python.org/pipermail/pyt

Re: Forcing Python to detect DocumentRoot

2013-01-21 Thread Dave Angel
On 01/21/2013 01:25 AM, Ferrous Cranus wrote: Τη Σάββατο, 19 Ιανουαρίου 2013 10:01:15 μ.μ. UTC+2, ο χρήστης Piet van Oostrum έγραψε: Ferrous Cranus writes: While /home/nikos/public_html/cafebar-idea.gr/cgi-bin/counter.py that has also embedded this line: mailto:supp...@superhost.gr";>

Re: Windows subprocess.call problem

2013-01-21 Thread Dave Angel
On 01/21/2013 06:25 AM, Tom Borkin wrote: Hi; I have this code: for song in my_songs: subprocess.call(['notepad.exe', '%s.txt' % song]) print song It opens the first song and hangs on subsequent songs. It doesn't open the next song or execute the print until I have closed the first one. I

Re: Uniquely identifying each & every html template

2013-01-21 Thread Dave Angel
On 01/21/2013 07:06 AM, Ferrous Cranus wrote: Seriously, you're asking for something that's beyond the power of humans or computers. You want to identify that something's the same file, without tracking the change or having any identifiable tag. That's a fundamentally impossible task.

Re: Storing class objects dynamically in an array

2013-01-21 Thread Dave Angel
On 01/21/2013 08:56 PM, Brian D wrote: Hi, I'm trying to instantiate a class object repeated times, dynamically for as many times as are required, storing each class object in a container to later write out to a database. It kind of looks like what's needed is a two-dimensional class object,

Re: Storing class objects dynamically in an array

2013-01-21 Thread Dave Angel
On 01/21/2013 08:56 PM, Brian D wrote: Hi, I'm trying to instantiate a class object repeated times, dynamically for as many times as are required, storing each class object in a container to later write out to a database. It kind of looks like what's needed is a two-dimensional class object,

Re: Using filepath method to identify an .html page

2013-01-22 Thread Dave Angel
On 01/22/2013 07:02 AM, Ferrous Cranus wrote: # # produce a hash string based on html page's filepath and convert it to an integer, that will then be used to iden

Re: Using filepath method to identify an .html page

2013-01-22 Thread Dave Angel
On 01/22/2013 09:55 AM, Ferrous Cranus wrote: Τη Τρίτη, 22 Ιανουαρίου 2013 4:33:03 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε: On Wed, Jan 23, 2013 at 12:57 AM, Ferrous Cranus wrote: Τη Τρίτη, 22 Ιανουαρίου 2013 3:04:41 μ.μ. UTC+2, ο χρήστης Steven D'Aprano έγραψε: What do you expec

Re: Using filepath method to identify an .html page

2013-01-22 Thread Dave Angel
On 01/22/2013 10:46 AM, Ferrous Cranus wrote: Thank you but the number needs to be a 4-digit integer only, if its to be stored in the database table correctly. pin = int( htmlpage.encode("hex"), 16 ) I just tried whayt you gace me This produces a number of: 140530319499494727...67752282212692

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Dave Angel
On 01/22/2013 11:15 AM, Ferrous Cranus wrote: I just need a way to CONVERT a string(absolute path) to a 4-digit unique number with INT!!! That's all i want!! But i cannot make it work :( And the best part is that "that" number must be able to turn back into a path. This way i DON'T EVEN HAVE T

Re: Using filepath method to identify an .html page

2013-01-22 Thread Dave Angel
On 01/22/2013 01:26 PM, Ferrous Cranus wrote: sub hashit { my $url=shift; my @ltrs=split(//,$url); my $hash = 0; foreach my $ltr(@ltrs){ $hash = ( $hash + ord($ltr)) %1; } printf "%s: %0.4d\n",$url,$hash } which yields: $ perl testMD5.pl /index.html:

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Dave Angel
On 01/22/2013 01:37 PM, Ferrous Cranus wrote: == pin = int( htmlpage.encode("hex"), 16 ) % 1 == Can you please explain the differences to what you have posted opposed to this perl coding? ===

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Dave Angel
On 01/22/2013 03:30 PM, Leonard, Arah wrote: The perl code will produce the same hash for "abc.html" as for "bca.html" That's probably one reason Leonard didn't try to transliterate the buggy code. Actually, to give credit where it's due, it wasn't me. I just modified someone else's inter

Re: Parse a Wireshark pcap file

2013-01-22 Thread Dave Angel
On 01/22/2013 08:32 PM, Kevin Holleran wrote: Is there a way to parse out a wireshark pcap file and extract key value pairs from the data? I am illustrated a sniff of some traffic and why it needs utilize HTTPS instead of HTTP but I was hoping to run the pcap through a python script and just out

Re: Parse a Wireshark pcap file

2013-01-22 Thread Dave Angel
On 01/22/2013 10:15 PM, Kevin Holleran wrote: Thanks, I have been trying to get it to work but I am on Mac OS 10.8.2. I tried to get it from Macports and download/install it myself. Both seem to get me to here: ImportError: No module named dnet I tried to download libdnet but no matter what I

Re: Any algorithm to preserve whitespaces?

2013-01-23 Thread Dave Angel
On 01/23/2013 04:20 AM, Santosh Kumar wrote: I am in a problem. words = line.split(' ') preserve whitespaces but the problem is it writes an additional line after every line. Think about what you said. It might be clearer if you wrote: "but the problem is it doesn't strip off the newl

Re: Converting a number back to it's original string (that was hashed to generate that number)

2013-01-23 Thread Dave Angel
On 01/23/2013 08:38 AM, Ferrous Cranus wrote: Please DON'T tell me to save both the pin <=> filepath and associate them (that can be done by SQL commands, i know) I will not create any kind of primary/unique keys to the database. I will not store the filepath into the database, just the number w

Re: Uniquely identifying each & every html template

2013-01-23 Thread Dave Angel
On 01/23/2013 05:29 AM, Ferrous Cranus wrote: 1. I'am a troll because i want to generate a solution in a specific way? 2. Am' i not wasting my time trying to reply to everybody? 1) your username is obviously a pseudonym, and identified by multiple websites as a troll. Further, your actio

Re: Increase value in hash table

2013-01-23 Thread Dave Angel
On 01/23/2013 10:39 AM, moonhkt wrote: On Jan 23, 11:33 pm, moonhk wrote: Works. For some definition of 'works" prndev = line.split() # print line for key in prndev : if key in 'lpr': This test will fire if key is the letter "l", or the letter "p"

Re: Using filepath method to identify an .html page

2013-01-23 Thread Dave Angel
On 01/23/2013 01:36 PM, Mark Lawrence wrote: On 23/01/2013 18:19, Leonard, Arah wrote: 3) This is a Python-specific resource and that's not even Python code. What next? Javascript? Ada? Fortran? COBOL? 8-bit x86 assembly with minimal comments written in Esperanto? Please can we have COR

Re: Uniquely identifying each & every html template

2013-01-23 Thread Dave Angel
On 01/23/2013 06:25 PM, Chris Angelico wrote: On Wed, Jan 23, 2013 at 11:38 PM, Dave Angel wrote: You think it's an accident that md5 size is roughly equivalent to 39 decimal digits? Or that the ones that haven't been proven insecure are much larger than that? The sha512 hash

Re: Uniquely identifying each & every html template

2013-01-23 Thread Dave Angel
On 01/23/2013 07:39 PM, Chris Angelico wrote: On Thu, Jan 24, 2013 at 11:09 AM, Dave Angel wrote: I certainly can't disagree that it's easy to produce a very long hash that isn't at all secure. But I would disagree that longer hashes *automatically* reduce chances of collision.

Re: Any algorithm to preserve whitespaces?

2013-01-23 Thread Dave Angel
On 01/23/2013 07:49 PM, Steven D'Aprano wrote: Santosh Kumar wrote: Yes, Peter got it right. Peter? Which Peter? What's "it" that he got right? You have deleted all context from your post, so I have no idea what you are talking about. Right. And whatever program you are using to post is

Re: monolithic apps

2013-01-24 Thread Dave Angel
On 01/24/2013 12:06 PM, tamn...@gmail.com wrote: Any suggestions for study?..: Is is possible to take a large executable with GUI and real time data and images, to extract modules, and it can run as if it looks like a monolithic application (windows over main windows, or images over other ima

Re: The best, friendly and easy use Python Editor.

2013-01-24 Thread Dave Hirschfeld
> > > > Sound advice. Most of the time I still use Visual Studio for editing Python > because I also use it for C++, so > it's just what I'm used to. No big deal, really. Whatever works is what > works. It's just a text file after all. > I assum

Re: Dict comp help

2013-01-24 Thread Dave Angel
On 01/24/2013 03:58 PM, Joseph L. Casale wrote: Hi, Slightly different take on an old problem, I have a list of dicts, I need to build one dict from this based on two values from each dict in the list. Each of the dicts in the list have similar key names, but values of course differ. [{'a': '

Re: create object base on text file

2013-01-25 Thread Dave Angel
On 01/25/2013 07:06 AM, moonhkt wrote: Hi All Python 2.6.x on AIX Data file PrinterA print Production batch1 xx print Production batch2 xx print Production batch3 xx

Re: The best, friendly and easy use Python Editor.

2013-01-25 Thread Dave Angel
On 01/25/2013 12:54 PM, Neil Cerutti wrote: On 2013-01-25, Leonard, Arah wrote: Though, that said, I have used Notepad and Wordpad any number of times in the past to edit Python files, all without bringing the universe to an untimely end. Even used DOS Edit once. You use what you have at the

Re: Retrieving an object from a set

2013-01-25 Thread Dave Angel
On 01/25/2013 06:14 PM, Arnaud Delobelle wrote: Dear Pythoneers, I've got a seemingly simple problem, but for which I cannot find a simple solution. I have a set of objects (say S) containing an object which is equal to a given object (say x). So x in S is true. So there is an object y

Re: looking for advice python

2013-01-26 Thread Dave Angel
On 01/26/2013 05:26 PM, twiztidtr...@gmail.com wrote: Hey I'm new to programming and I have been working on calculating miles per gallon. iv posted below what I have and constructive criticism would be wonderful. Thanks A good post for the python-tutor mailing list. If you want help with a

Re: simple tkinter battery monitor

2013-01-27 Thread Dave Angel
On 01/27/2013 05:59 PM, leonix.po...@gmail.com wrote: I tried to write a simple battery monitor for laptops which shows normally just the battery percentage, and when is clicked some more info. If I click just one time it works, but if I click a second time, the additional info Label seems to b

Re: Python Programming - 28 hours training in New York for $3999

2013-01-28 Thread Dave Angel
On 01/26/2013 06:57 PM, Chris Angelico wrote: On Sun, Jan 27, 2013 at 3:38 AM, Juhani Karlsson wrote: Or take this course for free and buy 500 lunches. Your choice. You spend $8 on lunch? Wow, that's taking TANSTAAFL a long way... ChrisA MYCROFTXXX I remember when lunches at IBM were nev

Re: Hello All

2013-01-28 Thread Dave Angel
On 01/28/2013 07:34 AM, Huey Mataruse wrote: I have been learning Python on my own and its been 1yr now and i still feel i dont know anything, is there a way that i can use to increase my way of learning. I feel there is more that i can do with python that other languages cannot. Please help.

Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Dave Angel
On 01/28/2013 08:31 AM, inshu chauhan wrote: In the code below I am trying to read 2 files f1 and f2 , extract some data from them and then trying to write them into a single file that is 'nf'. import cv f1 = open(r"Z:\modules\Feature_Vectors_300.arff") f2 = open(r"Z:\modules\Feature_Vectors_300

Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Dave Angel
On 01/28/2013 09:12 AM, inshu chauhan wrote: Yes Chris, I understand, My Original code was for l in f1: sp = l.split(",") if len(sp)!= 12: continue else: ix = sp[0].strip() iy = sp[1].strip() for s in f2: st = s.split(",") if l

Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Dave Angel
On 01/28/2013 09:47 AM, inshu chauhan wrote: Your current logic tries to scan through the first file, and for each line that has 12 elements, scans through the entire second file. It fails to actually do it, because you never do a seek on the second file. Now it appears your requirement is en

Re: WLAN tester

2013-01-28 Thread Dave Angel
On 01/28/2013 10:47 AM, Wanderer wrote: I'm looking to make a WLAN tester for a manufacturing test. Something that could send and receive a bunch of files and measure how long it took. I would repeat this a number of times for a device under test and then use some metric to decide pass/fail an

Re: what is the difference between commenting and uncommenting the __init__ method in this class?

2013-01-28 Thread Dave Angel
On 01/28/2013 09:09 PM, iMath wrote: what is the difference between commenting and uncommenting the __init__ method in this class? class CounterList(list): counter = 0 ##def __init__(self, *args): ##super(CounterList, self).__init__(*args) def __getitem__(self, index):

Re: [os.path.join(r'E:\Python', name) for name in []] returns []

2013-01-29 Thread Dave Angel
On 01/29/2013 08:21 AM, iMath wrote: why [os.path.join(r'E:\Python', name) for name in []] returns [] ? please explain it in detail ! [ os.path.join(r'E:\Python', name) for name in [] ] It'd be nice if you would explain what part of it bothers you. Do you know what a list comprehension is?

Re: Reading data from 2 different files and writing to a single file

2013-01-30 Thread Dave Angel
On 01/30/2013 05:43 AM, inshu chauhan wrote: On Mon, Jan 28, 2013 at 6:05 PM, Dennis Lee Bieber wrote: On Mon, 28 Jan 2013 14:31:31 +0100, inshu chauhan declaimed the following in gmane.comp.python.general: In the code below I am trying to read 2 files f1 and f2 , extract some data from th

Re: derived class name in python 2.6/2.7

2013-01-30 Thread Dave Angel
On 01/30/2013 03:05 PM, Sells, Fred wrote: This is simple, but I just cannot find it after quite a bit of searching I have this basic design class A: def __init__(self): print 'I am an instance of ', self.__class__.name class B(A): pass X = B I would like thi

Re: pyrudp

2013-01-30 Thread Dave Angel
On 01/30/2013 02:55 PM, Jorge Alberto Diaz Orozco wrote: I want to use a reliable UDP connection like you say, a TCP like connection but over UDP. thaks for your recomendation, if I get good results I promise to share them. It's nice to "want" but what is your actual condition/problem? Are

Re: confusion with decorators

2013-01-30 Thread Dave Angel
On 01/30/2013 07:34 PM, Jason Swails wrote: Hello, I was having some trouble understanding decorators and inheritance and all that. This is what I was trying to do: # untested class A(object): def _protector_decorator(fcn): def newfcn(self, *args, **kwargs): return fcn(sel

Re: help

2013-01-30 Thread Dave Angel
On 01/30/2013 04:16 PM, aramilda...@gmail.com wrote: Hi everyone! I don't mean to intrude, but ive heard great things about this group and ive stumped myself with my python code. heres my code: #! /usr/bin/python import sys global labelList labelList= dict() global counter counter = 0 def e

Re: PyHook to catch mouse events

2012-01-23 Thread Dave Angel
On 01/23/2012 08:35 AM, Neru Yume wrote: Date: Mon, 23 Jan 2012 08:24:41 -0500 From: d...@davea.name To: neruy...@hotmail.com CC: python-list@python.org Subject: Re: PyHook to catch mouse events On 01/23/2012 07:06 AM, Neru Yume wrote: Using PyHook to record mouse events, one has to add quite

Re: while True or while 1

2012-01-23 Thread Dave Angel
On 01/23/2012 08:28 AM, Hrvoje Niksic wrote: Dave Angel writes: I do something similar when there's a portion of code that should never be reached: assert("reason why I cannot get here") Shouldn't that be assert False, "reason why I cannot get here"? You ca

Re: problems with tkinter updates

2012-01-23 Thread Dave Angel
On 01/23/2012 08:09 PM, y...@zioup.com wrote: I'm missing something about tkinter updates. How can I give tkinter a chance to run? Here's some code: import time import tkinter import tkinter.scrolledtext tk = tkinter.Tk() f = tkinter.Toplevel(tk) st = tkinter.scrolledtext.ScrolledText(f) st

Re: how to get my character?

2012-01-26 Thread Dave Angel
On 01/26/2012 07:52 AM, contro opinion wrote: > my system:xp+python27 the codec, xp gbk;python 27 ascii > > a = '你好' > a > '\xc4\xe3\xba\xc3' > print a > 你好 > '\xc4\xe3\xba\xc3'.decode('gbk') > u'\u4f60\u597d' > '\xc4\xe3\xba\xc3'.encode('gbk') > Traceback (most recent call last): File "", line 1,

Re: write 中文 into c:\t1

2012-01-26 Thread Dave Angel
On 01/26/2012 09:46 PM, contro opinion wrote: s='\xd6\xd0\xce\xc4' print s 中文 s1=s.decode('gbk').encode('utf-8') print s1 涓 file=open('c:\\t1','w') file.write(s1) file.close() > when i open c:\t1,i get 中文 in it, > how can i write 涓 into c:\t1??

Re: what is the unicode?

2012-01-28 Thread Dave Angel
I'm guessing you're using Python 2.7 or something similar. Things are much different in Python 3.x On 01/28/2012 02:47 AM, contro opinion wrote: > as far as i know > u'中国'.encode('utf-8') > '\xe4\xb8\xad\xe5\x9b\xbd' > > so,'\xe4\xb8\xad\xe5\x9b\xbd' is the utf-8 of '中国' No, it is the utf

Re: add two strings

2012-01-30 Thread Dave Angel
On 01/30/2012 08:02 AM, contro opinion wrote: s1='\x45' s2='\xe4' s1+s2 'E\xe4' print s1+s2 E why s1+s2 not = '\x45\xe4'?? It is. "E" is "\x45". That's plain ASCII and documented everywhere. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError

2012-02-01 Thread Dave Angel
On 02/01/2012 11:53 AM, Clark, Kathleen wrote: Hello, Which python version, what operating system. Doesn't cost much to specify, and can frequently be relevant. I am new to python and am trying to correct the follow error: TypeError: sequence item 1: expected string, NoneType found That's n

Re: Question about name scope

2012-02-01 Thread Dave Angel
On 02/01/2012 12:11 PM, Olive wrote: I am learning python and maybe this is obvious but I have not been able to see a solution. What I would like to do is to be able to execute a function within the namespace I would have obtained with from import * For example if I write: def f(a): re

Re: Help writelines

2012-02-03 Thread Dave Angel
On 02/03/2012 03:27 PM, Anatoli Hristov wrote: Hi everyone, I`m totaly new in python and trying to figure out - how to write a list to a file with a newline at the end of each object. I tried alot of combinations :) like: users = ['toli','didi'] fob=open('c:/Python27/Toli/username','w') fob.writ

Re: building a dictionary dynamically

2012-02-06 Thread Dave Angel
On 02/04/2012 01:13 PM, noydb wrote: How do you build a dictionary dynamically? Doesn't seem to be an insert object or anything. So I need an empty dictionary that I then want to populate with values I get from looping through a list and grabbing some properties. So simply, I have (fyi, arcpy

Re: iterating over list with one mising value

2012-02-07 Thread Dave Angel
On 02/07/2012 07:27 AM, Sammy Danso wrote: Hello experts, I am having trouble accessing the content of my list. my list content has 2-pair value with the exception of one which has single value. here is an example ['a', 1, 'b', 1, 'c', 3, 'd'] I am unable to iterate through list to access in

Re: Reading files in from the proper directory

2012-02-07 Thread Dave Angel
On 02/07/2012 01:14 PM, smac2...@comcast.net wrote: Hello. I am admittedly a Python novice, and ran into some trouble trying to write a program that will pull multiple excel files all into one file, with each file on a different sheet. I am confident most of the code is correct, as the program r

Re: iterating over list with one mising value

2012-02-07 Thread Dave Angel
On 02/07/2012 03:23 PM, Sammy Danso wrote: Please don't top-post. It hopelessly mixes responses out of order. Hi Expert, Thanks for your responses and help. thought I should provide more information for clarity. Please find the error message below for more information for (key, value)

Re: when to use import statements in the header, when to use import statements in the blocks where they are used?

2012-02-07 Thread Dave Angel
On 02/07/2012 08:48 PM, Lei Cheng wrote: Hi all, In a py file, when to use import statements in the header, when to use import statements in the blocks where they are used? What are the best practices? Thanks! Pat Best practice is to put all the imports at the beginning of the modu

Re: when to use import statements in the header, when to use import statements in the blocks where they are used?

2012-02-07 Thread Dave Angel
You forgot to include the list in your reply, so I'm forwarding it for you. One way you could have done it was to reply-all. On 02/07/2012 09:32 PM, Patto wrote: Dave Angel: On Wed, Feb 8, 2012 at 10:05 AM, Dave Angel wrote: On 02/07/2012 08:48 PM, Lei Cheng wrote: Hi all,

Re: Apparent "double imports"

2012-02-09 Thread Dave Angel
On 02/09/2012 02:40 PM, HoneyMonster wrote: On Thu, 09 Feb 2012 12:02:03 -0700, Ian Kelly wrote: On Thu, Feb 9, 2012 at 11:53 AM, HoneyMonster wrote: One issue I have run into, which may or may not be a problem: I am finding that modules in the in-house "library" package sometimes have to im

Re: changing sys.path

2012-02-10 Thread Dave Angel
On 02/10/2012 08:08 AM, Andrea Crotti wrote: I think I finally located the issue with the sys.path extension. The problem is that I have many namespace directories, for example lib: - sub1 - sub2 lib: - sub3 - sub4 But to have everything working I had lib.sub3 in easy-install.pth. Now i

Re: changing sys.path

2012-02-10 Thread Dave Angel
On 02/10/2012 09:51 AM, Andrea Crotti wrote: Ok now it's getting really confusing, I tried a small example to see what is the real behaviour, so I created some package namespaces (where the __init__.py declare the namespace package). /home/andrea/test_ns: total used in directory 12 available 565

Re: Numeric root-finding in Python

2012-02-12 Thread Dave Angel
On 02/12/2012 10:20 AM, inq1ltd wrote: I don't know the first thing about this math problem however, if I were to code this I might try ; except ZeroDivisionError: assert w = -1 You top-posted. Please type your response after whatever you're quoting. In my case, I only need a

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