Re: Newby Python help needed with functions

2011-06-03 Thread Jonathan Gardner
dict.get(inp, None) That returned value is actually callable! That is, you can then do something like: fn("This is the input string") Of course, as you already know, you should test fn to see if it is None. If so, they typed in an option you don't recognize. Secondly

Writing a MUD Console

2011-07-22 Thread Jonathan Gardner
character's name. 1 Traceback (most recent call last): File "./telnetsubprocess.py", line 17, in cmd = raw_input() EOFError Connection closed by foreign host. Any ideas on what is going on here? -- Jonathan Gardner jgard...@jonathangardner.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Writing a MUD Console

2011-07-22 Thread Jonathan Gardner
whirl! > That code is surprisingly simple. Let me write one that uses asyncore so that the looping can incorporate other async processes as well. -- Jonathan Gardner jgard...@jonathangardner.net -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get started in GUI Programming?

2005-11-26 Thread Jonathan Gardner
I would argue with your assertion that either TKinter of PyGTK are the best. There are several other good alternatives, including wxPython and PyQt, which are very comparable, if not better. I would strongly suggest starting with PyQt. It's my personal favorite. I wrote a short tutorial on the Pyt

Re: How can I do this in Python?

2005-11-27 Thread Jonathan Gardner
I don't know what engine you are using. Basically all you have to do is render the login form at the url of the page that needs the login. You're going to have to hook in the authentication code before you render the page normally. For instance, this is a common way I've been doing it in various en

Re: Is this a good idea or a waste of time?

2006-08-29 Thread Jonathan Gardner
Simon Forman wrote: > > If you have a reason to restrict your code to using only ints (perhaps > you're packing them into an array of some sort, or passing them to a C > extension module) then yes, of course it's appropriate. I politely disagree. Rather than an interface that demands an actual in

Re: still a valid book?

2006-02-08 Thread Jonathan Gardner
You may want to read http://python.org/doc/2.4.2/whatsnew/whatsnew24.html to get an idea of what has changed from 2.3 to 2.4 if you buy the 2.3 book. -- http://mail.python.org/mailman/listinfo/python-list

Soduku

2006-02-14 Thread Jonathan Gardner
Here at my job, Python gets no respect. A programmer here wanted to see which language among Python, Perl, and Java was better. So he wrote a Python, perl, and Java version. Except the Python version was 20x slower than the perl and Java versions. Well, luckily he asked around in our little Pytho

Re: Soduku

2006-02-14 Thread Jonathan Gardner
27ms == 0.027s How do you have a 16x16 grid for soduku? Are you using 16 digits? 0-F? The one I am using has 9 digits, 9 squares of 9 cells each, or 9x9 cells. The least efficient part of the algorithm is that part to calculate what to put in a hole (as anyone might've guessed.) My algorithm cal

Re: How to cat None

2006-02-14 Thread Jonathan Gardner
You can just surround the offending value with str(...). You should probably be doing that anyway, because the value might be a number or something else not stringish. -- http://mail.python.org/mailman/listinfo/python-list

Re: Databases and python

2006-02-15 Thread Jonathan Gardner
I'm no expert in BDBs, but I have spent a fair amount of time working with PostgreSQL and Oracle. It sounds like you need to put some optimization into your algorithm and data representation. I would do pretty much like you are doing, except I would only have the following relations: - word to wo

Re: Databases and python

2006-02-17 Thread Jonathan Gardner
About the filename ID - word ID table: Any good database (good with large amounts of data) will handle the memory management for you. If you get enough data, it may make sense to get bothered with PostgreSQL. That has a pretty good record on handling very large sets of data, and intermediate sets a

Re: Databases and python

2006-02-17 Thread Jonathan Gardner
About indexes everywhere: Yes, you don't have to be a DB expert to know that indexes everywhere is bad. But look at this example. There are really two ways that the data is going to get accessed in regular use. Either they are going to ask for all files that have a word (most likely) or they are go

Re: Merging two lists of data (Pythonic way)

2006-02-17 Thread Jonathan Gardner
codes = map(lambda x: x[0], list1) for d in list2: if d['code'] in codes: d['VERIFIED'] = 1 Is this what you were looking for? -- http://mail.python.org/mailman/listinfo/python-list

Re: define loop statement?

2006-02-17 Thread Jonathan Gardner
No, not in the way you think it is. What you can do instead is something like this: def do_something(i): ... do_something ... def loop(n, func): for i in range(n): func(i) loop(10, do_something) -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference: __iadd__ and __add__

2006-02-17 Thread Jonathan Gardner
I would like to point out that it isn't entirely obvious where to find documentation for this particular thing. I know from experience where to go, but I remember spending a long time trying to hunt this down. For reference, you may want to check out the index of the language reference manual. ht

Re: Best python module for Oracle, but portable to other RDBMSes

2006-02-24 Thread Jonathan Gardner
On database portability... While it is noble to try to have a generic interface to these libraries, the end result is that the databases are always different enough that the interface just has to work differently. My experience in going from one database to another is that you should revisit your

Re: Playing with modules

2006-02-24 Thread Jonathan Gardner
You're going to have to create the home.base module somewhere. If you want to put in that some code that basically imports another module's namespace into the home.base module's namespace, then that may do what you want. -- http://mail.python.org/mailman/listinfo/python-list

Re: Best python module for Oracle, but portable to other RDBMSes

2006-02-27 Thread Jonathan Gardner
I've never seen the points of those tools. Just lay it out on paper or document it somewhere. Be consistant with your naming scheme and it shouldn't be hard to see the relations. If found that the people who don't understand how tables should relate to one another are also the same people who don't

Re: type = "instance" instead of "dict"

2006-02-27 Thread Jonathan Gardner
You should probably spend a bit more time in the documentation reading things for yourself. Read http://www.python.org/doc/2.4.2/ref/types.html under "Class Instances" for your answer. -- http://mail.python.org/mailman/listinfo/python-list

Re: Catch exceptions

2006-02-27 Thread Jonathan Gardner
(A) You'll have to be more specific about your problem if you want us to help. Under which circumstances did it work or not? What exactly is the problem? (B) Where you put your error-handling is up to you. It depends on what the function does and how it is to respond. Do you want the function to t

Re: How to say $a=$b->{"A"} ||={} in Python?

2007-08-16 Thread Jonathan Gardner
On Aug 16, 3:35 pm, beginner <[EMAIL PROTECTED]> wrote: > > In perl it is just one line: $a=$b->{"A"} ||={}. > a = b.setdefault('A', {}) This combines all two actions together: - Sets b['A'] to {} if it is not already defined - Assigns b['A'] to a More info on dict methods here: http://docs.pyt

Re: confused about why i get a type error when i call an object's method

2007-08-21 Thread Jonathan Gardner
On Aug 21, 11:07 am, [EMAIL PROTECTED] wrote: > I'm confused about why i get a type error when i call an object's > method. Here's the example code:>>> class Foo: > > def __init__(self): > self.foo = [] > def foo(self): > print "in foo!" > > >>> f =

Re: REGULAR EXPRESSION

2007-09-04 Thread Jonathan Gardner
On Sep 4, 6:32 am, AniNair <[EMAIL PROTECTED]> wrote: > hi.. I am trying to match '+ %&/-' etc using regular expression in > expressions like 879+34343. I tried \W+ but it matches only in the > beginning of the string Plz help Thanking you in advance... You may want to read the page describing

Re: parsing long `To' and 'Cc' from email

2007-09-06 Thread Jonathan Gardner
On Sep 6, 1:25 pm, Gerardo Herzig <[EMAIL PROTECTED]> wrote: > the email.* package dont seems to parse that kind of headers > `correctly'. What i want is to get a list with all the email address in > the `To' header. > > Someone know if there is a more sofisticated parser for doing this? > If you'

Re: initializing cooperative method

2007-09-06 Thread Jonathan Gardner
On Sep 6, 11:18 am, jelle <[EMAIL PROTECTED]> wrote: > Ai, calling super(Abstract) is just getting object, sure... > > However, I'm still curious to know if there's a good idiom for > repeating the argument in __init__ for the super(Concrete, > self).__init__ ? > If you don't know what the argumen

Re: getting the current function

2007-09-06 Thread Jonathan Gardner
On Sep 6, 8:43 am, Gary Robinson <[EMAIL PROTECTED]> wrote: > > I welcome feedback of any type. > This all seems a bit too complicated. Are you sure you want to do this? Maybe you need to step back and rethink your problem. Your example can be rewritten a number of different ways that are easier

Re: why should I learn python

2007-09-06 Thread Jonathan Gardner
On Sep 6, 2:32 pm, windandwaves <[EMAIL PROTECTED]> wrote: > Can someone tell me why I should learn python? I am a webdeveloper, > but I often see Python mentioned and I am curious to find out what I > am missing out on. The reason I use Python is because I get more done quicker with fewer bugs.

Re: Changing data in an QAbstractListModel

2007-09-06 Thread Jonathan Gardner
On Sep 6, 9:12 am, "exhuma.twn" <[EMAIL PROTECTED]> wrote: > I defined a simple "update" method in the model which I call on > certain events to fetch the new data in the DB. I tried to "emit" the > "dataChanged()" signal of the Model without success. I don't know > where I should get the two requi

Re: SSL Issue

2007-09-06 Thread Jonathan Gardner
On Sep 5, 10:47 pm, Harry George <[EMAIL PROTECTED]> wrote: > Jurian Botha <[EMAIL PROTECTED]> writes: > > Sorry if this is a real dumb question, but I'm totally stumped. > > > I'm trying to connect to a https url in order to do some xml-rpc method > > calls, but I'm getting the following error: >

Re: Changing data in an QAbstractListModel

2007-09-10 Thread Jonathan Gardner
On Sep 7, 1:24 am, "exhuma.twn" <[EMAIL PROTECTED]> wrote: > Still, nothing is happening when I call this method. Do I still need > to handle the "dataChanged" signal somehow? Or does the ListView take > care of this? You might have better luck asking these kinds of questions in the Qt or PyQt for

Re: getting the current function

2007-09-10 Thread Jonathan Gardner
On Sep 7, 9:19 am, Gary Robinson <[EMAIL PROTECTED]> wrote: > > This all seems a bit too complicated. Are you sure you want to do > > this? Maybe you need to step back and rethink your problem. > > In version 2.1 Python added the ability to add function attributes -- > seehttp://www.python.org/dev

Re: Python Database Apps

2007-09-11 Thread Jonathan Gardner
On Sep 11, 1:07 pm, Tom Brown <[EMAIL PROTECTED]> wrote: > > I have had a lot of good luck with PostgreSQL. It is easy to install and use. > It is also very stable. It maybe overkill for a client side database. The > psycopg package makes interfacing to PostgreSQL very easy and there is a > package

Re: Python Database Apps

2007-09-11 Thread Jonathan Gardner
On Sep 11, 1:39 pm, Jonathan Gardner <[EMAIL PROTECTED]> wrote: > > For client-side apps, managing a PostgreSQL installation might be > asking too much. But for a web site or web service, I absolutely > recommend it. I should mention that I wrote a medical billing software app

Re: Python Database Apps

2007-09-13 Thread Jonathan Gardner
On Sep 11, 5:56 am, Harry George <[EMAIL PROTECTED]> wrote: > I use postgresql as well. I wonder if Pythonistas do so out of > concern for rigor, clarity, and scalability. It works fine for a > quick one-off effort and still works fine after scaling to a DBMS > server supporting lots of clients,

Re: Python Database Apps

2007-09-13 Thread Jonathan Gardner
On Sep 12, 9:38 pm, Prateek <[EMAIL PROTECTED]> wrote: > Have you checked out Brainwave?http://www.brainwavelive.com > > We provide a schema-free non-relational database bundled with an app > server which is basically CherryPy with a few enhancements (rich JS > widgets, Cheetah/Clearsilver template

Re: plotting pixels in python

2007-09-13 Thread Jonathan Gardner
On Sep 13, 11:37 am, [EMAIL PROTECTED] wrote: > No currently I am using a canvas from the Tkinter module > What I actually want is to show how a line is plotted pixel by pixel > using a delay loop. I want functions something like putpixel not > draw_line Try drawing 1px wide rectangles. -- http:

Re: "sem_post: Invalid argument"

2007-10-25 Thread Jonathan Gardner
On Oct 25, 12:56 pm, robert <[EMAIL PROTECTED]> wrote: > On a server the binary (red hat) installed python2.4 and also a > fresh compiled python2.5 spits "sem_post: Invalid argument". > What is this and how can this solved? > ... > Python 2.4.3 (#1, Jun 6 2006, 21:10:41) > [GCC 3.2.3 20030502 (Red

Re: "sem_post: Invalid argument"

2007-10-26 Thread Jonathan Gardner
On Oct 25, 2:19 pm, robert <[EMAIL PROTECTED]> wrote: > Jonathan Gardner wrote: > > On Oct 25, 12:56 pm, robert <[EMAIL PROTECTED]> wrote: > >> On a server the binary (red hat) installed python2.4 and also a > >> fresh compiled python2.5 spits "sem_po

Re: how to/help installing impure packages

2007-10-26 Thread Jonathan Gardner
On Oct 26, 10:35 am, owl <[EMAIL PROTECTED]> wrote: > I love easy_install. > > I love watching it search and complete. > It's when it doesn't complete that causes me grief. > I don't program a lot these days and am relatively new to python but I > often wind up installing packages on both unix and

Re: why did these companies choose Tcl over Python

2007-10-30 Thread Jonathan Gardner
On Oct 30, 2:25 pm, chewie54 <[EMAIL PROTECTED]> wrote: > > I would prefer to use Python but can't deny how popular Tcl is, as > mentioned above, so my question is why wasn't Python selected by > these companies as the choice of scripting languages for their > product? > Here are some reasons wh

Re: Arp request to get MAc Adress with IP address

2007-10-30 Thread Jonathan Gardner
On Oct 30, 1:57 pm, [EMAIL PROTECTED] wrote: > Hello, > I have a network on same subnet. I have an ip address of a machine. > but i need to get its MAC Adress. > Sendingf ARP request is the way i am taking. > > IS there any other way to get this MAC Adress in python.?? > > Also does python go down

Re: shelve.open() and error 22: invalid argument

2007-11-01 Thread Jonathan Gardner
On Nov 1, 1:08 pm, [EMAIL PROTECTED] wrote: > Hi everyone > > I've come across the following problem: on two different linux > machines, both running python 2.5 (r25:51908), I have the same file > 'd.dat'. The md5 checksums are the same. > > Now, on one machine the following code works > > >>> impo

Re: just a crazy question

2007-11-01 Thread Jonathan Gardner
On Nov 1, 7:16 am, Robert LaMarca <[EMAIL PROTECTED]> wrote: > So.. how is Python for memory management? ... > Terrible. If you have a memory-intensive application, use ASM (perhaps C), not Python (or any other high-level language for that matter.) > My plan is to try measuring the memory usage

Re: Portrait of a "real life" __metaclass__

2007-11-09 Thread Jonathan Gardner
On Nov 9, 7:12 pm, Mark Shroyer <[EMAIL PROTECTED]> wrote: > I guess this sort of falls under the "shameless plug" category, but > here it is: Recently I used a custom metaclass in a Python program > I've been working on, and I ended up doing a sort of write-up on it, > as an example of what a "rea

Re: Portrait of a "real life" __metaclass__

2007-11-10 Thread Jonathan Gardner
On Nov 10, 3:34 am, Mark Shroyer <[EMAIL PROTECTED]> wrote: > On 2007-11-10, Jonathan Gardner <[EMAIL PROTECTED]> wrote: > > What would I have done? I wouldn't have had an age matching class. I > > would have had a function that, given the datetime and a range >

Re: Newbie design problem

2007-12-13 Thread Jonathan Gardner
On Dec 13, 11:32 am, [EMAIL PROTECTED] wrote: > Is there a pythonic design I'm overlooking? Well, if using something like PLY ( http://www.dabeaz.com/ply/ ) is considered more Pythonic than writing your own parser and lexer... Python doesn't have all of life's answers unfortunately. -- http://m

Re: Finding overlapping times...

2007-12-13 Thread Jonathan Gardner
On Dec 13, 3:45 pm, Breal <[EMAIL PROTECTED]> wrote: > I have a list that looks like the following > [(10, 100010), (15, 17), (19, 100015)] > > I would like to be able to determine which of these overlap each > other. So, in this case, tuple 1 overlaps with tuples 2 and 3. Tuple >

Re: Newbie design problem

2007-12-17 Thread Jonathan Gardner
On Dec 14, 8:02 am, [EMAIL PROTECTED] wrote: > > Lex is very crude. I've found that it takes about half a day to > organize your token definitions and another half day to write a > tokenizer by hand. What's the point of the second half-day's work? > As someone who has earned a BS in Physics, I hav

Re: New+old-style multiple inheritance

2007-12-18 Thread Jonathan Gardner
On Dec 18, 7:08 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > We are trying to monkey-patch a third-party library that mixes new and > old-style classes with multiple inheritance. In so doing we have > uncovered some unexpected behaviour: > > > I know this level of messing with python inte

Re: Does fileinput.input() read STDIN all at once?

2007-12-18 Thread Jonathan Gardner
On Dec 18, 5:55 am, Adam Funk <[EMAIL PROTECTED]> wrote: > I'm using this sort of standard thing: > >for line in fileinput.input(): > do_stuff(line) > > and wondering whether it reads until it hits an EOF and then passes > lines (one at a time) into the variable line. This appears to be

Re: checking a string against multiple patterns

2007-12-18 Thread Jonathan Gardner
On Dec 18, 4:41 am, tomasz <[EMAIL PROTECTED]> wrote: > Is there an alternative to it? Am I missing something? Python doesn't > have special variables $1, $2 (right?) so you must assign the result > of a match to a variable, to be able to access the groups. > > I'd appreciate any hints. > Don't us

Re: Allowing Arbitrary Indentation in Python

2007-12-18 Thread Jonathan Gardner
On Dec 18, 2:16 pm, Sam <[EMAIL PROTECTED]> wrote: > layouts = ['column', 'form', 'frame'] > cmds.window(t='gwfUI Builder') > cmds.paneLayout(configuration='vertical3', ps=((1, 25, 100), (3, 20, > 100))) > cmds.paneLayout(configuration='horizontal2') > cmds.frameLayout(l='Layouts') >

Re: object vs class oriented -- xotcl

2008-01-24 Thread Jonathan Gardner
On Jan 24, 12:35 pm, William Pursell <[EMAIL PROTECTED]> wrote: > I'm not sure that describes the method well. Basically, you can > instantiate an object A of class Foo, and later change A to be an > object of class Bar. Does Python support this type of flexibility? > As I stated above, I've bee

Re: Ignore exceptions

2008-01-24 Thread Jonathan Gardner
On Jan 24, 12:13 pm, SMALLp <[EMAIL PROTECTED]> wrote: > Hy. Is there any way to make interrupter ignore exceptions. I'm working > on bigger project and i used to put try catch blocks after writing and > testing code what's boring and it's easy to make mistake. I remember of > something like that

Re: a newbie regex question

2008-01-24 Thread Jonathan Gardner
On Jan 24, 12:14 pm, Shoryuken <[EMAIL PROTECTED]> wrote: > Given a regular expression pattern, for example, \([A-Z].+[a-z]\), > > print out all strings that match the pattern in a file > > Anyone tell me a way to do it? I know it's easy, but i'm completely > new to python > > thanks alot You may

Re: Python seems to be ignoring my except clause...

2008-02-19 Thread Jonathan Gardner
On Feb 19, 6:14 am, "Adam W." <[EMAIL PROTECTED]> wrote: > So I deleted my .pyc files and reran, same thing, but then I closed all > open windows and reran it, and it recompiled the pyc and the code > "worked". > ... > But now I know I have to keep deleting my > pyc files or else I will run into tr

Re: Web Development Project

2008-02-22 Thread Jonathan Gardner
On Feb 21, 3:34 pm, john_sm3853 <[EMAIL PROTECTED]> wrote: > Hey guys, I am interested in knowing, what new Web Development projects you > are doing, curious to know, what data base you use, and if you are using > Linux or Windows platform. Also, will like to know, if there are any > alternatives

Asynchronous urllib (urllib+asyncore)?

2008-02-26 Thread Jonathan Gardner
So, I ran into a problem that I would like to write as little code as possible to solve. The problem is that I would like to send out a bunch of HTTP requests simultaneously, using asynchronous techniques, and then do stuff with the results in parallel. Think of something like Google's map-reduce.

Re: Beautiful Code in Python?

2008-03-03 Thread Jonathan Gardner
On Mar 2, 8:35 am, Michele Simionato <[EMAIL PROTECTED]> wrote: > On Mar 2, 5:23 pm, js <[EMAIL PROTECTED]> wrote: > > > Hi, > > > Have you ever seen Beautiful Python code? > > Zope? Django? Python standard lib? or else? > > > Please tell me what code you think it's stunning. > > The doctest module

Re: Edit and continue for debugging?

2008-03-07 Thread Jonathan Gardner
This is an interesting issue because we who write web applications face the same problem. Except in the web world, the application state is stored in the browser so we don't have to work our way back to where we were. We just keep our url, cookies, and request parameters handy. Before I go on, I w

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-13 Thread Jonathan Gardner
On Mar 12, 6:37 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Mar 12, 8:11 pm, Justus Schwabedal <[EMAIL PROTECTED]> > wrote: > > > What do you need it for anyway? I just read about it and I think it's > > useless > > in python. > > Perl, like Python, has a separate compilation and run times.  One

Re: %x unsigned?

2008-03-14 Thread Jonathan Gardner
On Mar 14, 8:00 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > The %x conversion specifier is documented > inhttp://docs.python.org/lib/typesseq-strings.htmlas "Unsigned > hexadecimal (lowercase)."  What does "unsigned" refer to? > > >>> '0x%x' % 10 > '0xa' Somewhat unrelated, but have you seen t

Re: Monitoring SSHd and web servers?

2008-03-14 Thread Jonathan Gardner
On Mar 13, 11:32 pm, Gilles Ganault <[EMAIL PROTECTED]> wrote: > I'd like to monitor connections to a remote SSH and web server. Does > someone have some code handy that would try to connect every 5mn, and > print an error if the script can't connect? from time import sleep while True: # Try to

Re: eval and unicode

2008-03-20 Thread Jonathan Gardner
On Mar 20, 5:20 am, Laszlo Nagy <[EMAIL PROTECTED]> wrote: > How can I specify encoding for the built-in eval function? Here is the > documentation: > > http://docs.python.org/lib/built-in-funcs.html > > It tells that the "expression" parameter is a string. But tells nothing > about the encoding. S

Re: Change user on UNIX

2008-03-20 Thread Jonathan Gardner
On Mar 20, 4:51 am, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > Hi all. > Is there any way to su or login as a different user within a python > script? I mainly need to temporarily impersonate another user to > execute a command and then come back to the original user. > I tried to google a li

Re: eval and unicode

2008-03-20 Thread Jonathan Gardner
On Mar 20, 2:20 pm, Laszlo Nagy <[EMAIL PROTECTED]> wrote: > > >>  >>> eval( u'"徹底したコスト削減 ÁÍŰŐÜÖÚÓÉ трирова"' ) == eval( '"徹底し > >> たコスト削減 ÁÍŰŐÜÖÚÓÉ трирова"' ) > >> True > > > When you feed your unicode data into eval(), it doesn't have any > > encoding or decoding work to do. > > Yes, but what ab

Re: eval and unicode

2008-03-21 Thread Jonathan Gardner
On Mar 21, 1:54 am, Laszlo Nagy <[EMAIL PROTECTED]> wrote: >  >>> eval( "# -*- coding: latin2 -*-\n" + expr) > u'\u0170' # You can specify the encoding for eval, that is cool. > I didn't think of that. That's pretty cool. > I hope it is clear now.  Inside eval, an unicode object was created from

Re: Is this doable

2008-03-21 Thread Jonathan Gardner
On Mar 21, 4:48 am, fkallgren <[EMAIL PROTECTED]> wrote: > Hi. > > I have a little problem. I have a script that is in the scheduler > (win32). But every now and then I update this script and I dont want > to go to every computer and update it. So now I want the program to 1) > check for new versio

Re: urllib leaves connections/sockets waiting. BIG problem!!!

2008-03-24 Thread Jonathan Gardner
On Mar 24, 6:57 am, binaryj <[EMAIL PROTECTED]> wrote: > hi i am using urllib2 to do some automated web thing. > basically i hit on sites and check the price what they are offering > for their product and then decide if i want to lower or increase my > pricing.so in short i have to hit hundreds of

Re: Understanding search queries, semantics, and "Meaning" ...aren't we all looking for meaning?

2008-12-30 Thread Jonathan Gardner
On Dec 30, 12:35 pm, 5lvqbw...@sneakemail.com wrote: > I have Section 4.4.1 of SICP rattling around in my head (database > queries), and I'm trying to come up with a simple dictionary-based > database in Python to represent circuit diagrams.  My main confusion > isn't one of implementation, but a m

Re: need help with list/variables

2008-12-30 Thread Jonathan Gardner
On Dec 30, 11:41 am, 5lvqbw...@sneakemail.com wrote: > > >>> conc = lambda x,y: x[:] + y # concatenate 2 lists without side effects > >>> mylist = ['something\n', 'another something\n', 'something again\n'] > >>> myvar = reduce(conc, mylist) > >>> print myvar > "conc"? "side effects"? Missing Lisp

Re: Understanding search queries, semantics, and "Meaning" ...aren't we all looking for meaning?

2009-01-01 Thread Jonathan Gardner
On Dec 30 2008, 3:25 pm, 5lvqbw...@sneakemail.com wrote: > > In a typical SQL database, when you type in "SELECT foo FROM bar WHERE > > baz='bo'", you are not writing a program, at least not in the sense of > > Python or C or Java or Perl where you give instructions on HOW to run > > the program. Y

Re: Measuring bytes of packet sent from python application

2009-01-05 Thread Jonathan Gardner
On Jan 5, 2:26 pm, Kangkook Jee wrote: > I'd like to measure number of bytes sent(or recv'd) from my python > application. Does anyone have any idea how can I achieve this? > > I tried to do this by tracing some socket calls (send, sendto, sendAll) >   using 'metaclass' but I could find exactly pl

Re: Measuring bytes of packet sent from python application

2009-01-05 Thread Jonathan Gardner
On Jan 5, 3:23 pm, Kangkook Jee wrote: > Jonathan Gardner wrote: > > A good universal tool on the Linux platform is tcpdump. It takes some > > learning, but is very useful for this kind of task. You can use a tool > > like ethereal to visualize the data that tcpdump gathers.

Re: looking for tips on how to implement "ruby-style" Domain Specific Language in Python

2009-01-06 Thread Jonathan Gardner
On Jan 6, 8:13 am, sturlamolden wrote: > On Jan 6, 4:32 pm, mark wrote: > > > > Is it possible to > > switch between the custom DSL and the standard Python interpreter? > > > > - Write the DSL interpreter in Python. > There are Python modules out there that make writing a language interpreter al

Re: looking for tips on how to implement "ruby-style" Domain Specific Language in Python

2009-01-06 Thread Jonathan Gardner
On Jan 6, 8:18 am, sturlamolden wrote: > On Jan 6, 4:32 pm, mark wrote: > > > I want to implement a internal DSL in Python. I would like the syntax > > as human readable as possible. > > Also beware that Python is not Lisp. You cannot define new syntax (yes > I've seen the goto joke). This isn't

Re: looking for tips on how to implement "ruby-style" Domain Specific Language in Python

2009-01-06 Thread Jonathan Gardner
On Jan 6, 12:24 pm, J Kenneth King wrote: > Jonathan Gardner writes: > > On Jan 6, 8:18 am, sturlamolden wrote: > >> On Jan 6, 4:32 pm, mark wrote: > > >> > I want to implement a internal DSL in Python. I would like the syntax > >> > as human

Re: looking for tips on how to implement "ruby-style" Domain Specific Language in Python

2009-01-07 Thread Jonathan Gardner
On Jan 7, 7:50 am, J Kenneth King wrote: > Jonathan Gardner writes: > > On Jan 6, 12:24 pm, J Kenneth King wrote: > >> Jonathan Gardner writes: > >> > On Jan 6, 8:18 am, sturlamolden wrote: > >> >> On Jan 6, 4:32 pm, mark wrote: > > >

Re: looking for tips on how to implement "ruby-style" Domain Specific Language in Python

2009-01-07 Thread Jonathan Gardner
On Jan 7, 9:16 am, "Chris Mellon" wrote: > > The OP wants a Ruby-style DSL by which he means "something that lets > me write words instead of expressions". The ruby syntax is amenable to > this, python (and lisp, for that matter) syntax is not and you can't > implement that style of internal DSL i

Re: Making a decorator a staticmethod

2009-01-08 Thread Jonathan Gardner
On Jan 8, 11:18 am, "Zac Burns" wrote: > > In my use case (not the example below) the decorator returns a > function of the form def f(self, *args, **kwargs) which makes use of > attributes on the instance self. So, it only makes sense to use the > staticmethod in the class and in the baseclass. M

Re: Tree views - Best design practices

2009-01-08 Thread Jonathan Gardner
On Jan 8, 8:16 am, MRAB wrote: > Filip Gruszczyński wrote: > > Hi! > > > I have certain design problem, which I cannot solve elegantly. Maybe > > you know some good design patterns for this kind of tasks. > > > Task: > > > We have a model which has two kinds of objects: groups and elements. > > Gr

Re: Tree views - Best design practices

2009-01-08 Thread Jonathan Gardner
On Jan 8, 1:00 pm, "Filip Gruszczyński" wrote: > > Is it really any better than asking for class? I mean, if I need to > add another class to a hierarchy which behaves differently, will it be > more flexible (actually you have to add another method to every class > and check for in the gui). I bel

Re: Tree views - Best design practices

2009-01-08 Thread Jonathan Gardner
On Jan 8, 1:00 pm, "Filip Gruszczyński" wrote: > > Is it really any better than asking for class? I mean, if I need to > add another class to a hierarchy which behaves differently, will it be > more flexible (actually you have to add another method to every class > and check for in the gui). I bel

Re: Tree views - Best design practices

2009-01-08 Thread Jonathan Gardner
On Jan 8, 1:50 pm, "Filip Gruszczyński" wrote: > > But I am looking for a different type of flexibility. I would like to > be able to add more classes to my hierarchy and not have to change my > code in many places when I add new class to the hierarchy. If I have > to change every class in the hie

Re: looking for tips on how to implement "ruby-style" Domain Specific Language in Python

2009-01-09 Thread Jonathan Gardner
On Jan 8, 7:25 am, J Kenneth King wrote: > Jonathan Gardner writes: > > It seems we're defining "DSL" in two different ways. > > You can't write a DSL in Python because you can't change the syntax and > you don't have macros. > > You can

Re: looking for tips on how to implement "ruby-style" Domain Specific Language in Python

2009-01-09 Thread Jonathan Gardner
On Jan 8, 8:03 am, Kay Schluehr wrote: > On 8 Jan., 16:25, J Kenneth King wrote: > > > As another poster mentioned, eventually PyPy will be done and then > > you'll get more of an "in-Python" DSL. > > May I ask why you consider it as important that the interpreter is > written in Python? I see no

Re: Measuring bytes of packet sent from python application

2009-01-09 Thread Jonathan Gardner
On Jan 5, 6:08 pm, Grant Edwards wrote: > On 2009-01-05, Kangkook Jee wrote: > > I'm still struggling to solve it within python process since > > it looks cleaner but it doesn't seems to be easy at all. > > I don't why adding bunches of code to your app would be > "cleaner" than gathering data us

Re: Question

2008-10-13 Thread Jonathan Gardner
On Oct 13, 9:31 pm, "Aditi Meher" <[EMAIL PROTECTED]> wrote: > > I am connecting database using python,and i am inserting some data into it. > e.g.name and roll nos(some 100 records are stored) > > My question is "I want to display 10 records at a time and want to > store remaining records into buf

Re: How do I count the distance between strings in a list?

2009-02-23 Thread Jonathan Gardner
On Feb 23, 9:35 pm, collin wrote: > For example, if I were to have the code > > randomlist = ["1", "2", "3", "4"] > > And I want to count the distance between strings "1" and "4" which is > 3, what command can I use to do this? You'd have to get the indexes of the two items and subtract them. The

Re: code challenge: generate minimal expressions using only digits 1,2,3

2009-02-26 Thread Jonathan Gardner
On Feb 20, 6:31 am, Trip Technician wrote: > anyone interested in looking at the following problem. > > we are trying to express numbers as minimal expressions using only the > digits one two and three, with conventional arithmetic. so for > instance > > 33 = 2^(3+2)+1 = 3^3+(3*2) > > are both min

Re: suggestion on a complicated inter-process communication

2009-04-27 Thread Jonathan Gardner
On Apr 27, 8:59 pm, Way wrote: > Hello friends, > > I have a little messy situation on IPC. Please if you can, give me > some suggestion on how to implement. Thanks a lot! > > -> denotes create > > MainProcess -> Process1 -> Process3 (from os.system) >                    | >                     ->

Re: What replaces `` in py3k?

2008-05-21 Thread Jonathan Gardner
On May 21, 10:45 am, bukzor <[EMAIL PROTECTED]> wrote: > What are backticks going to be translated into? repr -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does python not have a mechanism for data hiding?

2008-06-10 Thread Jonathan Gardner
On Jun 10, 11:21 am, "Russ P." <[EMAIL PROTECTED]> wrote: > I took a risk in choosing Python, and I would > feel better about it if Python would move up to the next level with > more advanced features such as (optional) static typing and private > declarations. But every time I propose something li

Re: go to specific line in text file

2008-06-18 Thread Jonathan Gardner
On Jun 17, 3:10 am, Patrick David <[EMAIL PROTECTED]> wrote: > > I am searching for a way to jump to a specific line in a text file, let's > say to line no. 9000. > Is there any method like file.seek() which leads me to a given line instead > of a given byte? > As others have said, no. But if you'

Re: ask for a RE pattern to match TABLE in html

2008-06-26 Thread Jonathan Gardner
On Jun 26, 11:07 am, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-06-26, Stefan Behnel <[EMAIL PROTECTED]> wrote: > > > > Why not use an HTML parser instead? > > > > Stating it differently: in order to correctly recognize HTML > tags, you must use an HTML parser.  Trying to write an HTML > pa

Re: ask for a RE pattern to match TABLE in html

2008-06-26 Thread Jonathan Gardner
On Jun 26, 3:22 pm, MRAB <[EMAIL PROTECTED]> wrote: > Try something like: > > re.compile(r'.*?', re.DOTALL) So you would pick up strings like "foo"? I doubt that is what oyster wants. -- http://mail.python.org/mailman/listinfo/python-list

Re: ask for a RE pattern to match TABLE in html

2008-06-30 Thread Jonathan Gardner
On Jun 27, 10:32 am, "David C. Ullrich" <[EMAIL PROTECTED]> wrote: > (ii) The regexes in languages like Python and Perl include > features that are not part of the formal CS notion of > "regular expression". Do they include something that > does allow parsing nested delimiters properly? > In perl,

Re: x, = y (???)

2008-07-17 Thread Jonathan Gardner
On Jul 17, 12:55 pm, kj <[EMAIL PROTECTED]> wrote: > I still don't get it.  If we write > >   y  = 'Y' >   x, = y > > what's the difference now between x and y?  And if there's no > difference, what's the point of performing such "unpacking"? > Try: y = "abc" x, = y You were unpacking y into

Re: x, = y (???)

2008-07-17 Thread Jonathan Gardner
On Jul 17, 12:55 pm, kj <[EMAIL PROTECTED]> wrote: > what's the point of performing such "unpacking"? record = [name, address, telephone] ... name, address, telephone = record -- http://mail.python.org/mailman/listinfo/python-list

  1   2   3   >