On Wed, 11 Jul 2012, Steven D'Aprano wrote:
Chris Hare wrote:
Okay - I am officially embarrassed.
[...]
Meh, don't beat yourself up too badly. We've all been where you are now.
Sometimes I look back at my early Python code... I tell you, that's always a
good antidote for a big head.
I re
Alexander Q. wrote:
My question is how does Python know to return just the part in the
parentheses and not to return the "blahblah" and the "yattayattayatta",
etc...? The 're.search' function returns the whole thing, and if I want
just the parentheses parts, I do tuples.group(1) or tuples.group(
On Jul 10, 2012, at 6:24 PM, Alan Gauld wrote:
> On 11/07/12 00:16, Alan Gauld wrote:
>
>>> One thought was a RAM based SQLite database, but that seems
>> > like a lot of work. I dunno, maybe that is the option.
>>
>> is definitely the best option where the "global" needs to be shared
>> acros
On 11/07/12 00:16, Alan Gauld wrote:
One thought was a RAM based SQLite database, but that seems
> like a lot of work. I dunno, maybe that is the option.
is definitely the best option where the "global" needs to be shared
across different programs as well as different modules in a single
I
On 10/07/12 20:11, Chris Hare wrote:
I know they are bad.
They are not totally bad and most real programs wind up
having one or two globals, although usually those globals
are top level container classes, perhaps even an Application
class or similar.
I am not sure how else to handle this pro
Sent from my iPad
On Jul 10, 2012, at 3:11 PM, Chris Hare wrote:
>
> I know they are bad. That is why I would prefer not to use it, but I am not
> sure how else to handle this problem.
>
> In this app, the user must log in. Once authenticated, they have a userid
> stored in the SQLite da
> > Just as a note, this would not really work if the variable needs to be
> > changed and read from several places when the value is an immutable
> > type such as numbers / strings. In that case, then you could use
> > the same logic but instead place the value in a list and pass that
> > and alwa
On Tue, Jul 10, 2012 at 1:32 PM, Prasad, Ramit
wrote:
>> You should avoid using the global statement.
>>
>> In your case, I would think you could just add an argument to the method:
>>
>> class MyObj(object):
>> def __init__(self, arg):
>> self.arg = arg
>> def my_func(self, new_ar
On Tue, Jul 10, 2012 at 4:32 PM, Prasad, Ramit wrote:
> > You should avoid using the global statement.
> >
> > In your case, I would think you could just add an argument to the method:
> >
> > class MyObj(object):
> > def __init__(self, arg):
> > self.arg = arg
> > def my_func(self
> You should avoid using the global statement.
>
> In your case, I would think you could just add an argument to the method:
>
> class MyObj(object):
> def __init__(self, arg):
> self.arg = arg
> def my_func(self, new_arg):
> self.arg = new_arg
>
> to call it:
>
> arg =
> >
> > file: a.py
> >
> > import b
> > global_var = "global"
> >
> To answer your most basic question:
[file b.py]
> import a
> a.global_var
This would be a cyclical import and is bad even if it does not fail.
Remove the common dependencies (in this case the global variables)
and place it in a
On Tue, Jul 10, 2012 at 3:11 PM, Chris Hare wrote:
>
> I know they are bad. That is why I would prefer not to use it, but I am
> not sure how else to handle this problem.
>
> In this app, the user must log in. Once authenticated, they have a userid
> stored in the SQLite database. Before split
On Tue, Jul 10, 2012 at 12:11 PM, Chris Hare wrote:
>
> I know they are bad. That is why I would prefer not to use it, but I am not
> sure how else to handle this problem.
>
> In this app, the user must log in. Once authenticated, they have a userid
> stored in the SQLite database. Before spl
I know they are bad. That is why I would prefer not to use it, but I am not
sure how else to handle this problem.
In this app, the user must log in. Once authenticated, they have a userid
stored in the SQLite database. Before splitting my app into multiple files, I
used a global variable.
On Tue, Jul 10, 2012 at 9:26 PM, Alexander Q. wrote:
> I'm a bit confused about extracting data using re.search or re.findall.
>
> Say I have the following code: tuples =
> re.findall(r'blahblah(\d+)yattayattayatta(\w+)moreblahblahblah(\w+)over',
> text)
>
> So I'm looking for that string in 'tex
I'm a bit confused about extracting data using re.search or re.findall.
Say I have the following code: tuples =
re.findall(r'blahblah(\d+)yattayattayatta(\w+)moreblahblahblah(\w+)over',
text)
So I'm looking for that string in 'text', and I intend to extract the parts
which have parentheses around
Chris Hare wrote:
Okay - I am officially embarrassed.
[...]
Meh, don't beat yourself up too badly. We've all been where you are now.
Sometimes I look back at my early Python code... I tell you, that's always a
good antidote for a big head.
--
Steven
_
Okay - I am officially embarrassed.
As you might now, I am splitting this 10,000 line file apart, and that is
posing certain challenges which I am fixing, and cleaning up stuff that was
broken and visible only when doing this split.
This is one of them.
What I failed to remember -- and y
Chris Hare wrote:
def special_match(string, search=re.compile(r'[^a-zA-Z0-9\.\
\-\#\$\*\@\!\%\^\&]').search):
#string = string.rstrip()
return not bool(search(string))
The call to bool is redundant. Get rid of it. The not operator will
automatically convert its argument into a
On 10 Jul 2012 11:31, "Chris Hare" wrote:
>
>
> This piece of code works:
>
> Big-Mac:Classes chare$ more tmp.py
> import re
>
> return not bool(search(string))
> However, when I use the EXACT same code in the context of the larger
code, I get the error
>
> return not bool(search
James Bell wrote:
I'm attempting to learn how to use the "withas" statement in python.
I've read the documentation and also a few tutorials but I still cannot
understand the concept. or how this is normally used. Can someone please
write an example or 2 of simple ways to use the "with statem
> This piece of code works:
>
> Big-Mac:Classes chare$ more tmp.py
> import re
>
> def special_match(string, search=re.compile(r'[^a-zA-Z0-9\.\ \-
> \#\$\*\@\!\%\^\&]').search):
> #string = string.rstrip()
> return not bool(search(string))
>
> print special_match("admin")
> print
On 07/10/2012 10:56 AM, Chris Hare wrote:
> This piece of code works:
>
> Big-Mac:Classes chare$ more tmp.py
> import re
>
> def special_match(string, search=re.compile(r'[^a-zA-Z0-9\.\
> \-\#\$\*\@\!\%\^\&]').search):
> #string = string.rstrip()
> return not bool(search(string))
Y
On Tue, Jul 10, 2012 at 11:25 AM, Mark Lawrence wrote:
> On 10/07/2012 15:58, James Bell wrote:
>
>> I'm attempting to learn how to use the "withas" statement in python.
>>
>> I've read the documentation and also a few tutorials but I still cannot
>> understand the concept. or how this is norm
On Tue, Jul 10, 2012 at 10:56 AM, Chris Hare wrote:
> The input to the function in the larger program is the same as the first test
> in the small script that works -- "admin".
>
> As a side note -- the rstrip call is also broken, although the string module
> is imported. I just can't figure ou
On 10/07/2012 15:58, James Bell wrote:
I'm attempting to learn how to use the "withas" statement in python.
I've read the documentation and also a few tutorials but I still cannot
understand the concept. or how this is normally used. Can someone please
write an example or 2 of simple ways to
This piece of code works:
Big-Mac:Classes chare$ more tmp.py
import re
def special_match(string, search=re.compile(r'[^a-zA-Z0-9\.\
\-\#\$\*\@\!\%\^\&]').search):
#string = string.rstrip()
return not bool(search(string))
print special_match("admin")
print special_match("&!*")
p
I'm attempting to learn how to use the "withas" statement in python.
I've read the documentation and also a few tutorials but I still cannot
understand the concept. or how this is normally used. Can someone please
write an example or 2 of simple ways to use the "with statement".
I understand
On 10/07/2012 03:04, Steven D'Aprano wrote:
Mark Lawrence wrote:
On 09/07/2012 16:56, Chris Hare wrote:
So, I have to admit, imports have me really confused. I am trying to
break apart a 10,000+ line single file into various files
Please don't break the file up for the sake of doing it, you
On 09/07/12 22:59, Abhishek Pratap wrote:
I want to know whether it is possible for dynamically update the step
size in xrange or someother slick way.
Here is what I am trying to do, if during a loop I find the x in list
I want to skip next #n iterations.
You could use the next() method of t
30 matches
Mail list logo