Re: check_output

2014-11-04 Thread Kiuhnm
On Wednesday, November 5, 2014 3:05:32 AM UTC+1, Kiuhnm wrote: > When I call "subprocess.check_output()" I see the console window appear and > disappear very quickly. Is there a way to stop the console from showing up at > all? shell=True does the trick! -- https://mail

check_output

2014-11-04 Thread Kiuhnm
When I call "subprocess.check_output()" I see the console window appear and disappear very quickly. Is there a way to stop the console from showing up at all? -- https://mail.python.org/mailman/listinfo/python-list

Re: simple download manager

2014-11-04 Thread Kiuhnm
On Tuesday, November 4, 2014 4:10:59 PM UTC+1, Kiuhnm wrote: > On Tuesday, November 4, 2014 4:00:51 PM UTC+1, Chris Angelico wrote: > > On Wed, Nov 5, 2014 at 1:53 AM, Kiuhnm wrote: > > > I wish to automate the downloading from a particular site which has some > > >

Re: simple download manager

2014-11-04 Thread Kiuhnm
On Tuesday, November 4, 2014 4:00:51 PM UTC+1, Chris Angelico wrote: > On Wed, Nov 5, 2014 at 1:53 AM, Kiuhnm wrote: > > I wish to automate the downloading from a particular site which has some > > ADs and which requires to click on a lot of buttons before the download > >

simple download manager

2014-11-04 Thread Kiuhnm
I wish to automate the downloading from a particular site which has some ADs and which requires to click on a lot of buttons before the download starts. What library should I use to handle HTTP? Also, I need to support big files (> 1 GB) so the library should hand the data to me chunk by chunk.

Re: problem with pefile

2014-10-31 Thread Kiuhnm
On Friday, October 31, 2014 2:23:26 AM UTC+1, Cameron Simpson wrote: > On 30Oct2014 17:58, Kiuhnm wrote: > >On Friday, October 31, 2014 1:33:07 AM UTC+1, Cameron Simpson wrote: > >> On 29Oct2014 08:34, gandalf23 wrote: > >> >OT: how can I hide my email in these po

Re: problem with pefile

2014-10-30 Thread Kiuhnm
On Friday, October 31, 2014 1:33:07 AM UTC+1, Cameron Simpson wrote: > On 29Oct2014 08:34, gandalf23 wrote: > >OT: how can I hide my email in these posts? > >Every time I try to send a post, google warns me that my email is visible > >and so I edit it out. > > Why would you want to hide your emai

Re: optional types

2014-10-29 Thread Kiuhnm
On Wednesday, October 29, 2014 8:23:30 PM UTC+1, Mark Lawrence wrote: > On 29/10/2014 19:03, Kiuhnm wrote: > > On Wednesday, October 29, 2014 7:19:11 PM UTC+1, Marko Rauhamaa wrote: > >> Chris Angelico : > >> > >>> Yes, but if it's official, the standar

Re: optional types

2014-10-29 Thread Kiuhnm
On Wednesday, October 29, 2014 8:45:08 PM UTC+1, Marko Rauhamaa wrote: > Mark Lawrence : > > > Regarding 2) Python has somehow managed without optional types for > > over 20 years so it's my belief that they're not the panacea that so > > many people think they are. Sure if they get implemented an

Re: optional types

2014-10-29 Thread Kiuhnm
On Wednesday, October 29, 2014 8:03:16 PM UTC+1, Kiuhnm wrote: > On Wednesday, October 29, 2014 7:19:11 PM UTC+1, Marko Rauhamaa wrote: > > Chris Angelico : > > > > > Yes, but if it's official, the standard library (large parts of it, at > > > least) will

Re: optional types

2014-10-29 Thread Kiuhnm
On Wednesday, October 29, 2014 7:19:11 PM UTC+1, Marko Rauhamaa wrote: > Chris Angelico : > > > Yes, but if it's official, the standard library (large parts of it, at > > least) will use it, which will make it a lot more useful than it > > currently is. > > I doubt it. Python should decide if it

Re: optional types

2014-10-29 Thread Kiuhnm
On Wednesday, October 29, 2014 5:57:13 PM UTC+1, Peter Otten wrote: > Kiuhnm wrote: > > > I must say that the lack of static types in Python is a pain in the neck > > especially when I'm exploring new libraries. Recently, I learned a new > > language called Dart whi

optional types

2014-10-29 Thread Kiuhnm
I must say that the lack of static types in Python is a pain in the neck especially when I'm exploring new libraries. Recently, I learned a new language called Dart which have optional typing and I had a lot of fun with it. Basically, you use type annotations as documentation and to give useful

Re: problem with pefile

2014-10-29 Thread Kiuhnm
On Wednesday, October 29, 2014 4:34:42 PM UTC+1, Kiuhnm wrote: > OT: how can I hide my email in these posts? > Every time I try to send a post, google warns me that my email is visible and > so I edit it out. Problem solved :) -- https://mail.python.org/mailman/listinfo/python-list

Re: problem with pefile

2014-10-29 Thread Kiuhnm
Little test...sorry. -- https://mail.python.org/mailman/listinfo/python-list

Re: syntax for code blocks

2012-05-04 Thread Kiuhnm
On 5/4/2012 4:44, alex23 wrote: On May 4, 2:17 am, Kiuhnm wrote: On 5/3/2012 2:20, alex23 wrote: locals() is a dict. It's not injecting anything into func's scope other than a dict so there's not going to be any name clashes. If you don't want any of its content in your fu

Re: syntax for code blocks

2012-05-03 Thread Kiuhnm
On 5/3/2012 2:20, alex23 wrote: On May 2, 8:52 pm, Kiuhnm wrote: func(some_args, locals()) I think that's very bad. It wouldn't be safe either. What about name clashing locals() is a dict. It's not injecting anything into func's scope other than a dict so there&#

Re: key/value store optimized for disk storage

2012-05-03 Thread Kiuhnm
ache the accesses to that file hoping that the accesses are not as random as you think. If that's the case you should notice a *huge* improvement. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I read streaming output of a subprocess

2012-05-02 Thread Kiuhnm
rue, stdout = PIPE, stderr = STDOUT).stdout print(stdout.read()) just to see if it works. You can also use for line in stdout: print(line) or similar. Then you should add some error checking, etc... Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: reading data file into a list

2012-05-02 Thread Kiuhnm
://docs.scipy.org/doc/numpy/reference/routines.io.html Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: numpy (matrix solver) - python vs. matlab

2012-05-02 Thread Kiuhnm
3D vectors in matlab, very easily so maybe I better understand SVD if I hear/read the geometric explanation (references to textbook/similar is also appreciated). Russ's post is a very good starting point. I hope you read it. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: syntax for code blocks

2012-05-02 Thread Kiuhnm
On 5/2/2012 4:43, alex23 wrote: [Apologies in advance if this comes through twice] On May 2, 12:18 am, Kiuhnm wrote: "Most Pythonic" doesn't mean better, unfortunately. Nor does it mean "Kiuhnm prefers it". That goes without saying. For instance, assume that you

Re: numpy (matrix solver) - python vs. matlab

2012-05-01 Thread Kiuhnm
llelepiped. If our vectors are collinear or coplanar, the parallelepiped is degenerate, i.e. has volume 0. The converse is also true. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: syntax for code blocks

2012-05-01 Thread Kiuhnm
don't even have the decency of taking the time to read the documentation of a project and just run their mouth without any concern for facts. What I can't stand is that if I won't reply to your posts other lazy people will believe the nonsense you say, but I'll have to live with that because I've wasted enough time with you. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: syntax for code blocks

2012-05-01 Thread Kiuhnm
: pass with func(some_args) << ':dict': with when_prime as 'n': pass with when_perfect as 'n': pass with before_reduction as '': pass with after_reduction as '': pass Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: ctypes details was: Re: syntax for code blocks

2012-04-30 Thread Kiuhnm
On 4/30/2012 17:42, mwil...@the-wire.com wrote: On 4/30/2012 17:02, Kiuhnm wrote: BignumTypePtr = ctypes.POINTER(BignumType) for op, op_word in ((libbnem.BN_add, libbnem.BN_add_word), (libbnem.BN_sub, libbnem.BN_sub_word)): op.argtypes = [BignumTypePtr] * 3 op_word.argtypes = [BignumTypePtr

Re: syntax for code blocks

2012-04-30 Thread Kiuhnm
On 4/30/2012 17:02, Kiuhnm wrote: On 4/30/2012 16:17, mwil...@the-wire.com wrote: Ben Finney wrote: [ ... ] Even worse is the penchant for ‘foo .bar()’, the space obscures the fact that this is attribute access. I like the style sometimes when it helps to break the significantly different

Re: syntax for code blocks

2012-04-30 Thread Kiuhnm
N_add_word), (libbnem.BN_sub, libbnem.BN_sub_word)): op.argtypes = [BignumTypePtr] * 3 op_word.argtypes = [BignumTypePtr, ctypes.c_ulong] op.restype = op_word.restype = ctypes.c_int Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: numpy (matrix solver) - python vs. matlab

2012-04-30 Thread Kiuhnm
number is scale-invariant and it's useful when a matrix is ill-conditioned just because its rows are out of scale. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: numpy (matrix solver) - python vs. matlab

2012-04-30 Thread Kiuhnm
On 4/30/2012 2:17, someone wrote: On 04/30/2012 12:39 AM, Kiuhnm wrote: So Matlab at least warns about "Matrix is close to singular or badly scaled", which python (and I guess most other languages) does not... A is not just close to singular: it's singular! Ok. When do you

Re: numpy (matrix solver) - python vs. matlab

2012-04-29 Thread Kiuhnm
ber at all times before doing anything at all ? How to do that? If cond(A) is high, you're trying to solve your problem the wrong way. You should try to avoid matrix inversion altogether if that's the case. For instance you shouldn't invert a matrix just to solve a linear system. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Learn Technical Writing from Unix Man in 10 Days

2012-04-29 Thread Kiuhnm
identical to install except that packages are removed instead of installed. Note the removing a package leaves its configuration files in system. If a plus sign is appended to the package name (with no intervening space), the identified package will be installed instead of removed. <--- Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: why () is () and [] is [] work in other way?

2012-04-29 Thread Kiuhnm
On 4/28/2012 16:18, Adam Skutt wrote: On Apr 28, 7:26 am, Kiuhnm wrote: On 4/27/2012 19:15, Adam Skutt wrote: On Apr 27, 11:01 am, Kiuhnmwrote: The abstraction is this: - There are primitives and objects. - Primitives are not objects. The converse is also true. - Primitives can become

Re: confusing doc: mutable and hashable

2012-04-28 Thread Kiuhnm
take X. Modifying X is equivalent to modifying K in the example above. These kinds of problems are avoided if mutable objects can't be keys. Some containers require that keys be hashable, but since, by design, mutable objects can't be keys, there's no reason for them to be hashable eith

Re: why () is () and [] is [] work in other way?

2012-04-28 Thread Kiuhnm
On 4/27/2012 17:39, Adam Skutt wrote: On Apr 27, 8:07 am, Kiuhnm wrote: Useful... maybe, conceptually sound... no. Conceptually, NaN is the class of all elements which are not numbers, therefore NaN = NaN. NaN isn't really the class of all elements which aren't numbers. NaN is the

Re: why () is () and [] is [] work in other way?

2012-04-28 Thread Kiuhnm
On 4/27/2012 19:15, Adam Skutt wrote: On Apr 27, 11:01 am, Kiuhnm wrote: On 4/27/2012 1:57, Adam Skutt wrote: On Apr 26, 6:34 pm, Kiuhnmwrote: If you understand that your 'a' is not really an object but a reference to it, everything becomes clear and you see that '=='

Re: syntax for code blocks

2012-04-28 Thread Kiuhnm
On 4/27/2012 18:07, Steven D'Aprano wrote: > On Fri, 27 Apr 2012 17:03:19 +0200, Kiuhnm wrote: > >> On 4/27/2012 16:09, Steven D'Aprano wrote: >>> On Fri, 27 Apr 2012 13:24:35 +0200, Kiuhnm wrote: >>> >>>> I'd like to change the synta

Re: CPython thread starvation

2012-04-27 Thread Kiuhnm
cking performed? Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Kiuhnm
On 4/27/2012 16:07, Steven D'Aprano wrote: On Fri, 27 Apr 2012 14:17:48 +0200, Kiuhnm wrote: Define your terms: what do you mean by "equal"? a and b are equal iff Nope. What I meant is that we can talk of equality whenever... a = a a = b => b = a a = b and b = c =&

Re: syntax for code blocks

2012-04-27 Thread Kiuhnm
On 4/27/2012 16:09, Steven D'Aprano wrote: On Fri, 27 Apr 2012 13:24:35 +0200, Kiuhnm wrote: I'd like to change the syntax of my module 'codeblocks' to make it more pythonic. Current Syntax: with res << func(arg1) << 'x, y':

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Kiuhnm
On 4/27/2012 1:57, Adam Skutt wrote: On Apr 26, 6:34 pm, Kiuhnm wrote: On 4/26/2012 20:54, Adam Skutt wrote: On Apr 26, 12:02 pm, Kiuhnmwrote: On 4/26/2012 16:00, Adam Skutt wrote: On Apr 26, 9:37 am, Kiuhnm wrote: The fact that you think that that's "differing behaviou

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Kiuhnm
On 4/27/2012 14:07, Kiuhnm wrote: On 4/27/2012 13:09, Steven D'Aprano wrote: On Thu, 26 Apr 2012 18:02:31 +0200, Kiuhnm wrote: On 4/26/2012 16:00, Adam Skutt wrote: C# and Python do have a misfeature: '==' is identity comparison only if operator== / __eq__ is not overl

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Kiuhnm
On 4/27/2012 13:09, Steven D'Aprano wrote: On Thu, 26 Apr 2012 18:02:31 +0200, Kiuhnm wrote: On 4/26/2012 16:00, Adam Skutt wrote: C# and Python do have a misfeature: '==' is identity comparison only if operator== / __eq__ is not overloaded. Identity comparison and value

syntax for code blocks

2012-04-27 Thread Kiuhnm
, y) New Syntax: with res == func(arg1) .taking_block (x, y): print(x, y) with res == func(arg1) .taking_block (x, y) as block_name: print(x, y) The full form is equivalent to def anon_func(x, y): print(x, y) res = func(arg1, block_name = anon_func) Sugge

Re: Half-baked idea: list comprehensions with "while"

2012-04-27 Thread Kiuhnm
On 4/27/2012 11:49, Miles Rout wrote: On 27/04/2012 5:57 a.m., Kiuhnm wrote: On 4/26/2012 19:48, Paul Rubin wrote: Roy Smith writes: x = [a for a in iterable while a] from itertools import takewhile x = takewhile(bool, a) I see that as a 'temporary' solution, otherwise we wou

Re: why () is () and [] is [] work in other way?

2012-04-26 Thread Kiuhnm
On 4/26/2012 20:54, Adam Skutt wrote: On Apr 26, 12:02 pm, Kiuhnm wrote: On 4/26/2012 16:00, Adam Skutt wrote: On Apr 26, 9:37 am, Kiuhnm wrote: On 4/26/2012 13:45, Adam Skutt wrote: On Apr 26, 1:48 am, John Nagle wrote: This assumes that everything is, internally, an object

Re: Web Scraping - Output File

2012-04-26 Thread Kiuhnm
') for letter in range(A, Z): for line in urllib2.urlopen("http://www.skadden.com/Index.cfm?contentID=44&alphaSearch="+chr(letter)): x = line if ' >' in line: start=x.find(' >') end= x.find('',start) name=x[start+5:end] outfile.write(name+"\n") print name <--- Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Half-baked idea: list comprehensions with "while"

2012-04-26 Thread Kiuhnm
On 4/26/2012 19:48, Paul Rubin wrote: Roy Smith writes: x = [a for a in iterable while a] from itertools import takewhile x = takewhile(bool, a) I see that as a 'temporary' solution, otherwise we wouldn't need 'if' inside of list comprehensions either. Kiuhnm

Re: Half-baked idea: list comprehensions with "while"

2012-04-26 Thread Kiuhnm
he list where all elements of the tuple are string non-zero-length strings. Obviously, you'd do the corresponding generator expression as well. I think it's a nice idea. In the meantime, try this way: valid_answers = list(takewhile(all, pairs)) Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange __import__() behavior

2012-04-26 Thread Kiuhnm
On 4/26/2012 17:19, Frank Miles wrote: On Wed, 25 Apr 2012 23:03:36 +0200, Kiuhnm wrote: On 4/25/2012 22:05, Frank Miles wrote: I have an exceedingly simple function that does a "named import". It works perfectly for one file "r"- and fails for the second "x". I

Re: why () is () and [] is [] work in other way?

2012-04-26 Thread Kiuhnm
On 4/26/2012 16:00, Adam Skutt wrote: On Apr 26, 9:37 am, Kiuhnm wrote: On 4/26/2012 13:45, Adam Skutt wrote: On Apr 26, 1:48 am, John Naglewrote: On 4/25/2012 5:01 PM, Steven D'Aprano wrote: On Wed, 25 Apr 2012 13:49:24 -0700, Adam Skutt wrote: Though, maybe it

Re: Upgrading from 2.7 to 3.x

2012-04-26 Thread Kiuhnm
On 4/26/2012 15:02, deuteros wrote: On Thu 26 Apr 2012 07:37:20a, Kiuhnm wrote in news:4f993382$0$1378$4fafb...@reader2.news.tin.it: Python 2.7.3 and 3.2.3 (the latest versions) can coexist. Just install Python 3.2.3 in a different directory (python32, for instance). Python has been "f

Re: why () is () and [] is [] work in other way?

2012-04-26 Thread Kiuhnm
cts, but I don't exactly know how one would do that in Python. Why should we take from Java one of its worst misfeatures and disfigure Python for life? a==b compares references while a.equals(b) compares values. Really??? Come on... Python's way is much much cleaner. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: why () is () and [] is [] work in other way?

2012-04-26 Thread Kiuhnm
place names a, b with expressions: id([1,2]) == id([3,4]) True You forgot one: 5) It would be a pain to write (and read) if id(my_obj) == id(None) and so anyone would come up with his/her own same_as(), identical_to(), same_inst() and so on... Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Upgrading from 2.7 to 3.x

2012-04-26 Thread Kiuhnm
On 4/26/2012 13:37, Kiuhnm wrote: On 4/26/2012 5:08, deuteros wrote: I'm fairly new to Python I have version 2.7 installed on my computer. However my professor wants us all to use the latest version of Python. How do I go about upgrading? Do I just install the new version? Do I have

Re: Upgrading from 2.7 to 3.x

2012-04-26 Thread Kiuhnm
and clean it up. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange __import__() behavior

2012-04-25 Thread Kiuhnm
very weird that it works in the CL interpreter and not in my script. TIA for any hints or pointers to the relevant overlooked documentation! I can't reproduce your problem on my configuration. Anyway, you should note that if x.pyc and r.pyc are present, __import__ will try to import them and not the files x.py and r.py. Try deleting x.pyc and r.pyc. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: csv: No fields, or one field?

2012-04-25 Thread Kiuhnm
trust you when you say it isn't), but it makes a lot of sense: >>> next(csv.reader([''])) [] >>> next(csv.reader(['""'])) [''] >>> next(csv.reader([','])) ['', ''] >>> next(csv.reader([',,'])) ['', '', ''] ... Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: from calendar import* doesn't import everything

2012-04-24 Thread Kiuhnm
On 4/25/2012 1:54, Rotwang wrote: On 25/04/2012 00:42, Kiuhnm wrote: On 4/25/2012 1:18, Rotwang wrote: Sorry if this is a stupid question, but what is up with this: >>> from calendar import* >>> Calendar Traceback (most recent call last): File "", line 1,

Re: from calendar import* doesn't import everything

2012-04-24 Thread Kiuhnm
quot;firstweekday", "isleap", "leapdays", "weekday", "monthrange", "monthcalendar", "prmonth", "month", "prcal", "calendar", "timegm", "month_name", "month_abbr", "day_name", "day_abbr"] Only those names are imported with '*'. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: why () is () and [] is [] work in other way?

2012-04-24 Thread Kiuhnm
of tuples (id, data) where {(id, data1), (id, data2)} subset O => data1 = data2 Def. (id1, data1) and (id2, data2) in O are /the same/ iff id1 = id2. Now, it's easy to find a bijection between O and the set of Python's objects which are in memory at any single point in time. Anyway, you're being unnecessarily pedantic. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: why () is () and [] is [] work in other way?

2012-04-24 Thread Kiuhnm
you change the name of the operator or the language in which you define the operator, you'll realize that there's no real circularity in that definition. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Kiuhnm
On 4/23/2012 19:01, Paul Rubin wrote: Kiuhnm writes: I can't think of a single case where 'is' is ill-defined. If I can't predict the output of print (20+30 is 30+20) # check whether addition is commutative print (20*30 is 30*20) # check whether multiplicatio

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Kiuhnm
x27;b' are the same object. Why should 'is' lie to the user? It does exactly what it says it does: it tells the user whether two objects are the same. In C++, for greater efficiency, two objects are compared for equality by first checking their addresses and then their contents. 'is' would be perfect for that. What I don't like is 'isinstance'. I'd prefer an infix operator 'isa' or 'is_a'. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: global vars across modules

2012-04-22 Thread Kiuhnm
On 4/22/2012 23:08, Kiuhnm wrote: On 4/22/2012 21:39, mambokn...@gmail.com wrote: I need to use global var across files/modules: # file_1.py a = 0 def funct_1() : a = 1 # a is global print(a) # file_2.py from file_1 import * def main() : funct_1() a = 2 # a is local, it's not imported

Re: global vars across modules

2012-04-22 Thread Kiuhnm
When you write 'a = 1' and 'a = 2' you create local variables named 'a' local to your functions, unless you specify that you're referring to a global variable by declaring 'a' as 'global'. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Appending to []

2012-04-22 Thread Kiuhnm
f comp_list(from_, to_): # Some long computation which results in a list. return MyList(range(from_, to_)) x = comp_list(0, 1000) + comp_list(1000, 2000) + MyList([2000, 2001]) assert x == MyList(range(0, 2002)) assert optimizations == 2 <-- Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie, homework help, please.

2012-04-21 Thread Kiuhnm
x in xl]) topBorder = '^'*( xl_max + 4 ) print topBorder for x in xl: print "* %s%s *" % ( x, ' '*(xl_max - len( x )) ) Or print "* %-*s *" % (xl_max, x) I hope you don't mind. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Appending to []

2012-04-21 Thread Kiuhnm
On 4/21/2012 18:14, Kiuhnm wrote: On 4/21/2012 17:41, Bernd Nawothnig wrote: On 2012-04-21, Kiuhnm wrote: Returning a None-value is pretty useless. Why not returning self, which would be the resulting list in this case? Returning self would make the language a little bit more functional

Re: Appending to []

2012-04-21 Thread Kiuhnm
On 4/21/2012 17:41, Bernd Nawothnig wrote: On 2012-04-21, Kiuhnm wrote: Returning a None-value is pretty useless. Why not returning self, which would be the resulting list in this case? Returning self would make the language a little bit more functional, without any drawback

Re: Appending to []

2012-04-21 Thread Kiuhnm
estion: append returns None so that people can't use it the way you did. You make the reader believe that you're adhering to the functional paradigm whereas 'append' has actually side effects! Moreover, you use an assignment just to reinforce this wrong belief. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Appending to []

2012-04-20 Thread Kiuhnm
On 4/20/2012 22:03, Jan Sipke wrote: Can you explain why there is a difference between the following two statements? a = [] a.append(1) print a [1] print [].append(1) None Try this one: a = [] print a.append(1) Does that answer your question? Kiuhnm -- http://mail.python.org

Re: can I overload operators like "=>", "->" or something like that?

2012-04-20 Thread Kiuhnm
On 4/20/2012 19:49, Jussi Piitulainen wrote: Kiuhnm writes: On 4/20/2012 17:50, Nobody wrote: On Thu, 19 Apr 2012 12:28:50 -0700, dmitrey wrote: can I somehow overload operators like "=>", "->" or something like that? (I'm searching for appropriate overloa

Re: can I overload operators like "=>", "->" or something like that?

2012-04-20 Thread Kiuhnm
create new operators, but you can control how existing operators work on types which you define. IOW, you can't define "->" or "=>", but you could define">=" or ">>". You can also "overload" '<-' ;) Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

code blocks in Python 2 and 3

2012-04-20 Thread Kiuhnm
Read about it here: http://mtomassoli.wordpress.com/2012/04/20/code-blocks-in-python/ or just download the module from here: https://bitbucket.org/mtomassoli/codeblocks/ The module codeblocks (codeblocks.py) includes a detailed docstring. Kiuhnm -- http://mail.python.org/mailman/listinfo

Re: with statement

2012-04-19 Thread Kiuhnm
On 4/19/2012 20:02, Jacob MacDonald wrote: On Thursday, April 19, 2012 10:15:23 AM UTC-7, Kiuhnm wrote: A with statement is not at the module level only if it appears inside a function definition or a class definition. Am I forgetting something? Kiuhnm That sounds about right to me. However

Re: Framework for a beginner

2012-04-19 Thread Kiuhnm
On 4/19/2012 14:02, Roy Smith wrote: In article<4f8ff38c$0$1381$4fafb...@reader1.news.tin.it>, Kiuhnm wrote: I don't like when a community imposes style on a programmer. For instance, many told me that I shouldn't use camelCase and I should adhere to PEP8. Well, that'

Re: Bug in Python

2012-04-19 Thread Kiuhnm
On 4/18/2012 3:08, Kiuhnm wrote: I'm using Python 3.2.2, 64 bit on Windows 7. Consider this code: ---> print(1) print(2) print(3) with open('test') as f: data = f.read() with open('test') as f: data = f.read() <--- If I debug this code with python -m pdb script

Re: Framework for a beginner

2012-04-19 Thread Kiuhnm
to defend your language against "infidels". Python is a very good language, but so is Ruby, Scala and many other languages. Denying that fact is deluding oneself. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Bug in Python

2012-04-18 Thread Kiuhnm
The bug was confirmed and a patch is now available: http://bugs.python.org/issue14612 Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Bug in Python

2012-04-18 Thread Kiuhnm
On 4/18/2012 6:47, Hans Mulder wrote: On 18/04/12 03:08:08, Kiuhnm wrote: print(1) print(2) print(3) with open('test') as f: data = f.read() with open('test') as f: data = f.read() I get the same result with Pythin 3.3.0a0 on MacOS X 10.6: 93> ./python.ex

Bug in Python

2012-04-17 Thread Kiuhnm
I'm using Python 3.2.2, 64 bit on Windows 7. Consider this code: ---> print(1) print(2) print(3) with open('test') as f: data = f.read() with open('test') as f: data = f.read() <--- If I debug this code with python -m pdb script.py and I issue the comman

Re: python module

2012-04-16 Thread Kiuhnm
On 4/17/2012 1:23, Steven D'Aprano wrote: [...] Wherever you host the code itself, you should also register it on PyPI. Ok, thanks. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: python module

2012-04-16 Thread Kiuhnm
On 4/16/2012 13:02, Thomas Rachel wrote: Am 16.04.2012 12:23 schrieb Kiuhnm: I'd like to share a module of mine with the Python community. I'd like to encourage bug reports, suggestions, etc... Where should I upload it to? Kiuhnm There are several ways to do this. One of the

Re: escaping

2012-04-16 Thread Kiuhnm
On 4/16/2012 17:14, Jon Clements wrote: On Monday, 16 April 2012 11:03:31 UTC+1, Kiuhnm wrote: On 4/16/2012 4:42, Steven D'Aprano wrote: On Sun, 15 Apr 2012 23:07:36 +0200, Kiuhnm wrote: This is the behavior I need: path = path.replace('\\', &#x

Re: escaping

2012-04-16 Thread Kiuhnm
On 4/16/2012 12:03, Kiuhnm wrote: On 4/16/2012 4:42, Steven D'Aprano wrote: On Sun, 15 Apr 2012 23:07:36 +0200, Kiuhnm wrote: This is the behavior I need: path = path.replace('\\', '') msg = ". {} .. '{}' .. {} .".format(a, path, b) Is there a

python module

2012-04-16 Thread Kiuhnm
I'd like to share a module of mine with the Python community. I'd like to encourage bug reports, suggestions, etc... Where should I upload it to? Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: escaping

2012-04-16 Thread Kiuhnm
On 4/16/2012 4:42, Steven D'Aprano wrote: On Sun, 15 Apr 2012 23:07:36 +0200, Kiuhnm wrote: This is the behavior I need: path = path.replace('\\', '') msg = ". {} .. '{}' .. {} .".format(a, path, b) Is there a better way? This wo

escaping

2012-04-15 Thread Kiuhnm
This is the behavior I need: path = path.replace('\\', '') msg = ". {} .. '{}' .. {} .".format(a, path, b) Is there a better way? Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Zipping a dictionary whose values are lists

2012-04-13 Thread Kiuhnm
On 4/13/2012 17:58, Alexander Blinne wrote: Am 12.04.2012 18:38, schrieb Kiuhnm: Almost. Since d.values() = [[1,2], [1,2,3], [1,2,3,4]], you need to use list(zip(*d.values())) which is equivalent to list(zip([1,2], [1,2,3], [1,2,3,4])) Kiuhnm While this accidently works in this

Re: functions which take functions

2012-04-12 Thread Kiuhnm
On 4/12/2012 19:29, Jan Kuiken wrote: On 4/9/12 20:57 , Kiuhnm wrote: Do you have some real or realistic (but easy and self-contained) examples when you had to define a (multi-statement) function and pass it to another function? I don't use it daily but the first argument of list.sort

Re: Deep merge two dicts?

2012-04-12 Thread Kiuhnm
tes, but this could be the intended behavior. For instance, with the 'a' and 'b' above, the result would be {'a':1} Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: Zipping a dictionary whose values are lists

2012-04-12 Thread Kiuhnm
], [1,2,3,4])) Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: functions which take functions

2012-04-12 Thread Kiuhnm
On 4/12/2012 8:07, Tim Roberts wrote: Kiuhnm wrote: That won't do. A good example is when you pass a function to re.sub, for instance. This is an odd request. All shall be revealed :) I often pass functions to functions in order to simulate a C switch statement, such as in a lan

Re: functions which take functions

2012-04-12 Thread Kiuhnm
On 4/11/2012 16:01, Antti J Ylikoski wrote: On 9.4.2012 21:57, Kiuhnm wrote: Do you have some real or realistic (but easy and self-contained) examples when you had to define a (multi-statement) function and pass it to another function? Thank you. Kiuhnm A function to numerically integrate

Re: functions which take functions

2012-04-11 Thread Kiuhnm
On 4/10/2012 23:43, Eelco wrote: On Apr 10, 3:36 am, Kiuhnm wrote: On 4/10/2012 14:29, Ulrich Eckhardt wrote: Am 09.04.2012 20:57, schrieb Kiuhnm: Do you have some real or realistic (but easy and self-contained) examples when you had to define a (multi-statement) function and pass it to

Re: functions which take functions

2012-04-10 Thread Kiuhnm
On 4/10/2012 14:29, Ulrich Eckhardt wrote: Am 09.04.2012 20:57, schrieb Kiuhnm: Do you have some real or realistic (but easy and self-contained) examples when you had to define a (multi-statement) function and pass it to another function? Take a look at decorators, they not only take non

Re: ast.parse

2012-04-09 Thread Kiuhnm
On 4/9/2012 14:43, Irmen de Jong wrote: On 9-4-2012 13:53, Kiuhnm wrote: Is it a known fact that ast.parse doesn't handle line continuations and some multi-line expressions? For instance, he doesn't like for (x, y) in each([1, 2]): print

ast.parse

2012-04-09 Thread Kiuhnm
Is it a known fact that ast.parse doesn't handle line continuations and some multi-line expressions? For instance, he doesn't like for (x, y) in each([1, 2]): print(1) at all. Is there a workaround besides "repairing" the code on the

Re: multithreading

2012-04-08 Thread Kiuhnm
On 4/8/2012 7:04, Bryan wrote: Kiuhnm wrote: My question is this: can I use 'threading' without interfering with the program which will import my module? Yes. The things to avoid are described at the bottom of: http://docs.python.org/library/threading.html On platforms witho

  1   2   >