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

2013-05-07 Thread Fábio Santos
> > > - > > > 1) The memory gain for many of us (usually non ascii users) > just become irrelevant. > > >>> sys.getsizeof('maçã') > 41 > >>> sys.getsizeof('abcd') > 29 > > 2) More critical, Py 3.3, just becomes non unicode compliant, > (eg European languages or "ascii" typographers !) > > >>> i

Re: Making safe file names

2013-05-07 Thread Fábio Santos
lly are no limits on what characters can be in an artist name. > -- > CPython 3.3.1 | Windows NT 6.2.9200 / FreeBSD 9.1 > -- > http://mail.python.org/mailman/listinfo/python-list -- Fábio Santos -- http://mail.python.org/mailman/listinfo/python-list

Re: multiple versions of python

2013-05-08 Thread Fábio Santos
On 8 May 2013 01:03, "Roy Smith" wrote: > > In article <72f93710-9812-441e-8d3d-f221d5698...@googlegroups.com>, > sokovic.anamar...@gmail.com wrote: > > > Hi, > > > > what is the generally recommended structure when we have into play this type > > of problem: > > multiple versions of python (both

Re: Anybody familiar with pygments ?

2013-05-09 Thread Fábio Santos
On 9 May 2013 05:19, "dabaichi" wrote: > > And hereis the output file: That's not the output file. That is just an HTML fragment to put on your page. A full HTML file will need more things, which is the reason why you don't see color output. > I want to know why output html file with no color ?

Re: python call golang

2013-05-10 Thread Fábio Santos
On 10 May 2013 03:37, "Thanatos xiao" wrote: > > Hey ! > > Now! I have written a python script . I want to call a golang script in python script. > Who can give me some advices? > > thanks! Check out the subprocess module. You can use it to call other programs from python and get their error code

Re: Python for philosophers

2013-05-11 Thread Fábio Santos
On 11 May 2013 21:07, "Citizen Kant" wrote: > > Hi, > this could be seen as an extravagant subject but that is not my original purpose. I still don't know if I want to become a programmer or not. At this moment I'm just inspecting the environment. I'm making my way to Python (and OOP in general) f

Re: object.enable() anti-pattern

2013-05-12 Thread Fábio Santos
On 13 May 2013 00:22, "Greg Ewing" wrote: > > Wayne Werner wrote: >> >> On Fri, 10 May 2013, Gregory Ewing wrote: >> >>> f = open("myfile.dat") >>> f.close() >>> data = f.read() >> >> >> To clarify - you don't want a class that has functions that need to be called in a certain order with *va

Re: Message passing syntax for objects | OOPv2

2013-05-13 Thread Fábio Santos
On 12 May 2013 18:23, "Ned Batchelder" wrote: > > I've never understood why people use that site: the pages end up being unintelligible cocktail-party noise-scapes with no hope of understanding who is saying what, or in response to whom. > > --Ned. There's not so much noise there, but indeed the

Re: object.enable() anti-pattern

2013-05-13 Thread Fábio Santos
On 13 May 2013 08:40, "Chris Angelico" wrote: > > On Mon, May 13, 2013 at 4:32 PM, Fábio Santos wrote: > > > > On 13 May 2013 00:22, "Greg Ewing" wrote: > >> The same argument can be applied to: > >> > >>foo = Foo() > &

Re: Message passing syntax for objects | OOPv2

2013-05-13 Thread Fábio Santos
Sounds a lot like reddit threads. On 13 May 2013 08:17, "Mark Janssen" wrote: > On Sun, May 12, 2013 at 10:18 AM, Ned Batchelder > wrote: > > I've never understood why people use that site: the pages end up being > > unintelligible cocktail-party noise-scapes with no hope of understanding > who

Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ]

2013-05-13 Thread Fábio Santos
On 13 May 2013 11:04, "Alister" wrote: > this looks to me like an issue with operator precidence > > you code is evaluating as (Not x) == y > rather than not (x == y) I can say for sure that the precedence is as expected. I always use "not ... == ..." Instead of !=. -- http://mail.python.org/mai

Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ]

2013-05-13 Thread Fábio Santos
d Batchelder" wrote: > > On 5/13/2013 1:26 PM, Fábio Santos wrote: > > > On 13 May 2013 11:04, "Alister" wrote: > > this looks to me like an issue with operator precidence > > > > you code is evaluating as (Not x) == y > > rather than not (x ==

Re: [Off topic] Software epigrams

2013-05-13 Thread Fábio Santos
On 13 May 2013 19:48, "Neil Cerutti" wrote: > > On 2013-05-13, Skip Montanaro wrote: > >> 8. A programming language is low level when its programs > >> require attention to the irrelevant. > >> > >> So much a matter of debate. Indentation is irrelevant, why > >> should Python programs pay attenti

Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ]

2013-05-13 Thread Fábio Santos
On Mon, May 13, 2013 at 10:17 PM, Alister wrote: > On Mon, 13 May 2013 19:28:29 +0100, Fábio Santos wrote: > >> I think it is more readable. When doing more complicated statements I >> use != instead, but when it's a single test I prefer not … == >> >> It'

Writing a blog post on the new Enum.

2013-05-13 Thread Fábio Santos
will warn my readers about it not being final and not to use in production code. I am unsure whether the repository is not supposed to be shared with too many people. -- Fábio Santos -- http://mail.python.org/mailman/listinfo/python-list

Re: Writing a blog post on the new Enum.

2013-05-13 Thread Fábio Santos
world by publishing it on the internets! --- And here it is: http://fabiosantoscode.blogspot.pt/2013/05/pythons-new-enum-class.html -- Fábio Santos -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's sad, unimaginative Enum

2013-05-14 Thread Fábio Santos
On 13 May 2013 12:05, "Jean-Michel Pichavant" wrote: > > class Enum: > class __metaclass__(type): That's some cool metaclass fu! I didn't know that to be possible -- http://mail.python.org/mailman/listinfo/python-list

Re: Writing a blog post on the new Enum.

2013-05-14 Thread Fábio Santos
I corrected it indeed. On Tue, May 14, 2013 at 4:36 PM, Chris Angelico wrote: > On Wed, May 15, 2013 at 1:07 AM, Terry Jan Reedy wrote: >> On 5/14/2013 3:52 AM, Chris Angelico wrote: >>> >>> On Tue, May 14, 2013 at 9:40 AM, Fábio Santos >>> wrote: >&g

Re: Message passing syntax for objects | OOPv2

2013-05-14 Thread Fábio Santos
le after about a 100 interactions. To sort out the mess, > it takes another dimension. The project I'm working on uses a 3 > dimensional visualization model that can scale and order millions of > nodes. > > -- > MarkJ > Tacoma, Washington -- Fábio Santos -- http://mail.python.org/mailman/listinfo/python-list

Re: [Off topic] Software epigrams

2013-05-15 Thread Fábio Santos
On 15 May 2013 18:29, "Neil Cerutti" wrote: > > On 2013-05-13, F?bio Santos wrote: > > > > On 13 May 2013 19:48, "Neil Cerutti" wrote: > >> > >> On 2013-05-13, Skip Montanaro wrote: > >> >> 8. A programming language is low level when its programs > >> >> require attention to the irrelevant. > >

Re: Fwd: Fwd: Python for philosophers

2013-05-15 Thread Fábio Santos
On 15 May 2013 20:59, "Citizen Kant" wrote: > Of course one always may want to perform random hacking and turn tables just because and treat the word python as a variable's name, setting that python equals Monty Python in order to checkmate any given conversation. In that case we'll have to cope t

Re: [Off topic] Software epigrams

2013-05-15 Thread Fábio Santos
On 15 May 2013 19:33, "Neil Cerutti" wrote: > > On 2013-05-15, F?bio Santos wrote: > >> It is a tautology is disguise. When you use a low level > >> language, low level details are relevant to the scope of your > >> program. > > > > I don't see it that way. I think relevance and level are two > >

Re: spilt question

2013-05-16 Thread Fábio Santos
str.split takes a limit argument. Try your_string.split('_', 1) On 16 May 2013 16:11, "loial" wrote: > I want to split a string so that I always return everything BEFORE the > LAST underscore > > HELLO_.lst # should return HELLO > HELLO_GOODBYE_.ls # should return HELLO_G

RE: How to write fast into a file in python?

2013-05-18 Thread Fábio Santos
On 17 May 2013 19:38, "Carlos Nepomuceno" wrote: > > Think the following update will make the code more portable: > > x += len(line)+len(os.linesep)-1 > > Not sure if it's the fastest way to achieve that. :/ > Putting len(os.linesep)'s value into a local variable will make accessing it quite a bi

Re: How to write fast into a file in python?

2013-05-18 Thread Fábio Santos
On 18 May 2013 20:19, "Dennis Lee Bieber" wrote: > > tOn Sat, 18 May 2013 08:49:55 +0100, Fábio Santos > declaimed the following in > gmane.comp.python.general: > > > > You mentioned "\n" translating to two lines, but this won't happen. Windows &

Re: Please help with Threading

2013-05-19 Thread Fábio Santos
On 18 May 2013 20:33, "Dennis Lee Bieber" wrote: > Python threads work fine if the threads either rely on intelligent > DLLs for number crunching (instead of doing nested Python loops to > process a numeric array you pass it to something like NumPy which > releases the GIL while crunching

Re: Please help with Threading

2013-05-20 Thread Fábio Santos
Simpson" wrote: > On 20May2013 07:25, Fábio Santos wrote: > | On 18 May 2013 20:33, "Dennis Lee Bieber" wrote: > | > Python threads work fine if the threads either rely on > intelligent > | > DLLs for number crunching (instead of doing nested Python lo

Re: Question about ast.literal_eval

2013-05-20 Thread Fábio Santos
On 20 May 2013 09:19, "Frank Millman" wrote: > Quoting from the manual - > > "Safely evaluate an expression node or a string containing a Python expression. The string or node provided may only consist of the following Python literal structures: strings, bytes, numbers, tuples, lists, dicts, sets,

Re: Please help with Threading

2013-05-20 Thread Fábio Santos
It is pretty cool although it looks like a recursive function at first ;) On 20 May 2013 10:13, "Chris Angelico" wrote: > On Mon, May 20, 2013 at 6:35 PM, Cameron Simpson wrote: > > _lock = Lock() > > > > def lprint(*a, **kw): > > global _lock > > with _lock: > > print(*a, **kw

Re: Please help with Threading

2013-05-20 Thread Fábio Santos
I didn't know that. On 20 May 2013 12:10, "Dave Angel" wrote: > Are you making function calls, using system libraries, or creating or deleting any objects? All of these use the GIL because they use common data structures shared among all threads. At the lowest level, creating an object requires

Re: Question about ast.literal_eval

2013-05-21 Thread Fábio Santos
On 21 May 2013 09:10, "Frank Millman" wrote: > It doesn't address the issue of brackets. I imagine that the answer is something like - > > maintain a stack of results > for each left bracket, push a level > for each right bracket, pop the result > > or something ... > Time for me to suggest

Re: Newbie question about evaluating raw_input() responses

2013-05-21 Thread Fábio Santos
You have to convert `age` to an integer. Use int() to do it. Then you can compare it to other numbers and obtain the expected results. On 22 May 2013 07:29, "C. N. Desrosiers" wrote: > Hi, > > I'm just starting out with Python and to practice I am trying to write a > script that can have a simple

Re: Future standard GUI library

2013-05-22 Thread Fábio Santos
On 23 May 2013 03:39, "llanitedave" wrote: > > On Wednesday, May 22, 2013 7:24:15 AM UTC-7, Chris Angelico wrote: > > On Wed, May 22, 2013 at 11:42 PM, Wolfgang Keller wrote: ... > > there's another option that is available to every platform and > > (practially) every high level language: the web

RE: Future standard GUI library

2013-05-23 Thread Fábio Santos
It would be way more practical to have an embedded browser. Appjs doesn't even occupy a port on the client. We could totally benefit from that. Django applications practically make themselves. On 23 May 2013 08:02, "Carlos Nepomuceno" wrote: > You don't! If your app needs local content just use a

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Fábio Santos
On 24 May 2013 09:41, "Chris Angelico" wrote: > > On Fri, May 24, 2013 at 6:14 PM, Peter Brooks > wrote: > > What is the easiest way to reorder a sequence pseudo-randomly? > > > > That is, for a sequence 1,2,3,4 to produce an arbitrary ordering (eg > > 2,1,4,3) that is different each time. > > ..

Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Fábio Santos
On 25 May 2013 15:35, "Steven D'Aprano" < steve+comp.lang.pyt...@pearwood.info> wrote: > > On Sat, 25 May 2013 19:14:57 +1000, Chris Angelico wrote: > > > def random_number(): > > return 7 > > I call shenanigans! That value isn't generated randomly, you just made it > up! I rolled a die *hundre

Re: Newbie question about evaluating raw_input() responses

2013-05-25 Thread Fábio Santos
On 25 May 2013 19:37, "Chris Angelico" wrote: > Ah, who am I kidding. Be as rude as you like. I have to work with PHP all week. > > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list I have cried. -- http://mail.python.org/mailman/listinfo/python-list

Re: CrazyHTTPd - HTTP Daemon in Python

2013-05-26 Thread Fábio Santos
On 26 May 2013 05:18, "Mark Lawrence" wrote: > > On 26/05/2013 04:55, cdorm...@gmail.com wrote: >> >> This is a small little Project that I have started. Its a light little Web Server (HTTPd) coded in python. Requirements: Python 2.7 =< And Linux / BSD. I believe this could work in a CLI Emulator

Re: Python error codes and messages location

2013-05-27 Thread Fábio Santos
On 27 May 2013 12:41, "Mark Lawrence" wrote: > This should make life easier for us http://docs.python.org/3/whatsnew/3.3.html#pep-3151-reworking-the-os-and-io-exception-hierarchy Speaking of PEPs and exceptions. When do we get localized exceptions? -- http://mail.python.org/mailman/listinfo/pyth

Re: Python error codes and messages location

2013-05-27 Thread Fábio Santos
On Mon, May 27, 2013 at 2:11 PM, Steven D'Aprano wrote: > On Mon, 27 May 2013 13:46:50 +0100, Fábio Santos wrote: > >> Speaking of PEPs and exceptions. When do we get localized exceptions? > > > We're waiting for you to volunteer. When can you start? I'd

Re: Python error codes and messages location

2013-05-27 Thread Fábio Santos
On 27 May 2013 19:23, "Vito De Tullio" wrote: > > Fábio Santos wrote: > > >> This should make life easier for us > > http://docs.python.org/3/whatsnew/3.3.html#pep-3151-reworking-the-os-and-io-exception-hierarchy > > > > Speaking of PEPs and e

Re: Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()

2013-05-27 Thread Fábio Santos
On 27 May 2013 22:36, "Bryan Britten" wrote: > > Try to not sigh audibly as I ask what I'm sure are two asinine questions. > > 1) How is this approach different from twtrDict = [json.loads(line) for line in urllib.urlopen(urlStr)]? > The suggested approach made use of generators. Just because you

Re: Python error codes and messages location

2013-05-27 Thread Fábio Santos
On 27 May 2013 19:36, "Fábio Santos" wrote: > > > On 27 May 2013 19:23, "Vito De Tullio" wrote: > > > > Fábio Santos wrote: > > > > >> This should make life easier for us > > > http://docs.python.org/3/whatsnew/3.3.html#pep-3151

Re: I want to know how to implement concurrent threads in Python

2013-05-27 Thread Fábio Santos
On 28 May 2013 05:06, "Daniel Gagliardi" wrote: > > fuck! fuck! i'm gonna be fired if i didnt get this shit! i told my boss id do it. fuck! im gonna pipe some crakc. fuck... So do it. You've already been told how to. It's true that python does not do real concurrent execution, but if most of you

Re: Python error codes and messages location

2013-05-28 Thread Fábio Santos
On 28 May 2013 05:17, "Vito De Tullio" wrote: > > Fábio Santos wrote: > > >> > > Speaking of PEPs and exceptions. When do we get localized exceptions? > >> > > >> > What do you mean by "localized exceptions"? > >> &g

Re: Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()

2013-05-28 Thread Fábio Santos
On 28 May 2013 04:19, "Bryan Britten" wrote: > I'm not familiar with using read(4096), I'll have to look into that. When I tried to just save the file, my computer just sat in limbo for some time and didn't seem to want to process the command. That's just file.read with an integer argument. You c

Re: Python error codes and messages location

2013-05-28 Thread Fábio Santos
On 28 May 2013 08:19, "Chris Angelico" wrote: > > On Tue, May 28, 2013 at 4:57 PM, Fábio Santos wrote: > > > > On 28 May 2013 05:17, "Vito De Tullio" wrote: > >> I really hope really far... have you never tried to google a localized > >>

Re: Python error codes and messages location

2013-05-28 Thread Fábio Santos
On 28 May 2013 09:22, "Chris Angelico" wrote: > > On Tue, May 28, 2013 at 6:10 PM, Fábio Santos wrote: > > Just to clarify, I am suggesting to have the unchanged messages in > > tracebacks, but having some methods in the exception to get the exception > > and

RE: Python #ifdef

2013-05-28 Thread Fábio Santos
On 28 May 2013 21:26, "Carlos Nepomuceno" wrote: > Haha! That's it!!! > > Just realized how funny this can be: ;) > > ### never to be opened ### > def pandoras_box(v): > return v/0.0 > > if customer_didnt_pay(): > pandoras_box() > > #lol 1/0 is, after print, my most common debug statement

RE: Python #ifdef

2013-05-28 Thread Fábio Santos
On 28 May 2013 21:53, "Carlos Nepomuceno" wrote: > > > > Date: Tue, 28 May 2013 21:34:36 +0100 > > Subject: RE: Python #ifdef > > From: fabiosantos...@gmail.com > > To: carlosnepomuc...@outlook.com > > CC: python-list@python.org > > > > > > On 28 May 2013 21:26, "C

Re: Python error codes and messages location

2013-05-28 Thread Fábio Santos
On 29 May 2013 00:44, "Dennis Lee Bieber" wrote: > > On Tue, 28 May 2013 17:15:51 +1000, Chris Angelico > declaimed the following in gmane.comp.python.general: > > > > Can we internationalize English instead of localizing Python? > > > > Not-entirely-joking-ly yours, > > > All that is req

Re: MySQL dymanic query in Python

2013-05-29 Thread Fábio Santos
On 29 May 2013 10:13, "RAHUL RAJ" wrote: > > Can anyone tell me the proper way in which I can execute dynamic MySQL queries in Python? > > I want to do dynamic queries for both CREATE and INSERT statement. > > Here is my attempted code: > > > sql="create table %s (%%s, %%s, %%s ... )" % (tablename

Re: Output is not coming with defined color

2013-05-29 Thread Fábio Santos
On 29 May 2013 12:25, "Avnesh Shakya" wrote: > > hi, >I am trying to display my output with different colour on terminal, but it's > coming with that colour code. > Please help me how is it possible? > > my code is - > from fabric.colors import green, red, blue > def colorr(): > a = red('T

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_

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: 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 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: 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: 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: 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: 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-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: 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 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: 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: 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
> > 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: 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: 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: 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: 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: [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: 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: 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: 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: 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: 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: [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: 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: 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: 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: 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: 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: 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: 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: 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" <__pete...@web.de> 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-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 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: 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: 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
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: 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: 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
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: 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: 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: 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: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: 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: 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

  1   2   >