g functions frequently,
so GC issues shouldn't arise). The last parameter doesn't have to have
the name of the function; this works with lambdas:
>>> recursive(lambda x,_=None: print("Lambda",x) or (x>3 and _(x-1) or None))(5)
Lambda 5
Lambda 4
Lambda 3
Yes, this is a pretty stupid example. But is this sort of decorator
useful? It's not like people regularly want recursive lambdas.
Chris Angelico
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Aug 5, 2011 at 1:40 AM, Dan Stromberg wrote:
print int(hex(0x72).replace('0x', ''))
> 72
Or simpler: int(hex(0x72)[2:])
Although if you have it as a string, you need to ord() the string.
It's probably better to just do the bitwise operations though.
ChrisA
--
http://mail.python.o
On Fri, Aug 5, 2011 at 6:31 PM, Sells, Fred
wrote:
> After the completion of most training courses, the students are not yet
> ready to make a meaningful contribution to the community.
That's quite possibly true, but they may very well be in a position to
recognize a documentation error/omission
_name = currentframe().f_code.co_name
print(my_name)
I would recommend against a function knowing its own name though,
unless it's for debugging or necessary metaprogramming purposes.
Cheers,
Chris
--
http://mail.python.org/mailman/listinfo/python-list
>>>> calendar.month_name[8]
> 'ao\xfbt'
>>>> print calendar.month_name[8]
> ao?t
>>>> print unicode(calendar.month_name[8],"latin1")
> août
Some quick experimentation seems to indicate that your month names are
Latin-1-encoded on Linux and UTF-8-encoded on Mac.
Perhaps try using a locale that specifies a specific encoding? e.g. fr_CA.UTF-8
Cheers,
Chris
--
http://rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list
> On Fri, Aug 5, 2011 at 2:19 AM, Chris Rebert wrote:
>> On Thu, Aug 4, 2011 at 8:25 PM, John Riselvato
>> wrote:
>> > I am working on a license verification script. I am rather new to the
>> > concept and to JSON files in general.
>>
print "In decorator B"
return func(*args, **kwds)
return decorated
@decorator_B
@decorator_A
def myfunc(arg):
print "hello", arg
>>> myfunc('bob')
In decorator B
In decorator A
hello bob
Notice that myfunc() only got executed once.
Cheers,
Chris
--
http://rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list
ype (it's "class Foo"), but no, it's not a subclass
> of MyMetaclass, so this doesn't help.
The typical form of super(), mentioned earlier in the documentation,
is being used here:
super(type, obj) -> bound super object; requires isinstance(obj, type)
`type` here
of this is that you DECREF'd an object when you
shouldn't have, or failed to INCREF one when you should have. Check
over your object usage; if you can narrow down the "Do some stuff" bit
to the one function call that causes the crash, it'll help you figure
out where the err
On Sat, Aug 6, 2011 at 12:16 PM, Vipul Raheja wrote:
> Hi Chris,
> Thanks for the reply.
> However, the error occurs even if I don't do anything, that is, even if I
> simply import the library and exit() after that.
> I created a file a.py whose contents were the followi
mputer that's unable to reach your server? If
not, there's your problem.
Chris Angelico
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, Aug 6, 2011 at 2:34 PM, Vipul Raheja wrote:
> Here's the link: www.geofemengineering.it/data/master_wrap.cxx
> Thanks and Regards,
> Vipul Raheja
Ugh. Unfortunately that file is somewhat lengthy... I hate to say
"tl;dr" to people, but... is there any way to simplify that down?
Perhaps th
On Sat, Aug 6, 2011 at 6:07 PM, smith jack wrote:
> if a list L is composed with tuple consists of two elements, that is
> L = [(a1, b1), (a2, b2) ... (an, bn)]
>
> is there any simple way to divide this list into two separate lists , such
> that
> L1 = [a1, a2... an]
> L2=[b1,b2 ... bn]
>
> i do
On Sat, Aug 6, 2011 at 7:21 PM, bud wrote:
> Nice. :) I forgot about zip, still learning Python myself.
>
> I'll have to check up on the *L - is that a reference?
> I
It expands the list into the arguments. It's the parallel to:
def func(*args):
which collapses the args into a list.
ChrisA
--
On Sat, Aug 6, 2011 at 10:33 PM, Kevin Walzer wrote:
> The main complaint I've seen about DDE is that it is very old.
I can't speak about COM, as I have not used it to any great extent,
but DDE has a number of things going for it. Firstly though, "old"
does not need to be a criticism. How many ne
On Sun, Aug 7, 2011 at 1:58 AM, Tim Roberts wrote:
> I did momentarily consider the following slimy solution:
> L1 = dict(L).keys()
> L2 = dict(L).values()
> but that reorders the tuples. They still correspond, but in a different
> order.
>
Which can be overcome with collections.OrderedDict. B
On Sun, Aug 7, 2011 at 6:07 PM, Steven D'Aprano
wrote:
> class ThingWithTwoIntegers(object):
>
I'm not a lisp expert, but this might well be called a cons cell. Or a "pair".
ChrisA
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Aug 8, 2011 at 5:08 PM, Verde Denim wrote:
> and it returns -
> "TypeError" with no other information...
> It appears to be generated from the line
>
> msg = ("From: %s\r\nTo: %s\r\n\r\n"
>% (fromaddr, ", ".join(toaddrs)))
>
> But I'm not sure why...
>
I transcribed pieces manuall
On Mon, Aug 8, 2011 at 5:45 PM, Verde Denim wrote:
> I'm running 2.6.5 on a debian base...
> It didn't seem to matter what is input -
> I tried using a single recipient as well as multiples (separated by comma).
Since the recipient list is divided using split(), you should separate
multiple addre
module __main__ object:
class Test(__builtin__.object)
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| fred
| *This is a docstring.*
Chris
On Mon, Au
On Mon, Aug 8, 2011 at 8:50 PM, Croepha wrote:
> I am doing research into doing network based propagation of python
> objects. In order to maintain network efficiency. I wan't to just
> send the differences of python objects
You could send pickled versions of each of the object's attributes,
rat
On Tue, Aug 9, 2011 at 1:23 AM, Terry Reedy wrote:
> I have no idea how stable and local pickles are, but I know they were not
> designed for diff-ing. Json or yaml representations might do better if
> applicable.
>
In terms of stability, you'd probably have to have a rule that
dictionaries are s
accepting Cython or Shedskin.
Chris Angelico
--
http://mail.python.org/mailman/listinfo/python-list
l[0],l[1],...,l[len(l)-1]).
>
> Is there any operation "op" such that f(op(l)) will give the sequence
> of elements of l as arguments to f?
Yep!
f(*l)
Chris Angelico
--
http://mail.python.org/mailman/listinfo/python-list
You can using metaclasses (untested):
>>>class MyMetaClass(type):
>>>def __iter__(self):
>>>return [1, 2, 3, 4]
>>>class MyClass(object):
>>>__metaclass__ = MyMetaClass
>>>for value in MyClass:
>>>print value
1
2
r(2).cx(1).xy(1).
> foreground('black').bkground('white')
Python does not particularly endorse method chaining; it's why
list.sort(), list.append(), and similar methods of built-in types
return None rather than self.
Also, I dislike this for the dot opera
open) to
> execute the external commands in parallel, but the commands seems to
> hang.
What's your Popen() call look like?
Cheers,
Chris
--
http://mail.python.org/mailman/listinfo/python-list
quot;""
Popen.wait()
Wait for child process to terminate. Set and return returncode attribute.
Warning: ***This will deadlock*** when using stdout=PIPE and/or
stderr=PIPE and the child process generates enough output to a pipe
such that it blocks waiting for the OS pipe buffer
> From: Chris Rebert
>> On Tue, Aug 9, 2011 at 11:38 PM, Danny Wong (dannwong)
>> wrote:
>>> Hi All,
>>> I'm trying to execute some external commands from multiple database.
>>> I'm using threads and subprocess.Popen ( from docs, all the p
additional mileage
out of lambdas and list comps when writing one-liners. :)
(Cue long thread about whether or not one-liners are Pythonic.)
Chris Angelico
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Aug 10, 2011 at 10:56 AM, Dan Sommers wrote:
> In terms of easier to read, I find code easier to read when the operators
> are at the beginnings of the lines (PEP 8 notwithstanding):
>
> x = (someobject.somemethod(object3, thing)
> + longfunctionname(object2)
> + otherfu
rt 22; for VNC, port
5900. Other services are on other ports.
By the way, this is a networking question, not a Python one.
Chris Angelico
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Aug 10, 2011 at 12:17 PM, wrote:
> Hello,
>
> I'd like to write a python (2.6/2.7) script which connects to database,
> fetches
> hundreds of thousands of rows, concat them (basically: create XML)
> and then put the result into another table. Do I have any choice
> regarding string conca
On Wed, Aug 10, 2011 at 1:25 PM, Duncan Booth
wrote:
> Chris Angelico wrote:
>
>> On Wed, Aug 10, 2011 at 10:56 AM, Dan Sommers
>> wrote:
>>> In terms of easier to read, I find code easier to read when the
>>> operators are at the beginnings of the lines (
is, fundamentally, glue between your SQL engine
and your SQL engine. Look up what you get from your query and work
with that. Which SQL library are you suing?
Python may and may not be the best tool for this job.
Chris Angelico
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Aug 10, 2011 at 3:38 PM, Chris Angelico wrote:
> Which SQL library are you suing?
And this is why I should proof-read BEFORE, not AFTER, sending.
Which SQL library are you *using*?
ChrisA
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Aug 10, 2011 at 1:58 PM, Yingjie Lan wrote:
> Is it possible for python to allow free splitting of single-line statements
> without the backslashes, if we impose that expressions can only be split
> when it is not yet a finished expression?
The trouble is that in a lot of cases, the next
/or otherwise-unexpected indentation, an
expression beginning with a + could conceivably be applying the unary
plus operator to the rest of the expression, rather than implying that
it's continuing the previous line.
Chris Angelico
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Aug 10, 2011 at 2:19 PM, Yingjie Lan wrote:
> If ';' are employed (required), truely free line-splitting should be OK,
> the operators may appear at the beginnings of the lines as you wish.
>
And if we require {} then truly free indentation should be OK too! But
it wouldn't be Python any
On Wed, Aug 10, 2011 at 10:51 PM, Ben Finney wrote:
> Seebs writes:
>> I've seen bits of code in preprocessing-based "Python with {}" type
>> things, and they still look like Python to me, only they favor
>> explicit over implicit a little more strongly.
>
> They introduce unnecessary ambiguity:
On Thu, Aug 11, 2011 at 12:26 AM, Tim Chase
wrote:
> On 08/10/2011 05:42 PM, Chris Angelico wrote:
>>
>> PS. I mistakenly sent this to a Gilbert& Sullivan group
>> first. Oddly enough, opera-goers are not used to discussing
>> the relative merits of braces vs ind
On Thu, Aug 11, 2011 at 12:32 AM, Steven D'Aprano
wrote:
> Chris stated that putting the unary + at the end of the line
> prevents "that", that being applying the unary + operator to the value on
> the right. But that is not the case -- unary prefix operators in Python
On Thu, Aug 11, 2011 at 1:32 AM, Steven D'Aprano
wrote:
>> I've seen bits of code in preprocessing-based "Python with {}" type
>> things, and they still look like Python to me, only they favor explicit
>> over implicit a little more strongly.
>
> "Looks like" Python does not equal "is Python". Cob
On Thu, Aug 11, 2011 at 12:39 AM, Jack Hatterly
wrote:
> cookie['lastvisit'] = str(time.time())
> cookie['lastvisit']['expires'] = 30 * 24 * 60 * 60
> cookie['lastvisit']['path'] = '/var/www/html/my_site/'
> cookie['lastvisit']['comment'] = 'holds the last user\'s visit date'
>
When you index the string for a particular character, you aim
at a position and take the character after it.
Chris Angelico
--
http://mail.python.org/mailman/listinfo/python-list
>
> See also:
>
> http://mail.python.org/pipermail/tutor/2010-December/080592.html
> http://en.wikipedia.org/wiki/Off-by-one_error
And further:
http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html
Cheers,
Chris
--
http://mail.python.org/mailman/listinfo/python-list
clean and readable syntax.
Accidental semicolon omission is (IMO) the most irritating source of
syntax (and, inadvertently, sometimes other more serious) errors in
curly-braced programming languages.
Such a core syntax feature is not going to be changed lightly (or likely ever).
Cheers,
Chris
--
http://mail.python.org/mailman/listinfo/python-list
51 PM, Michael Trausch wrote:
> Perhaps it could be made an optional thing to enable; for example, some
> languages by default do dynamic typing, but with an option contained as the
> first statement of the file can enforce static typing.
I am intrigued. What languages(s) have the feature you refer to?
Cheers,
Chris
--
http://mail.python.org/mailman/listinfo/python-list
,
> assuming you also like properly indented code).
>
> And this can be done almost hassle-free for the coder.
> The trouble of adding a ';' to most of the lines can also be
> avoided by a smart editor (see my other reply).
The trouble of dealing with long lines can be avoided by a smart
editor. It's called line wrap.
Cheers,
Chris
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Aug 11, 2011 at 6:17 AM, Michael Trausch wrote:
> Somthing like an "option" keyword (which would only be a keyword until the
> first executable statement, e.g., would have to be before even imports)
> could enable things like "semicolon" or "explicit", or whatever really, and
> only affect
On Thu, Aug 11, 2011 at 7:40 AM, wrote:
> I am not a database developer so I don't want to change the whole process
> of data flow between applications in my company. Another process is
> reading this XML from particular Oracle table so I have to put the final XML
> there.
I think you may be lo
On Thu, Aug 11, 2011 at 12:52 PM, wrote:
> On Thu, Aug 11, 2011 at 11:59:31AM +0100, Chris Angelico wrote:
>> There's no guarantee that all of that 256GB is available to you, of course.
>
> I am the admin of this server - the memory is available for us :-)
Hehe. I me
On Thu, Aug 11, 2011 at 2:46 PM, wrote:
> This is the way I am going to use.
> But what is the best data type to hold so many rows and then operate on them ?
>
List of strings. Take it straight from your Oracle interface and work
with it directly.
ChrisA
--
http://mail.python.org/mailman/listi
ge; you are in a whitespace-significant
*environment*, and that's what matters.
Chris Angelico
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Aug 12, 2011 at 2:40 AM, Steven D'Aprano
wrote:
> Please be careful about conflating significant indentation with significant
> whitespace. Many languages have significant whitespace:
>
> foo bar
>
> is rarely the same thing as
>
> foobar
>
> but is the same as
>
> foo bar
>
> Py
On Fri, Aug 12, 2011 at 7:34 AM, Seebs wrote:
> If Python with braces wouldn't be Python at all, why on earth does the
> language even exist?
Every language has its philosophy. Python, as conceived by Guido van
Rossum, is a language which (guys, correct me where I'm wrong
please!):
* Eschews unn
On Thu, Aug 11, 2011 at 3:39 PM, wrote:
> On Thu, Aug 11, 2011 at 02:48:43PM +0100, Chris Angelico wrote:
>> List of strings. Take it straight from your Oracle interface and work
>> with it directly.
>
> Can I use this list in the following way ?
> subprocess_1 - run on
working around other limitations in the
language (i.e. lack of a with-statement equivalent).
Cheers,
Chris
--
http://rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Aug 12, 2011 at 4:33 PM, rantingrick wrote:
> On Aug 12, 2:20 am, Chris Angelico wrote:
>
>> Pike is very [snip]
>> Pike's purpose is [snip]
>> you go to Pike[snip]
>>
>> I hope I make myself clear, Josephine?
>
> The only thing that is
On Fri, Aug 12, 2011 at 5:33 PM, Seebs wrote:
> I've seen people in C do stuff like:
>
> for (i = 0; i < N; ++i);
> a[i] = 0;
>
> This is clearly a case where indentation matches intent, but doesn't match
> functionality, because C allows indentation to not-match functionalit
On Fri, Aug 12, 2011 at 6:57 PM, rantingrick wrote:
> I'm glad you brought this up! How about this instead:
>
> a = x + y * z
>
> ...where the calculation is NOT subject to operator precedence? I
> always hated using parenthesis in mathematical calculations. All math
> should resolve in a linea
On Fri, Aug 12, 2011 at 1:09 PM, Chris Angelico wrote:
> On Fri, Aug 12, 2011 at 6:57 PM, rantingrick
> wrote:
> > I'm glad you brought this up! How about this instead:
> >
> >a = x + y * z
> >
> > ...where the calculation is NOT subject to oper
On Fri, Aug 12, 2011 at 4:55 PM, Jack Hatterly wrote:
> It prints "None". However, when I look in my browser's cookie jar, there is
> a cookie "www.my_site.com" where my_site is the site from which I am surfing
> the above script. What gives?
>
I assume that what you mean is that it prints "None"
On Fri, Aug 12, 2011 at 6:02 PM, kj wrote:
> I ask myself, how does the journeyman Python programmer cope with
> such nonsense?
>
Firstly, figure out how many combinations of optional arguments
actually make sense. Any that don't, don't support. That may well cut
it down significantly. And then,
mplementation are relevant):
http://docs.python.org/library/stdtypes.html#set
http://en.wikipedia.org/wiki/Set_(mathematics)
http://en.wikipedia.org/wiki/Set_theory
Chris
--
http://mail.python.org/mailman/listinfo/python-list
it in the HTTP request; if not, you have a
configuration issue.
As I said earlier, setting the cookie with a path like that may mean
that the browser won't send it.
Chris Angelico
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Aug 12, 2011 at 11:39 PM, Steven D'Aprano
wrote:
> ask most writers or artists and they would say *of course*
> whitespace matters.
You can write Perl code in the shape of a camel. Can you do that in Python?
Okay. Open challenge to anyone. Write a Python script that outputs
"Just another
On Fri, Aug 12, 2011 at 11:53 PM, Jack Hatterly
wrote:
> cookie['lastvisit']['path'] = '/cgi-bin/'
>
Yep, that's looking a lot more useful!
Glad it's working.
ChrisA
--
http://mail.python.org/mailman/listinfo/python-list
datetime
the_date = datetime.strptime('07/27/2011', '%m/%d/%Y').date()
Cheers,
Chris
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, Aug 14, 2011 at 12:55 AM, OKB (not okblacke)
wrote:
> sys.path = sys.path[1:] + ['']
>
> (That is, move the current directory to the end of the search path
> instead of the beginning.)
>
Or, equivalently:
sys.path.append(sys.path.pop(0))
ChrisA
--
http://mail.python.org/mailman/listinf
On Sun, Aug 14, 2011 at 8:10 AM, Steven D'Aprano
wrote:
> Do you get worried by books if the last page doesn't include the phrase "The
> End"? These days, many movies include an extra clip following the credits.
> When the clip finishes, and the screen goes dark, how long do you sit
> waiting befo
On Sun, Aug 14, 2011 at 1:34 AM, Chris Angelico wrote:
> Yes. Not everything's an expression; a block of code is not an
> expression that returns a code object, and variable assignment is a
> statement. Some day, I'd like to play around with a language where
> everything
On Sun, Aug 14, 2011 at 11:58 AM, Alister Ware
wrote:
> That would mark the first constructive action from rantingnick ever
>
> Surely that would mark the end of the sentient universe?
Only if he actually did it. Many's the time people have called for him
to write a PEP, or (better still) to writ
7;s
actually doing; but I recommend a bit of patience. Also a better
subject line would help.
I'll respond to your actual question in a little while, but just
thought I'd "respond fast" to that part.
Chris Angelico
--
http://mail.python.org/mailman/listinfo/python-list
ly doing. Step through the program in your own head,
and be sure you fully understand what it's doing.
Chris Angelico
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, Aug 14, 2011 at 2:21 PM, Irmen de Jong wrote:
> On 14-8-2011 7:57, rantingrick wrote:
>> 8. Use "e.g." as many times as you can! (e.g. e.g.) If you use "e.g."
>> more than ten times in a single post, you will get an invite to
>> Guido's next birthday party; where you'll be forced to do sho
rt.baidu.com/?login , rather than the URL of the login
page itself.
The fields aren't called "username" and "password"; read the
page's HTML. You'll also see that there are a few hidden form fields
that are probably required.
Finally, even if you fix these problems, the
On Sun, Aug 14, 2011 at 3:26 PM, Steven D'Aprano
wrote:
> Yes, print as a statement was a mistake. But assignment as a statement, not
> so much. Assignment as an expression in languages that have it tends to be
> associated with frequent errors.
>
> The way I see it, if something operates by side-
On Sun, Aug 14, 2011 at 3:30 PM, Nobody wrote:
> BTW, unless you're using Windows 95/98/ME, you don't have a
> "DOS Prompt". The command prompt in Windows NT/2000/XP/Vista/7 isn't DOS.
>
I don't see this as any sloppier than referring to "opening a
prompt" when you mean "opening up a windowed co
On Sun, Aug 14, 2011 at 6:21 PM, rantingrick wrote:
>
> WRONG: "We are supposed to write clean code but i am not used to that"
> RIGHT: "We are required to write clean code however i am not accustom
> to that way of thinking.
>
Since when are we required to write clean code? If I write unclean
co
On Sun, Aug 14, 2011 at 9:20 PM, harrismh777 wrote:
> ... yup, ... was helping my little sis with her iMac over the phone from
> four states away and had her open a terminal for some magic... and it took
> her exactly 1.03 seconds to say, "Oh, the iMac has DOS installed in the
> utilities folder!
On Sun, Aug 14, 2011 at 10:27 AM, Ben Finney wrote:
> The house lights need to be controlled by someone who knows when the
> movie's end signal should be sent. What is our ending signal if we're
> watching it from media in our home, and no-one in the house knows when
> the movie ends?
>
If you're
On Sun, Aug 14, 2011 at 11:01 PM, Dave Angel wrote:
> I'm inclined to ignore typos in emails except in the case where the intent
> is to abuse others.
>
+1 QOTW.
It is, however, a well-known tradition that spelling/grammar flames
should contain one spelling/grammer error.
Oh, I just did it myse
On Sun, Aug 14, 2011 at 11:46 PM, Roy Smith wrote:
> In article ,
> Dave Angel wrote:
>
>> The thing that confuses people is that not only is the part up to and
>> through the domain name is case-insensitive, but that simple pages on
>> Windows become case-insensitive for the remainder simply be
or
the username and group-name respectively. Then use the id-based chown
function(s) you already came across.
http://docs.python.org/library/pwd.html#pwd.getpwnam
http://docs.python.org/library/grp.html#grp.getgrnam
Cheers,
Chris
--
http://mail.python.org/mailman/listinfo/python-list
rule, chaining method calls risks violating the Law of Demeter. Just
> sayin'.
Not in the specific case of fluent interfaces[1] though, which could
have been what Seebach had in mind.
Whether fluent interfaces are a good idea...
Cheers,
Chris
--
[1] http://en.wikipedia.org/wiki/Fluent_in
On Mon, Aug 15, 2011 at 5:28 AM, Seebs wrote:
> Character stream: tab tab tab "foo" newline tab "bar". This is, as you
> say, *usually* two dedents, but it could be one.
I see your point, though I cannot imagine anyone who would use "tab
tab" as an indent level. But if you go from 16 spaces dow
On Mon, Aug 15, 2011 at 3:14 AM, Dennis Lee Bieber
wrote:
> Depends... "DOS", to me, is just short for "Disk Operating
> System"... I've source code (in a book) for K2FDOS, source code for
> LS-DOS 6, and have used the AmigaDOS component of AmigaOS (granted --
> AmigaDOS technically was the
On Mon, Aug 15, 2011 at 2:41 PM, Roy Smith wrote:
> Demand, no, but sometimes it's a good idea. I've been writing computer
> programs for close to 40 years, and I still have no clue what most of
> the order of operations is. It's just not worth investing the brain
> cells to remember such trivia
On Mon, Aug 15, 2011 at 3:28 PM, Steven D'Aprano
wrote:
> And of course, once you start using floating point numbers, you can't assume
> commutativity:
>
0.1 + 0.7 + 0.3 == 0.3 + 0.7 + 0.1
> False
>
This isn't because programming languages fail to follow mathematics;
it's because floating po
FE" or "\xFE\xFF" or "\xEF\xBB\xBF", then it's
probably UTF-16LE, UTF-16BE, or UTF-8, respectively (those being the
encodings of the BOM). There may be other clues, too, but normally
it's best to get the encoding separately from the data rather than try
to decode it
On Mon, Aug 15, 2011 at 10:52 PM, Gerrat Rickert
wrote:
> With surprising regularity, I see program postings (eg. on StackOverflow)
> from inexperienced Python users accidentally re-assigning built-in names.
>
> For example, they’ll innocently call some variable, “list”, and assign a
> list of it
On Tue, Aug 16, 2011 at 1:34 AM, Roy Smith wrote:
> In article ,
> Chris Angelico wrote:
>
>> Or: "Blasted PHP, which
>> operators have precedence between || and or?" which is easy to forget.
>>
>> And you're right about the details changing f
rrect:
http://packages.python.org/testfixtures/datetime.html#timezones
The package is on PyPI and a full list of all the links to docs, issue
trackers and the like can be found here:
http://www.simplistix.co.uk/software/python/testfixtures
cheers,
Chris
--
Simplistix - Content Management,
can
> process the information for the next command. Any ideas? Thanks.
Pipe it thru `tee`:
http://en.wikipedia.org/wiki/Tee_%28command%29
Cheers,
Chris
--
http://mail.python.org/mailman/listinfo/python-list
/config/common-ngp/makefile
Assuming the #s aren't in the actual output:
import re
pat = re.compile("^ *(\\([^)]+\\))", re.MULTILINE)
print(pat.search(your_str).group(1))
Obviously can vary depending on how you want to go about defining the
target string.
Cheers,
Chris
P.S. If you reply, please remove
o manage users
> with python ?
You can replace the /etc/passwd parsing with a call to pwd.getpwnam():
http://docs.python.org/library/pwd.html#pwd.getpwnam
Cheers,
Chris
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Aug 16, 2011 at 2:32 AM, Steven D'Aprano
wrote:
> On Tue, 16 Aug 2011 08:15 am Chris Angelico wrote:
>
>> It's actually masking, not reassigning. That may make it easier or
>> harder to resolve the issue.
>
> The usual term is "shadowing builtins&qu
On Tue, Aug 16, 2011 at 3:13 PM, Philip Semanchuk wrote:
> I am an example. I know enough to turn the theoretical warning on, and I
> would if I could. I have never shadowed a builtin deliberately. I've done it
> accidentally plenty of times. There are 84 builtins in my version of Python
> and
On Tue, Aug 16, 2011 at 12:33 PM, Paul Wray wrote:
> The idea is simply to use python ASTs to transform this code so that it
> accumulates the values of the bare expressions.
That'd be similar to what the interactive loop does. Are you aware,
though, that docstrings are bare expressions? You may
3101 - 3200 of 20009 matches
Mail list logo