Retrieving a variable's name.

2007-08-20 Thread rodrigo
How would I go about retrieving a variable's name (not its value)? I
want to write a function that, given a list of variables, returns  a
string with each variable's name and its value, like:

a: 100
b: 200

I get the feeling this is trivial, but I have been unable to find an
answer on my own.

Thanks,

Rodrigo

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


Re: Retrieving a variable's name.

2007-08-21 Thread rodrigo
You're right, Paul, Evan, James, I should just use a dictionary.

Thanks!

Rodrigo

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


Check for dict key existence, and modify it in one step.

2007-08-28 Thread rodrigo
Im using this construct a lot:

if dict.has_key(whatever):
dict[whatever] += delta
else:
dict[whatever] = 1

sometimes even nested:

if dict.has_key(whatever):
if dict[whatever].has_key(someother):
dict[whatever][someother] += delta
else:
dict[whatever][someother] = 1
else:
dict[whatever]={}
dict[whatever][someother] = 1

there must be a more compact, readable and less redundant way to do
this, no?

Thanks,

Rodrigo

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


Re: Check for dict key existence, and modify it in one step.

2007-08-28 Thread rodrigo
evan,

yes, it does help. Works like it should:

class CountingDictionary(dict):
def increment(self, key, delta=1):
self[key] = self.get(key, 0) + delta

d = CountingDictionary()
d.increment('cat')
d.increment('dog',72)
print d

>>> {'dog': 72, 'cat': 1}

Thanks!

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


Re: Check for dict key existence, and modify it in one step.

2007-08-28 Thread rodrigo
You're right of course, I was unclear. I wasn't using 'dict' to
override the dict clas, but just as a standin for the example (the
actual dictionary names are varied).

Thanks,

Rodriog

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


Entering username & password automatically using urllib.urlopen

2007-10-14 Thread rodrigo
I am trying to retrieve a password protected page using:

get = urllib.urlopen('http://password.protected.url";').read()

While doing this interactively, I'm asked for  the username, then the
password at the terminal.
Is there any way to do this non-interactively? To hardcode the user/
pass into the script so I can get the page automatically?

(This is not a cracking attempt, I am trying to retrieve a page I have
legitimate access to, just doing it automatically when certain
conditions are met.)

Thanks,

Rodrigo

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


pyserial ser.write('string') TypeError in OS X

2009-10-20 Thread Rodrigo
Maybe this is not a bug at all, but i have installed python2.5. 3.01
and 3.1.1. In python 2.5 ser. write('this is a string') works just
fine.
On the other hand, with 3.01 and 3.1.1 (pyserial 2.5 rc1) when i do a
ser.write('this is a string') i get the following error"

>>> import serial
>>> ser = serial.Serial('/dev/tty.usbserial')
>>> ser.write('this is a string')
Traceback (most recent call last):
  File "", line 1, in 
  File "/Library/Frameworks/Python.framework/Versions/3.1/lib/
python3.1/site-packages/serial/serialposix.py", line 466, in write
raise TypeError('expected %s or bytearray, got %s' % (bytes, type
(data)))
TypeError: expected  or bytearray, got 

I honestly dont get what im doing wrong here

any feedback much appreciated

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


Re: Clickable hyperlinks

2017-01-04 Thread Rodrigo Bistolfi
2017-01-04 7:39 GMT-03:00 Steve D'Aprano :

> On Wed, 4 Jan 2017 08:32 pm, Deborah Swanson wrote:
>
> Aside: you've actually raised a fascinating question. I wonder whether
> there
> are any programming languages that understand URLs as native data types, so
> that *source code* starting with http:// etc is understood in the same way
> that source code starting with [ is seen as a list or { as a dict?
> ...
>

Some Smalltalk implementations have something that comes close:

st> 'https://python.org' asUrl retrieveContents

`asUrl` would be a string method returning a URL instance, which also has a
convenient method `retrieveContents` wrapping an http client. Not hard to
do with Python, I think this could be an interesting exercise for a learner.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Clickable hyperlinks

2017-01-06 Thread Rodrigo Bistolfi
2017-01-04 7:39 GMT-03:00 Steve D'Aprano :

> On Wed, 4 Jan 2017 08:32 pm, Deborah Swanson wrote:
>
> Aside: you've actually raised a fascinating question. I wonder whether
> there
> are any programming languages that understand URLs as native data types, so
> that *source code* starting with http:// etc is understood in the same way
> that source code starting with [ is seen as a list or { as a dict?
> ...
>

Some Smalltalk implementations have something that comes close:

st> 'https://python.org' asUrl retrieveContents

`asUrl` would be a string method returning a URL instance, which also has a 
convenient method `retrieveContents` wrapping an http client. Not hard to do 
with Python, I think this could be an interesting exercise for a learner.

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


Determining whether a package or module should be installed globally using pip

2018-04-25 Thread Rodrigo Acosta
Is there a rule of thumb in deciding where to install a package? What makes a 
package, other than security vulnerabilities, better to install globally e.g. 
using sudo pip install, or by changing directory to tmp folder, or by using 
virtualenv?

Thank you python users, you're my only hope,
RAR
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: best way to remove leading zeros from a tuple like string

2018-05-21 Thread Rodrigo Bistolfi
>>> repr(tuple(int(i) for i in s[1:-1].split(',')))
'(128, 20, 8, 255, -1203, 1, 0, -123)'

2018-05-21 4:26 GMT-03:00 Peter Otten <[email protected]>:

> [email protected] wrote:
>
> > Looking over the responses, I modified my original code as follows:
> >
>  s = "(128, 020, 008, 255, -1203,01,-000, -0123)"
>  ",".join([str(int(i)) for i in s[1:-1].split(",")])
> > '128,20,8,255,-1203,1,0,-123'
>
> I think this looks better with a generator instead of the listcomp:
>
> >>> ",".join(str(int(i)) for i in s[1:-1].split(","))
> '128,20,8,255,-1203,1,0,-123'
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Feasibility of console based (non-Gui) Tkinter app which can accept keypresses?

2018-07-11 Thread Rodrigo Bistolfi
You may want to check Urwid instead.

2018-07-11 16:22 GMT-03:00 Jim Lee :

> On 07/11/18 07:09, jkn wrote:
>
>> Hi All
>>  This is more of a Tkinter question rather than a python one, I
>> think, but
>> anyway...
>>
>> I have a Python simulator program with a Model-View_Controller
>> architecture. I
>> have written the View part using Tkinter in the first instance; later I
>> plan
>> to use Qt.
>>
>> However I also want to be able to offer an alternative of a console-only
>> operation. So I have a variant View with the beginnings of this.
>>
>> Naturally I want to keep this as similar as possible to my Tkinter-based
>> view. I
>> had thought that I had seen a guide somewhere to using Tk/Tkinter in a
>> non-GUI
>> form. I don't seem to be able to track this down now, but I have at least
>> been
>> successful in hiding ('withdrawing') the main Frame, and running a main
>> loop.
>>
>> The bit which I am now stumbling on is trying to bind key events to my
>> view,
>> and I am wondering if this actually makes any sense. In the absence of a
>> GUI I
>> want to accept keypresses to control the simulation. But in a console app
>> I will
>> have no visible or in focus window, and therefore at what level would any
>> keys be bound? Not at the widget level, nor the frame, and I am not sure
>> if the
>> the root makes sense either.
>>
>> So I am looking for confirmation of this, and/or whether there is any way
>> of
>> running a Tkinter application in 'console' mode, running a main loop and
>> both outputting data and accepting, and acting on, key presses.
>>
>>  Thanks
>>  J^n
>>
>>
> I think the general answer is no, but beyond that, it may be worth
> considering switching from an MVC architecture to a simpler
> frontend-backend, especially if you intend to add a third interface (Qt):
>
> MVC w/Tk, console, Qt:
>
> Seven conceptual modules (three controllers, three views, one model)
> Two abstraction layers (controller<->model, model<->view)
>
> Frontend-backend w/Tk, console, Qt:
>
> Four conceptual modules (three frontends, one backend)
> One abstraction layer (frontend<->backend)
>
> -Jim
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: limit number of connections from browser to my server?

2016-05-17 Thread Rodrigo Bistolfi
Long shot here: Create a JS framework for loading resources in a better way:

1. Load HTTP and your JS core.
2. Load the rest of the resources via JS (maybe using promises for chaining
the requests one after the other)
-- 
https://mail.python.org/mailman/listinfo/python-list


web programming with mod_python

2005-07-01 Thread Rodrigo Dominguez
Actually I'm using php4 for web programming, but I don't like it, I know
that manny hosting servers supports mod_python, so I want to start
programming in python for web applications with mod_python.
My question is: is there some kind of framework that works with mod_python?
I just want some classes to manage some kind of themplates (for MVC),
sessions, and if possible data persistence. I don't have root on these
servers and the admins won't install any application if I ask them, I need
to use just plain python files.

Thank you


-- 
Rodrigo Domínguez
Consultor
Av. Directorio 183 1º Piso
Tel: 4921-1648 / 4926-1067
Cel: 15-5695-6027
[EMAIL PROTECTED]
www.rorra.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list


Third PyConBrasil takes place in August 2007

2007-06-03 Thread Rodrigo Senra

 We are glad to announce the Third PyConBrasil organised by the
 Brazilian Python Community.

 The event will take place from 2007-08-30 to 2007-09-01 at
 Joinville city in Santa Catarina State (SC) in the
 Brazil's south region. 

 The event home page is http://pyconbrasil.com.br/
 We apologize but the site's content is only available 
 in Brazilian Portuguese Language (pt-br) for the time being.

 The call for speeches is open until 2007-06-30.

 I'd like to thank the python developers and the python community
 in general for outstanding tools, culture and community.

 best regards,
 Rod Senra

 III PyConBrasil 
 http://pyconbrasil.com.br
 [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which datastructure for fast sorted insert?

2008-05-25 Thread Rodrigo Lazo
Stefan Behnel <[EMAIL PROTECTED]> writes:

> [EMAIL PROTECTED] wrote:
>> im writing a webcrawler.
>> after visiting a new site i want to store it in alphabetical order.
>> 
>> so obv i want fast insert. i want to delete duplicates too.
>> 
>> which datastructure is best for this?
>
> Keep the data redundantly in two data structures. Use collections.deque() to
> append and remove as in a queue, and set() to find duplicates.
>

what about heapq for sorting? 

-- 

Rodrigo Lazo (rlazo)

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


"persistent" plot windows

2007-03-24 Thread Rodrigo Lopez-Negrete
Hi all,

I'm trying to write a python script using plotting form pylab.
Unfortunatelly I've encountered a problem. When I run the script via
'python myscript.py' the plot windows open and close very quickly, or
when I added the show() command the shell window was locked until I
closed the figures.

My question is: is there a way to open those windows in the background
without blocking the shell and without running it interactively??
something like gnuplot -persist?

Thanks all,
  Rodrigo Lopez-Negrete

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


Re: "persistent" plot windows

2007-03-24 Thread Rodrigo Lopez-Negrete
Hi James,

Thanks for the answer, the ampersand only works if I use the show()
command at the end of my script. I guess that helps although I haven't
tested it with plotting subroutines.

cheers,
  Rodrigo

On Mar 24, 6:50 pm, James Stroud <[EMAIL PROTECTED]> wrote:
> Rodrigo Lopez-Negrete wrote:
> > Hi all,
>
> > I'm trying to write a python script using plotting form pylab.
> > Unfortunatelly I've encountered a problem. When I run the script via
> > 'python myscript.py' the plot windows open and close very quickly, or

> > when I added the show() command the shell window was locked until I
> > closed the figures.
>
> > My question is: is there a way to open those windows in the background
> > without blocking the shell and without running it interactively??
> > something like gnuplot -persist?
>
> > Thanks all,
> >   Rodrigo Lopez-Negrete
>
> python whatever.py &
>
> (Don't forget the ampersand!)
>
> James


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


Re: Does python have the capability for driver development ?

2009-07-29 Thread Rodrigo S Wanderley
"Martin P. Hellwig"  writes:

> Python is interpreted, so the first requirement would be that the
> interpreter (the python VM to be more precise) would run in the kernel
> or that there is a way for the interpreter to delegate operations to
> kernel restricted operations. Most notably access to the memory
> location of the hardware you want to write a driver for and possibly
> also a way to pass through a callback function for triggered
> interrupt coming from the hardware.
>
> So technically speaking it shouldn't be impossible. And there is
> perhaps something to say for being able to write drivers in a
> readable/easy programming language however I am afraid that if such a
> beast would be made that it would remain an academical exercise only
> due to performance constraints.

What about user level device drivers? Think the Python VM could
communicate with the driver through the user space API.  Is there a
Python module for that?

-- 
Rodrigo S. Wanderley 
  -- Blog: http://rsw.digi.com.br
-- 
http://mail.python.org/mailman/listinfo/python-list


Any Softphone wrote in Python?

2009-08-24 Thread Rodrigo do Carmo
Hi python-community,

I would like to ask you if someone know any open source softphone wrote
entirely in Python. The thing is that I want to write a honeyphone but
starting from a softphone. Sorry if you think that I haven't "googled"
enough.

Regards,
Rodrigo.
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: Brazil organises its first PyConDayBrasil

2005-03-27 Thread Rodrigo Dias Arruda Senra

 Inspired by the PyCon tradition, the Brazilian Python Community
 is organising a PyCon-like event called: PyConDayBrasil.

 We have gathered 14 people to give speeches exclusively about
 Python in an event that will take place in April 28th/29th.

 The event's  URL is below (only in Brazilian Portuguese pt-br):
 http://www.pythonbrasil.com.br/moin.cgi/PyConDayBrasil

 We hope that this event will not be just a standalone happening,
 but the beginning of a tradition. Moreover, we will strive to find 
 sponsors to allow us to invite international speakers in the following
 years.

 To illustrate the scope of PyConDayBrasil, this year's program is composed by:
 
 - Python applications to science and  engineering (Vinicius Franco do 
Nascimento)
 - Molecular Alignment Analysis in Python (Frederico Gonzalez Colombo Arnoldi)
 - Python in Undergraduate Courses (Marco André Lopes Mendes)
 - Exploring Boa Constructor (Luciano Pacheco)
 - Python refreshes your thinking (Osvaldo Santana Neto)
 - Plone for Pythonistas (Fabiano "Xiru" Weimar dos Santos)
 - Python-Fu inside Gimp (Joao S. O. Bueno Calligaris)
 - The Language Boo by its Creator (Rodrigo "Bamboo"  de Oliveira)
 - Zope 3: Reality or myth  (Luciano Ramalho)
 - Python Game Programming (Gustavo Barbieri)
 - Advanced CMF and Plone Development (Jean Rodrigo Ferri)
 - And now something completely different: Pyrotecnical Show (Rodrigo Senra)
 - Python Puzzles and Other Curiosities (Gustavo Niemeyer)
 - Content publishing in the PUSH model (Sidnei da Silva)

 I'd like to thank the python developers and the python community in general
 for these outstanding: tool, culture and community.

 best regards,
 Rod Senra

-- 
   ,_   
   | )  Rodrigo Senra 
   |(__ ---
 _((|__|]   GPr Sistemas http://www.gpr.com.br  
_ |(|___|]  IC - Unicamp http://www.ic.unicamp.br/~921234  
___(|__|]   
   L___(|_|]---
--
http://mail.python.org/mailman/listinfo/python-list