Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-15 Thread Tim Roberts
Dennis Lee Bieber  wrote:
>
>On Sun, 12 Jun 2011 21:30:43 -0700, Tim Roberts 
>declaimed the following in gmane.comp.python.general:
>
>> More than that, any layout "more efficient" than QWERTY is practically
>> meaningless.  The whole "intentional inefficiency" thing in the design of
>> the QWERTY layout is an urban legend.
>
>   Oh, there was an "inefficiency" in QWERTY -- but it only applies to
>fully manual typewriters, in which some of the more common letters were
>placed under the weakest fingers -- to slow down key strokes enough to
>reduce jamming multiple type blocks 

That's what I was referring to.  That's a very common belief, but it's
nonsense.
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question regarding DNS resolution in urllib2

2011-06-15 Thread saurabh verma
>
>
>
> If you edit your hosts file, it will affect where something.com points
> - you can force it to be IPA and then test, then force it to IPB and
> test. You'll still be downloading https://something.com so the HTTPS
> handshake should work exactly the same way.
>
>
there are issues with editing /etc/hosts , what if i don't have sudo access
on the target server ? I need a way out programmatically to fix this problem
.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python for Web

2011-06-15 Thread sidRo
Is Python only for server side?
-- 
http://mail.python.org/mailman/listinfo/python-list


R: Leo 4.9 b4 released

2011-06-15 Thread LordMax
great!
I like much leo
^___^
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question regarding DNS resolution in urllib2

2011-06-15 Thread Chris Angelico
On Wed, Jun 15, 2011 at 5:50 PM, saurabh verma  wrote:
>> If you edit your hosts file, it will affect where something.com points
>> - you can force it to be IPA and then test, then force it to IPB and
>> test. You'll still be downloading https://something.com so the HTTPS
>> handshake should work exactly the same way.
>
> there are issues with editing /etc/hosts , what if i don't have sudo access
> on the target server ? I need a way out programmatically to fix this problem

You don't need to edit it on the server; just use any handy computer.
You need only tinker with the configuration on the client, not the
server.

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


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-15 Thread Chris Angelico
On Wed, Jun 15, 2011 at 5:16 PM, Tim Roberts  wrote:
> Dennis Lee Bieber  wrote:
>>       Oh, there was an "inefficiency" in QWERTY -- but it only applies to
>>fully manual typewriters, in which some of the more common letters were
>>placed under the weakest fingers -- to slow down key strokes enough to
>>reduce jamming multiple type blocks
>
> That's what I was referring to.  That's a very common belief, but it's
> nonsense.

Competing rumour: The layout was designed such that "typewriter" could
be typed out using only the top row, to improve demo speed by a factor
of three.

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


Subprocess Startup Error

2011-06-15 Thread Dan Riner
I just installed Python 3.2 and when starting the GUI from the start menu I
get a Subprocess Startup Error message : "IDLE's subprocess didn't make
connection.  Either IDLE can't start a subprocess or personal firewall
software is blocking the connection."  I'm running XP (SP3) and have added
python to windows firewall exceptions and then turned off the firewall all
together to no avail.  I was running Python 2.6 previously and never had
this problem.  Any suggestions would be greatly appreciated.

 

Dan

 

 

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


Re: Question regarding DNS resolution in urllib2

2011-06-15 Thread saurabh verma
> 
> You don't need to edit it on the server; just use any handy computer.
> You need only tinker with the configuration on the client, not the
> server.
> 

Hmm true , Ok i can widen the problem statement  but editing /etc/hosts still 
looks Ok for my test server . ( Thinking of putting this as a nagios plugin on 
the servers .. that will not be a viable right now ) 

Thanks chris. 

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


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-15 Thread Dotan Cohen
On Wed, Jun 15, 2011 at 11:30, Chris Angelico  wrote:
> Competing rumour: The layout was designed such that "typewriter" could
> be typed out using only the top row, to improve demo speed by a factor
> of three.
>

Utter nonsense. The QWERTY keyboard was - and this is verified fact -
designed the way is was because the inventor's mother in law's
initials were AS and his father is law was DF. The letter combinations
JK and L; were his childrens' initials.

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-15 Thread Chris Angelico
On Wed, Jun 15, 2011 at 7:22 PM, Dotan Cohen  wrote:
> Utter nonsense. The QWERTY keyboard was - and this is verified fact -
> designed the way is was because the inventor's mother in law's
> initials were AS and his father is law was DF. The letter combinations
> JK and L; were his childrens' initials.

He had a son called Harry ;emicolon? That's nearly as bad as Robert');
DROP TABLE Students; --.

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


Function within class and in modules

2011-06-15 Thread TheSaint
Hello
sorry, I'm bit curious to understand what could be the difference to pack up 
a class for some number of functions in it and a simple module which I just 
import and use the similar functions?
The only perspective that I think of is that class might instantiate a 
function several time. For my use I don't have multithread and mostly 
programs are sequencial.

-- 
goto /dev/null
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for Web

2011-06-15 Thread bruno.desthuilli...@gmail.com
On Jun 15, 9:50 am, sidRo  wrote:
> Is Python only for server side?

Is it a theoretical question or a practical one ?-)

More seriously: except for the old proof-of-concept Grail browser, no
known browser uses Python as a client-side scripting language.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function within class and in modules

2011-06-15 Thread Roy Smith
In article ,
 TheSaint  wrote:

> Hello
> sorry, I'm bit curious to understand what could be the difference to pack up 
> a class for some number of functions in it and a simple module which I just 
> import and use the similar functions?

If all you have is a bunch of functions, just sticking them in a module 
is fine.  The reason you would want to package them up as a class would 
be if there's some state that needs to be saved.

Don't think of a class as a collection of methods, think of it as a hunk 
of data, and some methods which operate on that data.  Looking at it 
another way, if you write a class and discover that none of the methods 
ever make any use of self, then what you probably really wanted to do 
was create a module to hold all those methods as top-level functions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-15 Thread rusi
On Jun 15, 9:35 am, Dotan Cohen  wrote:
> On Wed, Jun 15, 2011 at 06:00, rusi  wrote:
> > For keyboarding (in the piano/organ sense) the weakest finger is not
> > the fifth/pinky but the fourth.
> > Because for the fifth you will notice that the natural movement is to
> > stiffen the finger and then use a slight outward arm-swing; for thumb,
> > index and middle, they of course have their own strength.
>
> > The fourth has neither advantage.  IOW qwerty is not so bad as it
> > could have been if it were qewrty (or asd was sad)
>
> Thank you rusi! Tell me, where can I read more about the advantages of
> each finger? Googling turns up nothing. My intention is to improved
> the Noah ergonomic keyboard layout. Thanks!

Dont know how to answer that! I only have my experience to go by :-)

If you've spent a childhood and many of your adult hours breaking your
hands on Czerny
http://en.wikipedia.org/wiki/Carl_Czerny
and Hanon eg exercise 4 
http://www.hanon-online.com/the-virtuoso-pianist/part-i/exercise-n-4/
you will come to similar conclusions.

I should warn however that even for a modern electronic piano the
action is larger and heavier than a typical (computer) keyboard and
for a real/acoustic piano with a foot long slice of wood moved for
each keystroke its probably an order of magnitude heavier.

So its not exactly clear how much the experience of one carries over
to the other
-- 
http://mail.python.org/mailman/listinfo/python-list


integer to binary 0-padded

2011-06-15 Thread Olivier LEMAIRE
Hi there, 
I've been looking for 2 days for a way to convert integer to binary number 
0-padded, nothing... 
I need to get numbers converted with a defined number of bits. For example on 8 
bits 2 = 0010
I wrote the following:

#!/usr/bin/env python


def int2binPadded(number, size):
"""The purpose of this function is to convert integer number to binary 
number
0-padded."""
if type(number)!=int or number < 0:
raise ValueError, "should be a positive integer"
if type(size)!=int:
raise ValueError, "should be an integer"
if number > (2**size)-1:
raise ValueError, "number is too large"
# convert int to bin
b = str(bin(number))[2:]

if len(b) !=size:
b = (size-len(b))*"0"+b

return b


if __name__ == "__main__":
import sys
print int2binPadded(int(sys.argv[1]),int(sys.argv[2]))


This satisfies my needs !

Though, what do you think about it ?

Thank you for you remarks,

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


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-15 Thread Dotan Cohen
On Wed, Jun 15, 2011 at 15:19, rusi  wrote:
>> Thank you rusi! Tell me, where can I read more about the advantages of
>> each finger? Googling turns up nothing. My intention is to improved
>> the Noah ergonomic keyboard layout. Thanks!
>
> Dont know how to answer that! I only have my experience to go by :-)
>
> If you've spent a childhood and many of your adult hours breaking your
> hands on Czerny
> http://en.wikipedia.org/wiki/Carl_Czerny
> and Hanon eg exercise 4 
> http://www.hanon-online.com/the-virtuoso-pianist/part-i/exercise-n-4/
> you will come to similar conclusions.
>
> I should warn however that even for a modern electronic piano the
> action is larger and heavier than a typical (computer) keyboard and
> for a real/acoustic piano with a foot long slice of wood moved for
> each keystroke its probably an order of magnitude heavier.
>
> So its not exactly clear how much the experience of one carries over
> to the other
>

Thanks. From testing small movements with my fingers I see that the
fourth finger is in fact a bit weaker than the last finger, but more
importantly, it is much less dexterous. Good to know!

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: integer to binary 0-padded

2011-06-15 Thread Daniel Rentz

Hi,

Am 15.06.2011 14:29, schrieb Olivier LEMAIRE:

Hi there, I've been looking for 2 days for a way to convert integer
to binary number 0-padded, nothing... I need to get numbers converted
with a defined number of bits. For example on 8 bits 2 = 0010


bin(2)[2:].zfill(8)


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


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-15 Thread rusi
On Jun 15, 5:32 pm, Dotan Cohen  wrote:

> Thanks. From testing small movements with my fingers I see that the
> fourth finger is in fact a bit weaker than the last finger, but more
> importantly, it is much less dexterous. Good to know!

Most of the piano technique-icians emphasis, especially those of the
last century like Hanon, was to cultivate 'independence' of the
fingers.  The main target of these attacks being the 4th finger.

The number of potential-pianists who ruined their hands and lives
chasing this holy grail is unknown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: integer to binary 0-padded

2011-06-15 Thread Chris Angelico
On Wed, Jun 15, 2011 at 10:29 PM, Olivier LEMAIRE
 wrote:
>    b = str(bin(number))[2:]
>    if len(b) !=size:
>        b = (size-len(b))*"0"+b

You don't need the str() there as bin() already returns a number.
Here's a relatively trivial simplification - although it does make the
code more cryptic:

b = (size*"0"+bin(number)[2:])[-size:]

After typing this up, I saw Daniel's post, which is rather better. Go
with that one for zero-filling; mine's more general though, you can
pad with other tokens.

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


Re: integer to binary 0-padded

2011-06-15 Thread Peter Otten
Olivier LEMAIRE wrote:

> I've been looking for 2 days for a way to convert integer to binary number
> 0-padded, nothing... I need to get numbers converted with a defined number
> of bits. For example on 8 bits 2 = 0010 I wrote the following:

> b = str(bin(number))[2:]

The result of bin() is already a string, no need to apply str().

> if len(b) !=size:
> b = (size-len(b))*"0"+b

b.zfill(size) can do that.

> Though, what do you think about it ?

Here's another way (requires Python 2.7):

>>> "{:0{}b}".format(42, 10)
'101010'

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


Re: integer to binary 0-padded

2011-06-15 Thread Olivier LEMAIRE
Thank you to all of you !! 

so finally, I can simply write :

#!/usr/bin/env python


def int2binPadded(number, size):
"""The purpose of this function is to convert integer number to binary 
number
0-padded."""
if type(number)!=int or number < 0:
raise ValueError, "should be a positive integer"
if type(size)!=int:
raise ValueError, "should be an integer"
if number > (2**size)-1:
raise ValueError, "number is too large"
# convert int to bin

return bin(number)[2:].zfill(size)


if __name__ == "__main__":
import sys
print int2binPadded(int(sys.argv[1]),int(sys.argv[2]))

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


Re: integer to binary 0-padded

2011-06-15 Thread Tim Chase

On 06/15/2011 07:33 AM, Daniel Rentz wrote:

Am 15.06.2011 14:29, schrieb Olivier LEMAIRE:

Hi there, I've been looking for 2 days for a way to convert integer
to binary number 0-padded, nothing... I need to get numbers converted
with a defined number of bits. For example on 8 bits 2 = 0010


bin(2)[2:].zfill(8)


Just to have in the thread (though the OP seems to be using 2.6 
or later), the bin() function appears to have been added in 2.6 
which is something I wish had been back-ported to 2.4 and 2.5 as 
I've been sufficiently stuck coding against older versions of 
Python to have (re)written a bin() function multiple times.  Ah well.


-tkc



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


Re: integer to binary 0-padded

2011-06-15 Thread Olivier LEMAIRE
You're right, I use Python 2.6.6 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function within class and in modules

2011-06-15 Thread Zach Dziura
> On Jun 15, 7:57 am, TheSaint  wrote:
> Hello
> sorry, I'm bit curious to understand what could be the difference to pack up
> a class for some number of functions in it and a simple module which I just
> import and use the similar functions?
> The only perspective that I think of is that class might instantiate a
> function several time. For my use I don't have multithread and mostly
> programs are sequencial.

I had a hard time with this at first when I started using Python. I
personally come from a background of using Java in an educational
environment, so I'm pretty familiar with it. Going from a "pure"
Object-Oriented language, where everything MUST be bundled into a
class, and an Object is less of "a bit of data" and more of "a data
structure that actually DOES something", was a little difficult.

Just repeat this to yourself: Python ISN'T Java. Repeat it until the
words start sounding funny to you. Then continue for another 10
minutes. It'll sink in.

Anyhow... In Python, classes aren't necessarily treated as "things
that do stuff" (though they can DEFINITELY act in that way!). Python
classes are made to hold data. If you have something that you need to
save for later, put it in a class and call it a day. If you only have
a bunch of functions that are meant to process something, just put
them into a module. You'll save yourself some time, you won't have to
instantiate a class in order to call the functions, and you'll be
happier overall. (I know was happy from being freed from the Pure OO
model that Java shoves down your throat!)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for Coders or Testers for an Open Source File Organizer

2011-06-15 Thread Zach Dziura
On Jun 14, 8:22 pm, zainul franciscus 
wrote:
> Thank you for the reply. I should have mentioned where I am hosting
> the code *doh slap on the wrist.
>
> I am hosting the code in google 
> code:http://code.google.com/p/mirandafileorganizer/
>
> There is a link to the user/developer guide on how to get started with
> the 
> software:https://docs.google.com/document/d/1OGvrS5offb27WlkZ5genMJX2El18Aqrnf...
>
> Just email me directly if you are interested to join the project and I
> will add you as a contributor in Google Code
>
> Best Wishes

Sounds good, I shall take a look at it when I get home from work. (The
Google Docs domain is blocked here. Curses!)

Just as a tip: on the project's homepage, just write about your
project and what it's features are. Don't write in the first person.
This isn't about you, it's about the project. O=)
-- 
http://mail.python.org/mailman/listinfo/python-list


How to form a dict out of a string by doing regex ?

2011-06-15 Thread Satyajit Sarangi


data = "GEOMETRYCOLLECTION (POINT (-8.96484375
-4.130859375000), POINT (2.021484375000 -2.63671875),
POINT (-1.40625000 -11.162109375000), POINT
(-11.95312500,-10.89843750), POLYGON
((-21.62109375 1.845703125000,2.46093750
2.197265625000, -18.98437500 -3.69140625,
-22.67578125 -3.33984375, -22.14843750
-2.63671875, -21.62109375
1.845703125000)),LINESTRING (-11.95312500
11.337890625000, 7.73437500 11.513671875000,
12.30468750 2.548828125000, 12.216796875000
1.669921875000, 14.501953125000 3.955078125000))"

This is my string .
How do I traverse through it and form 3 dicts of Point , Polygon and
Linestring containing the co-ordinates ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for Coders or Testers for an Open Source File Organizer

2011-06-15 Thread Zach Dziura
Also, can I be added to the project? Email is zcdzi...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


creating a multi colored graph with respect to the values in y-axis

2011-06-15 Thread Ravikanth
Hi all,

I am a beginner in python. I need to implement a graph with multiple
colors in it.
In a way, I have a function which varies with respect to time and
amplitude. I have time on x-axis and amplitude on y-axis. Lets say the
amplitude of the graph is divided into 4 ranges, say 1-3,3-5,5-9,
10-3. I need to plot the graph in such a way that, when the values of
amplitude are in a particular range say 1-3, the color of graph should
be red.
If the amplitude is in the range from 3-5 the graph need to be in
color blue etc..,

Can somebody guide me on this, how to achive this functionality.

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


Re: creating a multi colored graph with respect to the values in y-axis

2011-06-15 Thread Wanderer
On Jun 15, 11:04 am, Ravikanth  wrote:
> Hi all,
>
> I am a beginner in python. I need to implement a graph with multiple
> colors in it.
> In a way, I have a function which varies with respect to time and
> amplitude. I have time on x-axis and amplitude on y-axis. Lets say the
> amplitude of the graph is divided into 4 ranges, say 1-3,3-5,5-9,
> 10-3. I need to plot the graph in such a way that, when the values of
> amplitude are in a particular range say 1-3, the color of graph should
> be red.
> If the amplitude is in the range from 3-5 the graph need to be in
> color blue etc..,
>
> Can somebody guide me on this, how to achive this functionality.
>
> Regards,
> Ravikanth

Check out the examples in matplotlib.

http://matplotlib.sourceforge.net/examples/pylab_examples/multicolored_line.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to form a dict out of a string by doing regex ?

2011-06-15 Thread Mel
Satyajit Sarangi wrote:

> 
> 
> data = "GEOMETRYCOLLECTION (POINT (-8.96484375
> -4.130859375000), POINT (2.021484375000 -2.63671875),
> POINT (-1.40625000 -11.162109375000), POINT
> (-11.95312500,-10.89843750), POLYGON
> ((-21.62109375 1.845703125000,2.46093750
> 2.197265625000, -18.98437500 -3.69140625,
> -22.67578125 -3.33984375, -22.14843750
> -2.63671875, -21.62109375
> 1.845703125000)),LINESTRING (-11.95312500
> 11.337890625000, 7.73437500 11.513671875000,
> 12.30468750 2.548828125000, 12.216796875000
> 1.669921875000, 14.501953125000 3.955078125000))"
> 
> This is my string .
> How do I traverse through it and form 3 dicts of Point , Polygon and
> Linestring containing the co-ordinates ?

Except for those space-separated number pairs, it could be a job for some 
well-crafted classes (e.g. `class GEOMETRYCOLLECTION ...`, `class POINT 
...`) and eval.

My approach would be to use a loop with regexes to recognize the leading 
element and pick out its arguments, then use the string split and strip 
methods beyond that point.  Like (untested):

recognizer = re.compile (r'(?(POINT|POLYGON|LINESTRING)\s*\(+(.*?)\)+,(.*)')
# regex is not good with nested brackets, 
# so kill off outer nested brackets..
s1 = 'GEOMETRYCOLLECTION ('
if data.startswith (s1):
data = data (len (s1):-1)

while data:
match = recognizer.match (data)
if not match:
break   # nothing usable in data
## now the matched groups will be:
## 1: the keyword
## 2: the arguments inside the smallest bracketed sequence
## 3: the rest of data
##  so use str.split and str.match to pull out the individual arguments,
## and lastly
data = match.group (3)

This is all from memory.  I might have got some details wrong in recognizer.

Mel.

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


Re: Looking for Coders or Testers for an Open Source File Organizer

2011-06-15 Thread Verde Denim
I'm interested in helping out, but I'm also curious to know how this
application will differentiate itself from those already in development
(i.e. more robust feature set, tighter functionality, better security, or
just because it is developed in Py)?

Regards
Jack

On Wed, Jun 15, 2011 at 10:53 AM, Zach Dziura  wrote:

> Also, can I be added to the project? Email is zcdzi...@gmail.com
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: creating a multi colored graph with respect to the values in y-axis

2011-06-15 Thread Ravikanth
On Jun 15, 10:32 am, Wanderer  wrote:
> On Jun 15, 11:04 am, Ravikanth  wrote:
>
>
>
>
>
> > Hi all,
>
> > I am a beginner in python. I need to implement a graph with multiple
> > colors in it.
> > In a way, I have a function which varies with respect to time and
> > amplitude. I have time on x-axis and amplitude on y-axis. Lets say the
> > amplitude of the graph is divided into 4 ranges, say 1-3,3-5,5-9,
> > 10-3. I need to plot the graph in such a way that, when the values of
> > amplitude are in a particular range say 1-3, the color of graph should
> > be red.
> > If the amplitude is in the range from 3-5 the graph need to be in
> > color blue etc..,
>
> > Can somebody guide me on this, how to achive this functionality.
>
> > Regards,
> > Ravikanth
>
> Check out the examples in matplotlib.
>
> http://matplotlib.sourceforge.net/examples/pylab_examples/multicolore...- 
> Hide quoted text -
>
> - Show quoted text -

I did go through the side wanderer.

I wasn't able to figure out the usage of boundaryNorm and
lc.set_array(z) , in that link.
according to my understanding,

cmap = ListedColormap(['r', 'g', 'b'])
norm = BoundaryNorm([-1, -0.5, 0.5, 1], cmap.N)

In the above lines of code, as per my understanding,
Listedcolor map, maps the colors r,g and b to specific indexes into
cmap
i.e cmap(0) represents red,
cmap(1) represents blue
cmap(2) represents green.
for any index greater than 3 a color of blue is returned..

>>> cmap = ListedColormap(['r', 'g', 'b'])
>>> cmap(0)
(1.0, 0.0, 0.0, 1.0)
>>> cmap(1)
(0.0, 0.5, 0.0, 1.0)
>>> cmap(2)
(0.0, 0.0, 1.0, 1.0)
>>> cmap(3)
(0.0, 0.0, 1.0, 1.0)

In this context, I was not able to understand what does boundaryNorm
does.
We have 3 colors and we are using 4 values as argument in boundaryNorm.
[-1, -0.5, 0.5, 1], the comment reads slope of 'z' is being mapped to
the values in boundary norm. How is it handled.
Does the function call " lc.set_array(z) " does it ?  what is the
exact use of linecollection.set_array(z) in this context.

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


Re: How to form a dict out of a string by doing regex ?

2011-06-15 Thread Miki Tebeka
One solution is https://gist.github.com/1027445.
Note that you have a stray , in your last POINT.

I recommend however using some kind of parser framework (PLY?).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: creating a multi colored graph with respect to the values in y-axis

2011-06-15 Thread Wanderer
On Jun 15, 12:00 pm, Ravikanth  wrote:
> On Jun 15, 10:32 am, Wanderer  wrote:
>
>
>
>
>
>
>
>
>
> > On Jun 15, 11:04 am, Ravikanth  wrote:
>
> > > Hi all,
>
> > > I am a beginner in python. I need to implement a graph with multiple
> > > colors in it.
> > > In a way, I have a function which varies with respect to time and
> > > amplitude. I have time on x-axis and amplitude on y-axis. Lets say the
> > > amplitude of the graph is divided into 4 ranges, say 1-3,3-5,5-9,
> > > 10-3. I need to plot the graph in such a way that, when the values of
> > > amplitude are in a particular range say 1-3, the color of graph should
> > > be red.
> > > If the amplitude is in the range from 3-5 the graph need to be in
> > > color blue etc..,
>
> > > Can somebody guide me on this, how to achive this functionality.
>
> > > Regards,
> > > Ravikanth
>
> > Check out the examples in matplotlib.
>
> >http://matplotlib.sourceforge.net/examples/pylab_examples/multicolore...Hide 
> >quoted text -
>
> > - Show quoted text -
>
> I did go through the side wanderer.
>
> I wasn't able to figure out the usage of boundaryNorm and
> lc.set_array(z) , in that link.
> according to my understanding,
>
> cmap = ListedColormap(['r', 'g', 'b'])
> norm = BoundaryNorm([-1, -0.5, 0.5, 1], cmap.N)
>
> In the above lines of code, as per my understanding,
> Listedcolor map, maps the colors r,g and b to specific indexes into
> cmap
> i.e cmap(0) represents red,
> cmap(1) represents blue
> cmap(2) represents green.
> for any index greater than 3 a color of blue is returned..
>
> >>> cmap = ListedColormap(['r', 'g', 'b'])
> >>> cmap(0)
>
> (1.0, 0.0, 0.0, 1.0)>>> cmap(1)
>
> (0.0, 0.5, 0.0, 1.0)>>> cmap(2)
>
> (0.0, 0.0, 1.0, 1.0)>>> cmap(3)
>
> (0.0, 0.0, 1.0, 1.0)
>
> In this context, I was not able to understand what does boundaryNorm
> does.
> We have 3 colors and we are using 4 values as argument in boundaryNorm.
> [-1, -0.5, 0.5, 1], the comment reads slope of 'z' is being mapped to
> the values in boundary norm. How is it handled.
> Does the function call " lc.set_array(z) " does it ?  what is the
> exact use of linecollection.set_array(z) in this context.
>
> Thanks,
> Ravikanth

The colors are referring to the slope of the line. Change
'lc.set_array(z)' to 'lc.set_array(y)' and it might be easier to
understand.  Here are the steps.

1. Define the functions x,y and z,
2. Define the colors 'red', 'green' and 'blue' with ListedColorMap
3. Define the three regions, (-1.0 to -0.50, -0.50 to 0.50, 0.50 to
1.0) with BoundaryNorm([-1,-0.50, 0.50,1], cmap.N).
   (Why they add the trailing zero in 0.50 and don't change 1 to 1.0;
I don't know)
4. Create an array of (x,y) points.
5. Create a collection of tiny segments [(x1,y1),(x2,y2)] and color
them with cmap using the boundary rules of norm. lc =
LineCollection(segments, cmap=cmap, norm=norm)
6. Use lc.set_array(y) to determine how to color the segments.
7. Plot it.


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


Re: creating a multi colored graph with respect to the values in y-axis

2011-06-15 Thread Ravikanth
On Jun 15, 11:57 am, Wanderer  wrote:
> On Jun 15, 12:00 pm, Ravikanth  wrote:
>
>
>
>
>
> > On Jun 15, 10:32 am, Wanderer  wrote:
>
> > > On Jun 15, 11:04 am, Ravikanth  wrote:
>
> > > > Hi all,
>
> > > > I am a beginner in python. I need to implement a graph with multiple
> > > > colors in it.
> > > > In a way, I have a function which varies with respect to time and
> > > > amplitude. I have time on x-axis and amplitude on y-axis. Lets say the
> > > > amplitude of the graph is divided into 4 ranges, say 1-3,3-5,5-9,
> > > > 10-3. I need to plot the graph in such a way that, when the values of
> > > > amplitude are in a particular range say 1-3, the color of graph should
> > > > be red.
> > > > If the amplitude is in the range from 3-5 the graph need to be in
> > > > color blue etc..,
>
> > > > Can somebody guide me on this, how to achive this functionality.
>
> > > > Regards,
> > > > Ravikanth
>
> > > Check out the examples in matplotlib.
>
> > >http://matplotlib.sourceforge.net/examples/pylab_examples/multicolore...quoted
> > > text -
>
> > > - Show quoted text -
>
> > I did go through the side wanderer.
>
> > I wasn't able to figure out the usage of boundaryNorm and
> > lc.set_array(z) , in that link.
> > according to my understanding,
>
> > cmap = ListedColormap(['r', 'g', 'b'])
> > norm = BoundaryNorm([-1, -0.5, 0.5, 1], cmap.N)
>
> > In the above lines of code, as per my understanding,
> > Listedcolor map, maps the colors r,g and b to specific indexes into
> > cmap
> > i.e cmap(0) represents red,
> > cmap(1) represents blue
> > cmap(2) represents green.
> > for any index greater than 3 a color of blue is returned..
>
> > >>> cmap = ListedColormap(['r', 'g', 'b'])
> > >>> cmap(0)
>
> > (1.0, 0.0, 0.0, 1.0)>>> cmap(1)
>
> > (0.0, 0.5, 0.0, 1.0)>>> cmap(2)
>
> > (0.0, 0.0, 1.0, 1.0)>>> cmap(3)
>
> > (0.0, 0.0, 1.0, 1.0)
>
> > In this context, I was not able to understand what does boundaryNorm
> > does.
> > We have 3 colors and we are using 4 values as argument in boundaryNorm.
> > [-1, -0.5, 0.5, 1], the comment reads slope of 'z' is being mapped to
> > the values in boundary norm. How is it handled.
> > Does the function call " lc.set_array(z) " does it ?  what is the
> > exact use of linecollection.set_array(z) in this context.
>
> > Thanks,
> > Ravikanth
>
> The colors are referring to the slope of the line. Change
> 'lc.set_array(z)' to 'lc.set_array(y)' and it might be easier to
> understand.  Here are the steps.
>
> 1. Define the functions x,y and z,
> 2. Define the colors 'red', 'green' and 'blue' with ListedColorMap
> 3. Define the three regions, (-1.0 to -0.50, -0.50 to 0.50, 0.50 to
> 1.0) with BoundaryNorm([-1,-0.50, 0.50,1], cmap.N).
>    (Why they add the trailing zero in 0.50 and don't change 1 to 1.0;
> I don't know)
> 4. Create an array of (x,y) points.
> 5. Create a collection of tiny segments [(x1,y1),(x2,y2)] and color
> them with cmap using the boundary rules of norm. lc =
> LineCollection(segments, cmap=cmap, norm=norm)
> 6. Use lc.set_array(y) to determine how to color the segments.
> 7. Plot it.- Hide quoted text -
>
> - Show quoted text -

Hi Wanderer,

Thanks for your help. It works now.
Just wanted to know how to go about when I have to do my color mapping
not only with respect to range of values on y-axis but also based on
some other conditions as well. i.e, say ( range &&  &&
 ) where condition1 could be occurance of some event say,
a flag1 is set true and condition2 may be another flag2 set to false.
Just wanted to use my color mapping not only based on boundaries but
also on occurance of other events as well.
In this context do i have to modify the source of BoundaryNorm in
matplotlib function...?? Can you give me some insights into this.

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


Re: creating a multi colored graph with respect to the values in y-axis

2011-06-15 Thread Wanderer
On Jun 15, 1:28 pm, Ravikanth  wrote:
> On Jun 15, 11:57 am, Wanderer  wrote:
>
>
>
>
>
>
>
>
>
> > On Jun 15, 12:00 pm, Ravikanth  wrote:
>
> > > On Jun 15, 10:32 am, Wanderer  wrote:
>
> > > > On Jun 15, 11:04 am, Ravikanth  wrote:
>
> > > > > Hi all,
>
> > > > > I am a beginner in python. I need to implement a graph with multiple
> > > > > colors in it.
> > > > > In a way, I have a function which varies with respect to time and
> > > > > amplitude. I have time on x-axis and amplitude on y-axis. Lets say the
> > > > > amplitude of the graph is divided into 4 ranges, say 1-3,3-5,5-9,
> > > > > 10-3. I need to plot the graph in such a way that, when the values of
> > > > > amplitude are in a particular range say 1-3, the color of graph should
> > > > > be red.
> > > > > If the amplitude is in the range from 3-5 the graph need to be in
> > > > > color blue etc..,
>
> > > > > Can somebody guide me on this, how to achive this functionality.
>
> > > > > Regards,
> > > > > Ravikanth
>
> > > > Check out the examples in matplotlib.
>
> > > >http://matplotlib.sourceforge.net/examples/pylab_examples/multicolore...text
> > > > -
>
> > > > - Show quoted text -
>
> > > I did go through the side wanderer.
>
> > > I wasn't able to figure out the usage of boundaryNorm and
> > > lc.set_array(z) , in that link.
> > > according to my understanding,
>
> > > cmap = ListedColormap(['r', 'g', 'b'])
> > > norm = BoundaryNorm([-1, -0.5, 0.5, 1], cmap.N)
>
> > > In the above lines of code, as per my understanding,
> > > Listedcolor map, maps the colors r,g and b to specific indexes into
> > > cmap
> > > i.e cmap(0) represents red,
> > > cmap(1) represents blue
> > > cmap(2) represents green.
> > > for any index greater than 3 a color of blue is returned..
>
> > > >>> cmap = ListedColormap(['r', 'g', 'b'])
> > > >>> cmap(0)
>
> > > (1.0, 0.0, 0.0, 1.0)>>> cmap(1)
>
> > > (0.0, 0.5, 0.0, 1.0)>>> cmap(2)
>
> > > (0.0, 0.0, 1.0, 1.0)>>> cmap(3)
>
> > > (0.0, 0.0, 1.0, 1.0)
>
> > > In this context, I was not able to understand what does boundaryNorm
> > > does.
> > > We have 3 colors and we are using 4 values as argument in boundaryNorm.
> > > [-1, -0.5, 0.5, 1], the comment reads slope of 'z' is being mapped to
> > > the values in boundary norm. How is it handled.
> > > Does the function call " lc.set_array(z) " does it ?  what is the
> > > exact use of linecollection.set_array(z) in this context.
>
> > > Thanks,
> > > Ravikanth
>
> > The colors are referring to the slope of the line. Change
> > 'lc.set_array(z)' to 'lc.set_array(y)' and it might be easier to
> > understand.  Here are the steps.
>
> > 1. Define the functions x,y and z,
> > 2. Define the colors 'red', 'green' and 'blue' with ListedColorMap
> > 3. Define the three regions, (-1.0 to -0.50, -0.50 to 0.50, 0.50 to
> > 1.0) with BoundaryNorm([-1,-0.50, 0.50,1], cmap.N).
> >    (Why they add the trailing zero in 0.50 and don't change 1 to 1.0;
> > I don't know)
> > 4. Create an array of (x,y) points.
> > 5. Create a collection of tiny segments [(x1,y1),(x2,y2)] and color
> > them with cmap using the boundary rules of norm. lc =
> > LineCollection(segments, cmap=cmap, norm=norm)
> > 6. Use lc.set_array(y) to determine how to color the segments.
> > 7. Plot it.- Hide quoted text -
>
> > - Show quoted text -
>
> Hi Wanderer,
>
> Thanks for your help. It works now.
> Just wanted to know how to go about when I have to do my color mapping
> not only with respect to range of values on y-axis but also based on
> some other conditions as well. i.e, say ( range &&  &&
>  ) where condition1 could be occurance of some event say,
> a flag1 is set true and condition2 may be another flag2 set to false.
> Just wanted to use my color mapping not only based on boundaries but
> also on occurance of other events as well.
> In this context do i have to modify the source of BoundaryNorm in
> matplotlib function...?? Can you give me some insights into this.
>
> Regards,
> Ravikanth

I don't know if there is another way, but I think changing the
lc.set_array input would be the easiest. Each point has an (x,y,z)
where z determines the color by what range it is in. You would use
your conditions to set points in z to the desired color.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: creating a multi colored graph with respect to the values in y-axis

2011-06-15 Thread Ravikanth
On Jun 15, 12:59 pm, Wanderer  wrote:
> On Jun 15, 1:28 pm, Ravikanth  wrote:
>
>
>
>
>
> > On Jun 15, 11:57 am, Wanderer  wrote:
>
> > > On Jun 15, 12:00 pm, Ravikanth  wrote:
>
> > > > On Jun 15, 10:32 am, Wanderer  wrote:
>
> > > > > On Jun 15, 11:04 am, Ravikanth  wrote:
>
> > > > > > Hi all,
>
> > > > > > I am a beginner in python. I need to implement a graph with multiple
> > > > > > colors in it.
> > > > > > In a way, I have a function which varies with respect to time and
> > > > > > amplitude. I have time on x-axis and amplitude on y-axis. Lets say 
> > > > > > the
> > > > > > amplitude of the graph is divided into 4 ranges, say 1-3,3-5,5-9,
> > > > > > 10-3. I need to plot the graph in such a way that, when the values 
> > > > > > of
> > > > > > amplitude are in a particular range say 1-3, the color of graph 
> > > > > > should
> > > > > > be red.
> > > > > > If the amplitude is in the range from 3-5 the graph need to be in
> > > > > > color blue etc..,
>
> > > > > > Can somebody guide me on this, how to achive this functionality.
>
> > > > > > Regards,
> > > > > > Ravikanth
>
> > > > > Check out the examples in matplotlib.
>
> > > > >http://matplotlib.sourceforge.net/examples/pylab_examples/multicolore...-
>
> > > > > - Show quoted text -
>
> > > > I did go through the side wanderer.
>
> > > > I wasn't able to figure out the usage of boundaryNorm and
> > > > lc.set_array(z) , in that link.
> > > > according to my understanding,
>
> > > > cmap = ListedColormap(['r', 'g', 'b'])
> > > > norm = BoundaryNorm([-1, -0.5, 0.5, 1], cmap.N)
>
> > > > In the above lines of code, as per my understanding,
> > > > Listedcolor map, maps the colors r,g and b to specific indexes into
> > > > cmap
> > > > i.e cmap(0) represents red,
> > > > cmap(1) represents blue
> > > > cmap(2) represents green.
> > > > for any index greater than 3 a color of blue is returned..
>
> > > > >>> cmap = ListedColormap(['r', 'g', 'b'])
> > > > >>> cmap(0)
>
> > > > (1.0, 0.0, 0.0, 1.0)>>> cmap(1)
>
> > > > (0.0, 0.5, 0.0, 1.0)>>> cmap(2)
>
> > > > (0.0, 0.0, 1.0, 1.0)>>> cmap(3)
>
> > > > (0.0, 0.0, 1.0, 1.0)
>
> > > > In this context, I was not able to understand what does boundaryNorm
> > > > does.
> > > > We have 3 colors and we are using 4 values as argument in boundaryNorm.
> > > > [-1, -0.5, 0.5, 1], the comment reads slope of 'z' is being mapped to
> > > > the values in boundary norm. How is it handled.
> > > > Does the function call " lc.set_array(z) " does it ?  what is the
> > > > exact use of linecollection.set_array(z) in this context.
>
> > > > Thanks,
> > > > Ravikanth
>
> > > The colors are referring to the slope of the line. Change
> > > 'lc.set_array(z)' to 'lc.set_array(y)' and it might be easier to
> > > understand.  Here are the steps.
>
> > > 1. Define the functions x,y and z,
> > > 2. Define the colors 'red', 'green' and 'blue' with ListedColorMap
> > > 3. Define the three regions, (-1.0 to -0.50, -0.50 to 0.50, 0.50 to
> > > 1.0) with BoundaryNorm([-1,-0.50, 0.50,1], cmap.N).
> > >    (Why they add the trailing zero in 0.50 and don't change 1 to 1.0;
> > > I don't know)
> > > 4. Create an array of (x,y) points.
> > > 5. Create a collection of tiny segments [(x1,y1),(x2,y2)] and color
> > > them with cmap using the boundary rules of norm. lc =
> > > LineCollection(segments, cmap=cmap, norm=norm)
> > > 6. Use lc.set_array(y) to determine how to color the segments.
> > > 7. Plot it.- Hide quoted text -
>
> > > - Show quoted text -
>
> > Hi Wanderer,
>
> > Thanks for your help. It works now.
> > Just wanted to know how to go about when I have to do my color mapping
> > not only with respect to range of values on y-axis but also based on
> > some other conditions as well. i.e, say ( range &&  &&
> >  ) where condition1 could be occurance of some event say,
> > a flag1 is set true and condition2 may be another flag2 set to false.
> > Just wanted to use my color mapping not only based on boundaries but
> > also on occurance of other events as well.
> > In this context do i have to modify the source of BoundaryNorm in
> > matplotlib function...?? Can you give me some insights into this.
>
> > Regards,
> > Ravikanth
>
> I don't know if there is another way, but I think changing the
> lc.set_array input would be the easiest. Each point has an (x,y,z)
> where z determines the color by what range it is in. You would use
> your conditions to set points in z to the desired color.- Hide quoted text -
>
> - Show quoted text -

does (x,y,z) mean adding another dimension 'z' (which is to be used as
a condition) to the step 4) as suggested in the steps outlined to me
before ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to form a dict out of a string by doing regex ?

2011-06-15 Thread Terry Reedy

On 6/15/2011 10:42 AM, Satyajit Sarangi wrote:



data = "GEOMETRYCOLLECTION (POINT (-8.96484375
-4.130859375000), POINT (2.021484375000 -2.63671875),
POINT (-1.40625000 -11.162109375000), POINT
(-11.95312500,-10.89843750), POLYGON
((-21.62109375 1.845703125000,2.46093750
2.197265625000, -18.98437500 -3.69140625,
-22.67578125 -3.33984375, -22.14843750
-2.63671875, -21.62109375
1.845703125000)),LINESTRING (-11.95312500
11.337890625000, 7.73437500 11.513671875000,
12.30468750 2.548828125000, 12.216796875000
1.669921875000, 14.501953125000 3.955078125000))"

This is my string .


If this what you are given by an unchangable external source or can you 
get something a bit better? One object per line would make the problem 
pretty simple, with no regex required.



How do I traverse through it and form 3 dicts of Point , Polygon and
Linestring containing the co-ordinates ?


Dicts map keys to values. I do not see any key values above. It looks 
like you really want three sets.



--
Terry Jan Reedy

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


Re: creating a multi colored graph with respect to the values in y-axis

2011-06-15 Thread Wanderer
On Jun 15, 2:10 pm, Ravikanth  wrote:
> On Jun 15, 12:59 pm, Wanderer  wrote:
>
>
>
>
>
>
>
>
>
> > On Jun 15, 1:28 pm, Ravikanth  wrote:
>
> > > On Jun 15, 11:57 am, Wanderer  wrote:
>
> > > > On Jun 15, 12:00 pm, Ravikanth  wrote:
>
> > > > > On Jun 15, 10:32 am, Wanderer  wrote:
>
> > > > > > On Jun 15, 11:04 am, Ravikanth  wrote:
>
> > > > > > > Hi all,
>
> > > > > > > I am a beginner in python. I need to implement a graph with 
> > > > > > > multiple
> > > > > > > colors in it.
> > > > > > > In a way, I have a function which varies with respect to time and
> > > > > > > amplitude. I have time on x-axis and amplitude on y-axis. Lets 
> > > > > > > say the
> > > > > > > amplitude of the graph is divided into 4 ranges, say 1-3,3-5,5-9,
> > > > > > > 10-3. I need to plot the graph in such a way that, when the 
> > > > > > > values of
> > > > > > > amplitude are in a particular range say 1-3, the color of graph 
> > > > > > > should
> > > > > > > be red.
> > > > > > > If the amplitude is in the range from 3-5 the graph need to be in
> > > > > > > color blue etc..,
>
> > > > > > > Can somebody guide me on this, how to achive this functionality.
>
> > > > > > > Regards,
> > > > > > > Ravikanth
>
> > > > > > Check out the examples in matplotlib.
>
> > > > > >http://matplotlib.sourceforge.net/examples/pylab_examples/multicolore...
>
> > > > > > - Show quoted text -
>
> > > > > I did go through the side wanderer.
>
> > > > > I wasn't able to figure out the usage of boundaryNorm and
> > > > > lc.set_array(z) , in that link.
> > > > > according to my understanding,
>
> > > > > cmap = ListedColormap(['r', 'g', 'b'])
> > > > > norm = BoundaryNorm([-1, -0.5, 0.5, 1], cmap.N)
>
> > > > > In the above lines of code, as per my understanding,
> > > > > Listedcolor map, maps the colors r,g and b to specific indexes into
> > > > > cmap
> > > > > i.e cmap(0) represents red,
> > > > > cmap(1) represents blue
> > > > > cmap(2) represents green.
> > > > > for any index greater than 3 a color of blue is returned..
>
> > > > > >>> cmap = ListedColormap(['r', 'g', 'b'])
> > > > > >>> cmap(0)
>
> > > > > (1.0, 0.0, 0.0, 1.0)>>> cmap(1)
>
> > > > > (0.0, 0.5, 0.0, 1.0)>>> cmap(2)
>
> > > > > (0.0, 0.0, 1.0, 1.0)>>> cmap(3)
>
> > > > > (0.0, 0.0, 1.0, 1.0)
>
> > > > > In this context, I was not able to understand what does boundaryNorm
> > > > > does.
> > > > > We have 3 colors and we are using 4 values as argument in 
> > > > > boundaryNorm.
> > > > > [-1, -0.5, 0.5, 1], the comment reads slope of 'z' is being mapped to
> > > > > the values in boundary norm. How is it handled.
> > > > > Does the function call " lc.set_array(z) " does it ?  what is the
> > > > > exact use of linecollection.set_array(z) in this context.
>
> > > > > Thanks,
> > > > > Ravikanth
>
> > > > The colors are referring to the slope of the line. Change
> > > > 'lc.set_array(z)' to 'lc.set_array(y)' and it might be easier to
> > > > understand.  Here are the steps.
>
> > > > 1. Define the functions x,y and z,
> > > > 2. Define the colors 'red', 'green' and 'blue' with ListedColorMap
> > > > 3. Define the three regions, (-1.0 to -0.50, -0.50 to 0.50, 0.50 to
> > > > 1.0) with BoundaryNorm([-1,-0.50, 0.50,1], cmap.N).
> > > >    (Why they add the trailing zero in 0.50 and don't change 1 to 1.0;
> > > > I don't know)
> > > > 4. Create an array of (x,y) points.
> > > > 5. Create a collection of tiny segments [(x1,y1),(x2,y2)] and color
> > > > them with cmap using the boundary rules of norm. lc =
> > > > LineCollection(segments, cmap=cmap, norm=norm)
> > > > 6. Use lc.set_array(y) to determine how to color the segments.
> > > > 7. Plot it.- Hide quoted text -
>
> > > > - Show quoted text -
>
> > > Hi Wanderer,
>
> > > Thanks for your help. It works now.
> > > Just wanted to know how to go about when I have to do my color mapping
> > > not only with respect to range of values on y-axis but also based on
> > > some other conditions as well. i.e, say ( range &&  &&
> > >  ) where condition1 could be occurance of some event say,
> > > a flag1 is set true and condition2 may be another flag2 set to false.
> > > Just wanted to use my color mapping not only based on boundaries but
> > > also on occurance of other events as well.
> > > In this context do i have to modify the source of BoundaryNorm in
> > > matplotlib function...?? Can you give me some insights into this.
>
> > > Regards,
> > > Ravikanth
>
> > I don't know if there is another way, but I think changing the
> > lc.set_array input would be the easiest. Each point has an (x,y,z)
> > where z determines the color by what range it is in. You would use
> > your conditions to set points in z to the desired color.- Hide quoted text -
>
> > - Show quoted text -
>
> does (x,y,z) mean adding another dimension 'z' (which is to be used as
> a condition) to the step 4) as suggested in the steps outlined to me
> before ?

In the matplotlib example they x,y and z.

x = np.linspace(0, 3 * np.pi, 500)
y = np.sin(x)
z = np.cos(

Re: creating a multi colored graph with respect to the values in y-axis

2011-06-15 Thread Ravikanth
On Jun 15, 1:59 pm, Wanderer  wrote:
> On Jun 15, 2:10 pm, Ravikanth  wrote:
>
>
>
>
>
> > On Jun 15, 12:59 pm, Wanderer  wrote:
>
> > > On Jun 15, 1:28 pm, Ravikanth  wrote:
>
> > > > On Jun 15, 11:57 am, Wanderer  wrote:
>
> > > > > On Jun 15, 12:00 pm, Ravikanth  wrote:
>
> > > > > > On Jun 15, 10:32 am, Wanderer  wrote:
>
> > > > > > > On Jun 15, 11:04 am, Ravikanth  wrote:
>
> > > > > > > > Hi all,
>
> > > > > > > > I am a beginner in python. I need to implement a graph with 
> > > > > > > > multiple
> > > > > > > > colors in it.
> > > > > > > > In a way, I have a function which varies with respect to time 
> > > > > > > > and
> > > > > > > > amplitude. I have time on x-axis and amplitude on y-axis. Lets 
> > > > > > > > say the
> > > > > > > > amplitude of the graph is divided into 4 ranges, say 
> > > > > > > > 1-3,3-5,5-9,
> > > > > > > > 10-3. I need to plot the graph in such a way that, when the 
> > > > > > > > values of
> > > > > > > > amplitude are in a particular range say 1-3, the color of graph 
> > > > > > > > should
> > > > > > > > be red.
> > > > > > > > If the amplitude is in the range from 3-5 the graph need to be 
> > > > > > > > in
> > > > > > > > color blue etc..,
>
> > > > > > > > Can somebody guide me on this, how to achive this functionality.
>
> > > > > > > > Regards,
> > > > > > > > Ravikanth
>
> > > > > > > Check out the examples in matplotlib.
>
> > > > > > >http://matplotlib.sourceforge.net/examples/pylab_examples/multicolore...
>
> > > > > > > - Show quoted text -
>
> > > > > > I did go through the side wanderer.
>
> > > > > > I wasn't able to figure out the usage of boundaryNorm and
> > > > > > lc.set_array(z) , in that link.
> > > > > > according to my understanding,
>
> > > > > > cmap = ListedColormap(['r', 'g', 'b'])
> > > > > > norm = BoundaryNorm([-1, -0.5, 0.5, 1], cmap.N)
>
> > > > > > In the above lines of code, as per my understanding,
> > > > > > Listedcolor map, maps the colors r,g and b to specific indexes into
> > > > > > cmap
> > > > > > i.e cmap(0) represents red,
> > > > > > cmap(1) represents blue
> > > > > > cmap(2) represents green.
> > > > > > for any index greater than 3 a color of blue is returned..
>
> > > > > > >>> cmap = ListedColormap(['r', 'g', 'b'])
> > > > > > >>> cmap(0)
>
> > > > > > (1.0, 0.0, 0.0, 1.0)>>> cmap(1)
>
> > > > > > (0.0, 0.5, 0.0, 1.0)>>> cmap(2)
>
> > > > > > (0.0, 0.0, 1.0, 1.0)>>> cmap(3)
>
> > > > > > (0.0, 0.0, 1.0, 1.0)
>
> > > > > > In this context, I was not able to understand what does boundaryNorm
> > > > > > does.
> > > > > > We have 3 colors and we are using 4 values as argument in 
> > > > > > boundaryNorm.
> > > > > > [-1, -0.5, 0.5, 1], the comment reads slope of 'z' is being mapped 
> > > > > > to
> > > > > > the values in boundary norm. How is it handled.
> > > > > > Does the function call " lc.set_array(z) " does it ?  what is the
> > > > > > exact use of linecollection.set_array(z) in this context.
>
> > > > > > Thanks,
> > > > > > Ravikanth
>
> > > > > The colors are referring to the slope of the line. Change
> > > > > 'lc.set_array(z)' to 'lc.set_array(y)' and it might be easier to
> > > > > understand.  Here are the steps.
>
> > > > > 1. Define the functions x,y and z,
> > > > > 2. Define the colors 'red', 'green' and 'blue' with ListedColorMap
> > > > > 3. Define the three regions, (-1.0 to -0.50, -0.50 to 0.50, 0.50 to
> > > > > 1.0) with BoundaryNorm([-1,-0.50, 0.50,1], cmap.N).
> > > > >    (Why they add the trailing zero in 0.50 and don't change 1 to 1.0;
> > > > > I don't know)
> > > > > 4. Create an array of (x,y) points.
> > > > > 5. Create a collection of tiny segments [(x1,y1),(x2,y2)] and color
> > > > > them with cmap using the boundary rules of norm. lc =
> > > > > LineCollection(segments, cmap=cmap, norm=norm)
> > > > > 6. Use lc.set_array(y) to determine how to color the segments.
> > > > > 7. Plot it.- Hide quoted text -
>
> > > > > - Show quoted text -
>
> > > > Hi Wanderer,
>
> > > > Thanks for your help. It works now.
> > > > Just wanted to know how to go about when I have to do my color mapping
> > > > not only with respect to range of values on y-axis but also based on
> > > > some other conditions as well. i.e, say ( range &&  &&
> > > >  ) where condition1 could be occurance of some event say,
> > > > a flag1 is set true and condition2 may be another flag2 set to false.
> > > > Just wanted to use my color mapping not only based on boundaries but
> > > > also on occurance of other events as well.
> > > > In this context do i have to modify the source of BoundaryNorm in
> > > > matplotlib function...?? Can you give me some insights into this.
>
> > > > Regards,
> > > > Ravikanth
>
> > > I don't know if there is another way, but I think changing the
> > > lc.set_array input would be the easiest. Each point has an (x,y,z)
> > > where z determines the color by what range it is in. You would use
> > > your conditions to set points in z to the desired color.- Hide quoted 
> > > text -
>
> > 

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-15 Thread Ian Kelly
On Tue, Jun 14, 2011 at 12:11 AM, Xah Lee  wrote:
> numerical keypad is useful to many. Most people can't touch type. Even
> for touch typist, many doesn't do the number keys. So, when they need
> to type credit, phone number, etc, they go for the number pad.

It's not about being *able* to touch type with the number keys in the
main section.  When you're doing primarily numerical data entry, the
number pad is typically much faster to touch type with than the main
number keys.  In the main section, the number keys are too far removed
from the home row to be able to type with any speed, and if you
reposition your hands directly above them then the Enter, decimal, and
Shift keys are no longer easily accessible.  Touch typing on the
number pad gives you everything you're likely to need in easy reach of
your right hand, and if you need something else as well then your left
hand is free to hover over it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for Coders or Testers for an Open Source File Organizer

2011-06-15 Thread zainul franciscus
On Jun 16, 2:53 am, Zach Dziura  wrote:
> Also, can I be added to the project? Email is zcdzi...@gmail.com

Thank you for the interest, I have added you as one of the committer.
Let me know if you have any problem with the application, just IM me
at gtalk, or email me. I am located in Wellington, New Zealand, so
there might be some lag in our communication. I shall try to answer
any of your questions as prompt as possible =)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for Coders or Testers for an Open Source File Organizer

2011-06-15 Thread zainul franciscus
On Jun 16, 2:49 am, Zach Dziura  wrote:
> On Jun 14, 8:22 pm, zainul franciscus 
> wrote:
>
> > Thank you for the reply. I should have mentioned where I am hosting
> > the code *doh slap on the wrist.
>
> > I am hosting the code in google 
> > code:http://code.google.com/p/mirandafileorganizer/
>
> > There is a link to the user/developer guide on how to get started with
> > the 
> > software:https://docs.google.com/document/d/1OGvrS5offb27WlkZ5genMJX2El18Aqrnf...
>
> > Just email me directly if you are interested to join the project and I
> > will add you as a contributor in Google Code
>
> > Best Wishes
>
> Sounds good, I shall take a look at it when I get home from work. (The
> Google Docs domain is blocked here. Curses!)
>
> Just as a tip: on the project's homepage, just write about your
> project and what it's features are. Don't write in the first person.
> This isn't about you, it's about the project. O=)

Thank you for the feedback, I really appreciate it =)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for Web

2011-06-15 Thread geremy condra
On Wed, Jun 15, 2011 at 5:11 AM, bruno.desthuilli...@gmail.com
 wrote:
> On Jun 15, 9:50 am, sidRo  wrote:
>> Is Python only for server side?
>
> Is it a theoretical question or a practical one ?-)
>
> More seriously: except for the old proof-of-concept Grail browser, no
> known browser uses Python as a client-side scripting language.

Not quite the same thing, but there's pyjamas.

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


os.path and Path

2011-06-15 Thread Ethan Furman
In my continuing quest for Python Mastery (and because I felt like it ;) 
I decided to code a Path object so I could dispense with all the 
os.path.join and os.path.split and os.path.splitext, etc., etc., and so 
forth.


While so endeavoring a couple threads came back and had a friendly 
little chat in my head:


Thread 1: "objects of different types compare unequal"
self: "nonsense!  we have the power to say what happens in __eq__!"

Thread 2: "objects that __hash__ the same *must* compare __eq__!"
self: "um, what? ... wait, only immutable objects hash..."

Thread 2: "you're Path object is immutable..."
self: "argh!"

Here's the rub:  I'm on Windows (yes, pity me...) but I prefer the 
unices, so I'd like to have / seperate my paths.  But I'm on Windows...


So I thought, "Hey!  I'll just do some conversions in __eq__ and life 
will be great!"


--> some_path = Path('/source/python/some_project')
--> some_path == '/source/python/some_project'
True
--> some_path == r'\source\python\some_project'
True
--> # if on a Mac
--> some_path == ':source:python:some_project'
True
--> # oh, and because I'm on Windows with case-insensitive file names...
--> some_path == '/source/Python/some_PROJECT'
True

And then, of course, the ghosts of threads past came and visited.  For 
those that don't know, the __hash__ must be the same if __eq__ is the 
same because __hash__ is primarily a shortcut for __eq__ -- this is 
important when you have containers that are relying on this behavior, 
such as set() and dict().


So, I suppose I shall have to let go of my dreams of

--> Path('/some/path/and/file') == '\\some\\path\\and\\file'

and settle for

--> Path('...') == Path('...')

but I don't have to like it.  :(



~Ethan~

What, you didn't see the opening 'whine' tag?  Oh, well, my xml isn't 
very good... ;)

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


Trapping MySQLdb warnings

2011-06-15 Thread Tim Johnson
Using Python 2.6.5 on linux.

When using MySQLdb I am getting warnings printed to stdout, but I would
like to trap, display and log those warnings.

In the past I have used _mysql_exceptions.Warning, but that approach
is not working in this case.

My cursor is created with the relevant following code:

## connection object
self.__conn = MySQLdb.connect(db = self.__db,
  host = self.__host, user = self.__user,
  passwd = self.__passwd)

## cursor object
self.__rdb = self.__conn.cursor()
## And implemented as :
try :
self.__rdb.execute(S)
except _mysql_exceptions.Warning,e:
raise e ## replace with log(e)

What else needs to be done?
TIA
-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Trapping MySQLdb warnings

2011-06-15 Thread geremy condra
On Wed, Jun 15, 2011 at 6:58 PM, Tim Johnson  wrote:
> Using Python 2.6.5 on linux.
>
> When using MySQLdb I am getting warnings printed to stdout, but I would
> like to trap, display and log those warnings.
>
> In the past I have used _mysql_exceptions.Warning, but that approach
> is not working in this case.
>
> My cursor is created with the relevant following code:
>
> ## connection object
> self.__conn = MySQLdb.connect(db = self.__db,
>  host = self.__host, user = self.__user,
>  passwd = self.__passwd)
>
> ## cursor object
> self.__rdb = self.__conn.cursor()
> ## And implemented as :
> try :
>    self.__rdb.execute(S)
> except _mysql_exceptions.Warning,e:
>    raise e ## replace with log(e)
>
> What else needs to be done?

Have you tried 
http://docs.python.org/library/warnings.html#temporarily-suppressing-warnings
?

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


pycurl and MAX_RECV_SPEED_LARGE

2011-06-15 Thread Emanuel dos Reis Rodrigues

Hello Folks,


I have a problem with pycurl. I need to do a download with a lower rate, 
+ or - 1 Kb / 128bytes.


I use the  MAX_RECV_SPEED_LARGE setting with 128 as value.

My problem is:  The download take a long time to be finished.

File:  test.jpg 92 KB, with 128 rate,  take 2.38 Minutes.

The strange behavior is that:   The connection keep ESTABLISHED only 1/5 
from all time ( 2.38 minutes )



Analyzing with wireshark, I see that: After pass 1/5 of all time, do not 
change packages anymore until reach 2.38 minutes, and client send a RST ACK.


Have a high delay between the transfer and the finished connection.


I need to solution that I can download with a lower rate, include using 
Multi-Threading with many simultaneous downloads.




Follow my test code:


import pycurl
import random
import os



def download1(t_url):
headers = [
   'Accept: 
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',

   'Accept-Language: en-us,pt-br;q=0.8,pt;q=0.5,en;q=0.3',
   'Accept-Encoding: gzip,deflate',
   'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7',
   'Cache-control: no-cache',
   'Pragma: no-cache',
   'Connection: Keep-Alive',
   'Keep-Alive: 300']

c = pycurl.Curl()
f = "/tmp/teste.tmp"
c.setopt(c.URL, t_url)
   c.setopt(c.FAILONERROR, 1)
#   c.setopt(c.VERBOSE, 1)
c.setopt(c.MAX_RECV_SPEED_LARGE, 128)
#c.setopt(c.TIMEOUT, timeout)
c.setopt(c.NOSIGNAL, 1)
c.setopt(pycurl.HTTPHEADER, headers)
c.setopt(c.CONNECTTIMEOUT,10)
c.setopt(c.WRITEDATA, file(f,"w"))
c.setopt(c.USERAGENT,"XADASSDASDASD")
try:
c.perform()
except pycurl.error:
print "Connection Problem"
c.close()
return 2
else:
print "Download Complete"
print f
c.close()
return 0

download1("http://192.168.111.128/teste.jpg";)


Thank You.

Emanuel





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


Re: Trapping MySQLdb warnings

2011-06-15 Thread Tim Johnson
* geremy condra  [110615 18:03]:
> On Wed, Jun 15, 2011 at 6:58 PM, Tim Johnson  wrote:
> > Using Python 2.6.5 on linux.
> >
> > When using MySQLdb I am getting warnings printed to stdout, but I would
> > like to trap, display and log those warnings.
<.> 
> Have you tried 
> http://docs.python.org/library/warnings.html#temporarily-suppressing-warnings
  Hi Geremy:
  I just looked at the docs there. This is a new module (to me), and
  I am unsure of the implementation or whether this is what I should
  use. 
  I tried the following :
try :
self.__rdb.execute(S)
except warnings.catch_warnings:
std.mrk('',0,"mysql.py:196")  ## DEBUG call 
## and it does not look like my code modification
## is catching the warning.
Thanks for introducing me to this new module, but I'm not
sure if it is what I should be using.

BTW: End of day in this part of the world. I look forward to any other comments
on this subject tomorrow.
chees
-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list