Re: class factory question

2013-06-26 Thread Joshua Landau
On 26 June 2013 15:46, Peter Otten __pete...@web.de wrote: The clean way to cope with the situation is to use a dict: classnames = [Vspace, ...] classes = {name: type(name, ...) for name in classnames} Then you can access the Vspace class with classes[Vspace] If that is inconvenient for

Re: Limit Lines of Output

2013-06-26 Thread Joshua Landau
On 25 June 2013 22:48, Gene Heskett ghesk...@wdtv.com wrote: On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine: I did not. -- http://mail.python.org/mailman/listinfo/python-list

Re: Limit Lines of Output

2013-06-26 Thread Joshua Landau
On 26 June 2013 17:46, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Wed, 26 Jun 2013 16:24:56 +0100, Joshua Landau wrote: On 25 June 2013 22:48, Gene Heskett ghesk...@wdtv.com wrote: On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine: I did not. Unless there are two

Re: Need help removing trailing zeros

2013-06-26 Thread Joshua Landau
On 26 June 2013 23:02, bandcam...@gmail.com wrote: Hello, i'm making a calculator and I want to be able to use decimals but I don't like it when it comes out as ex.12.0 when it should be 12. I tried using .rstrip(0.rstrip(.) but that never seemed to work. If anyone has a solution please

Re: Need help removing trailing zeros

2013-06-26 Thread Joshua Landau
On 26 June 2013 23:21, PyNoob bandcam...@gmail.com wrote: Sorry about that... And thanks for your help, but I don't quite understand. That's fine, but... Would that make it off your example print({:g}.format(1.0))? I don't understand this sentence. But, hey, I forgot to check what level you

Re: class factory question

2013-06-26 Thread Joshua Landau
On 26 June 2013 16:40, Peter Otten __pete...@web.de wrote: Joshua Landau wrote: I would say if a dict isn't good, there are still some cases where you might not want to use globals. I _might_ do: # Make a module module_for_little_classes = ModuleType(module_for_little_classes, All

Re: Is this PEP-able? fwhile

2013-06-25 Thread Joshua Landau
On 25 June 2013 00:13, Tim Chase python.l...@tim.thechases.com wrote: On 2013-06-24 23:39, Fábio Santos wrote: On 24 Jun 2013 23:35, Tim Chase wrote: On 2013-06-25 07:38, Chris Angelico wrote: Python has no issues with breaking out of loops, and even has syntax specifically to complement

Re: Is this PEP-able? fwhile

2013-06-25 Thread Joshua Landau
On 24 June 2013 23:50, Chris Angelico ros...@gmail.com wrote: In more free-form languages, I implement this by simply omitting a line-break: ... Python could afford to lose a little rigidity here rather than gain actual new syntax: for i in range(10): if i%3: print(i) And there you

Re: Limit Lines of Output

2013-06-25 Thread Joshua Landau
On 25 June 2013 21:22, Bryan Britten britten.br...@gmail.com wrote: Ah, I always forget to mention my OS on these forums. I'm running Windows. Supposedly, Windows has more [http://superuser.com/questions/426226/less-or-more-in-windows], For Linux+less; this works: from subprocess import Popen,

Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread Joshua Landau
Here's a little test to make sure you understand (this is one of the most confusing parts of Python's closures in my opinion): foo = I'm foo! def working(): print(foo) def broken(): print(foo) if False: # There's no way this could cause a problem! foo = This will *never*

Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread Joshua Landau
On 24 June 2013 21:12, John Gordon gor...@panix.com wrote: Since you're new to programming, this might be a bit tricky to explain, but I'll do my best. :-) The problem is that change() isn't being executed here; instead it's being executed from within root.mainloop(), whenever the user

Re: Is this PEP-able? fwhile

2013-06-24 Thread Joshua Landau
On 24 June 2013 20:52, jim...@aol.com wrote: Syntax: fwhile X in ListY and conditionZ: The following would actually exactly as: for X in ListY: fwhile X in ListY and True: fwhile would act much like 'for', but would stop if the condition after the 'and' is no longer True. The

Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread Joshua Landau
On 24 June 2013 21:19, pablobarhamal...@gmail.com wrote: Thank's to you all! Setting isWhite as global worked fine. I'll probably be back soon with another silly question, see you then :) By the way, it's normally bad to use globals like this. When you're learning it's something you just do,

Re: n00b question on spacing

2013-06-22 Thread Joshua Landau
On 21 June 2013 23:26, Gary Herron gher...@digipen.edu wrote: On 06/21/2013 02:17 PM, Yves S. Garret wrote: I have the following line of code: log.msg(Item wrote to MongoDB database %s/%s %(settings['MONGODB_DB'], settings['MONGODB_COLLECTION']), level=log.DEBUG, spider=spider) ... I was

Re: n00b question on spacing

2013-06-22 Thread Joshua Landau
On 22 June 2013 14:36, Joshua Landau joshua.landau...@gmail.com wrote: message = Item wrote to MongoDB database Pedant's note: Item *written* to MongoDB database -- http://mail.python.org/mailman/listinfo/python-list

Re: n00b question on spacing

2013-06-22 Thread Joshua Landau
On 22 June 2013 16:24, Rick Johnson rantingrickjohn...@gmail.com wrote: On Saturday, June 22, 2013 8:36:43 AM UTC-5, Joshua Landau wrote: message = Item wrote to MongoDB database message += {0[MONGODB_DB]}/{0[MONGODB_COLLECTION]}.format(settings) log.msg(message, level=log.DEBUG, spider

Re: n00b question on spacing

2013-06-22 Thread Joshua Landau
On 22 June 2013 14:36, Joshua Landau joshua.landau...@gmail.com wrote: My favourite way would be along the lines of: message = Item wrote to MongoDB database message += {0[MONGODB_DB]}/{0[MONGODB_COLLECTION]}.format(settings) log.msg(message, level=log.DEBUG, spider=spider) To make a habit

Re: n00b question on spacing

2013-06-22 Thread Joshua Landau
On 22 June 2013 16:55, Rick Johnson rantingrickjohn...@gmail.com wrote: On Saturday, June 22, 2013 10:40:24 AM UTC-5, Joshua Landau wrote: Plus, your use of the format syntax is incorrect. Wut? Well what i mean exactly is not that it's illegal, i just find the use of the getattr sugar, from

Re: n00b question on spacing

2013-06-22 Thread Joshua Landau
On 22 June 2013 18:28, Alister alister.w...@ntlworld.com wrote: On Sat, 22 Jun 2013 17:11:00 +0100, Joshua Landau wrote: On 22 June 2013 16:55, Rick Johnson rantingrickjohn...@gmail.com wrote: On Saturday, June 22, 2013 10:40:24 AM UTC-5, Joshua Landau wrote: Plus, your use of the format

Re: Problem with the for loop syntax

2013-06-20 Thread Joshua Landau
On 20 June 2013 04:11, Cameron Simpson c...@zip.com.au wrote: Also, opening-and-not-closing a set of brackets is almost the only way in Python to make this kind of error (syntax at one line, actual mistake far before). See if your editor has a show-the-matching-bracket mode. snip If you

Re: About GIL Questions!

2013-06-20 Thread Joshua Landau
On 20 June 2013 05:13, Thanatos xiao yanxiaopei...@gmail.com wrote: Hey everyone! Recently I see the python source code, but i still not understand about gil. first, why single core quicker multi-core ? Chris Angelico touched on your other points, but not this as clearly; Python threads run

Re: A Beginner's Doubt

2013-06-19 Thread Joshua Landau
Please be aware, Augusto, that Rick is known to be a bit... OTT. Don't take him too seriously (but he's not an idiot either). On 19 June 2013 14:58, augusto...@gmail.com wrote: Hello! This is my first post in this group and the reason why I came across here is that, despite my complete lack

Re: A Beginner's Doubt

2013-06-19 Thread Joshua Landau
On 19 June 2013 17:39, Joel Goldstick joel.goldst...@gmail.com wrote: What is the subject that this teacher of yours teaches? Do you know anyone who has every done any programming? Why python? One of those questions is too easy :P. But, no, I'd actually point out that Python might *not* be

Re: python game

2013-06-19 Thread Joshua Landau
This is prob'ly the freakiest thing I've ever run... Anyhoo, I recommend that when you post slabs of code to a mailing list you at least make it runnable for us. We don't have the images. I fixed it by doing: | playerImage = pygame.Surface((40, 40)) | bearImage = pygame.Surface((64, 64)) | |

Re: Problem with the for loop syntax

2013-06-19 Thread Joshua Landau
On 19 June 2013 23:53, Arturo B a7xrturo...@gmail.com wrote: Mmmm Ok guys, thank you I'm really sure that isn't a weird character, it is a space. My Python version is 3.3.2, I've runed this code in Python 2.7.5, but it stills the same. I've done what you said but it doesn't work.

Re: Why 'files.py' does not print the filenames into a table format?

2013-06-15 Thread Joshua Landau
On 15 June 2013 20:51, Nick the Gr33k supp...@superhost.gr wrote: On 15/6/2013 10:46 μμ, Jarrod Henry wrote: Nick, at this point, you need to hire someone to do your work for you. The code is completely ready. Some detail is missing and its not printing the files as expected. Look, Nick,

Re: Pattern Search Regular Expression

2013-06-15 Thread Joshua Landau
On 15 June 2013 11:18, Mark Lawrence breamore...@yahoo.co.uk wrote: I tend to reach for string methods rather than an RE so will something like this suit you? c:\Users\Mark\MyPythontype a.py for s in (In the ocean, On the ocean, By the ocean, In this group,

Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread Joshua Landau
On 14 June 2013 19:37, rusi rustompm...@gmail.com wrote: 2. The recent responses from Robert Kern are in my view the ideal. In summary it runs thus: Stupid question no. 6457 from Nikos: ... Robert : Look this up link Nikos: I dont understand Robert: Link explains Nikos: I DONTU NDERSTND

Re: My son wants me to teach him Python

2013-06-13 Thread Joshua Landau
On 13 June 2013 17:50, Tomasz Rola rto...@ceti.pl wrote: Of course kids are more interesting in things painted on screen, especially if they are colorful, move and make sounds at that. The next step would be a simple, interactive game. Which is why I would synthesize something neat yet

Re: My son wants me to teach him Python

2013-06-13 Thread Joshua Landau
On 13 June 2013 14:01, rusi rustompm...@gmail.com wrote: Some views of mine (controversial!). Python is at least two things, a language and a culture. As a language its exceptionally dogma-neutral. You can do OO or FP, throwaway one-off scripts or long-term system building etc However as a

Re: My son wants me to teach him Python

2013-06-13 Thread Joshua Landau
I don't normally respond to trolls, but I'll make an exception here. On 14 June 2013 04:33, Rick Johnson rantingrickjohn...@gmail.com wrote: On Thursday, June 13, 2013 3:18:57 PM UTC-5, Joshua Landau wrote: [...] GUI is boring. I don't give a damn about that. If I had it my way, I'd never

Re: PyWart: The problem with print

2013-06-12 Thread Joshua Landau
On 4 June 2013 14:35, Mark Lawrence breamore...@yahoo.co.uk wrote: On 04/06/2013 14:29, rusi wrote: The Clash of the Titans Lé jmf chârgeth with mightƴ might And le Mond underneath trembleth Now RR mounts his sturdy steed And the windmill yonder turneth +1 funniest poem of the week :)

Re: Split a list into two parts based on a filter?

2013-06-11 Thread Joshua Landau
On 11 June 2013 01:11, Peter Otten __pete...@web.de wrote: def partition(items, predicate=bool): a, b = itertools.tee((predicate(item), item) for item in items) return ((item for pred, item in a if not pred), (item for pred, item in b if pred)) I have to tell you this is

Re: Don't rebind built-in names* - it confuses readers

2013-06-11 Thread Joshua Landau
On 11 June 2013 01:14, Terry Jan Reedy tjre...@udel.edu wrote: Many long-time posters have advised Don't rebind built-in names*. For instance, open Lib/idlelib/GrepDialog.py in an editor that colorizes Python syntax, such as Idle's editor, jump down to the bottom and read up, and (until it is

Re: Re-using copyrighted code

2013-06-10 Thread Joshua Landau
On 10 June 2013 17:29, llanitedave llanited...@veawb.coop wrote: However, I have yet to see an example of source code that qualifies as either parody or satire under any standard. You should try reading Perl. -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner question

2013-06-04 Thread Joshua Landau
On 4 June 2013 04:39, eschneide...@comcast.net wrote: Is there a more efficient way of doing this? Any help is gratly appreciated. import random def partdeux(): print('''A man lunges at you with a knife! Do you DUCK or PARRY?''') option1=('duck') option2=('parry')

Re: How to get an integer from a sequence of bytes

2013-06-04 Thread Joshua Landau
On 4 June 2013 14:39, Grant Edwards invalid@invalid.invalid wrote: On 2013-06-03, Dan Stromberg drsali...@gmail.com wrote: Today though, it would be difficult to sell a conventional (Von Neumann) computer that didn't have 8 bit bytes. There are tons (as in millions of units per month) of CPUs

Re: [RELEASED] Python 2.7.5

2013-06-04 Thread Joshua Landau
On 4 June 2013 00:12, Mark Lawrence breamore...@yahoo.co.uk wrote: On 03/06/2013 23:37, Carlos Nepomuceno wrote: What still doesn't work in Python 3? http://python3wos.appspot.com/ Don't take this list too seriously - some of those do have fully working and stable Python 3 packages that just

Re: How to increment date by week?

2013-06-04 Thread Joshua Landau
On 4 June 2013 22:31, PieGuy r90...@gmail.com wrote: Starting on any day/date, I would like to create a one year list, by week (start date could be any day of week). Having a numerical week index in front of date, ie 1-52, would be a bonus. ie, 1. 6/4/2013 2. 6/11/2013

Re: Too many python installations. Should i remove them all and install the latest?

2013-06-03 Thread Joshua Landau
On 3 June 2013 04:18, Chris Angelico ros...@gmail.com wrote: On Mon, Jun 3, 2013 at 12:30 PM, alex23 wuwe...@gmail.com wrote: On Jun 1, 10:24 am, Chris Angelico ros...@gmail.com wrote: Hmm. What other MUD commands have obvious Unix equivalents? say -- echo emote -- python -c attack -- sudo

Re: Cutting a deck of cards

2013-06-01 Thread Joshua Landau
On 31 May 2013 12:56, Lee Crocker leedanielcroc...@gmail.com wrote: Why on Earth would you want to? Cutting a deck makes no sense in software. Randomize the deck properly (Google Fisher-Yates) and start dealing. Cutting the deck will not make it any more random, True and in fact will

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread Joshua Landau
On 30 May 2013 10:48, bhk...@gmail.com wrote: Question: - Function mergeSort is called only once, but it is getting recursively executed after the printing the last statement print(Merging ,alist). But don't recursion taking place except at these places mergeSort(lefthalf),

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread Joshua Landau
On 30 May 2013 11:19, bhk...@gmail.com wrote: Also, Can you please let me know how did you found out that I am using Python 2 Interpreter. Do you have access to a Python3 interpreter? If so, try running it and your output will look like: Splitting [54, 26, 93, 17, 77, 31, 44, 55, 20]

Re: User Input

2013-05-30 Thread Joshua Landau
On 30 May 2013 15:47, Eternaltheft eternalth...@gmail.com wrote: And perhaps you meant for your function to CALL drawBoard(), rather than returning the function object drawBoard. DaveA do you think it would be better if i call drawBoard? Please read

Fatal Python error

2013-05-29 Thread Joshua Landau
Hello all, again. Instead of revising like I'm meant to be, I've been delving into a bit of Python and I've come up with this code: class ClassWithProperty: @property def property(self): pass thingwithproperty = ClassWithProperty() def loop(): try: thingwithproperty.property except: pass

Re: Fatal Python error

2013-05-29 Thread Joshua Landau
On 29 May 2013 13:25, Dave Angel da...@davea.name wrote: On 05/29/2013 07:48 AM, Joshua Landau wrote: Hello all, again. Instead of revising like I'm meant to be, I've been delving into a bit of Python and I've come up with this code: To start with, please post in text mode. By using html

Re: Fatal Python error

2013-05-29 Thread Joshua Landau
On 29 May 2013 13:30, Marcel Rodrigues marcel...@gmail.com wrote: I just tried your code with similar results: it does nothing on PyPy 2.0.0-beta2 and Python 2.7.4. But on Python 3.3.1 it caused core dump. It's a little weird but so is the code. You have defined a function that calls itself

Re: Fatal Python error

2013-05-29 Thread Joshua Landau
On 29 May 2013 14:02, Dave Angel da...@davea.name wrote: On 05/29/2013 08:45 AM, Oscar Benjamin wrote: Joshua: Avoid doing anything complex inside an exception handler. Unfortunately, Ranger (the file manager in question) wraps a lot of stuff in one big exception handler. Hence there isn't

Re: Why do Perl programmers make more money than Python programmers

2013-05-06 Thread Joshua Landau
On 6 May 2013 13:03, Steven D'Aprano steve+comp.lang.pyt...@pearwood.infowrote: On Mon, 06 May 2013 17:30:33 +1000, Chris Angelico wrote: On Mon, May 6, 2013 at 4:28 PM, Fábio Santos fabiosantos...@gmail.com wrote: And of course, the Python Programmer's moral code is only 80 characters

Re: Help with loading file into an array

2013-05-06 Thread Joshua Landau
On 5 May 2013 07:06, peter berrett pwberr...@gmail.com wrote: I am trying to build a program that can find comets in a series of astronomical images. I have already written functions to find the comet in a series of images, the data of which is stored in embedded lists. The area I am having

Re: Collision of Two Rect

2013-05-06 Thread Joshua Landau
On 4 May 2013 00:42, Ian Kelly ian.g.ke...@gmail.com wrote: The other thing that is suspicious about the code you posted is that it has two different notions of the ball's position that are not necessarily in agreement. There is the ball_rect, and there are also the x and y variables. snip

Re: Nested iteration?

2013-04-23 Thread Joshua Landau
On 23 April 2013 21:49, Terry Jan Reedy tjre...@udel.edu wrote: ri= iter(range(3)) for i in ri: for j in ri: print(i,j) # this is somewhat deceptive as the outer loop executes just once 0 1 0 2 I personally would add a 'break' after 'outer_line = next(f)', since the first

Re: Nested iteration?

2013-04-23 Thread Joshua Landau
On 23 April 2013 22:29, Oscar Benjamin oscar.j.benja...@gmail.com wrote: I just thought I'd add that Python 3 has a convenient way to avoid this problem with next() which is to use the starred unpacking syntax: numbers = [1, 2, 3, 4] first, *numbers = numbers That creates a new list

Re: itertools.groupby

2013-04-21 Thread Joshua Landau
On 21 April 2013 01:13, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I wouldn't use groupby. It's a hammer, not every grouping job is a nail. Instead, use a simple accumulator: def group(lines): accum = [] for line in lines: line = line.strip() if

Re: I hate you all

2013-04-06 Thread Joshua Landau
it's not like it affects the actual code. Yours frustratedly, Joshua Landau But seriously, please at least look like you've read other people's posts. It doesn't matter what tabstop

Re: JIT compilers for Python, what is the latest news?

2013-04-06 Thread Joshua Landau
On 5 April 2013 19:37, Devin Jeanpierre jeanpierr...@gmail.com wrote: On Fri, Apr 5, 2013 at 4:34 AM, John Ladasky john_lada...@sbcglobal.net wrote: On Thursday, April 4, 2013 7:39:16 PM UTC-7, MRAB wrote: Have you looked at Cython? Not quite the same, but still... I'm already using

Re: JIT compilers for Python, what is the latest news?

2013-04-06 Thread Joshua Landau
On 5 April 2013 03:29, John Ladasky john_lada...@sbcglobal.net wrote: I'm revisiting a project that I haven't touched in over a year. It was written in Python 2.6, and executed on 32-bit Ubuntu 10.10. I experienced a 20% performance increase when I used Psyco, because I had a

Re: In defence of 80-char lines

2013-04-04 Thread Joshua Landau
On 4 April 2013 12:09, Tim Chase python.l...@tim.thechases.com wrote: On 2013-04-04 08:43, Peter Otten wrote: llanitedave wrote: self.mainLabel.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = FreeSans)) I think I would prefer labelfont = wx.Font( pointSize=12,

Re: Performance of int/long in Python 3

2013-04-02 Thread Joshua Landau
The initial post posited: The Python 3 merge of int and long has effectively penalized small-number arithmetic by removing an optimization. As we've seen from PEP 393 strings (jmf aside), there can be huge benefits from having a single type with multiple representations internally. Is there value

Re: Small program ideas

2013-02-26 Thread Joshua Landau
On 26 February 2013 22:47, eli m techgeek...@gmail.com wrote: How hard would it be to change one file to another and would it be a small-medium sized program? How do you want to change it? Like rename a file (os.rename)? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Newbie

2013-02-24 Thread Joshua Landau
On 24 February 2013 19:29, piterrr.dolin...@gmail.com wrote: Hi. Steve, I don't know where you have been over the past couple of days but it is widely known (if the thread title is any indication) that I am indeed very new to Python, but not new to programming in general. To give a bit of

Re: Python Newbie

2013-02-24 Thread Joshua Landau
On 24 February 2013 20:48, Roy Smith r...@panix.com wrote: In article mailman.2434.1361738581.2939.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: On Mon, Feb 25, 2013 at 7:34 AM, MRAB pyt...@mrabarnett.plus.com wrote: Some languages require parentheses, others don't.

Re: Python Newbie

2013-02-24 Thread Joshua Landau
On 24 February 2013 22:43, piterrr.dolin...@gmail.com wrote: Josh, Not thank you for your malicious post. Be careful, us programmers do *eventually* catch on to who is a troll, and if you say things like that we may eventually mark you off as just to hostile. I *honestly* meant no malice or

Re: Python Newbie

2013-02-24 Thread Joshua Landau
On 24 February 2013 22:08, Chris Angelico ros...@gmail.com wrote: On Mon, Feb 25, 2013 at 8:35 AM, Joshua Landau joshua.landau...@gmail.com wrote: def solve_quadratic(a, b, c): Solve a quadratic equation of the form ax² + bx + c = 0 The result will be a tuple of the two results

Re: Python Newbie

2013-02-24 Thread Joshua Landau
On 24 February 2013 23:18, Oscar Benjamin oscar.j.benja...@gmail.comwrote: On 24 February 2013 21:35, Joshua Landau joshua.landau...@gmail.com wrote: determinant = b**2 - 4*a*c It's called the discriminant. A determinant is something altogether different. *cries at own idiocy* Thank

Re: Python Newbie

2013-02-24 Thread Joshua Landau
On 25 February 2013 00:08, piterrr.dolin...@gmail.com wrote: For example (I believe it's already been mentioned) declaring intX with some integer value does *nothing* to maintain X as an integer: -- intX = 32 -- intX = intX / 3.0 -- intX 10.66 Yes I did see that

Re: Python Newbie

2013-02-24 Thread Joshua Landau
On 25 February 2013 02:08, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Sun, 24 Feb 2013 21:58:36 +, Joshua Landau joshua.landau...@gmail.com declaimed the following in gmane.comp.python.general: condition1 = long_condition_expression_1 condition2 = long_condition_expression_2

Re: problem with exam task for college

2013-01-04 Thread Joshua Landau
On 4 January 2013 19:00, Chris Angelico ros...@gmail.com wrote: On Sat, Jan 5, 2013 at 5:59 AM, Chris Angelico ros...@gmail.com wrote: Google tells me that brandstofmeter might mean Babylon 9 And by the way, in case it didn't come across, I'm jesting there. What I mean is that Google didn't

Re: Please help if you can!

2012-12-26 Thread Joshua Landau
THIS IS A LONG POST, BUT IF YOU WANT TO LEARN YOU SHOULD READ IT. SERIOUSLY. UNLIKE Mitya Sirenef's THIS DOES NOT ASSUME MORE KNOWLEDGE THAN IS IN YOUR POST ALREADY, ALTHOUGH HIS IS DEFINITELY BETTER OVERALL. AS SUCH, THERE ARE NO FUNCTIONS. OK. There are several small errors in here, but

Re: Please help if you can!

2012-12-26 Thread Joshua Landau
On 27 December 2012 00:04, bobflipperdoo...@gmail.com wrote: First, sorry for starting a new post - I didn't want anyone to have to read through the whole first one when the questions were completely different :/ Second, I honestly have no idea how to answer your questions. I am a

Re: Custom alphabetical sort

2012-12-26 Thread Joshua Landau
On 25 December 2012 06:18, Dave Angel d...@davea.name wrote: On 12/24/2012 06:19 PM, Pander Musubi wrote: snip Thanks very much for this efficient code. Perhaps you missed Ian Kelly's correction of Thomas Bach's approach: d = { k: v for v, k in enumerate(cs) } def collate(x):

Re: Custom alphabetical sort

2012-12-24 Thread Joshua Landau
On 24 December 2012 16:18, Roy Smith r...@panix.com wrote: In article 40d108ec-b019-4829-a969-c8ef51386...@googlegroups.com, Pander Musubi pander.mus...@gmail.com wrote: Hi all, I would like to sort according to this order: (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5', '6',

Re: argparse -- mutually exclusive sets of arguments?

2012-11-23 Thread Joshua Landau
On 23 November 2012 18:46, Roy Smith r...@panix.com wrote: My command either takes two positional arguments (in which case, both are required): $ command foo bar or the name of a config file (in which case, the positional arguments are forbidden): $ command --config file How can I

Re: Inconsistent behaviour os str.find/str.index when providing optional parameters

2012-11-22 Thread Joshua Landau
If you reply through Google Groups, please be careful not to do it the traditional way as us poor saps get hundreds of lines of added in. I believe (but this is mere recollection) that a good way to use the site is by selecting the text you want to quote before replying (even if it is the whole

Re: Yet another Python textbook

2012-11-22 Thread Joshua Landau
On 22 November 2012 22:41, Colin J. Williams c...@ncf.ca wrote: On 22/11/2012 1:27 PM, Ian Kelly wrote: On Thu, Nov 22, 2012 at 5:24 AM, Colin J. Williams c...@ncf.ca wrote: From my reading of the docs, it seems to me that the three following should be equivalent: (a)

Re: Inconsistent behaviour os str.find/str.index when providing optional parameters

2012-11-21 Thread Joshua Landau
snipping occurs On 21 November 2012 20:58, MRAB pyt...@mrabarnett.plus.com wrote: On 2012-11-21 19:25, Hans Mulder wrote: On 21/11/12 17:59:05, Alister wrote: On Wed, 21 Nov 2012 04:43:57 -0800, Giacomo Alzetta wrote: 'spam'.find('', 5) -1 Now, reading find's documentation:

Re: Yet another Python textbook

2012-11-21 Thread Joshua Landau
On 21 November 2012 22:17, Chris Angelico ros...@gmail.com wrote: On Thu, Nov 22, 2012 at 4:03 AM, Colin J. Williams c...@ncf.ca wrote: On 20/11/2012 4:00 PM, Chris Angelico wrote: To the OP: jmf has an unnatural hatred of Python 3.3 and PEP 393 strings. Take no notice; the rest of the

Re: 10 sec poll - please reply!

2012-11-20 Thread Joshua Landau
On 20 November 2012 16:19, Dave Angel d...@davea.name wrote: On 11/20/2012 11:09 AM, John Gordon wrote: In 3d71f175-164e-494c-a521-2eaa5679b...@googlegroups.com Michael Herrmann michael.herrm...@getautoma.com writes: What, in your view, would be the most intuitive alternative name?

Re: proxy??

2012-11-20 Thread Joshua Landau
On 20 November 2012 14:48, Jorge Alberto Diaz Orozco jaoro...@estudiantes.uci.cu wrote: Hi there. Does anyone knows how to manage headers using a simple proxy??? I'm doing this but It gives me problems In some pages. I don't know the answer, but I do know you'd get more favour if you

Re: Greedy parsing of argparse/positional arguments

2012-11-20 Thread Joshua Landau
On 20 November 2012 10:02, Johannes Bauer dfnsonfsdu...@gmx.de wrote: Hi list, I have a problem with Python3.2's argparse module. The following sample: parser = argparse.ArgumentParser(prog = sys.argv[0]) parser.add_argument(-enc, metavar = enc, nargs = +, type = str, default = [ utf-8 ])

Re: Dictionary of Functions

2012-11-15 Thread Joshua Landau
On 15 November 2012 17:13, Chris Kaynor ckay...@zindagigames.com wrote: On Thu, Nov 15, 2012 at 8:04 AM, Kevin Gullikson kevin.gullik...@gmail.com wrote: Hi all, I am trying to make a dictionary of functions, where each entry in the dictionary is the same function with a few of the

Re: Python questions help

2012-11-15 Thread Joshua Landau
On 15 November 2012 01:47, su29090 129k...@gmail.com wrote: I brought a python book and i'm a beginner and I read and tried to do the questions and I still get it wrong. How to create a program that reads an uspecified number of integers, that determines how many positive and negative values

Re: Simple Question regarding running .py program

2012-11-14 Thread Joshua Landau
Steven, whilst I hold you in high regard, this post seems spurned by bias. I would urge you to reconsider your *argument*, although your *position* has merit. On 14 November 2012 23:07, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Wed, 14 Nov 2012 10:20:13 -0800, rurpy

Re: List comprehension for testing **params

2012-11-12 Thread Joshua Landau
Just a few tricks you may have missed: On 12 November 2012 10:48, Ulrich Eckhardt ulrich.eckha...@dominolaser.comwrote: Am 11.11.2012 23:24, schrieb Cantabile: if required.intersection(params.**keys()) != required: if required.issubset(params): missing = required -

Re: List comprehension for testing **params

2012-11-12 Thread Joshua Landau
On 12 November 2012 13:23, Joshua Landau joshua.landau...@gmail.com wrote: Just a few tricks you may have missed: On 12 November 2012 10:48, Ulrich Eckhardt ulrich.eckha...@dominolaser.com wrote: Am 11.11.2012 23:24, schrieb Cantabile: if required.intersection(params.**keys

Re: Help building a dictionary of lists

2012-11-12 Thread Joshua Landau
On 12 November 2012 22:26, NJ1706 nickj1...@googlemail.com wrote: Chaps, I am new to Python have inherited a test harness written in the language that I am trying to extend. The following code shows how dictionaries holding lists of commands are handled in the script... Start of Code_1

Re: Help building a dictionary of lists

2012-11-12 Thread Joshua Landau
On 12 November 2012 22:26, NJ1706 nickj1...@googlemail.com wrote: # List of tests TestList = ( 'Test_1', 'Test_2' ) Note that TestList is a *tuple*, not a list. You normally would want to write test_names instead of TestList for several reasons: * Unless it's a class, Python

Re: Division matrix

2012-11-12 Thread Joshua Landau
On 13 November 2012 01:00, Cleuson Alves cleuso...@gmail.com wrote: Hello, I need to solve an exercise follows, first calculate the inverse matrix and then multiply the first matrix. This list isn't to give answers for homeworks, and this sounds like one. We *do* give help to those who have a

Re: Multi-dimensional list initialization

2012-11-07 Thread Joshua Landau
On 7 November 2012 11:11, Oscar Benjamin oscar.j.benja...@gmail.com wrote: On Nov 7, 2012 5:41 AM, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: If anything is to be done in this area, it would be better as an extension of list comprehensions, e.g. [[None times 5] times 10]

Re: Multi-dimensional list initialization

2012-11-07 Thread Joshua Landau
*Spoiler:* You've convinced me. On 7 November 2012 14:00, Oscar Benjamin oscar.j.benja...@gmail.com wrote: On 7 November 2012 13:39, Joshua Landau joshua.landau...@gmail.com wrote: On 7 November 2012 11:11, Oscar Benjamin oscar.j.benja...@gmail.com wrote: A more modest addition

Re: Multi-dimensional list initialization

2012-11-07 Thread Joshua Landau
On 7 November 2012 23:55, Andrew Robinson andr...@r3dsolutions.com wrote: On 11/07/2012 05:39 AM, Joshua Landau wrote: A more modest addition for the limited case described in this thread could be to use exponentiation: [0] ** (2, 3) [[0, 0, 0], [0, 0, 0]] I'm against over using

Re: Multi-dimensional list initialization

2012-11-05 Thread Joshua Landau
On 5 November 2012 06:27, Demian Brecht demianbre...@gmail.com wrote: a = [None] * 4 a[0] = 'a' a ['a', None, None, None] m = [[None] * 4] * 4 m[0][0] = 'm' m [['m', None, None, None], ['m', None, None, None], ['m', None, None, None], ['m', None, None, None]] Is this expected

Re: __unicode__() works, unicode() blows up.

2012-11-04 Thread Joshua Landau
On 4 November 2012 13:32, Roy Smith r...@panix.com wrote: Environment: Python-2.7.3 Ubuntu Precise mongoengine 0.6.20 I have a class which includes a __unicode__() method: class User(mongoengine.Document): def __unicode__(self): return self.username If I create an

Re: OT Questions

2012-10-28 Thread Joshua Landau
On 16 October 2012 18:23, Ian Kelly ian.g.ke...@gmail.com wrote: On Tue, Oct 16, 2012 at 9:21 AM, Demian Brecht demianbre...@gmail.com wrote: There's a small light somewhere deep down that says maybe this is just someone quite misdirected. A brief search shows that he has multiple

Re: A desperate lunge for on-topic-ness

2012-10-23 Thread Joshua Landau
On 23/10/2012, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Mon, 22 Oct 2012 16:02:34 -0600, Ian Kelly ian.g.ke...@gmail.com declaimed the following in gmane.comp.python.general: On my wishlist for Python is a big, fat SyntaxError for any variable that could be interpreted as either

Re: can we append a list with another list in Python ?

2012-10-23 Thread Joshua Landau
On 23/10/2012, inshu chauhan insidesh...@gmail.com wrote: can we append a list with another list in Python ? using the normal routine syntax but with a for loop ?? I assume you want to join two lists. You are corrrect that we can do: start = [1, 2, 3, 4] end = [5, 6, 7, 8] for end_item in

Re: can we append a list with another list in Python ?

2012-10-23 Thread Joshua Landau
On 23 October 2012 12:07, Jean-Michel Pichavant jeanmic...@sequans.comwrote: - Original Message - Thankyou.. but my problem is different than simply joining 2 lists and it is done now :) A lot of people though you were asking for joining lists, you description was

Re: can we append a list with another list in Python ?

2012-10-23 Thread Joshua Landau
On 23 October 2012 21:03, Joshua Landau joshua.landau...@gmail.com wrote: On 23 October 2012 12:07, Jean-Michel Pichavant jeanmic...@sequans.comwrote: - Original Message - Thankyou.. but my problem is different than simply joining 2 lists and it is done now :) A lot

Re: can we append a list with another list in Python ?

2012-10-23 Thread Joshua Landau
On 23 October 2012 21:06, Joshua Landau joshua.landau...@gmail.com wrote: On 23 October 2012 21:03, Joshua Landau joshua.landau...@gmail.comwrote: On 23 October 2012 12:07, Jean-Michel Pichavant jeanmic...@sequans.comwrote: - Original Message - Thankyou.. but my problem

Re: get each pair from a string.

2012-10-21 Thread Joshua Landau
On 21 October 2012 19:33, Vincent Davis vinc...@vincentdavis.net wrote: I am looking for a good way to get every pair from a string. For example, input: x = 'apple' output 'ap' 'pp' 'pl' 'le' I am not seeing a obvious way to do this without multiple for loops, but maybe there is not

<    1   2   3   4   5   >