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: 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

Re: Python usage numbers

2012-02-12 Thread Dave Angel
On 02/12/2012 05:27 PM, Roy Smith wrote: In article, Chris Angelico wrote: On Mon, Feb 13, 2012 at 9:07 AM, Terry Reedy wrote: The situation before ascii is like where we ended up *before* unicode. Unicode aims to replace all those byte encoding and character sets with *one* byte encoding

Re: Python usage numbers

2012-02-12 Thread Dave Angel
On 02/12/2012 05:30 PM, Steven D'Aprano wrote: On Sun, 12 Feb 2012 05:11:30 -0600, Andrew Berg wrote: On 2/12/2012 3:12 AM, Steven D'Aprano wrote: Windows has two separate APIs, one for "wide" characters, the other for single bytes. Depending on which one you use, the directory will appear t

Re: Generating a .pc file using distutils

2012-02-12 Thread Dave Angel
On 02/12/2012 06:04 PM, Tycho Andersen wrote: Just re-bumping this - I am fiddling with this code again and it's gross, so any input would be greatly appreciated :-) \t On Mon, Jan 23, 2012 at 05:31:20PM -0600, Tycho Andersen wrote: Is there some standard way to generate a .pc file (given a .p

Re: Numeric root-finding in Python

2012-02-12 Thread Dave Angel
On 02/12/2012 06:05 PM, Steven D'Aprano wrote: On Sun, 12 Feb 2012 12:18:15 -0800, Mark Dickinson wrote: On Feb 12, 6:41 am, Steven D'Aprano wrote: err = -a/b # Estimate of the error in the current w. if abs(err)<= 1e-16: break If the result you'r

Re: Python usage numbers

2012-02-12 Thread Dave Angel
On 02/12/2012 06:29 PM, Steven D'Aprano wrote: On Sun, 12 Feb 2012 17:27:34 -0500, Roy Smith wrote: Hopefully, we will eventually reach the point where storage is so cheap that nobody minds how inefficient UTF-32 is and we all just start using that. Life will be a lot simpler then. No more t

Re: Complexity question on Python 3 lists

2012-02-15 Thread Dave Angel
On 02/15/2012 01:20 PM, Franck Ditter wrote: What is the cost of calling primes(n) below ? I'm mainly interested in knowing if the call to append is O(1), even amortized. Do lists in Python 3 behave like ArrayList in Java (if the capacity is full, then the array grows by more than 1 element) ? d

Re: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL

2012-02-15 Thread Dave Angel
On 02/15/2012 01:36 PM, Miki Tebeka wrote: It depends on the overall runtime of the script vs start time of the vm. But yes in most benchmarks the script start time will bias against scripted languages. On a site note: ALL CAPS is considered shouting, please don't use that in news groups. Whe

Re: writing to a file from within nested loops

2012-02-15 Thread Dave Angel
On 02/15/2012 03:12 PM, Rituparna Sengupta wrote: Hi, I'm working on this code and I keep getting an error. It might be some very basic thing but I was wondering if someone could help. Its a loop within a loop. The part outside the innermost loop gets printed fine, but the part within the inn

Re: signed to unsigned

2012-02-17 Thread Dave Angel
On 02/17/2012 02:22 PM, Brad Tilley wrote: 0x& -327681234 3967286062 Very nice! Thanks for that example. Unsigned long longs: 0x& -9151314442815602945 9295429630893948671L Or more generally, use modulo -13452324 % 2^64 -- DaveA -- http://mail.python.org/mailman/l

Re: Undoing character read from file

2012-02-17 Thread Dave Angel
On 02/17/2012 10:38 PM, Emeka wrote: Hello All, Say I have something like this: mfile = open("cc.txt", "rb") mcount = 0 mset = False while True: c = mfile.read(1) if c == "e" and mset is True and mcount == 0: print c mfile.seek(-1,1) mcount = 1 continue elif c == "e" and mse

Re: netCDF4 variable manipulation

2012-02-20 Thread Dave Angel
On 02/20/2012 03:37 PM, Sheldon wrote: Hi, I'm trying to read a netCDF4 variable from a file (no problem) and then scale it before writing over the original variable in the file. I'm using python 2.7 and the latest netCDF4 module. It's not that I keep getting an error message but I want to do t

Re: Please verify!!

2012-02-23 Thread Dave Angel
On 02/23/2012 05:13 PM, Manish Sharma wrote: Hi I am new to python language. On my first day, somebody told me that if any python script file is opened with any editor except python editor, the file is corrupted. Some spacing or indentation is changed and script stops working. I was opening the s

Re: Please verify!!

2012-02-24 Thread Dave Angel
On 02/24/2012 08:25 PM, Chris Angelico wrote: On Sat, Feb 25, 2012 at 11:49 AM, Mark Lawrence wrote: Oo, thou sinner, fancy violating PEP 8 and standardising on tabs. PEP 8 applies only to Python code, our standard is across all our languages :) But yes, I'm a horrible sinner and I like tabs.

Re: wcout issue

2012-02-28 Thread Dave Angel
On 02/27/2012 10:26 PM, Ben Held wrote: Hello, After upgrading from Python 2.6 to 3.2 in our application we noticed that after calling Py_Initialize, our output from std::wcout has extra spaces in it: wcout<< L"Just a test\n"; now prints out: J u s t a t e s t Any clue why? Ben Held

Re: Listing children processes

2012-02-28 Thread Dave Angel
On 02/28/2012 06:41 PM, Mark Lawrence wrote: On 28/02/2012 21:47, Arnaud Delobelle wrote: Please don't top-post! Also, psutil.Process.get_children() looks to me like it "does" children. You are incorrect. I've been told of by the BDFL for stating that people should not top post on any Pyth

Re: Problem using s.strip() to remove leading whitespace in .csv file

2012-02-29 Thread Dave Angel
On 02/29/2012 04:05 AM, Guillaume Chorn wrote: Thanks, the suggestion print name.decode("utf-8").strip() worked like a charm. When I did the print repr(name) I got exactly what you predicted. I'm not yet sure what all of this means, but I'm going to read this

Re: Why this fails??

2012-02-29 Thread Dave Angel
On 02/29/2012 04:07 AM, Smiley 4321 wrote: Why below fails - #!/usr/bin/python import pickle class MyClass(object): Field1 = None Field2 = None def __init__(self, dictionary): self.__dict__.update(dictionary) my_List = {'Field1': 'Apple', 'Field2': 'Orange'

Re: On u'Unicode string literals' (Py3)

2012-02-29 Thread Dave Angel
Just who are you replying to? On 02/29/2012 08:45 AM, jmfauth wrote: For those who do not know: The u'' string literal trick has never worked in Python 2. No trick there. If you have something explicit to say, then say it. sys.version '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32

Re: sys.stdout.detach() results in ValueError

2012-03-07 Thread Dave Angel
On 03/07/2012 02:41 PM, Peter Kleiweg wrote: I want to write out some binary data to stdout in Python3. I thought the way to do this was to call detach on sys.stdout. But apparently, you can't. Here is a minimal script: #!/usr/bin/env python3.1 import sys fp = sys.stdout.detach()

Re: cython + scons + c++

2012-03-08 Thread Dave Angel
On 03/08/2012 09:23 AM, Neal Becker wrote: Is there a version of cython.py, pyext.py that will work with c++? I asked this question some time ago, but never got an answer. I tried the following code, but it doesn't work correctly. If the commented lines are uncommented, the gcc command is tota

Re: Finding MIME type for a data stream

2012-03-08 Thread Dave Angel
On 03/08/2012 04:55 PM, Tobiah wrote: I'm pulling image data from a database blob, and serving it from a web2py app. I have to send the correct Content-Type header, so I need to detect the image type. Everything that I've found on the web so far, needs a file name on the disk, but I only have t

Re: What's the best way to write this regular expression?

2012-03-08 Thread Dave Angel
On 03/08/2012 04:40 PM, John Salerno wrote: http://i271.photobucket.com/albums/jj138/JohnJSal/lxml_error.png Nothing to do with Python, but you'd save us all a lot of space and bandwidth if you learned how to copy/paste from a Windows cmd window. If you're just doing it rarely, you can rig

Re: Finding MIME type for a data stream

2012-03-08 Thread Dave Angel
On 03/08/2012 05:28 PM, Tobiah wrote: I should simplify my question. Let's say I have a string that contains image data called 'mystring'. I want to do mime_type = some_magic(mystring) and get back 'image/jpg' or 'image/png' or whatever is appropriate for the image data. Thanks! Tobiah

Re: What's the best way to write this regular expression?

2012-03-08 Thread Dave Angel
On 03/08/2012 06:02 PM, Prasad, Ramit wrote: Actually in quick-edit mode (XP and higher) you just select with left click and then hit enter which copies it to the clipboard. If you also enable insert mode (not sure if this is Win7 specific) you can even right click to paste into the console, just

Re: Launching A Truly Disjoint Process

2012-03-11 Thread Dave Angel
On 03/11/2012 05:01 PM, Ami Tavory wrote: Hello, I'm encountering a problem using the multiprocessing module to create a process that is truly disjoint from the parent process: i.e., one that contains no "memory" of the parent process, nor any record in the parent process that it is its ch

Re: Is it technically possible to give Python option of naming process of running script?

2012-03-14 Thread Dave Angel
On 03/14/2012 01:27 PM, Prasad, Ramit wrote: It seems like an excellent thing to add to the "os" module. If 'prctl' is a standard POSIX system call, then it should be a candidate for inclusion in the os module if someone opens a tracker enhancement issue and presents an argument in favor. I th

Re: Is it technically possible to give Python option of naming process of running script?

2012-03-15 Thread Dave Angel
On 03/15/2012 03:26 AM, xliiv wrote: Like the topic.. . I use Python a lot, both Windows and Linux, and it's little weird to have many python process without fast distinction which is what. I did google, I've played with Exemaker (it works perfect, but not py3) and i've seen questions on St

Re: Is it technically possible to give Python option of naming process of running script?

2012-03-15 Thread Dave Angel
On 03/15/2012 02:39 PM, Grant Edwards wrote: On 2012-03-15, Dave Angel wrote: On 03/15/2012 03:26 AM, xliiv wrote: Like the topic.. . I use Python a lot, both Windows and Linux, and it's little weird to have many python process without fast distinction which is what. I did google,

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-23 Thread Dave Angel
On 03/23/2012 02:28 PM, Peter Otten wrote: Ethan Furman wrote: Nathan Rice wrote: Logo. It's turtles all the way down. +1 QOTW Surely you're joking, Mr Furman! Cracking safes was the best chapter. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there any difference between print 3 and print '3' in Python ?

2012-03-26 Thread Dave Angel
On 03/26/2012 07:45 AM, redstone-c...@163.com wrote: I know the print statement produces the same result when both of these two instructions are executed ,I just want to know Is there any difference between print 3 and print '3' in Python ? This is a non-question. The input is the same, the

Re: python segfault

2012-03-27 Thread Dave Angel
On 03/27/2012 06:27 PM, Michael Poeltl wrote: hi, can anybody tell why this 'little stupid *thing* of code' let's python-3.2.2, 2.6.X or python 2.7.2 segfault? def get_steps2(pos=0, steps=0): ... if steps == 0: ... pos = random.randint(-1,1) ... if pos == 0: ... retur

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Dave Angel
On 03/28/2012 04:56 AM, Peter Daum wrote: Hi, is there any way to convert a string to bytes without interpreting the data in any way? Something like: s='abcde' b=bytes(s, "unchanged") Regards, Peter You needed to specify that you are using Python 3.x . In pyt

Re: tabs/spaces

2012-03-29 Thread Dave Angel
On 03/29/2012 03:18 AM, Ulrich Eckhardt wrote: Am 28.03.2012 20:26, schrieb Terry Reedy: On 3/28/2012 8:28 AM, Ulrich Eckhardt wrote: [...] # call testee and verify results try: ...call function here... except exception_type as e: if not exception is None: self.assertEqual(e, exception) Did

Re: tabs/spaces

2012-03-30 Thread Dave Angel
On 03/30/2012 03:05 AM, Ulrich Eckhardt wrote: Am 29.03.2012 17:25, schrieb Terry Reedy: I am using Thunderbird, win64, as news client for gmane. The post looked fine as originally received. The indents only disappeared when I hit reply and the >s were added. I can confirm this misbehaviour of

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-04-03 Thread Dave Angel
On 04/03/2012 11:16 AM, Mark Lawrence wrote: > On 03/04/2012 15:56, Chris Angelico wrote: >> On Wed, Apr 4, 2012 at 12:46 AM, Grant >> Edwards wrote: >>> Anybody remember DEC's VAX/VMS "patch" utility? Apparently, DEC >>> thought it was a practical way to fix things. It had a built-in >>> assemb

Re: Python Gotcha's?

2012-04-05 Thread Dave Angel
On 04/05/2012 08:02 PM, Cameron Simpson wrote: > On 05Apr2012 19:13, Alain Ketterlin wrote: > | Miki Tebeka writes: > | > (Note that I want over http://wiki.python.org/moin/PythonWarts already). > | > | The "local variable and scoping" is, imho, something to be really > | careful about. Here is

Re: f python?

2012-04-08 Thread Dave Angel
On 04/08/2012 08:04 PM, David Robinow wrote: > On Sun, Apr 8, 2012 at 6:55 PM, Dennis Lee Bieber > wrote: >>The main reason, as I recall, for the command line using \ for file >> paths is that it inherited / as command OPTION prefix from CP/M; MS-DOS >> being a 32-bit work-alike for CP/M

Re: pygame.Rect question

2012-04-08 Thread Dave Angel
On 04/08/2012 07:58 PM, Scott Siegler wrote: > Hello, > > I am new to Python and began using pygame to start some game programming. I > was hoping someone could help me out with something that seems simple but is > really confusing me. > > I am creating a rect and then using the attributes of th

Re: How to filter a dictionary ?

2012-04-10 Thread Dave Angel
On 04/10/2012 02:04 AM, Shashank Singh wrote: > On Mon, Apr 9, 2012 at 10:49 PM, Nikhil Verma wrote: > >> I am trying this but its giving me a generator object. >> >> In [9]: (k for k,v in for_patient_type.iteritems() if v == 'Real') >> > Iterating over a dict gives you all the keys, not the key v

Re: functions which take functions

2012-04-11 Thread Dave Angel
On 04/11/2012 06:55 AM, Kiuhnm wrote: > On 4/10/2012 23:43, Eelco wrote: >> On Apr 10, 3:36 am, Kiuhnm wrote: >>> On 4/10/2012 14:29, Ulrich Eckhardt wrote: >>> Am 09.04.2012 20:57, schrieb Kiuhnm: > Do you have some real or realistic (but easy and self-contained) > examples when you

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