Bug!

2015-08-21 Thread Miguel Alejandro Fernandez
hello, python3.5rc1 when trying to install , the installer did not show the 
button to start installing , to click in the middle he started ; after 
installing I thought that everything would work fine but I could never run it, 
telling me ' this is not a valid Win32 application '

*use a computer with WindowsXP-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ANN: Python Events Calendar - Please submit your 2015 events

2015-01-23 Thread Luis Miguel Morillas
Hi all

I wrote this script that can read the Python Calendars and shows the
geolocated info on a map and on a timeline.

http://lmorillas.github.io/python_events/


Enjoy

Saludos,

-- luismiguel  (@lmorillas)


2015-01-13 22:18 GMT+01:00 M.-A. Lemburg :
> [Please help spread the word by forwarding to other relevant mailing lists,
>  user groups, etc. world-wide; thanks :-)]
>
> 
> ANNOUNCING
>
>  Python Events Calendars - Please submit your 2015 events
>
>maintained by the Python Software Foundation (PSF)
> and a group of volunteers
>
> 
> INTRODUCTION
>
> As some of you may know, the PSF has a team of volunteers who are
> maintaining a set of central Python event calendars. We currently have
> two calendars in place:
>
>  * Python Events Calendar - meant for conferences and larger gatherings
>focusing on Python or a related technology (in whole or in part)
>
>  * Python User Group Calendar - meant for user group events and other
>smaller local events
>
> The calendars are displayed on http://pycon.org/ and also on the new
> https://python.org/ website at https://www.python.org/events/python-events/
> and https://www.python.org/events/python-user-group/.
>
> You can subscribe to the calendars using iCal and RSS feeds and also
> embed the calendar widgets on your sites. We have also added a
> Twitter feed @PythonEvents to get immediate updates whenever a new
> event is added. Please see our wiki page for details:
>
>https://wiki.python.org/moin/PythonEventsCalendar
>
> The calendars are open to the world-wide Python community, so you
> can have local user group events, as well as regional and
> international conference events added to the calendars.
>
> 
> NEWS
>
> Looking back on 2014, the calendars have proven to be a great tool
> for the Python community to connect, with more than 60 conferences
> and more than a hundred of user group events listed.
>
> We would therefore like to encourage everyone to submit their
> 2015 events, so that the Python community can get a better overview
> over what's happening in Python land.
>
> 
> ADDING EVENTS
>
> Please see the instructions at 
> https://wiki.python.org/moin/PythonEventsCalendar#Available_Calendars
> for details on how to
> submit an event. We've made it really easy for you: just need to send
> an email to our team address using the email template we
> provide for this. Thanks.
>
> 
> MORE INFORMATION
>
> More information on the calendars, the URLs, feed links, IDs, embedding,
> etc. is available on the wiki:
>
> https://wiki.python.org/moin/PythonEventsCalendar
>
> Enjoy,
> --
> Marc-Andre Lemburg
> Director
> Python Software Foundation
> http://www.python.org/psf/
>
> --
> https://mail.python.org/mailman/listinfo/python-announce-list
>
> Support the Python Software Foundation:
> http://www.python.org/psf/donations/
-- 
https://mail.python.org/mailman/listinfo/python-list


urllib with x509 certs

2014-05-16 Thread Luis Miguel Rojas Aguilera
Hi, i tried what you suggest but still asking me for the password, this 
time twice.

Please i need help so this is for my thesis.
VII Escuela Internacional de Verano en la UCI del 30 de junio al 11 de julio de 
2014. Ver www.uci.cu
--
https://mail.python.org/mailman/listinfo/python-list


Parsing soap/xml result

2013-06-25 Thread miguel olivares varela

I try to parse a soap/xml answer like:

http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
   
  http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:ns1="http://192.168.2.135:8490/gift-ws/services/SRV_GIFT_PKG";>
 http://schemas.xmlsoap.org/soap/encoding/";>
 xsi:type="xsd:string">0
 xsi:type="xsd:string">OK 
xsi:type="xsd:string">
 
  
   



here is my code
---
import xml.etree.ElementTree as ET
import re

def parse(answer):
print"\nANSWER<<", answer
try:
tree = ET.fromstring(answer)
result = {}
for item in tree.getiterator():
if item.tag in ['giftPkgReturn', 'giftPkgReturn']:
result[item.tag] = item.text

print "get<<%s" % result.get('status', None)
resp1 = result.get('giftPkgReturn', None)
resp2 = result.get('giftPkgReturn', None)

if (resp1 == "0" and resp2 == "OK"):
logger.info("Successful")
print "OK:"
return 0
else:
logger.info("Unsuccessful")
return -1

 except Exception, Err:
print "\nERROR <<", str(Err)
return -1



I got the error, i'm no a xml expert but it seems than the answser does not 
look like a pure xml.  i also tried with lxml instead of xml library but the 
result is te same

xml lib
ERROR << not well-formed (invalid token): line 5, column 77

lxml
ERROR << expected '>', line 5, column 37


could you help me to correctly parse the answer please?

regards,
Miguel

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


Re: John Carmack glorifying functional programing in 3k words

2012-05-02 Thread Miguel Guedes

On 27/04/12 03:11, Xah Lee wrote:

John Carmack glorifying functional programing in 3k words

http://www.altdevblogaday.com/2012/04/26/functional-programming-in-c/

where was he ten years ago?

O, and btw, i heard that Common Lispers don't do functional
programing, is that right?

Fuck Common Lispers. Yeah, fuck them. One bunch of Fuckfaces. (and
Fuck Pythoners. Python fucking idiots.)

O, don't forget,

〈Programing: What are OOP's Jargons and Complexities (Object Oriented
Program as Functional Program)〉
http://xahlee.org/Periodic_dosage_dir/t2/oop.html

please you peruse of it.


I'm not a 'Common Lisper' or a 'Pythoner' so I'm not directly or 
personally affected by your retarded and offensive comment. However, who 
the fuck do you think you are to post stuff of this nature? (I believe) 
I'll understand if you've got some sort of psychological issue affecting 
your behaviour.

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


RE: write file

2011-07-05 Thread miguel olivares varela



What's date_cdr supposed to be?

It was a mistake  it should be date_source


Is your exception handler doing unusual things with sys.exit?

Not really

Did you try to run this?  When I try to run it, it fails to compile.

it compiles i have no problems with the compilation. The issue is the result 
'out.csv',  what i want is to save all the modified rows from 'test.csv' into 
'out.csv' but i only can save the firs row.   



You might want to try opening your output file once and writing to it 
repeatedly, then close()ing it after all your writes are completed.  Or use 
"with": http://effbot.org/zone/python-with-statement.htm


On Tue, Jul 5, 2011 at 2:25 PM, miguel olivares varela  
wrote:







Hi,

i got a csv file that i need to modify and create a new one,  i have no problem 
to read mi 'test.cvs' which is the source file but when i try to create a new 
one with the modifications i only got the first row in my 'out.csv' file.  I 
think there is somethng wrong in my loop because i can't  put into the rest.   



this is my an example of source file:
[test.csv]
Name;Lastname;Age;ContractDate;PhoneNumber
John;Smith;20110128 105840;336
Mike;Brown;20110128 105842;336
James;Ryan;20110128 105850;336

Barry;Jackson;20110128 105847;336


[here my code:]

import sys
import csv
import os
import glob
import time

dir_cdr = "/tmp"
#loop to find files csv in a directory and read thoses files

for cdr_files_in in glob.glob(os.path.join(dir_cdr, '*.csv') ):
file_source = open(cdr_files_in, 'r')
reader = csv.reader(file_source, delimiter=';', quoting=csv.QUOTE_NONE)

try:
for data in reader:
if data:
firstname = data[0]
lastname = data[1]
date_source = data[2]

phone = data[3]
#Date to epoch

timestamp=int(time.mktime(time.strptime(date_source, "%Y%m%d %H%M%S")))
fout = open("out.csv", "w")

print >>fout, lastname, firstname, timestamp, 
phone
fout.close()
sys.exit()
file_source.close()

except csv.Error, e:
print e
file_source.close()
sys.exit('file %s, line %d: %s' % (file_source, 
reader.line_num, e)

[out.csv]
Smith John 1296208720 336



Could you help me?

Best Regards,
Miguel

  

--

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



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


write file

2011-07-05 Thread miguel olivares varela


Hi,

i got a csv file that i need to modify and create a new one,  i have no problem 
to read mi 'test.cvs' which is the source file but when i try to create a new 
one with the modifications i only got the first row in my 'out.csv' file.  I 
think there is somethng wrong in my loop because i can't  put into the rest.   


this is my an example of source file:
[test.csv]
Name;Lastname;Age;ContractDate;PhoneNumber
John;Smith;20110128 105840;336
Mike;Brown;20110128 105842;336
James;Ryan;20110128 105850;336
Barry;Jackson;20110128 105847;336


[here my code:]

import sys
import csv
import os
import glob
import time

dir_cdr = "/tmp"
#loop to find files csv in a directory and read thoses files
for cdr_files_in in glob.glob(os.path.join(dir_cdr, '*.csv') ):
file_source = open(cdr_files_in, 'r')
reader = csv.reader(file_source, delimiter=';', quoting=csv.QUOTE_NONE)
try:
for data in reader:
if data:
firstname = data[0]
lastname = data[1]
date_source = data[2]
phone = data[3]
#Date to epoch

timestamp=int(time.mktime(time.strptime(date_cdr, "%Y%m%d %H%M%S")))
fout = open("out.csv", "w")
print >>fout, lastname, firstname, timestamp, 
phone
fout.close()
sys.exit()
file_source.close()
except csv.Error, e:
print e
file_source.close()
sys.exit('file %s, line %d: %s' % (file_source, 
reader.line_num, e)

[out.csv]
Smith John 1296208720 336


Could you help me?

Best Regards,
Miguel

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


RE: Date2Epoch script

2011-06-13 Thread miguel olivares varela

Hi Gary,
thank you for your answer but i'm using int in my file cat 
/tmp/test.log201106121122332011012614553520110126185500

the problem is related to variable "line_log" that i use in the function, 

file_brut = open(log_files_in, 'r')line_log = file_brut.readline()while 
line_log:timestamp=int(time.mktime(time.strptime(line_log, 
"%Y%m%d%H%M%S")))
Miguel


Date: Mon, 13 Jun 2011 07:19:54 -0700
From: gher...@islandtraining.com
To: klica_...@hotmail.com
Subject: Re: Date2Epoch script



  



  
  
On 06/13/2011 06:03 AM, miguel olivares varela wrote:

  
  

  
  Hello 
  

  
  i try to create
a script to convert a date "mmddHHMMSS" as an UNIX
timestamp. This is an example of my log file 
  


  
cat
/tmp/test.log
20110612112233
20110126145535
20110126185500



  
  here is my
code: 
  


  #!
  /usr/bin/python
  


  
  import os
  import sys
  import glob
  import re
  import time
  

  
  dir_log = "/tmp"
  #loop to find files log in a directory
for log_files_in  in
  glob.glob(os.path.join(dir_log, '*.log') ):
  #print log_files
  file_brut = open(log_files_in, 'r')
  line_log = file_brut.readline()
  while line_log:
 
timestamp=int(time.mktime(time.strptime(line_log,
"%Y%m%d%H%M%S")))




Did you even bother to examine the results of any of these calls?  
A simple test like

   >>> time.mktime(time.strptime('20110613010101',
"%Y%m%d%H%M%S"))

   1307952061.0

makes it clear that the thing you are passing to int() is in fact
not an int.



Try removing the '.0', or use int(float(...)).





Gary Herron










  
  line_log=file_brut.readline()
  print timestamp
  

  
  

  
  And here the error code: 
  



Traceback (most recent call last):
  File "formatage_lms.py", line 32, in ?
timestamp=int(time.mktime(time.strptime(line_log,
  "%Y%m%d%H%M%S")))
  File "/usr/lib64/python2.4/_strptime.py", line 296,
  in strptime
raise ValueError("unconverted data remains: %s" %
ValueError: unconverted data remains:
  
  

      
  

  
  I don't know what i'm diong wrong please could you help
me
  

  
  Regards
  Miguel
  

  
  

  



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


Date2Epoch script

2011-06-13 Thread miguel olivares varela


Hello 
i try to create a script to convert a date "mmddHHMMSS" as an UNIX 
timestamp. This is an example of my log file 
cat /tmp/test.log201106121122332011012614553520110126185500
here is my code: 
#! /usr/bin/python
import osimport sysimport globimport reimport time
dir_log = "/tmp"#loop to find files log in a directoryfor log_files_in  in 
glob.glob(os.path.join(dir_log, '*.log') ):#print log_files
file_brut = open(log_files_in, 'r')line_log = file_brut.readline()  
  while line_log:
timestamp=int(time.mktime(time.strptime(line_log, "%Y%m%d%H%M%S"))) 
   line_log=file_brut.readline()print timestamp

And here the error code: 
Traceback (most recent call last):  File "formatage_lms.py", line 32, in ?
timestamp=int(time.mktime(time.strptime(line_cdr, "%Y%m%d%H%M%S")))  File 
"/usr/lib64/python2.4/_strptime.py", line 296, in strptimeraise 
ValueError("unconverted data remains: %s" %ValueError: unconverted data remains:

I don't know what i'm diong wrong please could you help me
RegardsMiguel

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


OT Pagina sobre programacion en paralelo

2010-05-17 Thread Miguel Beltran R.
Hola Lista,

Disculpen el off-topic, pero creo que aqui fue donde una vez postearon un
enlace sobre programación en paralelo y explica porque no es el doble de
rapido que con 1 micro.

Tambien hablaba de que si el algoritmo es log(n) o log(n2) o algo asi

ya lo busque en el historial pero no lo encuentro, alguien tiene el enlace?
o no lo vi aqui?

-- 

Lo bueno de vivir un dia mas
es saber que nos queda un dia menos de vida
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CPU usage while reading a named pipe

2009-09-12 Thread Miguel P
On Sep 12, 2:54 pm, Ned Deily  wrote:
> In article
> ,
>  Miguel P  wrote:
>
>
>
> > I've been working on parsing (tailing) a named pipe which is the
> > syslog output of the traffic for a rather busy haproxy instance. It's
> > a fair bit of traffic (upto 3k hits/s per server), but I am finding
> > that simply tailing the file  in python, without any processing, is
> > taking up 15% of a CPU core. In contrast HAProxy takes 25% and syslogd
> > takes 5% with the same load. `cat < /named.pipe` takes 0-2%
>
> > Am I just doing things horribly wrong or is this normal?
>
> > Here is my code:
>
> > from collections import deque
> > import io, sys
>
> > WATCHED_PIPE = '/var/log/haproxy.pipe'
>
> > if __name__ == '__main__':
> >     try:
> >         log_pool = deque([],1)
> >         fd = io.open(WATCHED_PIPE)
> >         for line in fd:
> >             log_pool.append(line)
> >     except KeyboardInterrupt:
> >         sys.exit()
>
> > Deque appends are O(1) so that's not it. And I am using 2.6's io
> > module because it's supposed to handle named pipes better. I have
> > commented the deque appending line and it still takes about the same
> > CPU.
>
> Be aware that the io module in Python 2.6 is written in Python and was
> viewed as a prototype.  In the current svn trunk, what will be Python
> 2.7 has a much faster C implementation of the io module backported from
> Python 3.1.
>
> --
>  Ned Deily,
>  n...@acm.org

Aha, I will test with trunk and see if the performance is better, if
so I'll use 2.6 in production until 2.7 comes out. I will report back
when I have made the tests.

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


CPU usage while reading a named pipe

2009-09-12 Thread Miguel P
Hey everyone,

I've been working on parsing (tailing) a named pipe which is the
syslog output of the traffic for a rather busy haproxy instance. It's
a fair bit of traffic (upto 3k hits/s per server), but I am finding
that simply tailing the file  in python, without any processing, is
taking up 15% of a CPU core. In contrast HAProxy takes 25% and syslogd
takes 5% with the same load. `cat < /named.pipe` takes 0-2%

Am I just doing things horribly wrong or is this normal?

Here is my code:

from collections import deque
import io, sys

WATCHED_PIPE = '/var/log/haproxy.pipe'

if __name__ == '__main__':
try:
log_pool = deque([],1)
fd = io.open(WATCHED_PIPE)
for line in fd:
log_pool.append(line)
except KeyboardInterrupt:
sys.exit()

Deque appends are O(1) so that's not it. And I am using 2.6's io
module because it's supposed to handle named pipes better. I have
commented the deque appending line and it still takes about the same
CPU.

The system is running Ubuntu 9.04 with kernel 2.6.28 and ext4 (not
sure the FS is relevant).

Any help bringing down the CPU usage would be really appreciated, and
if it can't be done I guess that's ok too, server has 6 cores not
doing much.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygame and socket.recv

2009-04-02 Thread Miguel Prada
I don't know if this might be causing your problem, but most socket
implementations use quite a big buffer for incoming data by default. I
had a lot of trouble with another real-time networked application
until I realised this. Reducing this buffer to the minimum helped a
lot in my case. Also, I would strongly recommend using UDP instead of
TCP.

BTW, does anyone know if any good bibliography about real-time
networked games, or real-time networked general applications?
--
http://mail.python.org/mailman/listinfo/python-list


Problem with urllib2 and authentification

2008-04-22 Thread Miguel Beltran R.
Using this script for connect to Zope I have this error

---script:
import urllib2

protocolo='http://'
servidor='10.28.1.239/'
pagina='manage'
fullurl=protocolo+servidor+pagina

aut=urllib2.HTTPBasicAuthHandler()
aut.add_password(realm=None,
 uri=servidor,
 user='myadmin',
 passwd='mypass')
opener=urllib2.build_opener(aut, urllib2.HTTPHandler(debuglevel=1))

print opener.open(fullurl).read()


---Error:
connect: (10.28.1.239, 80)
send: 'GET /manage HTTP/1.1\r\nAccept-Encoding: identity\r\nHost:
10.28.1.239\r\nConnection: close\r\nUser-agent:
Python-urllib/2.4\r\n\r\n'
reply: 'HTTP/1.1 401 Unauthorized\r\n'
header: Server: Zope/(Zope 2.10.5-final, python 2.4.4, win32) ZServer/1.1
header: Date: Tue, 22 Apr 2008 14:14:45 GMT
header: Bobo-Exception-Line: 713
header: Content-Length: 884
header: Bobo-Exception-Value: See the server error log for details
header: Content-Type: text/html; charset=iso-8859-15
header: Bobo-Exception-Type: Unauthorized
header: Connection: close
header: Bobo-Exception-File: HTTPResponse.py
header: WWW-Authenticate: basic realm="Zope"
Traceback (most recent call last):
  File "z.py", line 15, in ?
print opener.open(fullurl).read()
  File "/usr/local/lib/python2.4/urllib2.py", line 364, in open
response = meth(req, response)
  File "/usr/local/lib/python2.4/urllib2.py", line 471, in http_response
response = self.parent.error(
  File "/usr/local/lib/python2.4/urllib2.py", line 402, in error
return self._call_chain(*args)
  File "/usr/local/lib/python2.4/urllib2.py", line 337, in _call_chain
result = func(*args)
  File "/usr/local/lib/python2.4/urllib2.py", line 480, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 401: Unauthorized

why not send authentification?

I try python 2.5 on slackware 12
too on python 2.4 and 2.5 on windows xp

All same error



-- 

Lo bueno de vivir un dia mas
es saber que nos queda un dia menos de vida
--
http://mail.python.org/mailman/listinfo/python-list


Charging range

2007-12-06 Thread Miguel Galves
I was recently approached with a offer to work on a web related
project where I'd use Python as my main tool. I am using Python for
the past year, and this would be first project. Also, this is a remote
position. The company is located in the US, South Atlantic Region.

Considering it is contract work and it would be a 3-5 man-months
project, how much would you guys think to be the appropriate range to
charge for such project? Any type of figures would help me, to give me
at least an idea.

Thanks,

-- 
Miguel Galves - Engenheiro de Computação
Já leu meus blogs hoje?
Para geeks http://log4dev.com
Pra pessoas normais
http://miguelcomenta.wordpress.com

"Não sabendo que era impossível, ele foi lá e fez..."
-- 
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


My tail call optimizing decorator

2007-09-26 Thread Miguel Perez
Please critique this tail call optimizing decorator I've written. I've
tried to fix the pitfalls of other proposed decorators, and the result
is this one that supports mutual recursion, does not use exceptions,
stack inspection or any implementation-dependent hack, and is pretty
short and fast - the fastest out of the ones I could find and try. In
fact, in tail-recursive environments I tested the impact of using the
decorator is difficult to even measure, as the extra time the
decorator takes to run is probably saved by the better use of cache
memory. The only caveat is that if used in a function that's not
called in a tail-recursive fashion, bad things will happen.

def tailcall(f):
'''Decorator that implements tail call optimization.

Supports cooperative tail call - even when only one of the functions
is
decorated, and all exceptions pass through it. You can tell the
functions
that have been tail optimized because they have "tco" before them in
the
stack frame.

The only caveat is that if you attempt to decorate a function that
isn't
called in a tail recursive fashion from another decorated function,
you'll
get wrong results.'''
tdata = [False] #[Optimizing?]
DO_CALL = object() #Call marker
def tco(*a, **aa):
if tdata[0]:
return DO_CALL, a, aa
else:
tdata[0] = True
ret = f(*a, **aa)
while type(ret) is tuple and ret and ret[0] is DO_CALL:
ret = f(*ret[1], **ret[2])
tdata[0] = False
return ret
tco.__doc__ = f.__doc__
return tco

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


finding an element in a string

2007-06-25 Thread Miguel Oliveira
Hi,
  I was wondering if you could help me with this:
  I want to make an if statement in which I would like to find a certain word in a sentence; here is what i have so far:
 
x = raw_input("how are you?")
 
if x == "fine":
  print "Good."
 
But that, obviously, will only respond "good" when one writes "fine". I was looking for a way for the program to respond "good" to any sentence that would contain the word "fine" in it.
 
I'm sure it's something ridiculously easy, but I have no idea how to do it! :)
 Thank you,
    Miguel :)MSN Busca: fácil, rápido, direto ao ponto.  Encontre o que você quiser. Clique aqui. 

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


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: [IronPython] [ANN] IronPython Community Edition 1.0r2

2006-10-04 Thread Miguel de Icaza
Hello,

> And here's the license and the summary of applied patches:
> http://fepy.sourceforge.net/license.html
> http://fepy.sourceforge.net/patches.html

Do the patches include the various extensions that are being shipped?

Am wondering if you could distribute a IPCE that contains all the
documentation and sources, because it might be good for us to switch to
it from standard IronPython for our distribution purposes.

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


Current module reference

2006-08-16 Thread Miguel Galves
HiHow do I get a reference for the current module I'm in ?I have a package called services with a __init__.pythat need to use getattr() to fill out a hash whithmy package attributes. But to use getattr, I need
a object that references my package (kind of this this reference in Java).How can I do it ? the only way I found to o this is to call get attr from anothermodule that imports the services package. But I suppose
it's not the only wayThanks for your helpMiguel-- Miguel Galves - Engenheiro de ComputaçãoJá leu meus blogs hoje? Para geeks http://log4dev.blogspot.com
Pra pessoas normaishttp://miguelgalves.blogspot.com"Não sabendo que era impossível, ele foi lá e fez..."
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python or Ajax?

2006-06-09 Thread Miguel Galves
These are two very different things.Python is a programming language, that can be used to write server side code,and web applications. AJAX is mora way of life than a technology. Its a listof well known technologies that can be used together
to build rich user interfaces. AJAX and Python could be used togetherto build nice web applications.Inf fact..AJAX should be used within any web app.[]sMiguel
On 6/9/06, Redefined Horizons <[EMAIL PROTECTED]> wrote:
I've been hearing a ot about AJAX lately. I may have to build a webapplication in the near future, and I was curoius:How does a web application that uses Python compare with one that uses AJAX?I've done some basic web page design with HTML and CSS, but never any
web applications. I don't want to learn a new language if I can usePython. Would AJAX offer me any significant advantages?Thanks,Scott Huey--
http://mail.python.org/mailman/listinfo/python-list-- Miguel Galves - Engenheiro de ComputaçãoJá leu meus blogs hoje? Para geeks 
http://log4dev.blogspot.comPra pessoas normaishttp://miguelgalves.blogspot.com"Não sabendo que era impossível, ele foi lá e fez..."
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: what are you using python language for?

2006-06-06 Thread Miguel Galves
I'm using for processing genetic and biological data, anda for fun...On 6/4/06, hacker1017 <[EMAIL PROTECTED]
> wrote:im just asking out of curiosity.--
http://mail.python.org/mailman/listinfo/python-list-- Miguel Galves - Engenheiro de ComputaçãoJá leu meus blogs hoje? Para geeks 
http://log4dev.blogspot.comPra pessoas normaishttp://miguelgalves.blogspot.com"Não sabendo que era impossível, ele foi lá e fez..."
-- 
http://mail.python.org/mailman/listinfo/python-list

Adding attribute to objetcs

2006-06-04 Thread Miguel Galves
Hello,I`m starting to learn python, and I hava a very good background in Javaand C/C++ programming. I was reading Dive into python chapter aboutOO and I saw that in python we can do the following:class Person:
    passjoe = new Person()joe.name = "Joe"joe.age = 13It seems that it is possible to add attributes to any object instancein run time, as in _javascript_. It seems to me that it can be a source
of errors. One that come in my mind is the follwing:class Person:
    name = ""

joe = new Person()
joe.nome = "Joe"The code above adds an attribute called nome,  but the programmer may think it's name.What is the real interest of this feature ? Is there a way to block this kind of error ?
Thanks,Miguel-- Miguel Galves - Engenheiro de ComputaçãoJá leu meus blogs hoje? Para geeks http://log4dev.blogspot.comPra pessoas normais
http://miguelgalves.blogspot.com"Não sabendo que era impossível, ele foi lá e fez..."
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: List operation: Removing an item

2006-04-17 Thread Miguel E
Steven D'Aprano wrote:
> On Sat, 15 Apr 2006 22:39:37 -0600, Miguel E. wrote:
> 
> 
>>I am trying to create a function that removes an item as specified by
>>the user. Apparently, the list operation "del list[:]" deletes the
>>entire list. Below is the sample function.
> 
> 
> If you know the value of the item, and not its position:
> 
> somelist.remove("value")
> 
> This will raise an exception if "value" is not in somelist.
> 

Thank you. That fixed it.

Regards,



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


List operation: Removing an item

2006-04-15 Thread Miguel E.
Hi,

I've been (self) studying Python for the past two months and I have had
no background in OOP whatsoever.

I was able to write an interactive program that randomly selects an item
 from a list. From a Main Menu, the user has the option to add items to
an empty list, show the list, run the random selector, and of course
quit the program. The program also complains if a user tries to add an
item that is already in the list prompting the user to enter another item.

I am trying to create a function that removes an item as specified by
the user. Apparently, the list operation "del list[:]" deletes the
entire list. Below is the sample function.

Any ideas, suggestions, or tips on the list operation I should be using,
or a better way of writing this?

TIA





shopList = ['eggs', 'milk', 'bread', 'juice', 'fruit', 'deli']

def removeItem():
   "Remove an item from the list"
   print
   for items in shopList:
  print items
   print
   dlete = raw_input("Enter the item you want to remove: ")
   print
   for item in shopList:
  if dlete in shopList:
 del shopList[:]  # <--What is the correct function to use?
 print "%s has been removed" % dlete
 print "The new list is now", shopList
  else:
 print "Item is not in the list"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's The Best Editor for python

2006-03-24 Thread Miguel E.
PythonStudent wrote:
> Hi,
> Can one of you say to me what's the best editor for editing the python
> programs ( for linux or windows )


What may be "best" for me, may not necessarily work for you nor anybody
else. Personally, I like to use Kate, Pico, or Joe on Linux, and
Notepad2 or IDLE editor for Windows.

Cheers,


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


Perl XML::Simple and Data::Dumper - exists in Python?

2005-11-06 Thread Miguel Manso
Hi there,

I'm a Perl programmer trying to get into Python. I've been reading some 
documentation and I've choosed Python has being the "next step" to give.

Can you point me out to Python solutions for:

1) Perl's Data::Dumper

It dumps any perl variable to the stdout in a "readable" way.

2) Perl's XML::Simple

It maps a XML file into a Perl data structure.

Does Python have something like these two tools? I've been googling 
before posting this and didn't find anything.

Thanks for the help.

-- 
Miguel Manso <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting into Python, comming from Perl.

2005-04-24 Thread Miguel Manso




Mike Meyer wrote:

  Miguel Manso <[EMAIL PROTECTED]> writes:

  
  
I've tryed to use python some times but I get frustrated very quick. I
get myself many times needing to figure out how to loop through a
list, declare an associative array, checking how to pass named
parameters to functions, and simple things like that.

  
  
I went through some of those frustrations.

  
  
What I would like to know is if anyone had these problems and if you
can share that experience with me. I'm trying to minimize my
"frustration" :)

  
  
The thing is, the answers to all your questions are in the
documentation. You just need to know the Python names for things, and
not the Perl names. For instance, Python calls it's associative array
structure a dictionary, and a checking the documentation index for
dictionary turns up a link to the syntax for declaring one as
display/dictionary.

Read through the tutorial. Then look through some "interesting"
modules in the standard library to see how these things fit together.




I guess I'll just do that. I'll put the frustration in a bag, grab the
documentation and try to figure it out.

Thanks all.

-- 
Miguel Manso <[EMAIL PROTECTED]>

Amplitude Net
Net - Rua dos Salazares, 842
4100-442 Porto

Phone: +351 22 532 2000
Fax: +351 22 618 2157
Web: www.amplitudenet.pt



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

Getting into Python, comming from Perl.

2005-04-24 Thread Miguel Manso
Hi, list.
I'm into a psicological doubt that I would like to share with you 
(you'll know why later on this mail).

I'm a programmer with 5 year of experience into Perl. I'm on that point 
where you resolve problems without thinking on HOW you'll do it with 
that language but only on the problem itself.

Since Perl 6 started I've been following it. The conclusion I have is 
they're making a whole new language and I'll have to learn it. This 
being said and, since I've to learn a new language, I've started 
thinking in a new language. I've noticed Python is getting more and more 
developers and many projects are being made.

I've tryed to use python some times but I get frustrated very quick. I 
get myself many times needing to figure out how to loop through a list, 
declare an associative array, checking how to pass named parameters to 
functions, and simple things like that.

What I would like to know is if anyone had these problems and if you can 
share that experience with me. I'm trying to minimize my "frustration" :)

Thanks a lot.
--
Miguel Manso <[EMAIL PROTECTED]>

Amplitude Net
Net - Rua dos Salazares, 842
4100-442 Porto
Phone: +351 22 532 2000
Fax: +351 22 618 2157
Web: www.amplitudenet.pt

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