How to detect C Function block using python

2010-03-08 Thread Faheem
Hey All, I'm new in this community. I am writing a static analyzer for validating C Code using python and for that I'm looking for a python module/API that will detect Function block of a given C-File. I know simple function can be detected using push "{" and poping it if character "}" is found

Re: Calculating very large exponents in python

2010-03-08 Thread casevh
[also replying to Geremy since the OP's message doesn't appear...] On Mar 8, 11:05 am, geremy condra wrote: > On Mon, Mar 8, 2010 at 2:15 AM, Fahad Ahmad wrote: > > Thanks Geremy, > > > That has been an absolute bump... GOD i cant sit on my chair, it has > > worked even on 512 bit number

scipy sparse matrix question

2010-03-08 Thread Victor Eijkhout
I can't find any detailed information about scipy.sparse. My specific question: what does "for x in A" give me when A is a sparse matrix? It seems to yield all nonzero locations, but in what kind of form? Very specifically: how do I get the (i,j) coordinates and the value from x? Victor. -- Vic

Re: imported var not being updated

2010-03-08 Thread Alex Hall
Thanks, it worked as expected. I guess I figured that Python would read my mind and realize that I wanted mostRecent to act globally for the program, imported as a copy or accessed in its own namespace (right term?) Oh well, the day computers can read thoughts like that is the day programmers are o

Re: imported var not being updated

2010-03-08 Thread Gary Herron
Alex Hall wrote: Hello all: I have a project with many pyw files. One file holds a variable and a function that I find myself using across many other pyw files, so I called it helpers.pyw. The variable is "mostRecent", which is a string and is meant to hold a string so I know what the program mos

imported var not being updated

2010-03-08 Thread Alex Hall
Hello all: I have a project with many pyw files. One file holds a variable and a function that I find myself using across many other pyw files, so I called it helpers.pyw. The variable is "mostRecent", which is a string and is meant to hold a string so I know what the program most recently output;

Re: libc Sleep api performs a busy waiting

2010-03-08 Thread Joe Fox
Hi, actually i have simplified my scenario a lot here , In my actual case , i have to call a C-api which blocks on c select , in a separate thread. my thread is getting struck in that api , and thus blocking all the other threads. Can you point to something which will help me call this blockin

remove element with ElementTree

2010-03-08 Thread tdan
I have been using ElementTree to write an app, and would like to simply remove an element. But in ElementTree, you must know both the parent and the child element to do this. There is no getparent() function, so I am stuck if I only have an element. I am iterating over a table and getting all tag

Re: related lists mean value

2010-03-08 Thread John Posner
On 3/8/2010 9:43 PM, John Posner wrote: On 3/8/2010 9:39 PM, John Posner wrote: obj.id = y[i] <--- statement redundant, remove it Sorry for the thrashing! It's more correct to say that the Tally class doesn't require an "id" attribute at all. So the code becomes: #- from collect

Re: related lists mean value

2010-03-08 Thread John Posner
On 3/8/2010 9:39 PM, John Posner wrote: # gather data tally_dict = defaultdict(Tally) for i in range(len(x)): obj = tally_dict[y[i]] obj.id = y[i] <--- statement redundant, remove it obj.total += x[i] obj.count += 1 -John -- http://mail.python.org/mailman/listinfo/python-li

Re: related lists mean value

2010-03-08 Thread John Posner
On 3/8/2010 5:34 PM, dimitri pater - serpia wrote: Hi, I have two related lists: x = [1 ,2, 8, 5, 0, 7] y = ['a', 'a', 'b', 'c', 'c', 'c' ] what I need is a list representing the mean value of 'a', 'b' and 'c' while maintaining the number of items (len): w = [1.5, 1.5, 8, 4, 4, 4] I have looke

Re: Queue peek?

2010-03-08 Thread Aahz
In article <58f61382-ac79-46fb-8612-a3c9fde29...@c16g2000yqd.googlegroups.com>, Veloz wrote: > >The "peek" parts comes in when the user comes back later to see if >their report has done. That is, in my page controller logic, I'd like >to look through the complete queue and see if the specific rep

Re: related lists mean value

2010-03-08 Thread dimitri pater - serpia
thanks Chris and MRAB! Looks good, I'll try it out On Tue, Mar 9, 2010 at 12:22 AM, Chris Rebert wrote: > On Mon, Mar 8, 2010 at 2:34 PM, dimitri pater - serpia > wrote: >> Hi, >> >> I have two related lists: >> x = [1 ,2, 8, 5, 0, 7] >> y = ['a', 'a', 'b', 'c', 'c', 'c' ] >> >> what I need is a

Re: Python 3.1.2 release candidate

2010-03-08 Thread Mensanator
On Mar 6, 4:13 pm, Benjamin Peterson wrote: > On behalf of the Python development team, I'm pleased to announce a release > candidate for the second bugfix release of the Python 3.1 series, Python > 3.1.2. > > This bug fix release fixes numerous issues found in 3.1.1.  This release > candidate ha

Re: Reverse engineering CRC?

2010-03-08 Thread Dave Angel
Gregory Ewing wrote: Dave Angel wrote: If you know so little about the value, how do you even know it's a CRC ? Could it be a ones-complement sum, such as used in Ethernet? I'm going by the fact that the application reports a "CRC mismatch" when it's wrong. I can't be sure that what it calls

Re: related lists mean value

2010-03-08 Thread Chris Rebert
On Mon, Mar 8, 2010 at 2:34 PM, dimitri pater - serpia wrote: > Hi, > > I have two related lists: > x = [1 ,2, 8, 5, 0, 7] > y = ['a', 'a', 'b', 'c', 'c', 'c' ] > > what I need is a list representing the mean value of 'a', 'b' and 'c' > while maintaining the number of items (len): > w = [1.5, 1.5,

Re: related lists mean value

2010-03-08 Thread MRAB
dimitri pater - serpia wrote: Hi, I have two related lists: x = [1 ,2, 8, 5, 0, 7] y = ['a', 'a', 'b', 'c', 'c', 'c' ] what I need is a list representing the mean value of 'a', 'b' and 'c' while maintaining the number of items (len): w = [1.5, 1.5, 8, 4, 4, 4] I have looked at iter(tools) and

Re: Converting HTML to PDF using Python?

2010-03-08 Thread Grant Edwards
On 2010-03-08, Oltmans wrote: > Guys, any ideas on how to convert HTML files to PDF files? os.system("w3m -dump %s | a2ps -B --borders=no -o - | ps2pdf - %s" % (infile,outfile)) -- Grant Edwards grant.b.edwardsYow! Am I accompanied by a

Re: write to remote ile

2010-03-08 Thread MRAB
monkeys paw wrote: On 3/7/2010 9:53 PM, Martin P. Hellwig wrote: On 03/08/10 02:51, monkeys paw wrote: On 3/7/2010 9:20 PM, Martin P. Hellwig wrote: On 03/08/10 02:10, monkeys paw wrote: I can xfer a file from a remote server using: import urllib2 as u x=u.urlopen('http://tycho.usno.navy.mil

Re: negative "counts" in collections.Counter?

2010-03-08 Thread Raymond Hettinger
[Gregory Ewing] > I think you should be providing two types: one is a > multiset, which disallows negative counts altogether; > the other behaves like a sparse vector with appropriate > arithmetic operations. That is pretty close to what I said above: """ In this case, we have an indication that

related lists mean value

2010-03-08 Thread dimitri pater - serpia
Hi, I have two related lists: x = [1 ,2, 8, 5, 0, 7] y = ['a', 'a', 'b', 'c', 'c', 'c' ] what I need is a list representing the mean value of 'a', 'b' and 'c' while maintaining the number of items (len): w = [1.5, 1.5, 8, 4, 4, 4] I have looked at iter(tools) and next(), but that did not help me

Re: What to do if anything bites.

2010-03-08 Thread News123
Google Adsense wrote: > What to do if anything bites. > > Check our bites treatment at > > http://108ambulance.blogspot.com/2010/03/108-ambulance-home-page.html Pythons don't bite -- http://mail.python.org/mailman/listinfo/python-list

Re: libc Sleep api performs a busy waiting

2010-03-08 Thread News123
Hi Steve, Steve Holden wrote: > Mahesh wrote: >> Hi, >> >> I am having a problem while using sleep function from libc , the >> thread in which i am calling it is getting struck and not allowing >> other threads to execute. Here is a simple code that i am trying to >> exeute >> >> import threadin

Re: Import problem

2010-03-08 Thread News123
Jean-Michel Pichavant wrote: > Johny wrote: >> I have this directory structure >> >> C: >> \A >> __init__.py >> amodule.py >> >> \B >> __init__.py >> bmodule.py >> >>\D >> __init__.py >> dmodule.py >> >> and I

Re: Import problem

2010-03-08 Thread News123
Jean-Michel Pichavant wrote: > Johny wrote: >> I have this directory structure >> >> C: >> \A >> __init__.py >> amodule.py >> >> \B >> __init__.py >> bmodule.py >> >>\D >> __init__.py >> dmodule.py >> >> and I

Re: negative "counts" in collections.Counter?

2010-03-08 Thread Vlastimil Brom
2010/3/8 Raymond Hettinger : ... [snip detailed explanations] >... > In this case, we have an indication that what you really want is > a separate class supporting elementwise binary and unary operations > on vectors (where the vector fields are accessed by a dictionary > key instead of a positiona

Re: negative "counts" in collections.Counter?

2010-03-08 Thread Gregory Ewing
Raymond Hettinger wrote: Instead the choice was to implement the four methods as multiset operations. As such, they need to correspond to regular set operations. Seems to me you're trying to make one data type do the work of two, and ending up with something inconsistent. I think you should

Re: Import problem

2010-03-08 Thread News123
Hi Steven, Steven D'Aprano wrote: > On Sat, 06 Mar 2010 03:53:53 -0800, Johny wrote: > > import sys > sys.path.append('C:\\A') > from A.B import bmodule >> Traceback (most recent call last): >> File "", line 1, in >> ImportError: No module named A.B > > The current directory is irre

Re: Reverse engineering CRC?

2010-03-08 Thread Gregory Ewing
Dave Angel wrote: If you know so little about the value, how do you even know it's a CRC ? Could it be a ones-complement sum, such as used in Ethernet? I'm going by the fact that the application reports a "CRC mismatch" when it's wrong. I can't be sure that what it calls a "CRC" is really a t

Re: negative "counts" in collections.Counter?

2010-03-08 Thread Raymond Hettinger
[Vlastimil Brom] > Thank you very much for the exhaustive explanation Raymond! You're welcome. > I am by far not able to follow all of the mathematical background, but > even for zero-truncating multiset, I would expect the truncation on > input rather than on output of some operations. I debat

Re: write to remote ile

2010-03-08 Thread monkeys paw
On 3/7/2010 9:53 PM, Martin P. Hellwig wrote: On 03/08/10 02:51, monkeys paw wrote: On 3/7/2010 9:20 PM, Martin P. Hellwig wrote: On 03/08/10 02:10, monkeys paw wrote: I can xfer a file from a remote server using: import urllib2 as u x=u.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl')

Re: negative "counts" in collections.Counter?

2010-03-08 Thread Daniel Stutzbach
On Mon, Mar 8, 2010 at 1:24 PM, Raymond Hettinger wrote: > Instinct says that conflating two models can be worse for usability > than just picking one of the models and excluding the other. > Toward that end, shouldn't Counter do one (and only one) of the follow? 1) Disallow non-positive counts

Re: negative "counts" in collections.Counter?

2010-03-08 Thread Raymond Hettinger
[Steven D'Aprano] > Thanks for the explanation Raymond. A few comments follow: You're welcome :-) > Would you consider a feature enhancement adding an additional method, > analogous to update(), to perform subtractions? I recognise that it's > easy to subclass and do it yourself, but there does

Re: Calculating very large exponents in python

2010-03-08 Thread Mark Dickinson
[Replying to Geremy's reply because the OP's post didn't show up in my newsreader.] On Mar 7, 8:40 pm, geremy condra wrote: > On Sun, Mar 7, 2010 at 1:55 PM, Fahad Ahmad wrote: > > Dear All, > > > i am writing my crytographic scheme in python, i am just a new user to it. > > I have written the co

Newbie question: python versions differ per user?

2010-03-08 Thread BobAalsma
I'm on Mac OS X 10.5.8 and downloaded 2.6.4 Mac Installer Disk Image as/in(?) the sys admin user. For this user Pyhton 2.6.4 is now the current version. I want to use Python outside the sys asdmin user. However, all other users still use Python 2.5.1 (Apple delivered). The sys admin user looks in

Re: NoSQL Movement?

2010-03-08 Thread Duncan Booth
Xah Lee wrote: > For example, consider, if you are within world's top 100th user of > database in terms of database size, such as Google, then it may be > that the off-the-shelf tools may be limiting. But how many users > really have such massive size of data? You've totally missed the point. It

Re: Calculating very large exponents in python

2010-03-08 Thread geremy condra
On Mon, Mar 8, 2010 at 2:05 PM, geremy condra wrote: > On Mon, Mar 8, 2010 at 2:15 AM, Fahad Ahmad wrote: >> Thanks Geremy, >> >> That has been an absolute bump... GOD i cant sit on my chair, it has >> worked even on 512 bit number and with no time.. >> superb i would say. >> >> l

Re: Calculating very large exponents in python

2010-03-08 Thread geremy condra
On Mon, Mar 8, 2010 at 2:15 AM, Fahad Ahmad wrote: > Thanks Geremy, > > That has been an absolute bump... GOD i cant sit on my chair, it has > worked even on 512 bit number and with no time.. > superb i would say. > > lastly, i am using the code below to calculate Largest Prime fac

Re: Converting HTML to PDF using Python?

2010-03-08 Thread Terry Reedy
On 3/8/2010 12:51 PM, CM wrote: On Mar 8, 10:36 am, Oltmans wrote: Hi Python superstars, Guys, any ideas on how to convert HTML files to PDF files? Or as an alternative, how to convert HTML files to an image file(jpeg/png/etc)? Ideally, the converted PDF/Image file should like exactly like the

ssl, v23 client, v3 server...

2010-03-08 Thread Dino Viehland
In the ssl module docs (and in the tests) it says that if you have a client specifying PROTOCOL_SSLv23 (so it'll use v2 or v3) and a server specifying PROTOCOL_SSLv3 (so it'll only use v3) that you cannot connect between the two. Why doesn't this end up using SSL v3 for the communication? --

Re: Converting HTML to PDF using Python?

2010-03-08 Thread CM
On Mar 8, 10:36 am, Oltmans wrote: > Hi Python superstars, > > Guys, any ideas on how to convert HTML files to PDF files? Or as an > alternative, how to convert HTML files to an image file(jpeg/png/etc)? > Ideally, the converted PDF/Image file should like exactly like the way > HTML file looks in

Re: Trouble with quotes

2010-03-08 Thread Martin P. Hellwig
On 03/08/10 17:06, Stephen Nelson-Smith wrote: Hi, I've written some (primitive) code to parse some apache logfies and establish if apache has appended a session cookie to the end. We're finding that some browsers don't and apache doesn't just append a "-" - it just omits it. It's working fine

Trouble with quotes

2010-03-08 Thread Stephen Nelson-Smith
Hi, I've written some (primitive) code to parse some apache logfies and establish if apache has appended a session cookie to the end. We're finding that some browsers don't and apache doesn't just append a "-" - it just omits it. It's working fine, but for an edge case: Couldn't match 192.168.

Re: negative "counts" in collections.Counter?

2010-03-08 Thread Chris Rebert
On Mon, Mar 8, 2010 at 4:21 AM, Steven D'Aprano < st...@remove-this-cybersource.com.au> wrote: > On Sun, 07 Mar 2010 22:31:00 -0800, Raymond Hettinger wrote: >> On Mar 7, 5:46 pm, Steven D'Aprano > cybersource.com.au> wrote: >>> Given that Counter supports negative counts, it looks to me that the >

Converting HTML to PDF using Python?

2010-03-08 Thread Oltmans
Hi Python superstars, Guys, any ideas on how to convert HTML files to PDF files? Or as an alternative, how to convert HTML files to an image file(jpeg/png/etc)? Ideally, the converted PDF/Image file should like exactly like the way HTML file looks in the browser. I really have no idea about this

Re: NoSQL Movement?

2010-03-08 Thread Xah Lee
many people mentioned scalibility... though i think it is fruitful to talk about at what size is the NoSQL databases offer better scalability than SQL databases. For example, consider, if you are within world's top 100th user of database in terms of database size, such as Google, then it may be th

Re: A "scopeguard" for Python

2010-03-08 Thread sstein...@gmail.com
On Mar 8, 2010, at 7:28 AM, Steve Holden wrote: >> >> But your response, both the out of context quoting and your comment, >> seems solely designed to convey a negative impression instead of >> addressing any technical issue. >> > This isn't an isolated case, Alf. Physician, heal thyself. As fa

ANNOUNCE: Major Feature Release - NHI1-0.7, PLMK-1.6 and libmsgque-4.5

2010-03-08 Thread Andreas Otto
Dear User, ANNOUNCE:Major Feature Release libmsgque: Application-Server-Toolkit for C, C++, JAVA, C#, TCL, PERL, PYTHON, VB.NET PLMK: Programming-Language-Microkernel NHI1: Non-Human-Intelligence #1 SUMMARY === This is

What to do if anything bites.

2010-03-08 Thread Google Adsense
What to do if anything bites. Check our bites treatment at http://108ambulance.blogspot.com/2010/03/108-ambulance-home-page.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Import problem

2010-03-08 Thread Jean-Michel Pichavant
Johny wrote: I have this directory structure C: \A __init__.py amodule.py \B __init__.py bmodule.py \D __init__.py dmodule.py and I want to import bmodule.py C:\>cd \ C:\>python Python 2.5 (r25:51908, S

Re: Reverse engineering CRC?

2010-03-08 Thread Dave Angel
Gregory Ewing wrote: Steven D'Aprano wrote: Can you just ask the application developer what CRC is being used? Or look at the source code? Disassemble the binary? There's no source, and the binary is enormous. I could ask, but I wouldn't hold out much hope of them being willing to tell me.

Re: Conditional based on whether or not a module is being used

2010-03-08 Thread Jean-Michel Pichavant
Pete Emerson wrote: On Mar 5, 1:14 pm, Chris Rebert wrote: On Fri, Mar 5, 2010 at 12:25 PM, Pete Emerson wrote: On Fri, Mar 5, 2010 at 12:17 PM, Chris Rebert wrote: On 3/5/10, Pete Emerson wrote: In a module, how do I create a conditional that will do something bas

Re: libc Sleep api performs a busy waiting

2010-03-08 Thread Steve Holden
Mahesh wrote: > Hi, > > I am having a problem while using sleep function from libc , the > thread in which i am calling it is getting struck and not allowing > other threads to execute. Here is a simple code that i am trying to > exeute > > import threading > import time > import dl > > > def

Re: A "scopeguard" for Python

2010-03-08 Thread Steve Holden
Alf P. Steinbach wrote: > * Gabriel Genellina: >> En Thu, 04 Mar 2010 20:52:04 -0300, Alf P. Steinbach >> escribió: >> >>> Sorry, as with the places noted above, I can't understand what you're >>> trying to say here. >> >> Regarding your posts, neither can I. All the time. Sorry, deciphering >> yo

Re: negative "counts" in collections.Counter?

2010-03-08 Thread Steven D'Aprano
On Sun, 07 Mar 2010 22:31:00 -0800, Raymond Hettinger wrote: > On Mar 7, 5:46 pm, Steven D'Aprano cybersource.com.au> wrote: >> Given that Counter supports negative counts, it looks to me that the >> behaviour of __add__ and __sub__ is fundamentally flawed. You should >> raise a bug report (featu

Re: Curiosity stirkes me on 'import this'.

2010-03-08 Thread Ben Finney
Daniel Fetchinson writes: > > I'm curious. Was this encoded purely for fun? > > Yes. For some more fun, try measuring the ‘this’ module source code against the principles in the Zen. -- \ “Leave nothing to chance. Overlook nothing. Combine | `\ contradictory observa

Re: negative "counts" in collections.Counter?

2010-03-08 Thread Vlastimil Brom
2010/3/8 Raymond Hettinger : > On Mar 7, 5:46 pm, Steven D'Aprano cybersource.com.au> wrote: >> Given that Counter supports negative counts, it looks to me that the >> behaviour of __add__ and __sub__ is fundamentally flawed. You should >> raise a bug report (feature enhancement) on the bug tracke

Re: Reverse engineering CRC?

2010-03-08 Thread Gregory Ewing
Steven D'Aprano wrote: Can you just ask the application developer what CRC is being used? Or look at the source code? Disassemble the binary? There's no source, and the binary is enormous. I could ask, but I wouldn't hold out much hope of them being willing to tell me. it appears that the cr

Re: Curiosity stirkes me on 'import this'.

2010-03-08 Thread Daniel Fetchinson
> I took a look at the 'this' module to see where the file is stored. This is > probably old news to some people, but was new to me. > > print this.s > Gur Mra bs Clguba, ol Gvz Crgref > > Ornhgvshy vf orggre guna htyl. > Rkcyvpvg vf orggre guna vzcyvpvg. > Fvzcyr vf orggre guna pbzcyrk. > Pbzcyrk

Re: Best practice way to detect internet connectivity under Python 2.6/Windows

2010-03-08 Thread Tim Golden
On 08/03/2010 02:41, pyt...@bdurham.com wrote: Is the best pratice way to detect internet connectivity under Windows (using Python 2.6) simply to attempt to access a known internet website using urllib or urlib2 wrapped in a try/except construct? Well, in theory you could use the Internet API:

Re: Reverse engineering CRC?

2010-03-08 Thread Dave Angel
Steven D'Aprano wrote: On Mon, 08 Mar 2010 16:09:12 +1300, Gregory Ewing wrote: Given some known data/crc pairs, how feasible is it to figure out the polynomial being used to generate the crc? Google is your friend: http://www.woodmann.com/fravia/crctut1.htm That page was interes

libc Sleep api performs a busy waiting

2010-03-08 Thread Joe Fox
Hi , I am having a problem while using sleep function from libc , the thread in which i am calling it is getting struck and not allowing other threads to execute. Here is a simple code that i am trying to exeute import threading import time import dl def dummy1(): a=dl.open('/lib/libc.so.6

Re: running a program on many processors

2010-03-08 Thread Processor-Dev1l
On Mar 8, 1:18 am, Paweł Banyś wrote: > Hello, > > I have already read about Python and multiprocessing which allows using > many processors. The idea is to split a program into separate tasks and > run each of them on a separate processor. However I want to run a Python > program doing a single s

Re: The C language like the Python, by the Python and for the Python--- PythoidC

2010-03-08 Thread CHEN Guang
Dear Stefan, Thanks a lot for your interest in PythoidC. Yes, PythoidC takes regular expression to parse C header files, but there is no danger at all, because, the parsed result is only used for introspecting and auto-completion, has noting to do with syntax converting and compiling. I just im

libc Sleep api performs a busy waiting

2010-03-08 Thread Mahesh
Hi, I am having a problem while using sleep function from libc , the thread in which i am calling it is getting struck and not allowing other threads to execute. Here is a simple code that i am trying to exeute import threading import time import dl def dummy1(): a=dl.open('/lib/libc.so.6

Re: isinstance(False, int)

2010-03-08 Thread Bruno Desthuilliers
Rolando Espinoza La Fuente a écrit : On Fri, Mar 5, 2010 at 2:32 PM, mk wrote: Arnaud Delobelle wrote: 1 == True True 0 == False True So what's your question? Well nothing I'm just kind of bewildered: I'd expect smth like that in Perl, but not in Python.. Although I can understand the ra