Refactor/Rewrite Perl code in Python

2011-07-24 Thread Shashwat Anand
I am working with a huge codebase of Perl. The code have zero documentation and zero unit-tests. It seems like a huge hack. The underlying database schema is horrid. So I want to rewrite the whole of it in Python. How do I start ? The idea is to rewrite module by module. But how to make sure code

Re: Refactor/Rewrite Perl code in Python

2011-07-24 Thread Shashwat Anand
Thanks everyone for the insight. I got the idea as to how and where to start. Guess I need to work in Perl for now, so as to start the conversion process. Regarding Tests, I had already started writing tests before posting. Writing tests for every module will be a pain as well as a nice experience.

PUT with proxy-support

2011-08-25 Thread Shashwat Anand
I want to make a PUT request. I need some headers of my own ( certificates etc ) and I need to mandatorily use a proxy. Also the url is of the form http://www.xyz.com/abc and I don't have permission to put data on http://www.xyz.com while I do have permission to put data on http://www.xyz.com/abc

Re: PUT with proxy-support

2011-08-25 Thread Shashwat Anand
On Thu, Aug 25, 2011 at 4:48 PM, Thomas Jollans wrote: > On 25/08/11 13:07, Shashwat Anand wrote: > > I want to make a PUT request. > > I need some headers of my own ( certificates etc ) and I need to > > mandatorily use a proxy. > > Also the url is of the form http://

Re: PUT with proxy-support

2011-08-25 Thread Shashwat Anand
tificates in headers. Did not managed to find all of it. Am not sure is supports REST calls with proxy support. > Sent from my iPhone > > On Aug 25, 2011, at 7:07, Shashwat Anand wrote: > > I want to make a PUT request. > I need some headers of my own ( certificates etc ) and

Re: PUT with proxy-support

2011-08-25 Thread Shashwat Anand
On Thu, Aug 25, 2011 at 5:22 PM, Laszlo Nagy wrote: > ** > > I tried httplib, httplib2, urllib2 with no avail. > I managed to do this via command line curl: > > $ curl http:/xyz.com/testing/shashwat/test.txt -T test.txt -H > "sw-version: 1.0" -H > "CA-Cert-Auth:v=1;a=yxyz.prod;h=10.10.0.1;t=131

Re: PUT with proxy-support

2011-08-26 Thread Shashwat Anand
On Fri, Aug 26, 2011 at 3:15 PM, Laszlo Nagy wrote: > Running pycurl-7.19.0/setup.py -q bdist_egg --dist-dir > /tmp/easy_install-2ZCa8v/**pycurl-7.19.0/egg-dist-tmp-**DyHFls > >> Using curl-config (libcurl 7.12.1) >> src/pycurl.c:42:20: Python.h: No such file or directory >> src/pycurl.c:43:22: p

Common area of circles

2010-02-04 Thread Shashwat Anand
Given 'n' circles and the co-ordinates of their center, and the radius of all being equal i.e. 'one', How can I take out the intersection of their area. hope the picture makes it clear http://imagebin.us/images/p5qeo7hgc3547pnyrb6.gif -- http://mail.python.org/mailman/listinfo/python-list

Re: Common area of circles

2010-02-04 Thread Shashwat Anand
I wanted some general suggestion/tips only On Thu, Feb 4, 2010 at 5:11 PM, Chris Rebert wrote: > On Thu, Feb 4, 2010 at 2:39 AM, Shashwat Anand > wrote: > > Given 'n' circles and the co-ordinates of their center, and the radius of > > all being equal i.e. &

Re: Common area of circles

2010-02-04 Thread Shashwat Anand
y other approach possible. On Thu, Feb 4, 2010 at 5:24 PM, Xavier Ho wrote: > I'm not sure what you're after. Are you after how to calculate the area? Or > are you trying to graph it? Or an analytical solution? > > What do you mean by "take out the intersection"

Re: Common area of circles

2010-02-04 Thread Shashwat Anand
I needed 6 decimal places of accuracy, so first way of solution will not work for my case. However, your second strategy seems promising. Working on it. Thanks :D ~l0nwlf On Thu, Feb 4, 2010 at 5:49 PM, Bearophile wrote: > Shashwat Anand: > > > Given 'n' circles and the

Re: Common area of circles

2010-02-04 Thread Shashwat Anand
thanks, all of you On Thu, Feb 4, 2010 at 7:31 PM, Terry Reedy wrote: > On 2/4/2010 7:05 AM, Shashwat Anand wrote: > >> I want to calculate areas. >> like for two circles (0, 0) and (0, 1) : the output is '1.228370' >> >> similarly my aim is to take

Re: Common area of circles

2010-02-04 Thread Shashwat Anand
e happens with grid approach. On Fri, Feb 5, 2010 at 12:25 AM, Mark Dickinson wrote: > On 2/4/2010 7:05 AM, Shashwat Anand wrote: > > I want to calculate areas. > > like for two circles (0, 0) and (0, 1) : the output is '1.228370' > > > > similarly my aim

Re: Common area of circles

2010-02-05 Thread Shashwat Anand
his line : sol += curve_area(circle[i][0], circle[i][1], hull[-1][0], hull[-1][1], hull[-2][0], hull[-2][1]) Still trying to fix it. ~l0nwlf On Fri, Feb 5, 2010 at 11:48 AM, John Nagle wrote: > Chris Rebert wrote: > >> On Thu, Feb 4, 2010 at 2:39 AM, Shashwat Anand >> wrote

how to fix bugs (python)

2010-02-06 Thread Shashwat Anand
I am interested in fixing bugs in python. Are there entry-level bugs in python which makes me familiarize with the process just like gnome have gnome-love ? Just a small start-up guidance will be a big favour as I have never fixed any. Thanks, ~l0nwlf -- http://mail.python.org/mailman/listinfo/py

Re: how to fix bugs (python)

2010-02-06 Thread Shashwat Anand
Thanks Terry. I am looking on it. :) On Sun, Feb 7, 2010 at 1:19 AM, Terry Reedy wrote: > On 2/6/2010 1:54 PM, Shashwat Anand wrote: > >> I am interested in fixing bugs in python. Are there entry-level bugs in >> python which makes me familiarize with the process just like g

Re: Last M digits of expression A^N

2010-02-06 Thread Shashwat Anand
Yes, it can be done. Have a look at : http://en.wikipedia.org/wiki/Modular_exponentiation The algorithm is also mentioned in CLRS.I tried writing my own modular-exponentiation code following CLRS but observed that python pow() function is much more efficient. Have a look at this problem : https://w

Re: Last M digits of expression A^N

2010-02-06 Thread Shashwat Anand
a nice exercise to do can be this problem : http://www.codechef.com/MARCH09/problems/A4/ , it deals with both cases, first and last k digits and can be performed within O(log n) On Sun, Feb 7, 2010 at 3:58 AM, Shashwat Anand wrote: > Yes, it can be done. Have a look at : >

Re: max / min / smallest float value on Python 2.5

2010-02-06 Thread Shashwat Anand
On Sun, Feb 7, 2010 at 6:22 AM, duncan smith wrote: > Hello, > I'm trying to find a clean and reliable way of uncovering information > about 'extremal' values for floats on versions of Python earlier than 2.6 > (just 2.5 actually). I don't want to add a dependence on 3rd party modules > just

Re: Help with regex search-and-replace (Perl to Python)

2010-02-07 Thread Shashwat Anand
Here is one simple solution : >>> intext = """Lorem [ipsum] dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut [labore] et [dolore] magna aliqua.""" >>> intext.replace('[', '{').replace(']', '}') 'Lorem {ipsum} dolor sit amet, consectetur adipisicing elit, sed do ei

Re: python admin abuse complaint

2010-02-07 Thread Shashwat Anand
LOL pow(funny, sys.maxint) On Sun, Feb 7, 2010 at 6:27 PM, Daniel Fetchinson wrote: > >>> This is a short complaint on admin abuse on #python irc channel on > >>> freenode.net. > >> > >> Let's see, you are complaining about getting banned from #python by > >> CROSS-POSTING between c.l.py and com

Re: Bizarre arithmetic results

2010-02-11 Thread Shashwat Anand
Do you really believe that -0.1 ** 0.1 is a valid computational problem ? Can you raise a negative number to a fractional power ? Output on my console (python 2.6) >>> -.1 ** .1 -0.79432823472428149 >>> a,b = -.1,.1 >>> a**b Traceback (most recent call last): File "", line 1, in ValueError: neg

Re: Bizarre arithmetic results

2010-02-11 Thread Shashwat Anand
0.79432823472428149 since .1 ** .1 = 0.79432823472428149 and minus sign is appended prior to it. On Thu, Feb 11, 2010 at 6:01 PM, Shashwat Anand wrote: > Do you really believe that -0.1 ** 0.1 is a valid computational problem ? > Can you raise a negative number to a fractional power ?

Re: working with laptop battery

2010-02-13 Thread Shashwat Anand
I too am interested as to which module should I use. My OS is OS X Snow Leopard. On Sun, Feb 14, 2010 at 6:56 AM, Chris Rebert wrote: > On Sat, Feb 13, 2010 at 4:48 PM, Daniel Dalton > wrote: > > Hi, > > > > I'm constantly working in the command line and need to write a program > > to give me a

Re: Printing with raw_input

2010-02-15 Thread Shashwat Anand
raw_input uses sys.stderr I guess ? On Mon, Feb 15, 2010 at 5:35 PM, Peter Otten <[email protected]> wrote: > Joan Miller wrote: > > >> > Does `raw_input` uses internally `sys.stdout.write`? > > > It was to display the output inside a GUI app. overriding > > `sys.stdout`. And as `print` also uses

Re: MediaWiki to RTF/Word/PDF

2010-02-17 Thread Shashwat Anand
why not try installing cygwin. I am just guessing though but I had heard it emulates *nix decently on windows. Or a better idea is to shift to *nix ;) On Thu, Feb 18, 2010 at 2:30 AM, Josh English wrote: > I have several pages exported from a private MediaWiki that I need to > convert to a PDF do

the mystery of dirname()

2010-02-19 Thread Shashwat Anand
In the following code sample : def dirname(p): """Returns the directory component of a pathname""" i = p.rfind('/') + 1 head = p[:i] if head and head != '/'*len(head): head = head.rstrip('/') return head def dirname1(p): i = p.rfind('/') + 1 head = p[:i]

Re: Can't Access ANY url from python (errno 61)

2010-02-19 Thread Shashwat Anand
try this : >>> url = 'http://www.google.com' >>> proxy = {'http': 'http://username:passw...@proxy:port'} >>> content = urllib.urlopen(url, proxies = proxy).read() Hopefully it should run without error. Second approach can be to check whether your environment variables are setup. $set will show y

Re: the mystery of dirname()

2010-02-19 Thread Shashwat Anand
But this is posixpath, right ? So '//x' like path will not occur as far as I guess ? On Sat, Feb 20, 2010 at 8:35 AM, MRAB wrote: > Shashwat Anand wrote: > >> In the following code sample : >> >> def dirname(p): >> >>"""Retur

Re: the mystery of dirname()

2010-02-19 Thread Shashwat Anand
basically I infer that : dirname = path - basename, like for path = '//x', basename = x, hence dirname = '//' On Sat, Feb 20, 2010 at 8:47 AM, MRAB wrote: > Shashwat Anand wrote: > >> But this is posixpath, right ? So '//x' like path will not o

Re: Can I embedding a (python) console on python program?

2010-02-19 Thread Shashwat Anand
I am not sure what you are looking for, but you can try looking at 'cmd module' ~l0nwlf On Sat, Feb 20, 2010 at 11:08 AM, Kee K Y CHEN wrote: > HI All, > > Apologize for being a newbie to python area and sorry for my English. > > Actually what I need is embedding a python interactive console(or

Re: Can't Access ANY url from python (errno 61)

2010-02-20 Thread Shashwat Anand
throw up your 'ifconfig' and mozilla-proxy output here. It seems you don't know whether you are using proxy. For mozilla proxy : open mozilla -> cmd + "," -> Network -> Settings -> Paste everything that is there/ may be take a snapshot and upload a link. ~l0nwlf On Sat, Feb 20, 2010 at 2:06 PM,

Re: Precision issue in python

2010-02-20 Thread Shashwat Anand
A quick solution I came out with, no stirling numbers and had tried to avoid large integer multiplication as much as possible. import math for i in range(int(raw_input())): n, k, l = [int(i) for i in raw_input().split()] e = sum(math.log10(i) for i in range(1, n+1)) frac_e = e - math.

Re: Precision issue in python

2010-02-20 Thread Shashwat Anand
> I don't know if is possible to import this decimal module but kindly > tell me.Also a bit about log implementation > Why don't you read about decimal module (there is log too in it) and try writing your approach here in case it does not work? Or you insist someone to rewrite your code using decim

Re: the mystery of dirname()

2010-02-20 Thread Shashwat Anand
got it. thanks. :) On Sat, Feb 20, 2010 at 11:19 PM, MRAB wrote: > Shashwat Anand wrote: > >> basically I infer that : dirname = path - basename, like for path = >> '//x', basename = x, hence dirname = '//' >> >> [snip] > Basically, os.p

Re: Precision issue in python

2010-02-20 Thread Shashwat Anand
@Mark, The str(...).split('.') here doesn't do a good job of extracting the > integer part when its argument is >= 1e12, since Python produces a > result in scientific notation. I think you're going to get strange > results when k >= 13. > Yeah, you were correct. I tested it for k >= 13, and the

Re: Efficient way to break up a list into two pieces

2010-02-20 Thread Shashwat Anand
You can always implement your own data-structures or simply a function if you need so. A language consist of building blocks and not buildings. On Sun, Feb 21, 2010 at 6:36 AM, Jonathan Gardner < [email protected]> wrote: > On Sat, Feb 20, 2010 at 4:55 PM, marwie wrote: > > Hello, > >

Re: DreamPie - The Python shell you've always dreamed about!

2010-02-21 Thread Shashwat Anand
Just got it working in mac. Installing dependencies took a bit though. On Mon, Feb 22, 2010 at 7:38 AM, Philip Semanchuk wrote: > > On Feb 21, 2010, at 8:39 PM, rantingrick wrote: > > >> >> Mensanator snipped: """Yeah, I saw that. Funny that something >> important like that wasn't part of the ann

Re: A tool for find dependencies relationships behind Python projects

2010-02-22 Thread Shashwat Anand
Same issue here, easy_install fails here is traceback, Shashwat-Anands-MacBook-Pro:Downloads l0nwlf$ easy_install gluttony Searching for gluttony Reading http://pypi.python.org/simple/gluttony/ Reading http://code.google.com/p/python-gluttony/ Best match: Gluttony 0.3 Downloading http://pypi.pytho

Re: What's Going on between Python and win7?

2010-02-22 Thread Shashwat Anand
Programming is most fruiful in *nix environment. On Mon, Feb 22, 2010 at 9:59 PM, Grant Edwards wrote: > On 2010-02-22, W. eWatson wrote: > > > Last night I copied a program from folder A to folder B. > > [tail of various windows breakages elided] > > > Comments? > > Switch to Linux? > > Or at l

Re: Efficiently building ordered dict

2010-02-22 Thread Shashwat Anand
OrderedDict is a class in collection module in python 2.7a3+. Perhaps you can use it from there. >>> dir(collections) ['Callable', 'Container', 'Counter', 'Hashable', 'ItemsView', 'Iterable', 'Iterator', 'KeysView', 'Mapping', 'MappingView', 'MutableMapping', 'MutableSequence', 'MutableSet', 'Orde

Re: Files required for porting python

2010-02-22 Thread Shashwat Anand
what do you exactly mean by "port python on to windows" ? Are you talking about your application or python itself :-/ ~l0nwlf On Mon, Feb 22, 2010 at 10:23 PM, KIRAN wrote: > Hi ALL, > > I am newbie to python and wanted to port python on to some RTOS. The > RTOS I am trying to port python is no

Re: python dowload

2010-02-23 Thread Shashwat Anand
PyPdf/pdfminer library will be of help On Wed, Feb 24, 2010 at 1:47 AM, Tim Chase wrote: > monkeys paw wrote: > >> I used the following code to download a PDF file, but the >> file was invalid after running the code, is there problem >> with the write operation? >> >> import urllib2 >> url = 'htt

Re: Looking for an Application

2010-03-01 Thread Shashwat Anand
project sikuli : http://groups.csail.mit.edu/uid/sikuli/ On Mon, Mar 1, 2010 at 8:49 PM, Greg Lindstrom < [email protected]> wrote: > A few months ago there was a post dealing with an application that would > power scripts based on graphical snippets of the screen. Essentially, th

Re: New User

2010-03-01 Thread Shashwat Anand
for beginners : http://openbookproject.net/thinkcs/python/english2e/index.html python cookbook - 2 by alex martelli is fantastic if you have your basics cleared. On Tue, Mar 2, 2010 at 8:09 AM, Niranjan Kumar Das wrote: > Hello Group, > I am starting to programme in python 1st time. Just thought

Re: nonunique string replacements

2010-03-02 Thread Shashwat Anand
>>> s = 'PBUSH 201005 K 500 1. 1. 1. 1. 1.'#Your original string here >>> l#Create your desired list ['500.2', '5.2', '5.3', '5.4', '5.5', '5.6', '5.7'] >>> lsep = s.count(' 1.')#Count the occurrence of seperators >>> for i in range(lsep):#Repla

Re: Question about typing: ints/floats

2010-03-03 Thread Shashwat Anand
yes you can also try: >>> float(a)/b 0.1 On Thu, Mar 4, 2010 at 5:15 AM, Wells wrote: > This seems sort of odd to me: > > >>> a = 1 > >>> a += 1.202 > >>> a > 2.202 > > Indicates that 'a' was an int that was implicitly casted to a float. > But: > > >>> a = 1 > >>> b = 3 > >>> a

Re: How to login https sever with inputing account name and password?

2010-03-04 Thread Shashwat Anand
You may also want to look into mechanize module. On Thu, Mar 4, 2010 at 6:11 PM, Michael Rudolf wrote: > Am 04.03.2010 11:38, schrieb Karen Wang: > > Hi all, >> >> I want to use python to access to https server, like >> "https://212.218.229.10/chinatest/"; >> >> If open it from IE, will see the

Re: Selecting MAX from a list

2010-03-05 Thread Shashwat Anand
On Fri, Mar 5, 2010 at 5:09 PM, Ines T wrote: > I need to select a maximum number from a list use max() > and then call the variable that > identifies that number, for example: > x1,x2=1, y1,y2=4, z1,z2=3 > you mean x1 = y1 = 1 or x1, y1 = 1, 1 right ? > So I need first to find 4 and then

Re: Slicing [N::-1]

2010-03-05 Thread Shashwat Anand
On Fri, Mar 5, 2010 at 11:42 PM, Arnaud Delobelle wrote: > Joan Miller writes: > > > What does a slice as [N::-1] ? > > > > It looks that in the first it reverses the slice and then it shows > > only N items, right? > > > > Could you add an example to get the same result without use `::` to > > s

Re: a newbie's question

2010-03-10 Thread Shashwat Anand
Python is one language which is quite easy to get grasp of. one week and you'll start doing productive stuff. Best of luck on your quest. On Thu, Mar 11, 2010 at 10:26 AM, Lan Qing wrote: > hi Cheers, > Think you, that helps me a lot. > > > On Tue, Mar 9, 2010 at 10:00 PM, Simon Brunning >

using DictionaryServices module to get work with python2.6 #OSXspecific

2010-03-17 Thread Shashwat Anand
I wanted to use dictionary in my OSX terminal. So I wrote a function dict() in my ~/.bash_profile dict () { python2.5 -c 'import sys, DictionaryServices; word = " ".join(sys.argv[1:]); print DictionaryServices.DCSCopyTextDefinition(None, word, (0, len(word)))' $@ } here is the output: Shashw

Re: using DictionaryServices module to get work with python2.6 #OSXspecific

2010-03-17 Thread Shashwat Anand
> Are you thinking of this? > http://pypi.python.org/pypi/pyobjc-framework-DictionaryServices/2.2 > I get the same IndexError while working with this wrapper. My guess is python2.6 does not support DictionaryServices on Snow Leopard . -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is cool!!

2010-03-23 Thread Shashwat Anand
There is a project PyWhip (renamed as PyKata) which aims for the same purpose. Google AppEmgine + Django does the trick for that. May be you can take an inspiration or two from there especially because all code is open to/for you. ~l0nwlf On Wed, Mar 24, 2010 at 2:54 AM, Patrick Maupin wrote: >

Re: Pythonic way to trim and keep leading and trailing whitespace

2010-03-23 Thread Shashwat Anand
regex is not goto that you should always avoid using it. It have its own use-case, here regex solution is intuitive although @emile have done this for you via string manpulation. On Wed, Mar 24, 2010 at 4:09 AM, Daniel Chiquito wrote: > As far as I know, I don't think there is anything that strip

spams

2010-03-24 Thread Shashwat Anand
Lately this list have been spammed a lot. Any workarounds by moderators? ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list

Re: spams

2010-03-24 Thread Shashwat Anand
seems good :) On Wed, Mar 24, 2010 at 9:12 PM, D'Arcy J.M. Cain wrote: > On Wed, 24 Mar 2010 20:47:12 +0530 > Shashwat Anand wrote: > > Lately this list have been spammed a lot. Any workarounds by moderators? > > Not as long as it is gatewayed to Usenet. You can kil

Re: Advice needed on parallel processing in python

2010-03-24 Thread Shashwat Anand
have you checked hadoop ? On Wed, Mar 24, 2010 at 11:43 PM, Jon Clements wrote: > On 24 Mar, 15:27, Glazner wrote: > > Hi! > > > > I need to replace an app that does number crunching over a local > > network. > > it have about 50 computers as slaves > > each computer needs to run COM that will d

Re: Traversing through Dir()

2010-03-25 Thread Shashwat Anand
have you tried os.walk() ? On Fri, Mar 26, 2010 at 5:55 AM, Andrej Mitrovic wrote: > I would like to traverse through the entire structure of dir(), and > write it to a file. > > Now, if I try to write the contents of dir() to a file (via pickle), I > only get the top layer. So even if there are

Re: OT: Meaning of "monkey"

2010-03-26 Thread Shashwat Anand
evolved monkey = human (can relate codemonkey to it) 2010/3/26 Kushal Kumaran > > 2010/3/26 Luis M. González : > > Webmonkey, Greasemonkey, monkey-patching, Tracemonkey, Jägermonkey, > > Spidermonkey, Mono (monkey in spanish), codemonkey, etc, etc, etc... > > > > Monkeys everywhere. > > Sorry fo

Re: Have you embraced Python 3.x yet?

2010-03-26 Thread Shashwat Anand
2.6.x is what most applications rely on. It is still too early for python 3 On Fri, Mar 26, 2010 at 6:59 PM, Alex Hall wrote: > Because of compatibility, and many modules being built for 2.6 only, I > am still on 2.6.4 (updating to .5 soon). > > On 3/26/10, Harishankar wrote: > > Have you peopl

Re: Binary Decimals in Python

2010-03-30 Thread Shashwat Anand
decimal binary number is not included AFAIK On Tue, Mar 30, 2010 at 8:43 PM, aditya wrote: > To get the decimal representation of a binary number, I can just do > this: > > int('11',2) # returns 3 > > But decimal binary numbers throw a ValueError: > > int('1.1',2) # should return 1.5, throws err

Re: Binary Decimals in Python

2010-03-30 Thread Shashwat Anand
The conversion is not supported for decimal integers AFAIK, however '0b123.456' is always valid. I guess you can always get a decimal number convertor onto Python-recipes On Tue, Mar 30, 2010 at 9:05 PM, Grant Olson wrote: > On 3/30/2010 11:13 AM, aditya wrote: > > To get the decimal represent

Re: CPAN for python?

2010-03-30 Thread Shashwat Anand
This has been discussed tons of times. You should have atleast googled it. Python have nothing like CPAN and Cheese Shop (pypi) comes closest to it. On Tue, Mar 30, 2010 at 10:21 PM, Kushal Kumaran < [email protected] > wrote: > On Tue, Mar 30, 2010 at 9:53 PM, Someone Something >

Re: no module named exceptions?

2010-04-01 Thread Shashwat Anand
There i no module named 'exceptions' in python 2.6 as well as python 3.1 What are you expecting ? On Thu, Apr 1, 2010 at 10:42 PM, Joaquin Abian wrote: > In python 3.1, > > >>> import exceptions > Traceback (most recent call last): > File "", line 1, in >import exceptions > ImportError: No

Re: Splitting a string

2010-04-02 Thread Shashwat Anand
>>> s = 'si_pos_99_rep_1_0.ita' >>> res = tuple(re.split(r'(\d+)', s)) >>> res ('si_pos_', '99', '_rep_', '1', '_', '0', '.ita') >>> On Fri, Apr 2, 2010 at 3:42 PM, Thomas Heller wrote: > Maybe I'm just lazy, but what is the fastest way to convert a string > into a tuple containing character se

Re: pynotify for python 3.1.. Help Please..

2010-04-02 Thread Shashwat Anand
I guess it is a 3rd party module. Run setup.py with python3.1, however it can happen that the module is not python3 compatible. In that case try using 2to3 if you can. On Fri, Apr 2, 2010 at 3:43 PM, Xavier Ho wrote: > On Fri, Apr 2, 2010 at 8:13 PM, Xavier Ho wrote: > >> Hi Jebamnana, >> > > J

Language Detection Library/Code

2010-12-27 Thread Shashwat Anand
Can anyone suggest a *language detection library* in python which works on a phrase of say 2-5 words. -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list

Re: Language Detection Library/Code

2010-12-27 Thread Shashwat Anand
On Tue, Dec 28, 2010 at 6:03 AM, Katie T wrote: > On Mon, Dec 27, 2010 at 7:10 PM, Shashwat Anand > wrote: > > Can anyone suggest a language detection library in python which works on > a > > phrase of say 2-5 words. > > Generally such libraries work by bi/trigra

Re: Init a dictionary with a empty lists

2011-02-05 Thread Shashwat Anand
On Sat, Feb 5, 2011 at 6:38 PM, Lisa Fritz Barry Griffin < [email protected]> wrote: > Hi there, > > How can I do this in a one liner: > >maxCountPerPhraseWordLength = {} >for i in range(1,MAX_PHRASES_LENGTH+1): >maxCountPerPhraseWordLength[i] = 0 > maxCountPerPhr

Re: How to output the commands that are executed in a python script?

2010-04-05 Thread Shashwat Anand
You need a debugger here. On Tue, Apr 6, 2010 at 8:41 AM, Lie Ryan wrote: > On 04/06/10 12:38, Peng Yu wrote: > > I want to show what commands have been executed when I run a python > > script. Is there an option which can instruct python to print the > > commands automatically? > > > > (If you

Re: help req: installing debugging symbols

2010-04-07 Thread Shashwat Anand
Install python in a different directory, use $prefix for that. Change PATH value accordingly 2010/4/5 sanam singh > Hi, > > I am using ununtu 9.10. I want to install a version of Python that was > compiled with debug symbols. > > But if I delete python from ubuntu it would definitely stop wo

Re: doctests working both in Python 2.X and Python 3.X

2010-04-11 Thread Shashwat Anand
On Sun, Apr 11, 2010 at 1:59 PM, Michele Simionato < [email protected]> wrote: > I do not want to write two documentations for a module working both in > Python 2.X and Python 3.X. > There are modules which work in both 2.x and 3.x but still behave differently. How will you handle those

Re: curious about python version numbers

2010-04-13 Thread Shashwat Anand
It is like releasing window Xp SP3 even if Vista is out. The problem is we should start using python 3.x but many application like django, twisted had not migrated yet. Hence this stuff to support 2.x . 2.7 is the last 2.x version, no more. On Tue, Apr 13, 2010 at 2:28 PM, Alf P. Steinbach wrote

Re: Hi, Everyone: what's the most popular xml parser module on python?

2010-04-15 Thread Shashwat Anand
BeautifulSoup On Thu, Apr 15, 2010 at 1:39 PM, Stefan Behnel wrote: > Jo Chan, 14.04.2010 15:28: > > Hi, everyone~~~ I am new. >> What is the most popular xml parser module used on python? Thanks for >> answering... >> > > Why do you want to know? Just out of curiosity, or are you looking for

Re: Hi, Everyone: what's the most popular xml parser module on python?

2010-04-15 Thread Shashwat Anand
BeatifulSoup can be used as one IMO On Thu, Apr 15, 2010 at 3:50 PM, Stefan Behnel wrote: > Shashwat Anand, 15.04.2010 11:55: > > BeautifulSoup > > The OP asked for an XML parser. > > Stefan > > -- > http://mail.python.org/mailman/listinfo/python-list > -

Re: launching vi/vim from console

2010-05-24 Thread Shashwat Anand
or in a reverse way you can open vim and use ':shell' followed by python. I prefer it that way generally On Mon, May 24, 2010 at 6:01 PM, adm wrote: > On May 24, 4:59 pm, Jean-Michel Pichavant > wrote: > > adm wrote: > > > I am newbie to python. > > > Is there a way to launch vi/vim or any othe

Re: Chatroom

2010-05-24 Thread Shashwat Anand
seems like an academic project which is worth grades On Tue, May 25, 2010 at 7:01 AM, alex23 wrote: > "Martin P. Hellwig" wrote: > > What have you tried so far? > > Alternatively, how much is it worth to you? > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.

Re: Help with Regexp, \b

2010-05-29 Thread Shashwat Anand
\b is NOT spaces >>> p = re.compile(r'\sword\s') >>> m = p.match(' word ') >>> assert m >>> m.group(0) ' word ' >>> On Sat, May 29, 2010 at 8:34 PM, andrew cooke wrote: > > This is a bit embarassing, but I seem to be misunderstanding how \b > works in regexps. > > Please can someone explain wh

Re: Help with Regexp, \b

2010-05-29 Thread Shashwat Anand
Also what you are probably looking for is this I guess, >>> p = re.compile(r'\bword\b') >>> m = p.match('word word') >>> assert m >>> m.group(0) 'word' On Sat, May 29, 2010 at 8:44 PM, Shashwat Anand wrote: > \b is NO

Re:

2010-06-03 Thread Shashwat Anand
I have not much idea but Online Judges like SPOJ/codechef have regular programming-contests and python is one of allowed languages. So yes, it's possible. If I guess right, are you making an Online Judge for python. On Thu, Jun 3, 2010 at 8:39 PM, Amit Sethi wrote: > Hi , > > I wish to execute so

Re: map is useless!

2010-06-06 Thread Shashwat Anand
map is not needed. LC is great :D On Sun, Jun 6, 2010 at 10:32 PM, Alain Ketterlin < [email protected]> wrote: > rantingrick writes: > > > Python map is just completely useless. [...] > > import time > def test1(): > > l = range(1) > > t1 = time.time() > >

Re: How to read source code of python?

2010-06-09 Thread Shashwat Anand
And if you are interested in source and have no particular goal, start with stdlib. On Thu, Jun 10, 2010 at 6:39 AM, rantingrick wrote: > On Jun 9, 7:28 pm, Leon wrote: > > > I'm trying to read the source code of python. > > I read around, and am kind of lost, so where to start? > > Leon, if yo

Re: regarding the dimensions in gui

2010-06-10 Thread Shashwat Anand
Do you realize you are spamming the list. You generally fire one question and wait rather than supplying us a bunch of questions. And please stop using 'sir' for heaven's sake. I realize you are from India and it is a culture there but people don't use it in mailing lists. Thanks. On Thu, Jun 10,

Re: Python on Android Mobile?

2010-06-13 Thread Shashwat Anand
Well, AFAIK Nokia N900 supports python fully. On Mon, Jun 14, 2010 at 4:08 AM, Anthony Papillion wrote: > Thank you gentleman for your input. I'm starting to look at Python/GTK > for desktop development and was hoping there might also be something > for Android. Oh well, like Simon said (pardon t

Re: how to build with 2.4 having 2.6 as main python

2010-06-14 Thread Shashwat Anand
You can try a package : python_select On Mon, Jun 14, 2010 at 2:00 PM, Alexzive wrote: > Hello there, > > my Mandriva has the 2.6.4 python pre-installed (in /usr/lib64/ > python2.6/) > I need to install numpy 1.4 for python 2.4.3 (I installed it > separately from source on/usr/local/lib/python2.

Re: Community (A Modest Proposal)

2010-06-15 Thread Shashwat Anand
IDEs are seriously over-rated. Vim FTW. The only issue for beginners is they should know touch typing to fully utilize Vim and the initial curve is a bit high as compared to normal editors/IDEs. On Tue, Jun 15, 2010 at 4:16 PM, Andreas Waldenburger wrote: > On Tue, 15 Jun 2010 17:45:43 +1000 Jam

Re: pythonize this!

2010-06-15 Thread Shashwat Anand
>>> sum(i*i*(-1)**((i % 5) / 4 + (i + 4) % 5 / 4) for i in range(1,2011)) 536926141 On Tue, Jun 15, 2010 at 6:25 PM, superpollo wrote: > superpollo ha scritto: > > Peter Otten ha scritto: >> >>> superpollo wrote: >>> >>> goal (from e.c.m.): evaluate 1^2+2^2+3^2-4^2-5^2+6^2+7^2+8^2-9^2-1

Re: 500 tracker orphans; we need more reviewers

2010-06-19 Thread Shashwat Anand
Terry: Thanks for bringing this to notice. Mark: Kudos for your effort in cleaning up bugs.python.org On Sat, Jun 19, 2010 at 10:16 PM, Mark Lawrence wrote: > On 19/06/2010 03:37, Terry Reedy wrote: > >> Go to the bottom of >> http://bugs.python.org/iss...@template=search&status=1 >> enter 1 in t

Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Shashwat Anand
Josef: Make sure you ask this question on Ruby mailing list too. Just like James I too am personally biased towards python and so will be a lot of people on this list. On Tue, Jun 22, 2010 at 2:50 PM, James Mills wrote: > On Tue, Jun 22, 2010 at 6:58 PM, Josef Tupag wrote: > > Before I really di

Re: print line number and source filename

2010-06-22 Thread Shashwat Anand
22:26:51 l0nwlf-MBP:~/Desktop$ cat test.py print __file__ 22:26:55 l0nwlf-MBP:~/Desktop$ python test.py test.py On Tue, Jun 22, 2010 at 10:26 PM, Shashwat Anand wrote: > you can use __file__ > > > On Tue, Jun 22, 2010 at 10:14 PM, Peng Yu wrote: > >> I want to print fil

Re: print line number and source filename

2010-06-22 Thread Shashwat Anand
you can use __file__ On Tue, Jun 22, 2010 at 10:14 PM, Peng Yu wrote: > I want to print filename and line number for debugging purpose. So far > I only find how to print the line number but not how to print > filename. > > import inspect > print inspect.currentframe().f_lineno > > I found inspec

Re: print line number and source filename

2010-06-22 Thread Shashwat Anand
begin - import logging logging.basicConfig(level=logging.DEBUG,format="%(asctime)s" "%(levelname)-5.5s [%(name)s %(module)s:%(funcName)s:%(lineno)d]" "%(message)s") def run(): x = 5 logging.debug("X = %d" % x) run() - end - You can probably use string default concatenation

Re: Help on finding word is valid as per English Dictionary through python

2010-06-25 Thread Shashwat Anand
why do you need that ? which platform are you onto ? On OSX you can use 'DictionaryServices' API eg., import sys import DictionaryServices word = " ".join(sys.argv[1:]) print DictionaryServices.DCSCopyTextDefinition(None, word, (0, len(word))) Gives the meaning of the input word (works with pyth

Re: why python don't support "extended slice direct assignment" for lists?

2010-07-02 Thread Shashwat Anand
On Sat, Jul 3, 2010 at 4:54 AM, Robert William Hanks < [email protected]> wrote: > why pure python don't support "extended slice direct assignment" for lists? > > today we have to write like this, > > >>> aList=[0,1,2,3,4,5,6,7,8,9] > >>> aList > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] > >>> aList[::

Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-02 Thread Shashwat Anand
On Sat, Jul 3, 2010 at 5:27 AM, Steven D'Aprano < [email protected]> wrote: > On Fri, 02 Jul 2010 12:07:33 -0700, John Nagle wrote: > > > Where's the business case for moving to Python 3? It's not faster. It > > doesn't do anything you can't do in Python 2.6. There's no "kill

Re: Argh! Name collision!

2010-07-06 Thread Shashwat Anand
On Wed, Jul 7, 2010 at 8:21 AM, Richard Thomas wrote: > On Jul 7, 3:11 am, "Alf P. Steinbach /Usenet" [email protected]> wrote: > > Donald Knuth once remarked (I think it was him) that what matters for a > program > > is the name, and that he'd come up with a really good name, now all he'd > had

Re: 500 tracker orphans; we need more reviewers

2010-07-08 Thread Shashwat Anand
On Fri, Jul 9, 2010 at 3:28 AM, Mark Lawrence wrote: > On 19-6-2010 23:45, Shashwat Anand wrote: > >> Terry: Thanks for bringing this to notice. >> Mark: Kudos for your effort in cleaning up bugs.python.org >> >> > Like I've said elsewhere, flattery

Re: nicer way to remove prefix of a string if it exists

2010-07-13 Thread Shashwat Anand
On Wed, Jul 14, 2010 at 5:42 AM, MRAB wrote: > News123 wrote: > >> I wondered about a potentially nicer way of removing a prefix of a >> string if it exists. >> >> >> Here what I tried so far: >> >> >> def rm1(prefix,txt): >>if txt.startswith(prefix): >>return txt[len(prefix):] >>

Re: python namespace question

2010-07-13 Thread Shashwat Anand
On Wed, Jul 14, 2010 at 8:33 AM, chad wrote: > Given the following code... > > #!/usr/bin/python > > class cgraph: >def printme(self): >print "hello\n" > No need to do print "hello\n", python is not C, print "hello" prints hello with a newline. Try it on interpretor. > > x = cgraph

  1   2   >