gc.DEBUG_LEAK and gc.garbage

2005-04-19 Thread Cesar
Hi,

I am new with python, and I am having a look to program that leaks.
The first thing I have to do is to determine if what leaks it is the
python code of my company.

I have set the DEBUG_LEAK flag with the GC and in the program cycle
printed the length of the garbage list. Is this enough to determine if
there is a leak in the python code? (the value rises). I am not
totally sure (see below).

I played with other flags as DEBUG_SAVEALL, but I think they are not
useful for what I want.

Finally, in this group I have seen a reference to an article in which
they had the look to gc.garbage after calling explicitally to
gc.collect(). is this necessary?

Thanks, Cesar
-- 
http://mail.python.org/mailman/listinfo/python-list


Generating custom Windows installers

2012-04-05 Thread cesar . covarrubias
Hello,

I am working on creating an installer of a Python 3.2 application that we 
programmed. The end goal is to create an installer in which we can specify the 
install path, and create shortcuts in the Start Menu and Desktop. Ideally, we 
would like to give the users the option to create the Desktop or Start Menu 
shortcuts. 

I was able to create a .msi file with the setup.py and install.py files below. 
This allowed me to specify the custom default path but not create the shortcut 
in the Start Menu. 

Can anyone help me figure out what I'm missing?


setup.py


from cx_Freeze import setup, Executable
import sys

productName = "ProductName"
if 'bdist_msi' in sys.argv:
sys.argv += ['--initial-target-dir', 'C:\InstallDir\\' + productName]
sys.argv += ['--install-script', 'install.py']

exe = Executable(
  script="main.py",
  base="Win32GUI",
  targetName="Product.exe"
 )
setup(
  name="Product.exe",
  version="1.0",
  author="Me",
  description="Copyright 2012",
  executables=[exe],
  scripts=[
   'install.py'
   ]
  )
-

install.py
--
import os
import sys
import win32com.client as w32client

shortcut_group_name = "Start Menu Dir"
shortcut_name = "Product Name"
shortcut_target = "http://www.microsoft.com";

sh = w32client.Dispatch("WScript.Shell")
p = sh.SpecialFolders("AllUsersPrograms")
assert(os.path.isdir(p))
p = os.path.join(p, shortcut_group_name)
if (not os.path.isdir(p)):
os.makedirs(p)
lnk = sh.CreateShortcut(os.path.join(p, shortcut_name + ".lnk"))
lnk.TargetPath = shortcut_target
lnk.Save()


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Generating custom Windows installers

2012-04-06 Thread Cesar Covarrubias
I'm still getting my feet wet on the Windows side of things with Python, so
I apologize for the noobish question.

If i am reading the create_link.py example correctly, that is created when
the application itself is invoked, not during installation. Is that
correct? If it is, how would I be able to invoke that when generating the
MSI so that the installer creates the shortcut?

Cesar

On Thu, Apr 5, 2012 at 8:42 PM, Mark Hammond wrote:

> Seeing you are relying on win32com, you might as well add the links
> directly rather than via the intermediate WScript.shell object.  Look in
> win32comext\shell\demos\**create_link.py for an example of how to create
> shortcuts directly.
>
> HTH,
>
> Mark
>
> On 6/04/2012 5:23 AM, [email protected] wrote:
>
>> Hello,
>>
>> I am working on creating an installer of a Python 3.2 application that we
>> programmed. The end goal is to create an installer in which we can specify
>> the install path, and create shortcuts in the Start Menu and Desktop.
>> Ideally, we would like to give the users the option to create the Desktop
>> or Start Menu shortcuts.
>>
>> I was able to create a .msi file with the setup.py and install.py files
>> below. This allowed me to specify the custom default path but not create
>> the shortcut in the Start Menu.
>>
>> Can anyone help me figure out what I'm missing?
>>
>>
>> setup.py
>> 
>>
>> from cx_Freeze import setup, Executable
>> import sys
>>
>> productName = "ProductName"
>> if 'bdist_msi' in sys.argv:
>> sys.argv += ['--initial-target-dir', 'C:\InstallDir\\' + productName]
>> sys.argv += ['--install-script', 'install.py']
>>
>> exe = Executable(
>>   script="main.py",
>>   base="Win32GUI",
>>   targetName="Product.exe"
>>  )
>> setup(
>>   name="Product.exe",
>>   version="1.0",
>>   author="Me",
>>   description="Copyright 2012",
>>   executables=[exe],
>>   scripts=[
>>'install.py'
>>]
>>   )
>> --**---
>>
>> install.py
>> --
>> import os
>> import sys
>> import win32com.client as w32client
>>
>> shortcut_group_name = "Start Menu Dir"
>> shortcut_name = "Product Name"
>> shortcut_target = "http://www.microsoft.com";
>>
>> sh = w32client.Dispatch("WScript.**Shell")
>> p = sh.SpecialFolders("**AllUsersPrograms")
>> assert(os.path.isdir(p))
>> p = os.path.join(p, shortcut_group_name)
>> if (not os.path.isdir(p)):
>> os.makedirs(p)
>> lnk = sh.CreateShortcut(os.path.**join(p, shortcut_name + ".lnk"))
>> lnk.TargetPath = shortcut_target
>> lnk.Save()
>>
>>
>>
>
>


-- 
Very Respectfully,
Cesar Covarrubias
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to print non-printable chars??

2011-08-12 Thread Julio Cesar
On Aug 13, 1:22 am, Nobody  wrote:
> On Sat, 13 Aug 2011 00:59:42 -0400, Julio Cesar Rodriguez Cruz wrote:
>
> > Hi all,
> > If I open an .exe file in any text editor I get lot of odd chars,
> > what I want is to know how to output those chars if I have the hexadecimal
> > code. I found out how to do the reverse process with the quopri module,
>
> > i.e.:
> >>>> import quopri
> >>>> quopri.encodestring('ñè ')
> > '=F1=E8=18'
> >>>> quopri.decodestring('=F1=E8=18')
> > '\xf1\xe8\x18'
>
> > but how to do the reverse? ...gived '\xf1\xe8\x18', print 'ñè '
>
>         print(quopri.decodestring('=F1=E8=18'))
> or:
>         sys.stdout.write(quopri.decodestring('=F1=E8=18'))
>
> If you type an expression into the interactive Python interpreter, the
> result is converted to a string using repr(); for strings, this converts
> 8-bit characters to their hexadecimal escape sequences, so that the result
> only uses ASCII.
>
> OTOH, the print statement converts values to strings using str(); for
> strings, this is an identity operation (i.e. it returns the original
> string untouched). Similarly, the .write() method of file objects uses str().

It just works!! thanks a lot and also for the explanations ;)
Cheers
Julio Cesar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: what's OOP's jargons and complexities?

2005-01-30 Thread Cesar Rabak
Pascal Bourguignon escreveu:
"Larry" <[EMAIL PROTECTED]> writes:

Xah Lee wrote:
in computer languages, often a function definition looks like this:

[EMAIL PROTECTED]
http://xahlee.org/PageTwo_dir/more.html
Your ideas are original, insightful and simply reflect incredibly deep
creative genius.  I have read your work and I want to hire you for
highly classified work in software design and philosophical writing.
Would you possibly be available to meet with me in my secret mountain
compound to discuss terms?
Larry

You forgot to mention the coordinates of your secret mountain compound: 

   28 deg 5 min N, 86 deg 58 min E
Pascal!!
You spoiled a carefully kept Larry's secret. . . now it will have to 
change his compound. . .



--
http://mail.python.org/mailman/listinfo/python-list


question

2013-10-23 Thread Cesar Campana
Hi!

Im installing the python library for the version 2.7 but Im getting the
error unable to find vcvarsall.bat

I was looking on line but it says is related to Visual Studio...?

Can you guys please help me to fix this...

Cesar
-- 
https://mail.python.org/mailman/listinfo/python-list


Memory Management in python 2.5

2006-10-09 Thread cesar . ortiz
Hi, I am starting to have a look to a python program that does not free
memory (I am using python 2.4.3). As I have read about a new memory
management in python 2.5 (http://evanjones.ca/python-memory.html) I
decided to try the program with the new version.
With the new version of python the memory consumption is the same. Now
I am asking myself if  python 2.5 has any improving  in memory
management or maybe not yet. Thank you.

-- Cesar

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Memory Management in python 2.5

2006-10-09 Thread cesar . ortiz
I just checked the comsuptiom with the 'top' unix util. I am procesing
html docs and the amount of memory rises continiously.
I am using a lot of lists and docs. Some of them with objects. Do i
have to make any special thing in order to get them released back to
the Memory Manager? For instantec.. is it enough to do a clear() in a
dictionary?

-- Cesar

-- 
http://mail.python.org/mailman/listinfo/python-list


Using sax libxml2 html parser

2007-01-05 Thread cesar . ortiz
Hi all,

I have created an example using libxml2 based in the code that appears
in http://xmlsoft.org/python.html.
My example processes an enough amount of html files to see that the
memory consumption rises till the process ends (I check it with the
'top' command).

I don´t know if I am forgetting something in the code, as I have not
been able to find any example on the web.

Thanks in advance, Cesar

Note: I have also tried to put the cleanup functions inside the 'for'
loop.

] The Code
[

#!/usr/bin/python -u
import libxml2

#--


# Memory debug specific
libxml2.debugMemory(1)

#--

class callback:
def startDocument(self):
print "."

def endDocument(self):
pass

def startElement(self, tag, attrs):
pass

def endElement(self, tag):
pass

def characters(self, data):
pass

def warning(self, msg):
pass

def error(self, msg):
pass

def fatalError(self, msg):
pass

#--
#--

import os
import sys

programName = os.path.basename(sys.argv[0])

if len(sys.argv) != 2:
  print "Use: %s " % programName
  sys.exit(1)

inputPath = sys.argv[1]

if not os.path.exists (inputPath):
  print "Error: directory does not exist"
  sys.exit(1)

inputFileNames = []
dirContent = os.listdir(inputPath)
for fichero in dirContent:
  extension1=fichero.rfind(".htm")
  extension2=fichero.rfind(".html")
  dot = fichero.rfind(".")
  extension = max(extension1,extension2)
  if extension != -1 and extension == dot:
  inputFileNames.append (fichero)

if len(inputFileNames) == 0:
  print "Error: no input files"
  sys.exit(1)


handler = callback()
NUM_ITERS = 5
for i in range(NUM_ITERS):
  for inputFileName in inputFileNames:
print inputFileName
inputFilePath = inputPath + inputFileName
f = open(inputFilePath)
data = f.read()
f.close()

ctxt = libxml2.htmlCreatePushParser(handler, "", 0, inputFileName)

ctxt.htmlParseChunk(data, len(data), 1)
ctxt = None


# Memory debug specific
libxml2.cleanupParser()
if libxml2.debugMemory(1) == 0:
print "OK"
else:
print "Memory leak %d bytes" % (libxml2.debugMemory(1))
libxml2.dumpMemory()

# Other cleanup functions
#libxml2.cleanupCharEncodingHandlers()
#libxml2.cleanupEncodingAliases()
#libxml2.cleanupGlobals()
#libxml2.cleanupInputCallbacks()
#libxml2.cleanupOutputCallbacks()
#libxml2.cleanupPredefinedEntities()

-- 
http://mail.python.org/mailman/listinfo/python-list


Getting a function name from string

2007-05-08 Thread Cesar Härdfeldt

" It has been my experience that, more often than not,
any time you think you want to evaluate strings, you
don't need to.

For instance, instead of passing around the name of the
function as a string:

s = "someFunction"
eval(s)()

you can pass around the function as an object:

s = someFunction  # note the lack of brackets
s()


--
Steven. "

I want to read a module name and a function in that module from a ini-file
and then run the function with some arguments also read from the ini-file.
Is there a way to do this, still avoiding the eval()-method?

example:

module = modelParser.getModule()
function = modelParser.getFunc()
parms = modelParser.getParms()

(modelParser just extracts string from the ini-file)

I now have 'module' and 'function' as strings and 'parms' normally as a list
of strings. I can import the module by __import__(module) but is there
another way to call:
module.function(parms) than using eval()?

Thanks for any suggestions,

Best Cesar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: importing with .m instead of .py

2009-09-25 Thread Cesar Koers

Wanderer wrote:

I would like to import Matlab/Octave files of the .m sort into Python
that look like this.

# comment
y=[1,2,3,4,5\
,6,7,8,9];
# comment

The only problem is I have to change the extensions from .m to .py. Is
there a way to get python to import files that don't end in .py?

Thank you

Hi,

(untested:) read the .m file as a string, then evaluate the string (see 
eval()) in appropriate context?



success!

bye

--
http://mail.python.org/mailman/listinfo/python-list


Basic question

2007-05-12 Thread Cesar G. Miguel
I've been studying python for 2 weeks now and got stucked in the
following problem:

for j in range(10):
  print j
  if(True):
   j=j+2
   print 'interno',j

What happens is that "j=j+2" inside IF does not change the loop
counter ("j") as it would in C or Java, for example.

Am I missing something?

[]'s
Cesar

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Basic question

2007-05-12 Thread Cesar G. Miguel
On May 12, 2:45 pm, Basilisk96 <[EMAIL PROTECTED]> wrote:
> On May 12, 12:18 pm, "Cesar G. Miguel" <[EMAIL PROTECTED]> wrote:
>
>
>
> > I've been studying python for 2 weeks now and got stucked in the
> > following problem:
>
> > for j in range(10):
> >   print j
> >   if(True):
> >j=j+2
> >print 'interno',j
>
> > What happens is that "j=j+2" inside IF does not change the loop
> > counter ("j") as it would in C or Java, for example.
>
> > Am I missing something?
>
> > []'s
> > Cesar
>
> What is your real intent here? This is how I understand it after
> reading your post: you want to create a loop that steps by an
> increment of 2. If that's the case, then:
>
> >>> for j in range(0,10,2):
>
> ... print j
> ...
> 0
> 2
> 4
> 6
> 8
>
> would be a simple result.
>
> Cheers,
> -Basilisk96

Actually I'm trying to convert a string to a list of float numbers:
str = '53,20,4,2' to L = [53.0, 20.0, 4.0, 2.0]

As some of you suggested, using while it works:

-
L = []
file = ['5,1378,1,9', '2,1,4,5']
str=''
for item in file:
   j=0
   while(j= len(item)): break

  if(str != ''):
 L.append(float(str))
 str = ''

  j=j+1

print L
-

But I'm not sure this is an elegant pythonic way of coding :-)

Thanks for all suggestions!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Basic question

2007-05-12 Thread Cesar G. Miguel
On May 12, 3:09 pm, Karlo Lozovina <[EMAIL PROTECTED]> wrote:
> Cesar G. Miguel wrote:
> > -
> > L = []
> > file = ['5,1378,1,9', '2,1,4,5']
> > str=''
> > for item in file:
> >j=0
> >while(j >   while(item[j] != ','):
> >  str+=item[j]
> >  j=j+1
> > if(j>= len(item)): break
>
> >   if(str != ''):
> > L.append(float(str))
> >  str = ''
>
> >   j=j+1
>
> > print L
> > But I'm not sure this is an elegant pythonic way of coding :-)
>
> Example:
>
> In [21]: '5,1378,1,9'.split(',')
> Out[21]: ['5', '1378', '1', '9']
>
> So, instead of doing that while-based traversal and parsing of `item`,
> just split it like above, and use a for loop on it. It's much more
> elegant and pythonic.
>
> HTH,
> Karlo.

Great! Now it looks better :-)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Basic question

2007-05-12 Thread Cesar G. Miguel
On May 12, 3:40 pm, Dmitry Dzhus <[EMAIL PROTECTED]> wrote:
> > Actually I'm trying to convert a string to a list of float numbers:
> > str = '53,20,4,2' to L = [53.0, 20.0, 4.0, 2.0]
>
> str="53,20,4,2"
> map(lambda s: float(s), str.split(','))
>
> Last expression returns: [53.0, 20.0, 4.0, 2.0]
> --
> Happy Hacking.
>
> Dmitry "Sphinx" Dzhushttp://sphinx.net.ru

Nice!

The following also works using split and list comprehension (as
suggested in a brazilian python forum):

---
L = []
file = ['5,1378,1,9', '2,1,4,5']
str=''
for item in file:
L.append([float(n) for n in item.split(',')])
---

Thank you for all suggestions!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Basic question

2007-05-13 Thread Cesar G. Miguel
On May 12, 8:13 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
> Cesar G. Miguel <[EMAIL PROTECTED]> wrote:
>
> > On May 12, 3:40 pm, Dmitry Dzhus <[EMAIL PROTECTED]> wrote:
> > > > Actually I'm trying to convert a string to a list of float numbers:
> > > > str = '53,20,4,2' to L = [53.0, 20.0, 4.0, 2.0]
>
> > > str="53,20,4,2"
> > > map(lambda s: float(s), str.split(','))
>
> > > Last expression returns: [53.0, 20.0, 4.0, 2.0]
> > > --
> > > Happy Hacking.
>
> > > Dmitry "Sphinx" Dzhushttp://sphinx.net.ru
>
> > Nice!
>
> As somebody else alredy pointed out, the lambda is supererogatory (to
> say the least).
>
> > The following also works using split and list comprehension (as
> > suggested in a brazilian python forum):
>
> > ---
> > L = []
> > file = ['5,1378,1,9', '2,1,4,5']
> > str=''
> > for item in file:
> >   L.append([float(n) for n in item.split(',')])
>
> The assignment to str is useless (in fact potentially damaging because
> you're hiding a built-in name).
>
> L = [float(n) for item in file for n in item.split(',')]
>
> is what I'd call Pythonic, personally (yes, the two for clauses need to
> be in this order, that of their nesting).
>
> Alex

Yes, 'str' is unnecessary. I just forgot to remove it from the code.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GLE-like python package

2007-10-14 Thread Cesar G. Miguel
On Oct 14, 12:54 pm, Wildemar Wildenburger
<[EMAIL PROTECTED]> wrote:
> Hello there,
>
> I'm exploring possibilities of using python as an alternative to Matlab.
> The obvious way to go seems to be matplotlib for plotting, but I do like
> GLE http://glx.sourceforge.net/> a lot. One reason is that with GLE
> you can also do diagrams, that is, descriptive pictures (like
> http://glx.sourceforge.net/examples/diagrams/index.html>)
>
> Is there anything similar for python?
>
> /W

I think this is what you're looking for:

http://pyx.sourceforge.net/

Cesar

-- 
http://mail.python.org/mailman/listinfo/python-list


Output buffer

2007-12-22 Thread Cesar D. Rodas
Hello

I am newbie in Python, but I like it very much.

Right now I am having a problem, I am working with mod_python in apache.
What I needing is a stdout buffering, that means that everything that I send
to stdout keep it in a variable, then flush it and clear.


Thanks in advance.

-- 
Best Regards

Cesar D. Rodas
http://www.cesarodas.com
http://www.thyphp.com
http://www.phpajax.org
Phone: +595-961-974165
-- 
http://mail.python.org/mailman/listinfo/python-list

Re:Re: Output buffer

2007-12-23 Thread Cesar D. Rodas
On 22/12/2007, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>
> Cesar D. Rodas wrote:
>
> > I am newbie in Python, but I like it very much.
> >
> > Right now I am having a problem, I am working with mod_python in apache.
> > What I needing is a stdout buffering, that means that everything that I
> > send to stdout keep it in a variable, then flush it and clear.
>
> plug in a StringIO instance on sys.stdout, or use (or adapt) a library
> designed for this purpose:
>
>  http://www.mnot.net/cgi_buffer/


hum, seems working right if I'll code  but what about if I want to print the
content of the function "help()" (which print and return nothing) into a
website?

Can I inherit the class system and override the output?


>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Best Regards

Cesar D. Rodas
http://www.cesarodas.com
http://www.thyphp.com
http://www.phpajax.org
Phone: +595-961-974165
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Happy Christmas Pythoneers

2007-12-23 Thread Cesar D. Rodas
On 24/12/2007, rishi pathak <[EMAIL PROTECTED]> wrote:
>
> Is santa clause subscribed to the list .
> I want a gift:)


Me too!, :-)

On 12/24/07, Paddy <[EMAIL PROTECTED]> wrote:
> >
> > After quite enjoying participating in the group in 2007, I'd like to
> > wish you all a Merry Xmas.
> >
> > - Paddy.
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
>
>
> --
> Regards--
> Rishi Pathak
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Best Regards

Cesar D. Rodas
http://www.cesarodas.com
http://www.thyphp.com
http://www.phpajax.org
Phone: +595-961-974165
-- 
http://mail.python.org/mailman/listinfo/python-list

Language detector using N-grams

2009-05-12 Thread Cesar D. Rodas
Hello Pythoners!

I just finished my first useful project in Python, It is a language
detector using N-grams. I hope this can be useful for someone,

http://github.com/crodas/py-languess/tree/master

The License of the project is BSD

Best regards

-- 
Cesar D. Rodas
http://cesar.la/
Phone: +595-961-974165
Jay Leno  - "Don't forget Mother's Day. Or as they call it in Beverly
Hills, Dad's Third Wife Day." -
http://www.brainyquote.com/quotes/authors/j/jay_leno.html
-- 
http://mail.python.org/mailman/listinfo/python-list


How to print non-printable chars??

2011-08-12 Thread Julio Cesar Rodriguez Cruz
Hi all,
If I open an .exe file in any text editor I get lot of odd chars,
what I want is to know how to output those chars if I have the hexadecimal
code. I found out how to do the reverse process with the quopri module,

i.e.:
>>> import quopri
>>> quopri.encodestring('ñè')
'=F1=E8=18'
>>> quopri.decodestring('=F1=E8=18')
'\xf1\xe8\x18'

but how to do the reverse? ...gived '\xf1\xe8\x18', print 'ñè'

any tips?
thanks
Julio Cesar
-- 
http://mail.python.org/mailman/listinfo/python-list


Write an hexadecimal file

2005-03-30 Thread Cesar Andres Roldan Garcia
Hi

I'm trying to write an hexadecimal file... I mean not a text plain... 
I have to convert a float decimal number in float hexadecimal one, and
that's done.

That number is the one I'm gonna write in the hex file... can anybody
help me 'cause i don't know how python write an hex file!

Thanks!

-- 
Atentamente,

Cesar Andres Roldan Garcia
Presidente Comunidad Académica Microsoft Javeriana
Cali - Colombia
--
http://mail.python.org/mailman/listinfo/python-list


Controling the ALU

2005-03-31 Thread Cesar Andres Roldan Garcia
Hi

How can I control an ALU from a PC using Python?

Thanks!


Hola...

Como puedo controlar la ALU de un PC usando Pyhton?

Gracias!

-- 
Atentamente,

Cesar Andres Roldan Garcia
Presidente Comunidad Académica Microsoft Javeriana
Teléfono: 300 8169857
Cali - Colombia
--
http://mail.python.org/mailman/listinfo/python-list