Re: building an online judge to evaluate Python programs

2013-09-23 Thread Fábio Santos
On 20 Sep 2013 21:14, "Jabba Laci" wrote: > > > That last seems to me to be the biggie. Several times in the past few > > years, people in this mailing list have tried to build a safe sandbox. > > And each one was a big failure, for a hacker of sufficient interest. > > Some of them were spectacul

Re: How can I remove the first line of a multi-line string? (SOLVED)

2013-09-11 Thread Fábio Santos
On 2 Sep 2013 18:13, "Roy Smith" wrote: > > In article , > Anthony Papillion wrote: > > > On 09/02/2013 11:12 AM, Chris “Kwpolska” Warrick wrote: > > > On Mon, Sep 2, 2013 at 6:06 PM, Anthony Papillion > > > wrote: > > >> Hello Everyone, > > >> > > >> I have a multi-line string and I need to re

Re: MySQL data types vs Django/Python data types

2013-09-04 Thread Fábio Santos
On 1 Sep 2013 21:54, "Gary Roach" wrote: > > Hi all, > > System: > Debian Wheezy Linux > Python 2.7 > Django 1.5 > MySql 5.5 > > I am new to Python and Django and am having trouble matching Python data types with those of MySQL. MySQL has about 7 basic data types in

Re: semicolon at end of python's statements

2013-09-02 Thread Fábio Santos
On 09/02/2013 10:45 AM, Antoon Pardon wrote: Op 02-09-13 10:05, Steven D'Aprano schreef: It doesn't keep a whole chain of if clauses together. It doesn't let you do anything that you haven't already done. It just saves an indent and a newline. The cost, on the other hand, includes the risk that

Re: Best practice for generalizing and documenting each method's behaviour

2013-08-31 Thread Fábio Santos
On 30 Aug 2013 19:07, wrote: > > I'm starting a small project coding in Python as I learn the ropes. As the project grows bigger, there are more and more overlapping and even redundant methods. For example, several classes have a checkAndClean_obj_state() method. If just one or two such classes, i

Re: semicolon at end of python's statements

2013-08-30 Thread Fábio Santos
On 29 Aug 2013 23:20, "Ben Finney" wrote: > > Fábio Santos writes: > > > It is a shame that this is not possible in python. for..if exists in > > comprehensions and not in regular loops but that would be nice > > sometimes. > > So you use it in a

Re: semicolon at end of python's statements

2013-08-29 Thread Fábio Santos
On 29 Aug 2013 10:54, "Chris Angelico" wrote: > > foreach (some_array, mixed val) if (some_condition) > { > //do something with val > } > I hope that you don't mind that I have started to use this in JavaScript back at work. Its foreach loop requires you to do a filter all the time. It is a

Re: About executable

2013-08-26 Thread Fábio Santos
On 25 Aug 2013 21:47, "Luis José Novoa" wrote: > > Hi All. I am trying to create an executable file containing an optimization code using the pyomo package for optimization modeling along with ither packages like Numpy. When using py2exe to perform the task it generates the executable file, but wh

Re: pydoc vs. non-def'd methods

2013-08-22 Thread Fábio Santos
On 22 Aug 2013 06:17, "Dan Sommers" wrote: > > Greetings, > > I'm hava a class in which there are two equally useful names for one > method. Consider this design (there are other approaches, but that's > not what my question is about): > > class Spam1: > > def eggs(self): > '''Return

Re: Basic Python Query

2013-08-22 Thread Fábio Santos
On 22 Aug 2013 08:58, "chandan kumar" wrote: > > Hi all, > > Sorry for not explaining question properly.Here Its not about threading and dont worry about any indentations.Please see below example > > class Call_Constructor(): > def __init__(self): > print "In __init__ " > > class Test_

Re: Basic Python Query

2013-08-21 Thread Fábio Santos
On 21 Aug 2013 20:07, "Johannes Bauer" wrote: > > On 21.08.2013 11:11, Ulrich Eckhardt wrote: > > > That said, there is never a need for deriving > > from the Thread class, you can also use it to run a function without > > that. That way is IMHO clearer because the threading.Thread instance is > >

Re: How to keep cookies when making http requests (Python 2.7)

2013-08-21 Thread Fábio Santos
On 21 Aug 2013 09:22, "Luca Cerone" wrote: > > > > > I have used "cookielib" externally to "urllib2". It looks > > > > like this: > > > > from urllib2 import urlopen, Request > > > > from cookielib import CookieJar > > cookies = CookieJar() > > > > > > > > r = Request(...) > > > > cookies.add

Re: Is this PEP-able? (syntax for functools.partial-like functionality)

2013-08-20 Thread Fábio Santos
On 20 Aug 2013 10:14, "Ian Kelly" wrote: > > On Tue, Aug 20, 2013 at 2:28 AM, Fábio Santos wrote: > > I do realize that syntax in python is practically written in stone, but I > > have seen changes come by if they have good reasons. For example, > > keyw

Re: Replace blanks with letter

2013-08-20 Thread Fábio Santos
On 20 Aug 2013 09:42, wrote: > > I'm trying to replace the blank(_) with the letter typed in by the user, in the appropriate blank(_) spot where the letter should be (where is in the letters list). > > letters='abcdefg' > blanks='_ '*len(letters) > print('type letter from a to g') > print(blanks)

Re: Is this PEP-able? (syntax for functools.partial-like functionality)

2013-08-20 Thread Fábio Santos
On 20 Aug 2013 07:22, "Steven D'Aprano" wrote: > > On Tue, 20 Aug 2013 00:49:16 +0100, Fábio Santos wrote: > > > I had an idea for a handy syntax which I thought of while designing a > > language for fun. This would be a syntax for creating, from a function,

Is this PEP-able? (syntax for functools.partial-like functionality)

2013-08-19 Thread Fábio Santos
I had an idea for a handy syntax which I thought of while designing a language for fun. This would be a syntax for creating, from a function, a function which is just like it but with some parameters pre-filled. The usage is much like functools.partials, and my proposed syntax is like this: def sp

Re: many constructors in a class?

2013-08-15 Thread Fábio Santos
I agree with Steven here. classmethod is the best practise, most practical, readable, future-proof, one obvious way to do it. On 15 Aug 2013 08:29, "Steven D'Aprano" wrote: > On Wed, 14 Aug 2013 14:16:31 +, climb65 wrote: > > > Hello, > > > > here is a small basic question : > > > > Is it po

RE: sqlite3 version lacks instr

2013-08-01 Thread Fábio Santos
I'm not sure but it seems like you could use operator.__contains__ . it might be faster. On 28 Jul 2013 20:18, "Peter Otten" <[email protected]> wrote: > Joseph L. Casale wrote: > > >> Has anyone encountered this and utilized other existing functions > >> within the shipped 3.6.21 sqlite version to

Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread Fábio Santos
On 19 Jul 2013 03:24, "CTSB01" wrote: > > Thanks for the alternative links, I'll use gmane.org as an access point next time. > > > > > Don't paraphrase. Just copy/paste it into your email message. And I'm > > > > assuming you know to run things from the terminal window, and not from > > > > IDLE

Re: Jabber Bot

2013-07-18 Thread Fábio Santos
On 18 Jul 2013 18:52, "Matt" wrote: > > Anyone have any luck with creating Jabber Bots? > > Everyone I have found so far for python 3.3 has been outdated, or the required modules are outdated. You can find some modules here. http://stackoverflow.com/questions/1901828/best-python-xmpp-jabber-clie

Re: [ANN] bbfreeze 1.1.2

2013-07-17 Thread Fábio Santos
On 17 Jul 2013 21:46, "Ralf Schmitt" wrote: > bbfreeze will not > work with python 3 or higher. > > > -- > Cheers > Ralf Seems like it has awesome features, but py3k is really important to me. Is this on your roadmap? -- http://mail.python.org/mailman/listinfo/python-list

Re: [ANN]:JSONStream

2013-07-17 Thread Fábio Santos
On 17 Jul 2013 20:40, "Sol Toure" wrote: > > I didn't look into using YAML processor. > Also that would have required pre-processing the data to add the separators. > With this method you don't need the separators. You can have 0 or more white space between objects: > > for obj in JSONStream(Strin

Re: Dihedral

2013-07-15 Thread Fábio Santos
> On 07/15/2013 08:36 AM, Steven D'Aprano wrote: >> >> Devyn, >> >> 8 Dihedral is our resident bot, not a human being. Nobody knows who >> controls it, and why they are running it, but we are pretty certain that >> it is a bot responding mechanically to keywords in people's posts. >> >> It's a

Re: xslice idea | a generator slice

2013-07-11 Thread Fábio Santos
On 11 Jul 2013 17:38, "Oscar Benjamin" wrote: > > On 11 July 2013 17:21, Russel Walker wrote: > > To confess, this is the second time I've made the mistake of trying to implement generator like functionality of a builtin when there already is on in itertools. Need to start studying that module ab

Re: ElementTree: can't figure out a mismached-tag error

2013-07-11 Thread Fábio Santos
On 11 Jul 2013 10:24, wrote: > > Actually, I don't think etree has a HTML parser. And I would counter-recommend lxml if speed is an issue: BeautifulSoup takes a long time to parse a large document. > > On Thursday, July 11, 2013 5:08:04 PM UTC+8, Fábio Santos wrote: > >

Re: ElementTree: can't figure out a mismached-tag error

2013-07-11 Thread Fábio Santos
On 11 Jul 2013 10:04, "F.R." wrote: > > Hi all, > > I haven't been able to get up to speed with XML. I do examples from the tutorials and experiment with variations. Time and time again I fail with errors messages I can't make sense of. Here's the latest one. The url is " http://finance.yahoo.com/

Re: Mypy

2013-07-11 Thread Fábio Santos
On 11 Jul 2013 09:08, "Steven D'Aprano" wrote: > > Things are certainly heating up in the alternate Python compiler field. > Mypy is a new, experimental, implementation of Python 3 with optional > static typing and aiming for efficient compilation to machine code. > > http://www.mypy-lang.org/inde

Re: Buying a used iPhone 5

2013-07-10 Thread Fábio Santos
On 10 Jul 2013 15:15, "Rodrick Brown" wrote: > > Die > > > On Wed, Jul 10, 2013 at 6:49 AM, oswaldclem wrote: >> >> I'm planning on buying a used ATT iPhone 5 off of craigslist, and i've been >> reading on how some people sell their iPhones to people and later on >> blacklisting it, screwing the

Re: make sublists of a list broken at nth certain list items

2013-07-08 Thread Fábio Santos
You don't want to use index() to figure out the index of the tuples. It is slower, and will not find the item you want if there is more than one of the same. For example, [1, 4, 4, 4].index(4) will always be 1, no matter how many times you loop through it. Instead, use enumerate() to keep track

Re: How to make this faster

2013-07-05 Thread Fábio Santos
On 5 Jul 2013 15:59, "Helmut Jarausch" wrote: > > On Fri, 05 Jul 2013 13:44:57 +0100, Fábio Santos wrote: > May I suggest you avoid range and use enumerate(the_array) instead? It > might be faster. > > How does this work? > > Given > > Grid= [[0 for j in r

Re: How to make this faster

2013-07-05 Thread Fábio Santos
On 5 Jul 2013 11:58, "Helmut Jarausch" wrote: > > On Fri, 05 Jul 2013 11:13:33 +0100, Oscar Benjamin wrote: > > > My one comment is that you're not really making the most out of numpy > > arrays. Numpy's ndarrays are efficient when each line of Python code > > is triggering a large number of numer

Re: How to make this faster

2013-07-05 Thread Fábio Santos
On 5 Jul 2013 09:29, "Helmut Jarausch" wrote: > > Hi, > > I have coded a simple algorithm to solve a Sudoku (probably not the first one). > Unfortunately, it takes 13 seconds for a difficult problem which is more than 75 times slower > than the same algorithm coded in C++. > Is this to be expected

Re: PYTHONPATH and module names

2013-07-01 Thread Fábio Santos
On 1 Jul 2013 20:58, "Tobiah" wrote: >> >> Are you familiar with absolute and relative imports: >> http://docs.python.org/release/2.5/whatsnew/pep-328.html > > > Doesn't seem to work: > > Python 2.7.3 (default, May 10 2012, 13:31:18) > [GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)] on linux2 > Type "help", "

Re: Closures in leu of pointers?

2013-06-29 Thread Fábio Santos
On 29 Jun 2013 10:38, wrote: > > Hi, > > I'd like to use closures to set allow a subroutine to set variables in its caller, in leu of pointers. But I can't get it to work. I have the following test pgm, but I can't understand its behaviour: > > It uses a function p2() from the module modules.clo

Re: How to make a web framework

2013-06-27 Thread Fábio Santos
On 27 Jun 2013 14:49, wrote: > > I've used web frameworks, but I don't know how they work. Is there anywhere that I can learn how this all works from scratch? Write CGI scripts. It is the most raw way to program for the web. That way you can dig into what frameworks do for you. -- http://mail.py

Re: class factory question

2013-06-26 Thread Fábio Santos
On 26 Jun 2013 14:14, "Tim" wrote: > > I am extending a parser and need to create many classes that are all subclassed from the same object (defined in an external library). When my module is loaded I need all the classes to be created with a particular name but the behavior is all the same. Curr

Re: Is this PEP-able? fwhile

2013-06-26 Thread Fábio Santos
On 26 Jun 2013 11:45, wrote: > > On Tuesday, June 25, 2013 9:30:54 PM UTC+5:30, Ian wrote: > > In my experience the sorts of people who preach "one exit point" are > > also all about defining preconditions and postconditions and proving > > that the postconditions follow from the preconditions. I

Re: Is this PEP-able? fwhile

2013-06-24 Thread Fábio Santos
On 25 Jun 2013 01:08, "alex23" wrote: > > On 25/06/2013 9:35 AM, Fábio Santos wrote: >> >> > I'd probably just go with a generator expression to feed the for loop: >> > >> > for X in (i for i in ListY if conditionZ): >> >

Re: Is this PEP-able? fwhile

2013-06-24 Thread Fábio Santos
On 25 Jun 2013 00:31, "alex23" wrote: > > On 25/06/2013 6:12 AM, Ian Kelly wrote: >> >> On Mon, Jun 24, 2013 at 1:52 PM, wrote: >>> >>> Syntax: >>> fwhile X in ListY and conditionZ: >>> >>> fwhile would act much like 'for', but would stop if the condition after the >>> 'and' is no longer True. >

Re: Is this PEP-able? fwhile

2013-06-24 Thread Fábio Santos
On 25 Jun 2013 00:06, "Fábio Santos" wrote: > I like how discussions on this list tend to go off topic ;) And now I'm off topic myself :( -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this PEP-able? fwhile

2013-06-24 Thread Fábio Santos
On 25 Jun 2013 00:04, "MRAB" wrote: > > On 24/06/2013 23:35, Chris Angelico wrote: >> >> On Tue, Jun 25, 2013 at 8:30 AM, 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 comp

Re: Is this PEP-able? fwhile

2013-06-24 Thread Fábio Santos
On 24 Jun 2013 22:29, "Ian Kelly" wrote: > > On Mon, Jun 24, 2013 at 2:34 PM, Fábio Santos wrote: > > This can probably be best achieved by adding to the existing for loop, > > so maybe taking advantage of the existing for...if syntax and adding > > for...whi

Re: Is this PEP-able? fwhile

2013-06-24 Thread Fábio Santos
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 it (the 'else:' clause). Use > > break/continue when appropriate. > > from minor_gripes import breaking_ou

Re: Is this PEP-able? fwhile

2013-06-24 Thread Fábio Santos
nd there is a new keyword, "fwhile". This can probably be best achieved by adding to the existing for loop, so maybe taking advantage of the existing for...if syntax and adding for...while would be a better idea? So, maybe: for x in y while cond: And for list/set/dict comprehensions and generator expressions: [x for x in range(123) while cond] Just maybe. -- Fábio Santos -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for a name for a deployment framework...

2013-06-24 Thread Fábio Santos
On 24 Jun 2013 13:39, wrote: > > Hi all, > > Any suggestions for a good name, for a framework that does automatic server deployments? > > It's like Fabric, but more powerful. > It has some similarities with Puppet, Chef and Saltstack, but is written in Python. > > Key points are that it uses Pytho

Re: Error running xmlrpc Client and server under different Python versions

2013-06-20 Thread Fábio Santos
On 20 Jun 2013 08:46, wrote: > > Hello. > > I need to run xmlrpc Server under Python 3.3 and Client under Python 2.7. But when I try to do so, I receive the following exception: > > ":global name 'xmlrpclib' is not defined" Somewhere in your code you are trying to use the name 'xmlrpclib' but it

Re: Beginner Question: 3D Models

2013-06-19 Thread Fábio Santos
s, entities, lights, etc., place them wherever you want and run the simulation. You can very likely import your CAD models into Blender using the many importers it has. It can import .3DS, .OBJ, etc. files with ease, provided you find (or write!) the plugins for them. -- Fábio Santos -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner Question: 3D Models

2013-06-19 Thread Fábio Santos
On 19 Jun 2013 12:56, "Oscar Benjamin" wrote: > > On 19 June 2013 12:13, wrote: > > > > I've seen some information on Blender. Is it possible to have the entire program contained within a single exe (or exe and some other files) so that it can be passed around and used by others without having

Re: decorator to fetch arguments from global objects

2013-06-18 Thread Fábio Santos
ith_optional_db > If db is always the first argument, you could also use type (or hasattr) checking of the first argument, and push a db if it's not one. Or be specific about it and take a db or some kind of placeholder (such as an object, DEFAULT_DB, or the "default" string) Cheers -- Fábio Santos -- http://mail.python.org/mailman/listinfo/python-list

Re: RFD: rename comp.lang.python to comp.support.superhost

2013-06-15 Thread Fábio Santos
; How much of a bastard can you be? > > -- > What is now proved was at first only imagined! > -- > http://mail.python.org/mailman/listinfo/python-list Yes, Nick. You are not the problem. He is for telling on you. Shame on him! (or her? idk) -- Fábio Santos -- http://mail.python.org/mailman/listinfo/python-list

Re: Potential Python 3.3.2 pyvenv bug on Windows

2013-06-15 Thread Fábio Santos
ople will not be able to use pydoc.py because it was renamed. It would be slightly better to use pydoc.bat (which could then call pydocs.py), but even so it would be pretty bad. -- Fábio Santos -- http://mail.python.org/mailman/listinfo/python-list

Re: Don't feed the troll...

2013-06-14 Thread Fábio Santos
On Fri, Jun 14, 2013 at 1:58 PM, Heiko Wundram wrote: > Am 14.06.2013 14:45, schrieb Nick the Gr33k: > >> we are all benefit out of this. > > > Let's nominate you for a nobel prize, saviour of python-list! > I don't want to be saved. I just found out how to mute

Re: Don't feed the troll... (was: Re: A few questiosn about encoding)

2013-06-14 Thread Fábio Santos
On 14 Jun 2013 10:20, "Heiko Wundram" wrote: > > Am 14.06.2013 10:37, schrieb Nick the Gr33k: >> >> So everything we see like: >> >> 16474 >> nikos >> abc123 >> >> everything is a string and nothing is a number? not even number 1? > > > Come on now, this is _so_ obviously trolling, it's not even r

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

2013-06-14 Thread Fábio Santos
On 14 Jun 2013 10:59, "Nick the Gr33k" wrote: > > I started another thread because the last one was !@#$'ed up by irrelevant replies and was difficult to jeep track. > > >>> name="abcd" > >>> month="efgh" > >>> year="ijkl" > > >>> print(name or month or year) > abcd > > Can understand that, it tak

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Fábio Santos
On 14 Jun 2013 09:56, "Nick the Gr33k" wrote: > > On 14/6/2013 11:03 πμ, Nick the Gr33k wrote: >> >> On 14/6/2013 4:14 πμ, Steven D'Aprano wrote: >>> >>> On Thu, 13 Jun 2013 17:26:18 +0300, Νικόλαος Κούρας wrote: >>> i just want 4 cases to examine so correct execute to be run: i'm r

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Fábio Santos
On 14 Jun 2013 09:51, "Nick the Gr33k" wrote: > > On 14/6/2013 11:28 πμ, Jussi Piitulainen wrote: > > 'Parker' and 'May' and '2001' >> >> '2001' > > > But why? > > that expression should return True since all stings are not empty. > > >> Either way, the interactive prompt is your friend. >> >

Re: RFD: rename comp.lang.python to comp.support.superhost

2013-06-14 Thread Fábio Santos
On 14 Jun 2013 04:33, "alex23" wrote: > > On Jun 14, 2:24 am, Νικόλαος Κούρας wrote: > > iam researchign a solution to this as we speak. > > Spamming endless "ZOMG HELP ME I'M INCOMPETENT" posts isn't "research". +1 -- http://mail.python.org/mailman/listinfo/python-list

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Fábio Santos
On 14 Jun 2013 09:09, "Nick the Gr33k" wrote: > >>> print(name and month and year) > ijkl > > Seems here is returning the last string out of 3 strings, but have no clue why Python doing this. > You have been told this above. All languages kind of do that. Ever seen this command on a shell? mkdi

Re: Version Control Software

2013-06-13 Thread Fábio Santos
On 13 Jun 2013 22:34, "Chris Angelico" wrote: > [...] > It's > possible to get git for Windows, including gitk and 'git gui' (not > sure about any other graphical tools, they're the only two I use), but > the most convenient way to use them is from a ported bash. I must disagree. I used git a lot

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

2013-06-12 Thread Fábio Santos
ss the generator to deque() with maxlen=0 - >> this consumes the iterator with constant memory usage. > > > any((new_songs if s.is_new() else old_songs).append(s) for s in songs) > > > -- > http://mail.python.org/mailman/listinfo/python-list -- Fábio Santos -- http://mail.python.org/mailman/listinfo/python-list

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

2013-06-12 Thread Fábio Santos
On 5 Jun 2013 06:23, "Tim Roberts" wrote: > A single machine word was 60 bits, so a single register read got you 10 > characters. 10 characters! Now that sounds like it's enough to actually store a word. However long words can inadverten be cropped. -- http://mail.python.org/mailman/listinfo/pyt

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

2013-06-12 Thread Fábio Santos
On 12 Jun 2013 12:43, "Roy Smith" wrote: > > In article , > Phil Connell wrote: > > > > Well, continuing down this somewhat bizarre path: > > > > > > new_songs, old_songs = [], [] > > > itertools.takewhile( > > > lambda x: True, > > > (new_songs if s.is_new() else old_songs).append(s) fo

Re: A certainl part of an if() structure never gets executed.

2013-06-12 Thread Fábio Santos
On 12 Jun 2013 12:08, "Νικόλαος Κούρας" wrote: > > Oh my God! > > i just need to do this: > > > for i, month in enumerate( months ): > print(' %s ' % (month, month) ) Usually what goes in is an ID of something. You should keep using (i, month) and then do months[id] to get the month stri

Re: A certainl part of an if() structure never gets executed.

2013-06-12 Thread Fábio Santos
On 12 Jun 2013 10:29, "Νικόλαος Κούρας" wrote: > > On 12/6/2013 12:07 μμ, F�bio Santos wrote: >> >> On Wed, Jun 12, 2013 at 9:54 AM, Νικόλαος Κούρας wrote: >>> >>> but if enumerate yields 0 instead of '==' then elif '=' not in >>> year of course fails. >>> >>> So, i must tell: >>> >>> for

Re: A certainl part of an if() structure never gets executed.

2013-06-12 Thread Fábio Santos
) ) > > to somehow return '==' instead of 0 but don't know how. > -- > http://mail.python.org/mailman/listinfo/python-list Well, you could try this: > for i, month in enumerate(months): > if i == 0: > month = ('=' * 10) > print(' %s ' % (i, month) ) No? -- Fábio Santos -- http://mail.python.org/mailman/listinfo/python-list

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

2013-06-11 Thread Fábio Santos
On 11 Jun 2013 18:48, "Chris Angelico" wrote: > > On Wed, Jun 12, 2013 at 3:23 AM, rusi wrote: > > On Jun 11, 10:05 pm, Fábio Santos wrote: > >> On 11 Jun 2013 17:47, "rusi" wrote: > >> > >> > [Of course I would prefer a 3-liner w

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

2013-06-11 Thread Fábio Santos
On 11 Jun 2013 17:47, "rusi" wrote: > [Of course I would prefer a 3-liner where the body of the for is > indented :-) ] Is this an aside comprehension? -- http://mail.python.org/mailman/listinfo/python-list

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

2013-06-11 Thread Fábio Santos
On 11 Jun 2013 07:47, "Peter Otten" <[email protected]> wrote: > > Fábio Santos wrote: > > > On 10 Jun 2013 23:54, "Roel Schroeven" wrote: > >> > >> You could do something like: > >> > >> new_songs, old_songs = [

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

2013-06-10 Thread Fábio Santos
On 10 Jun 2013 23:54, "Roel Schroeven" wrote: > > You could do something like: > > new_songs, old_songs = [], [] > [(new_songs if s.is_new() else old_songs).append(s) for s in songs] > > But I'm not sure that that's any better than the long version. This is so beautiful! -- http://mail.python.or

Re: Encoding questions (continuation)

2013-06-10 Thread Fábio Santos
On 10 Jun 2013 15:04, "Νικόλαος Κούρας" wrote: > > Τη Δευτέρα, 10 Ιουνίου 2013 2:41:07 μ.μ. UTC+3, ο χρήστης Steven D'Aprano έγραψε: > > On Mon, 10 Jun 2013 14:13:00 +0300, Νικόλαος Κούρας wrote: > > > > > > > > > Τη Δευτέρα, 10 Ιουνίου 2013 1:42:25 μ.μ. UTC+3, ο χρήστης Andreas > > > > > Persting

Re: Sorting a set works, sorting a dictionary fails ?

2013-06-10 Thread Fábio Santos
On 10 Jun 2013 10:53, "Νικόλαος Κούρας" wrote: > > After many tried this did the job: > > for key in sorted(months.items(),key=lambda num : num[1]): > print(''' > %s > ''' % (key[1], key[0]) ) > > > but its really frustrating not being able to: > > for key in sort

Re: Sorting a set works, sorting a dictionary fails ?

2013-06-10 Thread Fábio Santos
On 10 Jun 2013 09:34, "Νικόλαος Κούρας" wrote: > > Trying this: > > months = { 'Ιανουάριος':1, 'Φεβρουάριος':2, 'Μάρτιος':3, 'Απρίλιος':4, 'Μάϊος':5, 'Ιούνιος':6, \ >'Ιούλιος':7, 'Αύγουστος':8, 'Σεπτέμβριος':9, 'Οκτώβριος':10, 'Νοέμβριος':11, 'Δεκέμβριος':12 } > > for key in sorted( mo

Re: Redirecting to a third party site with injected HTML

2013-06-10 Thread Fábio Santos
On 10 Jun 2013 07:58, "Guy Tamir" wrote: > since i wrote some extensions in the past that allowed me to change the DOM easily i thought there might be an way to do so from the server before redirecting the user.. There could be a way to do that, but some of the features in the target site would n

Re: Re-using copyrighted code

2013-06-09 Thread Fábio Santos
On 9 Jun 2013 21:39, "Mark Janssen" wrote: > > On Sun, Jun 9, 2013 at 12:50 PM, Michael Torrie wrote: > > On 06/09/2013 11:18 AM, Mark Janssen wrote: > >> You actually do not. Attaching a legal document is purely a secondary > >> protection from those who would take away right already granted by

Re: problem with if then

2013-06-09 Thread Fábio Santos
On 9 Jun 2013 21:24, "Jean Dubois" ... > And here is the result: > > jean@antec4:~$ ./try.py > wget -q -O - http://www.deredactie.be/cm/vrtnieuws/videozone/programmas/journaal/EP_130607_JO7 > >/dev/null ; echo $? > 8 > 2013-06-07 22:07:00.016807 stream is available > wget -q -O - http://www.deredac

Re: [newbie] problem with if then

2013-06-09 Thread Fábio Santos
On 9 Jun 2013 20:49, "Jean Dubois" wrote: > > I'm writing some code to check whether an url is available or not, > therefore I make use of a wget-command in Linux and then check whether > this is successful (returning a 0) or not returning an 8 > However the if then statement seems to give the sam

Re: Redirecting to a third party site with injected HTML

2013-06-09 Thread Fábio Santos
On 9 Jun 2013 18:15, wrote: > > Hi all, > > new to group and pretty new to python. > > I'm working on a new project and i want to receive a request from a user and to redirect him to a third party site, but on the page after i redirect my users i want to them to see injected html (on the third par

Re: A few questiosn about encoding

2013-06-09 Thread Fábio Santos
On 9 Jun 2013 11:49, "Νικόλαος Κούρας" wrote: > > A few questiosn about encoding please: > > >> Since 1 byte can hold up to 256 chars, why not utf-8 use 1-byte for > >> values up to 256? > > >Because then how do you tell when you need one byte, and when you need > >two? If you read two bytes, and

Re: Installing PyGame?

2013-06-08 Thread Fábio Santos
On 8 Jun 2013 19:19, "Eam onn" wrote: > Wait, the python -c "help('modules')" worked after spamming it a few times. Pygame was listed but it won't do anything when I type in 'import pygame' I still get the error :( Try to always say what your error was. Do you have pip installed? Pygame AFAIK is

Re: Installing PyGame?

2013-06-08 Thread Fábio Santos
On 8 Jun 2013 17:17, "Eam onn" wrote: > I keep getting an error in all my versions of IDLE. What error is that? Show us. Errors carry strong hints. Also, are you following an install guide/tutorial? Which one? Cheers -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Game Development?

2013-06-08 Thread Fábio Santos
> On Fri, 07 Jun 2013 08:53:03 -0700, letsplaysforu wrote: > > > I was planning on making a small 2D game in Python. Are there any > > libraries for this? I know of: It wasn't your question, but I was happy to find out that box2d exists for python. -- http://mail.python.org/mailman/listinfo/python

Re: [RELEASED] Python 2.7.5

2013-06-04 Thread Fábio Santos
On 4 Jun 2013 21:47, "Joshua Landau" wrote: > > On 4 June 2013 00:12, Mark Lawrence 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 > work

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-04 Thread Fábio Santos
On 4 Jun 2013 21:18, "Νικόλαος Κούρας" wrote: > > Lele the output of: > > stmt = "cur.execute('''SELECT url FROM files WHERE url = %s''', ( fullpath, )" > chars_count = Counter(stmt) > print("Number of '(': %d" % chars_count['(']) > print("Number of ')': %d" % chars_count[')']) > > is: > > Number

Re: create new python file

2013-06-04 Thread Fábio Santos
On 4 Jun 2013 17:14, wrote: > > Hi, > Can anyone please tell me how to dynamically create a new python file within a program??? That's generally a bad idea. Why are you doing that? That said, it's just like writing to a text file. So if you write python in a text file, you're good. -- http://ma

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-04 Thread Fábio Santos
On 4 Jun 2013 17:04, "Chris Angelico" wrote: > > On Wed, Jun 5, 2013 at 1:44 AM, Rick Johnson > wrote: > > But we are really ignoring the elephant in the room. Implict > > conversion to Boolean is just a drop in the bucket compared > > to the constant "shell game" we are subjected to when > > rea

Re: lstrip problem - beginner question

2013-06-04 Thread Fábio Santos
On 4 Jun 2013 16:34, "mstagliamonte" wrote: > > On Tuesday, June 4, 2013 11:21:53 AM UTC-4, mstagliamonte wrote: > > Hi everyone, > > > > > > > > I am a beginner in python and trying to find my way through... :) > > > > > > > > I am writing a script to get numbers from the headers of a text file.

RE: Beginner question

2013-06-04 Thread Fábio Santos
> > Awesome! Now I can do it just like that: > > >>> dict([(chr(ord('a')+x),x) for x in range(2)]) > {'a': 0, 'b': 1} > > Thanks a lot! ;) > Or dict((c, i) for (i, c) in enumerate('ab')) But at this point you could just use a dict comprehension. {c: i for i, c in enumerate('ab')} -- http://mail

RE: Beginner question

2013-06-04 Thread Fábio Santos
On 4 Jun 2013 12:57, "Carlos Nepomuceno" wrote: > > >On 4 Jun 2013 12:28, "Carlos Nepomuceno" wrote: > [...] > > >> What's going on? Is there a way to make dict() to resolve the variables? > >Well yes. > >dict(**{a:0,b:1}) > >The dict() constructor makes a dictionary from keyword arguments. So yo

RE: Beginner question

2013-06-04 Thread Fábio Santos
On 4 Jun 2013 12:28, "Carlos Nepomuceno" wrote: > > Started answering... now I'm asking! lol > > I've tried to use dict() to create a dictionary to use like the switch statement providing variable names instead of literals, such as: > > >>> a='A' > >>> b='B' > >>> {a:0,b:1}#here the variables

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

2013-06-04 Thread Fábio Santos
On 4 Jun 2013 12:26, "Fábio Santos" wrote: > > > On 4 Jun 2013 10:54, "Νικόλαος Κούρας" wrote: > > > > Okey found it. > > > > since couldnt install pip i did: > > > > easy_install pymysql > > It is not the recommended way to

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

2013-06-04 Thread Fábio Santos
On 4 Jun 2013 10:54, "Νικόλαος Κούρας" wrote: > > Okey found it. > > since couldnt install pip i did: > > easy_install pymysql It is not the recommended way to install pip, but you can ironically easy_install pip -- http://mail.python.org/mailman/listinfo/python-list

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

2013-06-04 Thread Fábio Santos
On 4 Jun 2013 07:44, "Νικόλαος Κούρας" wrote: > > Could you please install them because i need to work? > > a) pip (so that i can successfully run 'pip install pymysql' > b) development tools > > I wiped the while perl away (leaving intact 2.6) but i wiped out pip at the proces to. > -- > http://m

Re: Interactive interpreter hooks

2013-06-03 Thread Fábio Santos
On 3 Jun 2013 09:04, "Steven D'Aprano" wrote: > > The sys module defines two hooks that are used in the interactive > interpreter: > > * sys.displayhook(value) gets called with the result of evaluating the > line when you press ENTER; > > * sys.excepthook(type, value, traceback) gets called with t

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

2013-05-31 Thread Fábio Santos
On 31 May 2013 19:09, "Νικόλαος Κούρας" wrote: > > On Fri, May 31, 2013 at 11:42 AM, Νικόλαος Κούρας wrote: > > > > > OMG i gave by mistake > > > root@nikos [/]# rm -rf /root/.local/ > > > did i screwed up my remote VPS which i host 10 peoples webpages? Couldn't you check ten websites which are

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

2013-05-31 Thread Fábio Santos
On 31 May 2013 16:28, "Νικόλαος Κούρας" wrote: > > I'am using CentOS v6.4 on my VPS and hence 'yum' install manager and i just tried: > > Code: > root@nikos [~]# which python > /usr/bin/python > root@nikos [~]# which python3 > /root/.local/lib/python2.7/bin/python3 > root@nikos [~]# which python3.

Re: How clean/elegant is Python's syntax?

2013-05-31 Thread Fábio Santos
On Fri, May 31, 2013 at 10:08 AM, Alister wrote: > I think that is the winning argument. > Next question is what should be the default ("", " " or',')? join, comma_join, whitejoin, linejoin variants, with different defaults? -- Fábio Santos -- http://mai

Re: User Input

2013-05-30 Thread Fábio Santos
On 30 May 2013 13:24, "Eternaltheft" wrote: > > Ok thanks guys. but when i use > > filename = input('file name: ') > if not filename: #i get filename is not defined > return(drawBoard) #possible to return function when no file input from user? I don't really understand what you mean. Do

Re: User Input

2013-05-30 Thread Fábio Santos
On 30 May 2013 12:58, "Eternaltheft" wrote: > > On Thursday, May 30, 2013 7:33:41 PM UTC+8, Eternaltheft wrote: > > Hi, I'm having trouble oh how prompt the user to enter a file name and how to set up conditions. For example, if there's no file name input by the user, a default is returned > > Tha

Re: User Input

2013-05-30 Thread Fábio Santos
On 30 May 2013 12:42, "Eternaltheft" wrote: > > Hi, I'm having trouble oh how prompt the user to enter a file name and how to set up conditions. For example, if there's no file name input by the user, a default is returned Are you using raw_input? It returns an empty string if the user enters not

Re: Getting a callable for any value?

2013-05-29 Thread Fábio Santos
On 29 May 2013 18:51, "Croepha" wrote: > > Is there anything like this in the standard library? > > class AnyFactory(object): > def __init__(self, anything): > self.product = anything > def __call__(self): > return self.product > def __repr__(self): > return "%s.%s(%r)" % (self.__class__.__module_

  1   2   >