Re: C#3.0 and lambdas

2005-09-23 Thread Ganesan Rajagopal
>>>>> "Fredrik" == Fredrik Lundh <[EMAIL PROTECTED]> writes:

> Reinhold Birkenfeld wrote:
>>> And I think the discussion that followed proved your point perfectly
>>> Fredrik. Big discussion over fairly minor things, but no "big picture".
>>> Where are the initiatives on the "big stuff" (common documentation
>>> format, improved build system, improved web modules, reworking the
>>> standard library to mention a few)  Hey, even Ruby is passing us here.
>> 
>> This is Open Source. If you want an initiative, start one.

> you know, this "you have opinions? fuck off!" attitude isn't really
> helping.

I agree. I am a lurker in this list and the python-devel list and I've also
noticed that increasingly big discussions happen over fairly minor
things. Python's DB API is still stuck at 2.0 and we can't even agree on a
single parameter style while C# is innovating and moving ahead with the "big
picture" stuff.

I mean who really cares what's the exact syntax for the ternary
operator. Python's white space significance was a shock when I first learnt
python. I have learnt to live with it because there are a lot other things
to like about the language. I'll live with whatever final decision on the
ternary syntax or whether "and" and "or" should a boolean or the last
expression. 

I'd like to see the DB API move forward, and experimental new innovations
like static typing (with automatic type inferencing), stackless python
etc. If the experiments don't survive, fine. It's still better than
quibbling over minor syntactic detail.

Ganesan


-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com

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


Re: C#3.0 and lambdas

2005-09-23 Thread Ganesan Rajagopal
>>>>> A M Kuchling <[EMAIL PROTECTED]> writes:

> The group of committers is a diverse group of people, and not every one of
> them uses a relational database; that effort would be better done on the
> DB-SIG mailing list, because the people there presumably do all use an
> RDBMS.  (Now, if you wanted to include SQLite in core Python, that *would*
> be a python-dev topic, and ISTR it's been brought up in the past.) 

I would definitely love to see SQLite included in core python. I am a Unix
systems/networking programmer myself. Just like the fact that everything
looks like a database programmers to most database, I've observed that the
reverse is true for non database programmers. In other words, most non RDMS
normally don't think of a database even the solution screams for a
database. I think SQLite does an amazing job in bridging this gap. 

> Agreed; python-dev has gotten pretty boring with all the endless discussions
> over some minor point.  Of course, it's much easier and lower-effort to
> propose a syntax or nitpick a small point issue than to tackle a big
> complicated issue like static typing.  

You have a point there :-). 

> Similar things happen on the catalog SIG: people suggest, or even
> implement, an automatic package management system, But bring up the
> question of whether it should be called PyPI or Cheeseshop or the Catalog,
> and *everyone* can make a suggestion.

My memory may not be perfect but I remember reading that Python 2.5's focus
is libraries and no language changes. If that's correct, I can understand
why core python folks are more interested in discussing language features
for Python 3000 ;-). Speaking of libraries, I haven't seen many discussions
on libraries in python-dev. Is there some other list with more discussions
on libraries?  

Ganesan

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com

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


Re: popen4

2005-10-18 Thread Ganesan Rajagopal
>>>>> "billie" == billie  <[EMAIL PROTECTED]> writes:

> Piet van Oostrum wrote:
>> I think you need something like pyexpect for this.

> PyExpect seems to be no more mantained.

Try pexpect instead. http://pexpect.sourceforce.net/

Ganesan

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com

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


Re: hello, I want to change n bytes of a binary file

2005-11-02 Thread Ganesan Rajagopal
>>>>> "Fredrik" == Fredrik Lundh <[EMAIL PROTECTED]> writes:

> if you want to XOR the bytes, you can do something like:

> import array
> b = array.array("B", a)
> for i in range(len(b)):
> b[i] = b[i] ^ 255
> b = b.tostring()

> or

> b = "".join([chr(ord(c) ^ 255) for c in a])

I wish python would soon get a byte array type. For now I find numarray to
be very convenient to do stuff like this.

import numarray
b = (numarray.array(a, type = 'u1') ^ 255).tostring()

It's also significantly faster for large byte array sizes.

Ganesan

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com

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


Re: Flat file, Python accessible database?

2005-11-02 Thread Ganesan Rajagopal
>>>>> "Peter" == Peter Hansen <[EMAIL PROTECTED]> writes:

> Karlo Lozovina wrote:
>> [EMAIL PROTECTED] (=?utf-8?Q?Bj=C3=B6rn_Lindstr=C3=B6m?=) wrote
>> in news:[EMAIL PROTECTED]:
>> 
>>> If you need it to be SQL-like, SQLite seems to be the right thing.
>> Tried that one, but had some problems setting things up. On the
>> other hand, BerkeleyDB + Pybsddb worked like a charm, with no
>> setting up (under Cygwin).

> I'm very curious what problems you had.  In my experience SQLite
> requires *nothing* I'd call "setup".  You install Pysqlite or APSW,
> write your code, and it runs and works.  

I imagine that's the "setup" OP is talking about. You need to install it
separately as opposed to bsddb. I wish SQLite is bundled with Python 2.5. To
the OP, you could try gadfly (http://gadfly.sourceforge.net/gadfly.html) or
KirbyBase (http://www.netpromi.com/kirbybase.html) but they are also
separate packages to install. I would personally stick with SQLite.

Ganesan

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com

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


Re: Hi, from my login i want to login as a other user ,

2005-11-10 Thread Ganesan Rajagopal
>>>>> sumi  <[EMAIL PROTECTED]> writes:

> Hi, i am very new to python , it is just 2 days i started reading abt
> it. I did not understand the above statement.  

Just read the document at the URL given to you.

> what i want to do is , i want to login as a super user eg : $su xyz , and
> then i need to enter the passwd, i want to do these steps using python ,
> how can i do it??

This is a slightly better description of the problem. However it's still not
clear what exactly you want to achieve. Do you need to continue running your
python script as the new user? Or do you want to run other commands as teh
new user? In any case, take a look at pexpect
(http://pexpect.sourceforge.net) and see if it fits your purpose.

Ganesan

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com


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


Re: Why are there no ordered dictionaries?

2005-11-22 Thread Ganesan Rajagopal
>>>>> [EMAIL PROTECTED] com <[EMAIL PROTECTED]> writes:  > what would be 
the definition of "sorted" and "ordered", before we can > go on ? 
Sorted would be ordered by key comparison. Iterating over such a 
container will give you the keys in sorted order. Java calls this 
a SortedMap. See 
http://java.sun.com/j2se/1.4.2/docs/api/java/util/SortedMap.html 
C++ STL map container is also a Sorted Associative container. See 
http://www.sgi.com/tech/stl/Map.html  Ganesan 

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key:
1024D/5D8C12EA Web: http://employees.org/~rganesan|
http://rganesan.blogspot.com


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


Re: Why are there no ordered dictionaries?

2005-11-22 Thread Ganesan Rajagopal
 
>>>>> Alex Martelli <[EMAIL PROTECTED]> writes:  > Ordered 
*by order of key insertion*: Java, PHP > Ordered *by other 
criteria*: LISP, C++  Java supports both ordered by key insertion 
(LinkedHashMap) as well as ordered by key comparison (TreeMap). 
Ganesan 

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key:
1024D/5D8C12EA Web: http://employees.org/~rganesan|
http://rganesan.blogspot.com


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


Re: pexpect question....

2005-07-02 Thread Ganesan Rajagopal
>>>>> "[EMAIL PROTECTED]" == [EMAIL PROTECTED] com <[EMAIL PROTECTED]> writes:

> Hi,
> I am using pexpect to spawn an interactive program and wait for
> particular string in its output. It works fine but once I get this
> required information, I really don't care about the child process
> anymore. I would effectively want to "detach" from it. 

How about just calling close(), i.e. without wait=1? No need to spawn a new
thread. 

Ganesan

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com

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


Re: Why Python does *SLICING* the way it does??

2005-04-19 Thread Ganesan Rajagopal
>>>>> "[EMAIL PROTECTED]" == [EMAIL PROTECTED] navy mil <[EMAIL PROTECTED]> 
>>>>> writes:

> Many people I know ask why Python does slicing the way it does.
> Can anyone /please/ give me a good defense/justification???

Try http://www.everything2.com/index.pl?node_id=1409551

Ganesan

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com

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


Re: how to convert string like '\u5927' to unicode string u'\u5927'

2005-12-27 Thread Ganesan Rajagopal
>>>>> "Chris" == Chris Song <[EMAIL PROTECTED]> writes:

> Here's my solution
> _unicodeRe = re.compile("(\\\u[\da-f]{4})")
> def unisub(mo):
>   return unichr(int(mo.group(1)[2:],16))

> unicodeStrFromNetwork = '\u5927'
> unicodeStrNative = _unicodeRe(unisub, unicodeStrFromNetwork)

How about unicodeStrNative = eval("u'%s'" % (unicodeStrFromNetwork,))

Ganesan

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com


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


Re: how to convert string like '\u5927' to unicode string u'\u5927'

2005-12-27 Thread Ganesan Rajagopal
>>>>> "Fredrik" == Fredrik Lundh <[EMAIL PROTECTED]> writes:

> Ganesan Rajagopal wrote:
>>> unicodeStrFromNetwork = '\u5927'
>>> unicodeStrNative = _unicodeRe(unisub, unicodeStrFromNetwork)
>> 
>> How about unicodeStrNative = eval("u'%s'" % (unicodeStrFromNetwork,))

> unicodeStrFromNetwork = "' + str(__import__('os').system('really bad idea')) 
> + '"

Thanks for the warning. I should really know better! *blush* 

Ganesan

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com


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


Re: Regex anomaly

2006-01-02 Thread Ganesan Rajagopal
>>>>> mike klaas <[EMAIL PROTECTED]> writes:

> In [48]: import re
> In [49]: reStr = r"([a-z]+)://"
> In [51]: against = "http://www.hello.com";
> In [53]: re.match(reStr, against).groups()
> Out[53]: ('http',)
> In [54]: re.match(reStr, against, re.I).groups()
> Out[54]: ('http',)
> In [55]: reCompiled = re.compile(reStr)
> In [56]: reCompiled.match(against).groups()
> Out[56]: ('http',)
> In [57]: reCompiled.match(against, re.I).groups()
> Out[57]: ('tp',)

I can reproduce this on Debian Linux testing, both python 2.3 and python
2.4. Seems like a bug. search() also exhibits the same behavior.

Ganesan


-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com


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


Re: Regex anomaly

2006-01-02 Thread Ganesan Rajagopal
>>>>> mike klaas <[EMAIL PROTECTED]> writes:

> Thanks guys, that is probably the most ridiculous mistake I've made in
> years 

I was taken too :-). This is quite embarassing, considering that I remember
reading a big thread in python devel list about this a while back!

Ganesan

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com


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


Re: [OT] How can I change Debian's default Python version?

2006-01-04 Thread Ganesan Rajagopal
>>>>> Franz GEIGER <[EMAIL PROTECTED]> writes:

> Now, when I install Python packages using the convenient Synaptic Package
> Manager, everything goes into the 2.3-directory-tree. How can I change
> that?

That's because synaptic installs packages compiled for the default debian
python. You have two alternatives:

1. Compile the python packages manually.
2. Debian already has python 2.4. Install python2.4 using synaptic. Also
   install any required python2.4-* packages. You will need a symlink to
   make sure you get python2.4 by default.

Ganesan


Ganesan



-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com


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


Re: C regex equiv to Python implementation?

2006-01-06 Thread Ganesan Rajagopal
>>>>> techiepundit  <[EMAIL PROTECTED]> writes:

> I've been writing code in Python to prototype part of an application.
> I've used the re regular expression pattern matcher. Now I have to take
> what I've written and recode it in C to fit in an existing C app.

What platform? Linux includes a regex(7) implementation in the C
library. However, it doesn't support many of the extensions that Python
regexes support. Try http://www.pcre.org/. There are pre-build binaries for
Windows also. 

Ganesan

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com


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


Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Ganesan Rajagopal
>>>>> "Terry" == Terry Hancock <[EMAIL PROTECTED]> writes:

> Note that it is trivial to catch collisions on entry and correct them:

> key = hash(url_string)
> i  = 0
> if d.has_key(key):
>while d.has_key(key):
>i += 1

hash is a number. It's sufficient to do

while d.has_key(key):
key += 1
   
> I am a little surprised that hash(hash(s)) == hash(s), is that actually
> true?

>>> hash(42)
42

Ganesan

-- 
Ganesan Rajagopal

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


Re: ctypes wrapping libpam.so on FreeBSD 6.1 - Python Bus Error

2006-07-13 Thread Ganesan Rajagopal
>>>>> "Martin" == Martin P Hellwig <[EMAIL PROTECTED]> writes:

> Now according to OpenPAM documentation all sessions start with pam_start().
> According to the man page it should contain this:
> pam_start(const char *service, const char *user,
>const struct pam_conv *pam_conv, pam_handle_t **pamh)

Note that pam_conv is a structure. Passing a string 'PAM_PROMPT_ECHO_ON' and
not passing a pointer for getting the pam_handle_t are both candidates to
cause a crash. 

Ganesan

-- 
Ganesan Rajagopal

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


Re: Simple file writing techiques ...

2006-07-19 Thread Ganesan Rajagopal
>>>>> cdecarlo  <[EMAIL PROTECTED]> writes:

> fout = open('somefile','w')
> for line in convertedData:
>   fout.write("%s\n" % line)
> fout.close()

>  -- or --

> fout = open('somefile','w')
> fout.write("%s" % '\n'.join(convertedData))
> fout.close()

> ... or maybe some hybrid of the two which writes chunks of the
> convertedData list out in one shot ...

The second option would be definitely faster. 

> An issue that I'm probably most concerned with is scalabitiy, what if
> the file was huge, like some sort of log file. 

Considering that you've already read in the whole file into a list, it's too
late to worry about scalability when writing out :-). Have you considered
the fileinput module?

Ganesan

-- 
Ganesan Rajagopal

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


Re: Memory usage of an 'empty' python interpreter

2006-08-16 Thread Ganesan Rajagopal
>>>>> neokosmos  <[EMAIL PROTECTED]> writes:

> I was wondering what the approximate amount of memory needed to load a
> Python interpreter (only, no objects, no scripts, no nothing else) in a
> Linux 2.6 environment.  According to ps, it appears to be 3312 bytes,
> which seems absurdly low to me.  However, when I check the size of my
> Python executable, it looks like it is only about 5600 bytes in size,
> so maybe this is reasonable?

It is, when you consider that ps reports in kilobytes :-). It's
meaningless just to compare the size of the python binary. In your case it's
obvious that the python binary is linking to a shared python library.

Ganesan

-- 
Ganesan Rajagopal

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


Re: Programmatically finding "significant" data points

2006-11-14 Thread Ganesan Rajagopal
>>>>> Jeremy Sanders <[EMAIL PROTECTED]> writes:

>> How do I sort through this data and pull out these points of
>> significance?

> Get a book on statistics. One idea is as follows. If you expect the points
> to be centred around a single value, you can calculate the median or mean
> of the points, calculate their standard deviation (aka spread), and remove
> points which are more than N-times the standard deviation from the median.

Standard deviation was the first thought that jumped to my mind
too. However, that's not what the OP is after. He's seems to be looking for
points when the direction changes. 

Ganesan

-- 
Ganesan Rajagopal

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


Re: Python 411.

2006-06-13 Thread Ganesan Rajagopal
>>>>> Mike T <[EMAIL PROTECTED]> writes:

> What exactly is 411 in this context?  A reference to higher education
> perhaps?  Or perhaps part of the American constitution? What exactly?
> Also for that matter what is 101?

It's a directory assistance number in the US. The site is a directory of
URLs.

Ganesan

-- 
Ganesan Rajagopal

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


Re: popen and password entry

2006-06-14 Thread Ganesan Rajagopal
>>>>> sinan nalkaya <[EMAIL PROTECTED]> writes:

> i want to use rsync for remote file transfer via popen, but couldnt pass
> the Password yet.

For interactive input try the pexpect module instead of popen (see
http://pexpect.sf.net). 

Ganesan

-- 
Ganesan Rajagopal

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


Re: popen and password entry

2006-06-15 Thread Ganesan Rajagopal
>>>>> Sinan Nalkaya <[EMAIL PROTECTED]> writes:

> hi,
> i have found expect method for this purpose. i`m trying to use pexpect but
> following code gives me an something strange as a result.

When working with pexpect, logging the entire conversation is extremely
useful fro debugging

> import pexpect
> cmd = '/usr/bin/rsync config [EMAIL PROTECTED]:/tmp/.'
> #cmd = 'ssh [EMAIL PROTECTED]'
> child = pexpect.spawn(cmd)

Add "child.logfile = sys.stdout" here and check what's going on.

Ganesan

-- 
Ganesan Rajagopal

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


Re: popen and password entry

2006-06-15 Thread Ganesan Rajagopal
>>>>> sinan nalkaya <[EMAIL PROTECTED]> writes:

> thanks for reply, i add the line you suggested, thats what i get
> [EMAIL PROTECTED]:~/tmp/multi_server$ python deneme.py
> Password: qwe123
> finished

Ah, got it. You didn't wait for the rsync process to complete. Put the body
of the "try:" in a while loop.

Ganesan

-- 
Ganesan Rajagopal

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


Re: popen and password entry

2006-06-15 Thread Ganesan Rajagopal
>>>>> sinan nalkaya <[EMAIL PROTECTED]> writes:

> child.expect(['Password:','Password: ',pexpect.EOF,pexpect.TIMEOUT])
> if i == 0:  child.sendline(passwd)
> elif i == 1:print 1
> elif i == 2:print 2
> elif i == 3:print 3

You don't need the second pattern, the first pattern will catch the second
case also. You also need to break when i == 2 or i == 3. 

Ganesan

-- 
Ganesan Rajagopal

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


Re: How to terminate a main script?

2006-07-11 Thread Ganesan Rajagopal
>>>>> Helmut Jarausch <[EMAIL PROTECTED]> writes:

> Using sys.exit(0) produces an error message which looks dangerous to an
> uninitiated user.

What message? Your program should exit silently when you call sys.exit(0). 

Ganesan

-- 
Ganesan Rajagopal

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


Re: mobile phone app

2006-09-08 Thread Ganesan Rajagopal
>>>>> Aravind  <[EMAIL PROTECTED]> writes:

> Can anyone tell me if python can be used for developing mobile phone apps as
> Java ? If yes, any comparisons ? Also pls tell me where i can get the tools
> and tutorials for the same...

Not in the same league as J2ME, but in some restricted cases, yes. See

http://forum.nokia.com/python

-- 
Ganesan Rajagopal

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


Re: pexpect baudrate and mode settings

2006-09-21 Thread Ganesan Rajagopal
>>>>> Bryce Bolton <[EMAIL PROTECTED]> writes:

> In short, setting of critical parameters is unclear under pexpect's
> documentation, but may be obvious to those more familiar with os.open or
> other filesystem internals.

Try using "stty" program on Linux to set these parameters before you use
pexpect. 

Ganesan

-- 
Ganesan Rajagopal

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


Re: About undisclosed recipient

2006-02-13 Thread Ganesan Rajagopal
>>>>> Liyana Robert <[EMAIL PROTECTED]> writes:

> Pls help me to know About undisclosed recipient.
> How we can sent mails to other like this.

Use Bcc header instead of To or Cc.

Ganesan

-- 
Ganesan Rajagopal



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


Re: pysqlite problem

2006-03-01 Thread Ganesan Rajagopal
>>>>> bapolis  <[EMAIL PROTECTED]> writes:

> con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_COLNAMES)
   ^^
   
Did you really intend this? Since you're opening a database in memory, you
will have access to tbl1 only if you create the table after the connect.

Ganesan

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com


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


Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-02 Thread Ganesan Rajagopal

I am stuck on level 3. I've tried every re that I can think of. Some body
give me a clue. 

Ganesan

-- 
Ganesan Rajagopal


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


Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-02 Thread Ganesan Rajagopal
>>>>> "darren" == darren kirby <[EMAIL PROTECTED]> writes:

> quoth the Ganesan Rajagopal:
>> I am stuck on level 3. I've tried every re that I can think of. Some body
>> give me a clue.
>> 
>> Ganesan
>> 
>> --
>> Ganesan Rajagopal

>>>> t = /text of page source.../
>>>> re.findall('[a-z][A-Z]{3}[a-z]{1}[A-Z]{3}[a-z]', t)

> You should get ten results. Consider all ten together to get your
> solution...

Ah, thanks. I tried having both sides identical, no results. Then I tried
the above re but stopped at the first result :-(.

Ganesan

-- 
Ganesan Rajagopal


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


Re: List objects are un-hashable

2007-04-27 Thread Ganesan Rajagopal
>>>>> "Andy" == Andy  <[EMAIL PROTECTED]> writes:

> if keyword.iskeyword(tempwords):
> print tempwords

  for word in tempwords:
  if keyword.iskeyword(word):
      print word

Ganesan 


-- 
Ganesan Rajagopal

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


Re: Pexpect: SSH, Command and Password

2007-04-04 Thread Ganesan Rajagopal
>>>>> "Gil" == Gil H <[EMAIL PROTECTED]> writes:

> class SSH:
> def __init__(self, user, password, host):
> self.child = pexpect.spawn("ssh [EMAIL PROTECTED]"%(user, 
> host))

Try adding the following line here

self.child.logfile = sys.stdout

That should give you some clue.

Ganesan


-- 
Ganesan Rajagopal

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


Re: Python Feature Request: Explicit variable declarations

2007-04-14 Thread Ganesan Rajagopal
>>>>> "Martin" == Martin v Löwis <[EMAIL PROTECTED]> writes:

> [EMAIL PROTECTED] schrieb:
>> Hello. Please tell me whether this feature request is sane (and not
>> done before) for python so it can be posted to the python-dev mailing
>> list. I should say first that I am not a professional programmer with
>> too much technical knowledge.

> I believe it has been requested before, but I'm too lazy now to search
> for prior discussion. 

I remember the benevolent dictator's blogs on this. Googling for "optional
static typing" brought up these references:

http://www.artima.com/weblogs/viewpost.jsp?thread=85551
http://www.artima.com/weblogs/viewpost.jsp?thread=87182

and an older one:

http://www.python.org/~guido/static-typing/

> The request is sane, but is also incomplete: there
> is no syntax suggested for the actual declarations of local variables,
> and no discussion whether this is meant to apply to local variables
> only, or also to global variables and object attributes.

None of the above links talk about variable declarations but object
attributes are considered. 

Ganesan

-- 
Ganesan Rajagopal

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


Re: maximum number of threads

2007-01-12 Thread Ganesan Rajagopal
>>>>> Felipe Almeida Lessa <[EMAIL PROTECTED]> writes:
>> 
>> to modify the maximum number of user process (AFAIK each thread use a
>> process entry on Linux)

> I don't think it's only this.

It isn't that at all. The default Linux POSIX threads stack size is
8MB. Linux user space is 3GB (Kernel is mapped at upper 1GB). 

382 * 8 = 3056MB.

Basically, you're running out of address space. I don't know if you have any
control at python level. In C you can call pthread_attr_setstacksize(). 

Ganesan

-- 
Ganesan Rajagopal

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


Re: problems loading modules

2007-02-04 Thread Ganesan Rajagopal
>>>>> Frank  <[EMAIL PROTECTED]> writes:

>>>> import random
>>>> from numpy import *
>>>> 
>>>> print random.randrange(10)
> Traceback (most recent call last):
>  File "", line 1, in ?
> AttributeError: 'module' object has no attribute 'randrange'
>>>> 

> Here it does not work.

Here's a clue.

==
>>> import numpy
>>> numpy.random 

===

Ganesan

-- 
Ganesan Rajagopal

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


Re: Convert to binary and convert back to strings

2007-02-21 Thread Ganesan Rajagopal
>>>>> "Harlin" == Harlin Seritt <[EMAIL PROTECTED]> writes:

> I tried doing this:

> text = 'supercalifragilisticexpialidocius'

> open('sambleb.conf', 'wb').write(text)

> Afterwards, I was able to successfully open the file with a text
> editor and it showed:
> 'supercalifragilisticexpialidocius'



> I am hoping to have it show up some weird un-readable text. And then
> of course be able to convert it right back to a string. Is this even
> possible?

Looks like you just want to obfuscate the string. How about this?

import base64
text = 'supercalifragilisticexpialidocius'
open('sambleb.conf', 'w').write(base64.encodestring(text))

print base64.decodestring(open('sambleb.conf', 'r').read())

Ganesan

-- 
Ganesan Rajagopal

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


Re: Convert to binary and convert back to strings

2007-02-21 Thread Ganesan Rajagopal
>>>>> Grant Edwards <[EMAIL PROTECTED]> writes:

>> print base64.decodestring(open('sambleb.conf', 'r').read())

> It'll only remain obfuscated for about 30 seconds after even a
> mildly curious user looks at the file.

It depends on the requirement. If the intention is to just to
discourage someone with messing around with some config
settings, it's good enough. If the user can figure out that
it's base64 encoded and takes pains to decode, modify, encode
and save it back, then he's earned the right to mess around
;-).

Ganesan

-- 
Ganesan Rajagopal

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


Re: memory error with zipfile module

2006-05-19 Thread Ganesan Rajagopal
>>>>> Hari Sekhon <[EMAIL PROTECTED]> writes:

> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "D:\u\Python24\lib\zipfile.py", line 357, in read
> bytes = dc.decompress(bytes)
> MemoryError

Looks like the .iso file is huge. Even if it's only a CD image (approx
650MB), reading it all into memory in a single string is not a good idea.

> The python zipfile module is obviously broken...

Indeed. I am surprised that there is no API that returns a file object.

Ganesan
-- 
Ganesan Rajagopal

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