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 <__pete...@web.de> 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 < jgard...@jonathangardner.net> 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 < greg.lindst...@novasyshealth.com> 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

Bug in Python APscheduler module.

2010-03-18 Thread anand jeyahar
sched.unschedule_func(test_func) sched.unschedule_func(tc.test_class1) print "jobs after unschedule" print sched.jobs sched.shutdown() if __name__=='__main__': main() ~ ~ ~ ~ == Anan

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 < kushal.kumaran+pyt...@gmail.com > 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

Errors while using strip and remove on a variable.

2011-02-03 Thread anand jeyahar
assignment. please find the script below* a ='oe,eune,eueo, ,u' b = a.split(',') print b c = b.remove('oe') print a print c == Anand Jeyahar http://sites.google.com/a/cbcs.ac.in/students/anand ===

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 < lisaochba...@gmail.com> 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 < michele.simion...@gmail.com> 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 < al...@dpt-info.u-strasbg.fr> 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 < astroultra...@gmail.com> 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 < st...@remove-this-cybersource.com.au> 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" +use...@gmail.com> 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

Re: Check if a command is valid

2010-07-13 Thread Shashwat Anand
On Tue, Jul 13, 2010 at 6:59 AM, Kenny Meyer wrote: > Hello, > > I have to figure out if a string is callable on a Linux system. I'm > actually doing this: > >def is_valid_command(command): >retcode = 100 # initialize >if command: >retcode = subprocess.call(command

Re: rstrip()

2010-07-16 Thread Shashwat Anand
On Fri, Jul 16, 2010 at 10:28 PM, Jason Friedman wrote: > $ python > Python 2.6.4 (r264:75706, Dec 7 2009, 18:43:55) > [GCC 4.4.1] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> "x.vsd-dir".rstrip("-dir") > 'x.vs' > > I expected 'x.vsd' as a return value.

Re: Performance ordered dictionary vs normal dictionary

2010-07-29 Thread Shashwat Anand
> > > It depends on the problem. A dictionary is a hash table. An ordered > dictionary is a binary search tree (BST). Those are different data > structures. > > The main things to note is that: > > - Access is best-case O(1) for the hash table and O(log n) for the > BST. > > - Worst case behavior i

Re: how to change a string into dictionary

2010-08-09 Thread Shashwat Anand
On Mon, Aug 9, 2010 at 3:03 PM, aimeixu wrote: > Hi, > I am newbie for python ,Here is my question: > a = "{'a':'1','b':'2'}" > how to change a into a dictionary ,says, a = {'a':'1','b':'2'} > Thanks a lot .Really need help. > Parse the string and re-create the dictionary. >>> s = "{'a':'1','b'

Re: simple renaming files program

2010-08-09 Thread Shashwat Anand
On Mon, Aug 9, 2010 at 3:14 PM, blur959 wrote: > Hi, all, I am working on a simple program that renames files based on > the directory the user gives, the names the user searched and the > names the user want to replace. However, I encounter some problems. > When I try running the script, when it

Re: freq function

2010-08-22 Thread Shashwat Anand
On Sun, Aug 22, 2010 at 1:31 PM, Dirk Nachbar wrote: > Here is a function which takes any list and creates a freq table, > which can be printed unsorted, sorted by cases or items. It's supposed > to mirror the proc freq in SAS. > > Dirk > > def freq(seq,order='unsorted',prin=True): >#order ca

Re: Source code for itertools

2010-08-30 Thread Shashwat Anand
On Tue, Aug 31, 2010 at 7:30 AM, vsoler wrote: > I'm interested in studying the itertools source code, especially the > permutations function. > > However, I cannot find the library. Where could I find it? > > Running Python 3.1 > > Thank you > Either you can download it or browse it on the net.

Re: Dumb Stupid Question About List and String

2010-08-31 Thread Shashwat Anand
On Wed, Sep 1, 2010 at 12:27 AM, Alban Nona wrote: > Hi all, > > Im stuck on this problem: > I have a function which return me a list of string (basically the result > looks like: ["FN067_098_MEN", FN067_098_JIN", FN067_098_BG"] > In other hand, I have another list full of that kind of entries: >

Re: Find closest matching string based on collection of strings in list/dict/set

2010-08-31 Thread Shashwat Anand
On Tue, Aug 31, 2010 at 9:12 PM, wrote: > I'm parsing a simple, domain specific scripting language that has commands > like the following: *page, *title, *text, *footer, etc. There are about 100 > of these '*' commands. When we see a command that we don't recognize, I > would like to find the clo

Re: Find closest matching string based on collection of strings in list/dict/set

2010-08-31 Thread Shashwat Anand
On Wed, Sep 1, 2010 at 2:31 AM, Joel Goldstick < joel.goldst...@columbuswebmakers.com> wrote: > pyt...@bdurham.com wrote: > >> I'm parsing a simple, domain specific scripting language that has >> commands like the following: *page, *title, *text, *footer, etc. >> There are about 100 of these '*' c

Re: Reversing a List

2010-09-01 Thread Shashwat Anand
On Wed, Sep 1, 2010 at 6:45 PM, Matt Saxton wrote: > On Wed, 1 Sep 2010 09:00:03 -0400 > Victor Subervi wrote: > > > Hi; > > I have this code: > > > > cursor.execute('describe products;') > > cols = [item[0] for item in cursor] > > cols = cols.reverse() > > cols.append('Delete') > > co

Is python is the safest language ...

2010-09-02 Thread Anand Sadasivam
Hi All, Is python is the safest language is my question. I feel its good language, but however java has good occupancy. About four years back I did few python programs and worked with some of add-on product over ZOPE and Plone. The suggestion to me is mostly welcome. Regards, -- Anand.S anand.s

Re: compare dictionaries

2010-09-07 Thread Shashwat Anand
On Wed, Sep 8, 2010 at 1:56 AM, Baba wrote: > On 7 sep, 22:08, Gary Herron wrote: > > On 09/07/2010 12:46 PM, Baba wrote: > > > > > word= 'even' > > > dict2 = {'i': 1, 'n': 1, 'e': 1, 'l': 2, 'v': 2} > > > > Just go through each letter of word checking for its existence in > > dict2. Return Fal

Re: Numpy: Multiplying arrays of matrices

2010-09-15 Thread Shashwat Anand
On Tue, Sep 14, 2010 at 7:54 PM, Gregory Ewing wrote: > Suppose I have two N+2 dimensional arrays, representing > N-d arrays of 2-d matrices. I want to perform matrix > multiplication between corresponding matrices in these > arrays. > > I had thought that dot() might do this, but it appears > not

Re: Python autocomplete module

2010-09-16 Thread Shashwat Anand
On Thu, Sep 16, 2010 at 5:34 PM, dusans wrote: > Is there a python module to make autocomplete suggestion easy. > Try 'rlcompleter' module. Though I haven't tried it myself, just used it in .pythonrc for auto-completion in intepretor mode. http://docs.python.org/library/rlcompleter.html -- ~l

Re: Python2.7 on OSX

2010-09-25 Thread Shashwat Anand
On Sun, Sep 26, 2010 at 12:32 AM, Jonas Galvez wrote: > Just installed Python2.7 on my OSX Leopard with make altinstall. > > No missing dependencies, but I have one annoying problem: the delete key > prints '^H' on the Python shell. > > Does anyone know how to fix that? > > Thanks in advance, > I

Re: list problem...

2010-09-28 Thread Shashwat Anand
On Wed, Sep 29, 2010 at 12:14 AM, Rog wrote: > Hi all, > Have been grappling with a list problem for hours... > a = [2, 3, 4, 5,.] > b = [4, 8, 2, 6,.] > Basicly I am trying to place a[0], b[0] in a seperate list > IF a[2] and b[2] is present. > You are not exactly clear with your proble

Re: list problem...

2010-09-28 Thread Shashwat Anand
On Wed, Sep 29, 2010 at 1:15 AM, rog wrote: > Shashwat Anand wrote: > > >> >> On Wed, Sep 29, 2010 at 12:14 AM, Rog > r...@pynguins.com>> wrote: >> >>Hi all, >>Have been grappling with a list problem for hours... >>a = [2, 3, 4,

Re: list problem...

2010-09-29 Thread Shashwat Anand
On Thu, Sep 30, 2010 at 3:20 AM, Rog wrote: > On Wed, 29 Sep 2010 05:52:32 -0700, bruno.desthuilli...@gmail.com wrote: > > > On 29 sep, 14:17, Steven D'Aprano > > > wrote: > >> On Tue, 28 Sep 2010 20:11:51 +0100, Rog wrote: > >> > On Tue, 28 Sep 2010 11:59:08 -0700, geremy condra wrote: > >> > >

Problem with mechanize redirect

2010-10-16 Thread Shashwat Anand
I was trying some sort of timed programming challenges which require getting the value from url and auto-posting. Here is what I was doing - http://securityoverride.com/challenges/programming/10/index.php Here is the content : In order to complete Programming Challenge 10, you must code a script t

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Shashwat Anand
On Fri, Nov 5, 2010 at 7:26 PM, Krister Svanlund wrote: > On Fri, Nov 5, 2010 at 2:43 PM, Matty Sarro wrote: > > Hey Everyone, > > Just curious - I'm working on a program which includes a calculation of a > > circle, and I found myself trying to use pi*radius^2, and getting errors > > that data

Re: Python obfuscation

2005-11-09 Thread Anand S Bisen
source. What do you think ? Anand S Bisen petantik wrote: > Are there any commercial, or otherwise obfuscators for python source > code or byte code and what are their relative advantages or > disadvantages. I wonder because there are some byte code protection > available for j

<    1   2   3   >