Whan I run the following function, I see a mem leak, a 20 mb of memory
is allocated and is not freed. Here is the code I run:
>>> import esauth
>>> for i in range(100):
... ss = esauth.penc('sumer')
...
>>> for i in range(100):
... ss = esauth.penc('sumer')
...
And here is the pen
Gerhard Häring wrote:
> char* buf = strdup(s);
> if (!buf) {
> PyErr_SetString(PyExc_MemoryError, "Out of memory: strdup failed");
> return NULL;
> }
>
> /* TODO: your string manipulation */
Don't forget to free(buf). ;)
Christian
--
http://mail.python.org/mailman/listinfo/python-list
k3xji wrote:
> Hi all,
>
> This might be a newbie question. I am trying to implement a simple
> string decoder/encoder algorithm. Just suppose I am substrcating some
> values from the string passed as a parameter to the function and I
> want the function to return encoded/decoded version of the st
Sorry, Here is the correct output:
>>> ss= esauth.penc('s')
>>> print ss
╣
>>> esauth.pdec(ss)
'\xb9'
>>> print ss
s --> Works fine!!!
>>> ss= esauth.penc('s')
>>> print ss
s
>>> ss = esauth.pdec(ss)
>>> print ss
╣ --> how did this happen if the param and return values are same? I
cannot understan
Hi all,
This might be a newbie question. I am trying to implement a simple
string decoder/encoder algorithm. Just suppose I am substrcating some
values from the string passed as a parameter to the function and I
want the function to return encoded/decoded version of the string.
Here is the call:
Dennis Lee Bieber wrote:
> On Tue, 05 Feb 2008 04:03:04 GMT, Odysseus
> <[EMAIL PROTECTED]> declaimed the following in
> comp.lang.python:
>
>> Sorry, translation problem: I am acquainted with Python's "for" -- if
>> far from fluent with it, so to speak -- but the PS operator that's most
>> simi
Marc 'BlackJack' Rintsch wrote:
> On Tue, 05 Feb 2008 06:19:12 +, Odysseus wrote:
>
>> In article <[EMAIL PROTECTED]>,
>> Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>>
>>> Another issue is testing. If you rely on global names it's harder to test
>>> individual functions. [...]
>>>
>
On Tue, 05 Feb 2008 06:19:12 +, Odysseus wrote:
> In article <[EMAIL PROTECTED]>,
> Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>
>> Another issue is testing. If you rely on global names it's harder to test
>> individual functions. [...]
>>
>> In programs without such global names
In article <[EMAIL PROTECTED]>,
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> The term "global" usually means "module global" in Python.
Because they're like the objects obtained from "import"?
> [T]he functions depend on some magic data coming from "nowhere" and
> it's much harder t
In article <[EMAIL PROTECTED]>,
Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Mon, 04 Feb 2008 09:43:04 GMT, Odysseus
> <[EMAIL PROTECTED]> declaimed the following in
> comp.lang.python:
>
> >
> > Thanks, that will be very useful. I was casting about for a replacement
> > for PostScript's
On Mon, 04 Feb 2008 09:43:04 +, Odysseus wrote:
> In article <[EMAIL PROTECTED]>,
> Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>
>> def extract_data(names, na, cells):
>> found = dict()
>
> The problem with initializing the 'super-dictionary' within this
> function is that I w
On Mon, 04 Feb 2008 12:25:24 +, Odysseus wrote:
> I'm not clear on what makes an object global, other than appearing as an
> operand of a "global" statement, which I don't use anywhere. But "na" is
> assigned its value in the program body, not within any function: does
> that make it global
In article <[EMAIL PROTECTED]>,
Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> Rather complicated description... A sample of the real/actual input
> /file/ would be useful.
Sorry, I didn't want to go on too long about the background, but I guess
more context would have helped. The data
On Feb 4, 8:43 pm, Odysseus <[EMAIL PROTECTED]> wrote:
> In article <[EMAIL PROTECTED]>,
> Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> > found = dict()
> BTW what's the difference between the above and "found = {}"?
{} takes 4 fewer keystrokes, doesn't have the overhead of a functio
On Feb 4, 3:21 am, Odysseus <[EMAIL PROTECTED]> wrote:
> The next one is much messier. A couple of the strings represent times,
> which I think will be most useful in 'native' form, but the input is in
> the format "DD Mth HH:MM:SS UTC".
time.strptime will do this!
You can find the documenta
In article <[EMAIL PROTECTED]>,
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> Here and in later code you use a ``while`` loop although it is known at
> loop start how many times the loop body will be executed. That's a job
> for a ``for`` loop. If possible not over an integer that is
On Mon, 04 Feb 2008 03:21:18 +, Odysseus wrote:
> def extract_data():
> i = 0
> while i < len(names):
> name = names[i][6:] # strip off "Name: "
> found[name] = {'epoch1': cells[10 * i + na],
>'epoch2': cells[10 * i + na + 1],
>
I'm writing my first 'real' program, i.e. that has a purpose aside from
serving as a learning exercise. I'm posting to solicit comments about my
efforts at translating strings from an external source into useful data,
regarding efficiency and 'pythonicity' both. My only significant
programming
On Nov 28, 2007 1:23 PM, Paul McGuire <[EMAIL PROTECTED]> wrote:
> On Nov 28, 11:32 am, "Ryan Krauss" <[EMAIL PROTECTED]> wrote:
> > I need to parse the following string:
> >
> > $$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left({{{\it m_2}\,s^2
> > }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr
Interesting. Thanks Paul and Tim. This looks very promising.
Ryan
On Nov 28, 2007 1:23 PM, Paul McGuire <[EMAIL PROTECTED]> wrote:
> On Nov 28, 11:32 am, "Ryan Krauss" <[EMAIL PROTECTED]> wrote:
> > I need to parse the following string:
> >
> > $$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left
Paul McGuire wrote:
> On Nov 28, 1:23 pm, Paul McGuire <[EMAIL PROTECTED]> wrote:
>> As Tim Grove points out, ...
>
> s/Grove/Chase/
>
> Sorry, Tim!
No problem...it's not like there aren't enough Tim's on the list
as it is. :)
-tkc
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 28, 1:23 pm, Paul McGuire <[EMAIL PROTECTED]> wrote:
> As Tim Grove points out, ...
s/Grove/Chase/
Sorry, Tim!
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 28, 11:32 am, "Ryan Krauss" <[EMAIL PROTECTED]> wrote:
> I need to parse the following string:
>
> $$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left({{{\it m_2}\,s^2
> }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it m_2}\,s^2\,F
> }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it m_
> The trick is that there are extra curly braces inside the \pmatrix{ }
> strings and I don't know how to write a regexp that would count the
> number of open and close curly braces and make sure they match, so
> that it can find the correct ending curly brace.
This criterion is pretty much a deal
I need to parse the following string:
$$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left({{{\it m_2}\,s^2
}\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it m_2}\,s^2\,F
}\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it m_2}\,s^2}\over{k}}+1
\right)+{\it m_2}\,s^2\right)\,{\it x_1}\cr 1\cr }
Dennis Lee Bieber wrote:
>
> I was trying to stay with a solution the should have been available
> in the version of Python equivalent to the Jython being used by the
> original poster. HTMLParser, according to the documents, was 2.2 level.
I guess I should read the whole thread before posting. ;
On 9 May, 06:42, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
>
[HTMLParser-based solution]
Here's another approach using libxml2dom [1] in HTML parsing mode:
import libxml2dom
# The text, courtesy of Dennis.
sample = """
"""
# Parse the string in HTML mode.
d = libxml2dom.parseString(sa
BTW, here's what I used, the other ideas have been squirreled away in
my neat tricks and methods folder.
for el in data.splitlines():
if el.find('LastUpdated') <> -1:
s = el.split("=")[-1].split('"')[1]
print 's:', s
Thanks
> This looks to be simple HTML (and I'm presuming that's a type on
> that ?> ending). A quick glance at the Python library reference (you do
> have a copy, don't you) reveals at least two HTML parsing modules...
>
No that is not a typo and bears investigation. Thanks for the find.
I foun
Thanks all.
Carsten, you are here early and late. Do you ever sleep? ;^)
--
http://mail.python.org/mailman/listinfo/python-list
On 8 May 2007 19:06:14 -0700, HMS Surprise wrote
> Thanks for posting. Could you reccommend an HTML parser that can be
> used with python or jython?
BeautifulSoup (http://www.crummy.com/software/BeautifulSoup/) makes HTML
parsing easy as pie, and sufficiently old versions seem to work with Jython.
En Tue, 08 May 2007 23:06:14 -0300, HMS Surprise <[EMAIL PROTECTED]>
escribió:
> Thanks for posting. Could you reccommend an HTML parser that can be
> used with python or jython?
Try BeautifoulSoup, which handles malformed pages pretty well.
--
Gabriel Genellina
--
http://mail.python.org/ma
On May 8, 9:19 pm, HMS Surprise <[EMAIL PROTECTED]> wrote:
> Yes it could, after I isolate that one string. Making sure I that I
> isolate that complete line and only that line is part of the problem.
>
It comes in as one large string...
--
http://mail.python.org/mailman/listinfo/python-list
Yes it could, after I isolate that one string. Making sure I that I
isolate that complete line and only that line is part of the problem.
thanks for posting.
jh
--
http://mail.python.org/mailman/listinfo/python-list
Thanks for posting. Could you reccommend an HTML parser that can be
used with python or jython?
john
--
http://mail.python.org/mailman/listinfo/python-list
; 'LastUpdated' with .find but not sure about how to isolate the
> number. 'LastUpdated' is guaranteed to occur only once. Would
> appreciate it if one of you string parsing whizzes would take a stab
> at it.
>
Does this help?
In [7]: s = ''
In [8]: i
ind
> 'LastUpdated' with .find but not sure about how to isolate the
> number. 'LastUpdated' is guaranteed to occur only once. Would
> appreciate it if one of you string parsing whizzes would take a stab
> at it.
>
>
>
>
>
>
>
> alig
d' is guaranteed to occur only once. Would
appreciate it if one of you string parsing whizzes would take a stab
at it.
Thanks,
jh
http://mail.python.org/mailman/listinfo/python-list
38 matches
Mail list logo